list.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. $(function(){
  2. if(window.BLightApp){//判断如果是百度app还用旧的filter
  3. loadJS("/template/js/filter.js",function(){
  4. if($(".filter").length){
  5. var myfilter = new filter(filter_data);
  6. myfilter.drawList();
  7. }
  8. });
  9. }else{
  10. window.keyword_other = '';
  11. $(".filter_item").each(function(){
  12. var len=$(this).find("dd a").length;
  13. //如果a标签的长度大于4,并且数据类型是cmc或者cmcs
  14. if(len>3 && $(this).attr("type")=="cmc_cmcs"){
  15. $(this).find("dd").append("<div class='ico_more'></div>");
  16. $(this).find("dd").css("padding-right","30px");
  17. }
  18. //如果a标签的长度大于4,并且数据类型是商圈数据
  19. if(len>4 && $(this).attr("type")=="subarea"){
  20. $(this).find("dd").append("<div class='ico_more'></div>");
  21. $(this).find("dd").css("padding-right","30px");
  22. }
  23. //如果a标签的长度大于或等于5,并且数据类型是区域,设置ico位置和dd高度
  24. if(len>=5 && $(this).attr("type")=="area"){
  25. $(this).find("dd").append("<div class='ico_more'></div>");
  26. $(".ico_more").css("top","24px");
  27. $(this).find("dd").css({"padding-right":"30px","height":"56px"});
  28. }
  29. });
  30. var isclick = false;
  31. $(".ico_more,.ico_more2").bind("touchstart",function(){isside=false});
  32. $(".ico_more,.ico_more2").bind("touchmove",function(){isside=true});
  33. $(".ico_more,.ico_more2").bind("touchend",function(){
  34. if(isside){return;}
  35. $('.filter').css({"height":"auto","-webkit-transition-duration":"0ms"});
  36. isclick=true;
  37. if($(this).hasClass("up")){
  38. if($(this).parent().parent().attr("type")=="area"){
  39. $(this).parent().css("height","56px");
  40. }else{
  41. $(this).parent().css("height","28px");
  42. }
  43. $(this).removeClass("up");
  44. }else{
  45. $(this).parent().css("height","auto");
  46. $(this).addClass("up");
  47. }
  48. setTimeout(function(){
  49. isclick=false;
  50. },500);
  51. });
  52. $(".filter_item a").bind("click",function(){
  53. var _a=$(this);
  54. var urls = _a.attr("href");
  55. if(isclick){
  56. isclick=false;
  57. _a.attr("href","javascript:;");
  58. setTimeout(function(){
  59. _a.attr("href",urls);
  60. },500);
  61. }
  62. });
  63. $(".filter_more").bind("click",function(){
  64. var btn_more = $(this);
  65. $(".filter .filter_item").each(function(){
  66. if($(this).css('display') == "none" ){
  67. $(this).css('display','block').addClass('none');
  68. btn_more.addClass("less").find("span").text("精简筛选条件");
  69. }else if($(this).hasClass("none") && $(this).css('display') != "none"){
  70. $(this).css('display','none');
  71. btn_more.removeClass("less").find("span").text("更多筛选条件");
  72. }
  73. });
  74. });
  75. }
  76. });