1(function (Skyline) { 2 Skyline.activity = Skyline.activity || {}; 3 Skyline.activity.exploreActivity = Skyline.activity.exploreActivity || {}; 4 5 Skyline.activity.exploreActivity = function ($App) { 6 this.$.$App = $App; 7 }; 8 9 var typingTimer, 10 sortTimer; 11 12 Skyline.activity.exploreActivity.prototype = { 13 constructor: Skyline.activity.exploreActivity, 14 15 // DOM ç©ä»¶ 16 $ : { 17 template : {} 18 }, 19 // è®æ¸ 20 variable: { 21 filter : { 22 category : [], 23 region : [], 24 price : [], 25 duration : [], 26 start_at : [], 27 end_at : [], 28 time_filter : [], 29 keywords : '', 30 } 31 }, 32 // åå§å 33 init: function () { 34 this.initDom(); 35 this.bind(); 36 }, 37 initDom: function () { 38 this.$.$datepicker = this.$.$App.find('.datepicker'); 39 this.$.$StartAt = this.$.$App.find('#start_at'); 40 this.$.$EndAt = this.$.$App.find('#end_at'); 41 this.$.$TimeFilter = this.$.$App.find('#time_filter'); 42 this.$.$Keywords = this.$.$App.find('.activity_keywords_filter') 43 this.$.$ActivityExploreBtn = this.$.$App.find('.activity_explore_btn'); 44 // this.$.$AvatarImage = this.$.$App.find('#avatar_image'); 45 // éæ¿¾å¨ 46 this.$.$ActivityExploreFilter = {}; 47 this.$.$ActivityExploreFilter.category = this.$.$App.find('.activity_category_explore_filter'); 48 this.$.$ActivityExploreFilter.region = this.$.$App.find('.activity_region_explore_filter'); 49 this.$.$ActivityExploreFilter.price = this.$.$App.find('.activity_price_explore_filter'); 50 this.$.$ActivityExploreFilter.duration = this.$.$App.find('.activity_duration_explore_filter'); 51 52 53 }, 54 // ç¶å®äºä»¶ 55 bind: function () { 56 var _this = this; 57 this.bindCollection.Datepicker.init(this); 58 this.bindCollection.ActivityExplore.init(this); 59 }, 60 saveExploreParameter : function () { 61 var filter = this.variable.filter, 62 start_at = this.$.$StartAt.val(), 63 end_at = this.$.$EndAt.val(); 64 65 if (start_at && end_at) { 66 var is_before_at = moment(start_at).isBefore(end_at); 67 if (!is_before_at) { 68 alert('çµææ¥æå¿ é å¨éå§æ¥æä¹å'); 69 this.$.$EndAt.val(start_at); 70 return; 71 } 72 } 73 74 this.variable.filter.start_at = this.$.$StartAt.val(); 75 this.variable.filter.end_at = this.$.$EndAt.val(); 76 this.variable.filter.time_filter = this.$.$TimeFilter.val(); 77 this.variable.filter.keywords = this.$.$Keywords.val(); 78 var saveExplore = { 79 category : filter.category, 80 region : filter.region, 81 price : filter.price, 82 duration : filter.duration, 83 time_filter : this.$.$TimeFilter.val(), 84 start_at : this.$.$StartAt.val(), 85 end_at : this.$.$EndAt.val(), 86 keywords : this.$.$Keywords.val() 87 }; 88 // console.log(saveExplore); 89 store.set('activity_explore', saveExplore); 90 console.log(store.get('activity_explore')); 91 }, 92 bindCollection : { 93 ActivityExplore : { 94 parent : null, 95 init : function (parent) { 96 this.parent = parent; 97 this.initStoreExplore(); 98 this.bindActivityExplore(); 99 }, 100 initStoreExplore : function () { 101 var _this = this.parent; 102 var saveExplore = store.get('activity_explore'), 103 $ExploreSection, explore_section_name, type_name, type_id, 104 url_param; 105 106 // console.log(saveExplore); 107 108 if (saveExplore) { 109 for (type_name in saveExplore) { 110 if (saveExplore.hasOwnProperty(type_name)) { 111 // é¡åç·¨è 112 type_id = saveExplore[type_name]; 113 114 if (typeof type_id == 'string') { 115 // èçå®é¸ï¼ç§»é¤èçè³æ 116 // store.remove('activity_explore'); 117 type_id = [type_id]; 118 } 119 120 // åå¾ç¶²åååæ¸è³æ 121 url_param = '?' + type_name; 122 url_type_id = url(url_param); 123 if (url_type_id) { 124 console.log(url_type_id); 125 // ç¶²åæé¡åè³æï¼å°é¡åè³æè½æçºé£å 126 url_type_id = url_type_id.split(','); 127 } else { 128 // ç¶²åæ²æé¡åè³æ 129 url_type_id = []; 130 } 131 132 if (url_type_id.length) { 133 // ç¶²åæé¡åè³æï¼ä»¥ç¶²åçºä¸» 134 type_id = url_type_id; 135 } 136 // console.log(type_id); 137 // è¨å®ææ°åæ¸ 138 _this.variable.filter[type_name] = type_id; 139 140 if (type_id.length) { 141 // æé¡åè³æï¼ç§»é¤ä¸é 142 explore_section_name = 'activity_' + type_name + '_explore_filter_0'; 143 $ExploreSection = _this.$.$App.find('#' + explore_section_name).removeClass('BodySelect'); 144 // æé¡åè³æ
145 type_id.forEach(function(val){ 146 // console.log(val); 147 // é¡ååå¡å稱 148 explore_section_name = 'activity_' + type_name + '_explore_filter_' + val; 149 // é¸æè©²åå¡ 150 $ExploreSection = _this.$.$App.find('#' + explore_section_name).addClass('BodySelect'); 151 }); 152 } 153 154 } 155 } 156 157 // å²åææ°åæ¸ 158 _this.saveExploreParameter(); 159 160 if (saveExplore.start_at) { 161 _this.$.$StartAt.val(saveExplore.start_at); 162 } 163 if (saveExplore.end_at) { 164 _this.$.$EndAt.val(saveExplore.end_at); 165 } 166 if (saveExplore.time_filter) { 167 _this.$.$TimeFilter.val(saveExplore.time_filter); 168 } 169 if (saveExplore.keywords) { 170 _this.$.$Keywords.val(saveExplore.keywords); 171 } 172 } 173 174 }, 175 bindActivityExplore : function () { 176 var _this = this.parent; 177 178 Skyline.$.$document.on('click', ".activity_explore_btn", function (event) { 179 Skyline.Util.eventStop(event); // 黿¢å泡 180 filter = _this.variable.filter; 181 console.log(filter); 182 var param = [], 183 param_item; 184 for (type_name in filter) { 185 if (filter.hasOwnProperty(type_name)) { 186 param_item = ''; 187 console.log(typeof filter[type_name], filter[type_name]); 188 if (typeof filter[type_name] == 'object' && filter[type_name].length) { 189 param_item = type_name + '=' + filter[type_name].join(','); 190 } 191 if (typeof filter[type_name] == 'string' && filter[type_name].length) { 192 param_item = type_name + '=' + filter[type_name]; 193 } 194 if (param_item.length) { 195 param.push(param_item); 196 } 197 } 198 } 199 param = param.join('&'); 200 201 var url = location.origin + location.pathname + '?' + param; 202 window.location = url; 203 }); 204 205 Skyline.$.$document.on('change', "#time_filter", function (event) { 206 Skyline.Util.eventStop(event); // 黿¢å泡 207 _this.saveExploreParameter.bind(_this)(); 208 _this.$.$ActivityExploreBtn.trigger('click'); 209 }); 210 211 Skyline.$.$document.on('change', ".activity_time_explore_filter", function (event) { 212 Skyline.Util.eventStop(event); // 黿¢å泡 213 _this.saveExploreParameter.bind(_this)(); 214 }); 215 216 Skyline.$.$document.on('change', ".activity_keywords_filter", function (event) { 217 Skyline.Util.eventStop(event); // 黿¢å泡 218 _this.saveExploreParameter.bind(_this)(); 219 }); 220 221 Skyline.$.$document.on('click touchend', ".activity_explore_filter", function (event) { 222 Skyline.Util.eventStop(event); // 黿¢å泡 223 var type_name = this.dataset.type, 224 type_id = this.dataset.id, 225 explore_section_name; 226 var $this = $(this); 227 228 if ($this.hasClass('BodySelect')) { 229 $action = 'remove'; 230 } else { 231 $action = 'add'; 232 } 233 234 235 // if (_this.$.$ActivityExploreFilter[type_name]) { 236 // // å°æææ¤é¡å¥é¸æåæ¶ 237 // _this.$.$ActivityExploreFilter[type_name].removeClass('BodySelect'); 238 // } 239 240 switch ($action) { 241 // ç§»é¤ 242 case 'remove': 243 if (type_id == 0) { 244 // ä¸è½ç§»é¤ä¸é 245 } else { 246 $this.removeClass('BodySelect'); 247 _this.variable.filter[type_name] = Skyline.Util.splice(type_id, _this.variable.filter[type_name]); 248 249 if (!_this.variable.filter[type_name].length) { 250 // å¦ææ²æé¸æä»»ä½é¡å¥ï¼å°è¨å®çºä¸é 251 explore_section_name = 'activity_' + type_name + '_explore_filter_0'; 252 $ExploreSection = _this.$.$App.find('#' + explore_section_name).addClass('BodySelect'); 253 } 254 } 255 // _this.variable.filter[type_name] = ''; 256 break; 257 // æ°å¢ 258 case 'add': 259 if (type_id == 0) { 260 // åæ¶ææé¸æï¼è¨å®çºä¸é 261 explore_section_name = 'activity_' + type_name + '_explore_filter'; 262 $ExploreSection = _this.$.$App.find('.' + explore_section_name).removeClass('BodySelect'); 263 _this.variable.filter[type_name] = []; 264 265 $this.addClass('BodySelect'); 266 } else { 267 // ç§»é¤ä¸é 268 explore_section_name = 'activity_' + type_name + '_explore_filter_0'; 269 $ExploreSection = _this.$.$App.find('#' + explore_section_name).removeClass('BodySelect'); 270 271 $this.addClass('BodySelect'); 272 _this.variable.filter[type_name].push(type_id); 273 } 274 break; 275 default: 276 break; 277 } 278 // console.log(_this.variable.filter); 279 _this.saveExploreParameter.bind(_this)(); 280 // 鏿æ¤é ç® 281 // $this.addClass('BodySelect'); 282 // è¨å®ç®åå¼çºæ¥è©¢é ç® 283 284 285 // console.log(111); 286 // console.log(_this.variable.filter); 287 }); 288 } 289 }, 290 Datepicker : { 291 parent : null, 292 init : function (parent) { 293 this.parent = parent; 294 this.bindDatepicker(); 295 }, 296 bindDatepicker : function () { 297 var _this = this.parent; 298 299 // datepicker trigger 300 _this.$.$datepicker.datepicker({ 301 format: 'yyyy-mm-dd' 302 }); 303 // datepicker æé trigger 304 Skyline.$.$document.on('click', ".datepicker_btn", function () { 305 var $this = $(this); 306 $this.parent().find('.datepicker').trigger('focus'); 307 }); 308 } 309 } 310 } 311 }; 312 313 Skyline.$.$document.ready(function(){ 314 var $App = Skyline.$.$document.find('#activity-explore-container'); 315 if($App.length){ 316 // æå°è©²é é¢ï¼åå§åç¨å¼ 317 Skyline.activity.exploreActivity = new Skyline.activity.exploreActivity($App); 318 Skyline.activity.exploreActivity.init(); 319 } 320 }); 321 322})(typeof Skyline !== 'undefined' ? Skyline : (this.Skyline = {}));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.