1/** 2 * get Event list 3 **/ 4var eventListClass = function(options){ 5 6 /* 7 * Variables accessible in the class 8 * Be carefull before changing variable name, It's may affect current working functionality 9 */ 10 var vars = { 11 viewType : 'grid', // Default view type is grid view 12 page_name : null, // Pass cookie name to remeber last event view 13 iLimit : 24, // default limit 24 14 auctionSearchType : 'all', // Default show all view 15 orderBy : null, // Pass oeder by 16 page : 1, //Default page 1 17 iAuctionType : 1, // Default upcoming auction 18 iSellerId : null, // seller Id 19 ajaxLoader : null, // Pass ajax loader object ex: $('#upcoming_event_list .ajax-loader') 20 listWrapper : $('#auction_content'), // ajax list wrapper 21 pagiWrapper : $('#ajax-pagi'), // ajax pagination wrapper 22 listTypeWrapper : $('.upcomSec .btnSwitch button'), // list type icon wrapper 23 ajaxURL : null, // Ajax request url 24 tabBarSelector : null, // Auction tab bar wrapper 25 pushState : false, // history pushState default false 26 origURL : null, // pushState base url 27 noBadge : false, // nobadge default false 28 showMore : false, // nobadge default false 29 tempPushStateOff : false, // temporarary push state use when you want to not change url of any action, it's automatic off after every ajax call 30 debug : false, 31 isTab : false, 32 popPage : function(data){} 33 }; 34 35 /* 36 * Set url veriable and their setting 37 * Key: (auctionSearchType/orderBy) it's same as ajaxvar,, if you can pass diff from that It's not working 38 * Param: createUrl (BOOL) if true then set url for this search result 39 * Param: name (string) It's use for url variable name what you want for that page 40 * Param: defaultValue (string) If you can set default value and search param have same value then It's not set in url 41 */ 42 var urlParams = { 43 'auctionSearchType': { 44 'createUrl' : true, 45 'name':'auction_type' 46 }, 47 'orderBy': { 48 'createUrl' : true, 49 'name':'order_by' 50 }, 51 'page': { 52 'createUrl' : true, 53 'name':'page' 54 }, 55 'iSellerId': { 56 'createUrl' : false, 57 'name':'ah' 58 }, 59 }; 60 61 /* 62 * You have to declare veriable here if you want to pass param in ajax request 63 */ 64 var ajaxVars = [ 65 'auctionSearchType', 66 'iAuctionType', 67 'iSellerId', 68 'orderBy', 69 'iLimit', 70 'viewType', 71 'page_name', 72 'page', 73 'noBadge', 74 'showMore', 75 'periodDate' 76 ] 77 78 /* 79 * Can access this.method 80 * inside other methods using 81 * root.method() 82 */ 83 var root = this; 84 /* 85 * Constructor 86 */ 87 this.construct = function(options){ 88 root.addSettings(options); 89 listTypeChange(); 90 root.tabChanged(); 91 popstateData(); 92 setReplaceState(); 93 }; 94 95 /* 96 * Public method 97 * Can be called outside class 98 */ 99 // Add/update vars 100 this.addSettings = function(options) { 101 if (typeof options.urlParams !== 'undefined') {
102 $.extend( true, urlParams, options.urlParams ); 103 delete options.urlParams; 104 } 105 $.extend(vars , options); 106 }; 107 108 // Call this method when we want to reload event 109 this.changeData = function(options) { 110 root.addSettings(options); 111 eventData(); 112 }; 113 114 this.tabChanged = function() { 115 if(vars.tabBarSelector) { 116 var selector = $(vars.tabBarSelector).find('li') 117 selector.unbind('click').click(function(e){ 118 $(this).addClass('active').siblings().removeClass('active'); 119 root.addSettings({auctionSearchType:$(this).data('event_type'),page:1}); 120 eventData(); 121 }); 122 } 123 } 124 125 /* 126 * Private method 127 * Can only be called inside class 128 */ 129 // Get event data 130 var eventData = function() { 131 if(vars.ajaxLoader) vars.ajaxLoader.show(); 132 var data = {}; 133 var urlParts = {}; 134 var pushUrlData = {}; 135 var currURL = location.href; 136 137 var res = createAjaxParam(); 138 var data = res.data; 139 var urlParts = res.urlParts; 140 var pushUrlData = res.pushUrlData; 141 var url = jQuery.param(urlParts); 142 if(vars.ajaxURL) { 143 if(vars.origURL) { 144 var symbole = (url)?((vars.origURL.indexOf("?") > -1) ? '&' : '?'):""; 145 var pushURL = vars.origURL+symbole+url; 146 data.pagi_url = pushURL; 147 } 148 // if(vars.showMore != 1 || vars.page == 1) vars.listWrapper.empty(); 149 var varsAjaxUrl = vars.ajaxURL; 150 varsAjaxUrl += (varsAjaxUrl.match('\\?') ? '&' : '?') + 'is_ajax=1'; 151 $.ajax({ 152 url : varsAjaxUrl, 153 method : 'POST', 154 dataType : 'json', 155 data : data, 156 success : function (res) { 157 // Past last page (under hard max) â same as full-page 302 to last page 158 if (res && res.redirect) { 159 if (typeof redirectTo === 'function') { 160 redirectTo(res.redirect); 161 } else { 162 window.location.href = res.redirect; 163 } 164 return; 165 } 166 var warpperType = 'type2'; 167 if(vars.viewType == 'grid') { 168 warpperType = 'type1'; 169 } 170 if(vars.pushState && vars.origURL && !vars.tempPushStateOff) { 171 if (pushURL != currURL) { 172 window.history.pushState(pushUrlData, null, pushURL); 173 } else { 174 window.history.replaceState(pushUrlData, null, pushURL); // just in case to create the proper state even though the location.href matches 175 } 176 } 177 vars.tempPushStateOff = false; 178 vars.listWrapper.removeClass("type1").removeClass("type2"); 179 if(vars.showMore == 1 && vars.page != 1) { 180 vars.listWrapper.addClass(warpperType).append(res.page_content); 181 } 182 else { 183 vars.listWrapper.empty(); 184 /* 185 GTM element visibility was not working after replacing the html 186 emptying the container and then updating it after 10ms seems to make GTM detect the DOM change 187 this is temporary until we find a better way to get GTM to detect the DOM change 188 */ 189 setTimeout(function(){ vars.listWrapper.addClass(warpperType).append(res.page_content); }, 10); 190 } 191 vars.pagiWrapper.html(res.paginationLink); 192 193 194 if(vars.ajaxLoader) vars.ajaxLoader.hide(); 195 }, 196 error: function (jqXHR, exception) { 197 if(vars.ajaxLoader) vars.ajaxLoader.hide(); 198 logMessage(jqXHR.status+":-"+exception); 199 } 200 }); 201 } 202 else { 203 if(vars.ajaxLoader) vars.ajaxLoader.hide(); 204 logMessage("Please Add ajaxURL"); 205 } 206 }; 207 208 // Print message in console 209 var logMessage = function(msg) { 210 if(vars.debug) { 211 console.log(msg); 212 } 213 } 214 // create ajax data and url obj 215 var createAjaxParam = function() { 216 var data = {}; 217 var urlParts = {}; 218 var pushUrlData = {}; 219 $.each(ajaxVars, function (index , value){ 220 pushUrlData[value] = vars[value]; 221 if(vars[value]) { 222 data[value] = vars[value];
223 if((urlVarObj = urlParams[value]) && typeof urlVarObj.name !== 'undefined' && urlVarObj.createUrl !== false && urlVarObj.defaultValue != vars[value]) { 224 if(value == 'page' && vars[value] == 1) { 225 return true; 226 } 227 urlParts[urlVarObj.name] = vars[value]; 228 } 229 } 230 }); 231 return {'data':data,'urlParts':urlParts,'pushUrlData':pushUrlData}; 232 } 233 234 // When we chnaged event list type view This method called 235 var listTypeChange = function() { 236 vars.listTypeWrapper.unbind('click'); 237 vars.listTypeWrapper.click(function() { 238 if (!$(this).hasClass('active')) { 239 $(this).addClass('active').siblings().removeClass('active'); 240 vars.viewType = $(this).data('viewtype'); 241 if(vars.viewType == 'grid') { 242 $(this).closest('.gridSwitch').addClass('gridView'); 243 } 244 else { 245 $(this).closest('.gridSwitch').removeClass('gridView'); 246 } 247 if(vars.showMore == 1) { 248 vars.page = 1; 249 } 250 vars.tempPushStateOff = true; 251 eventData(); 252 } 253 }); 254 } 255 256 // call popstate data 257 var popstateData = function() { 258 if(vars.pushState && vars.origURL) { 259 $(window).on('popstate', function (e) { 260 var state = e.state || e.originalEvent.state; 261 if (state) { 262 vars.tempPushStateOff = true; 263 root.changeData(state); 264 changeTabIndex(); 265 changeListType(); 266 vars.popPage(state); 267 } 268 }); 269 } 270 } 271 // Change the tab index 272 var changeTabIndex = function() { 273 if(vars.auctionSearchType && vars.isTab && vars.tabBarSelector) { 274 $(vars.tabBarSelector).find('li[data-event_type = "'+vars.auctionSearchType+'"]').addClass('active').siblings().removeClass('active'); 275 } 276 } 277 278 // Change list type view selected 279 var changeListType = function() { 280 vars.listTypeWrapper.removeClass('active'); 281 vars.listTypeWrapper.each(function(e){ 282 if($(this).data('viewtype') == vars.viewType) { 283 $(this).addClass('active'); 284 } 285 }); 286 } 287 // This is setting replace state for first time, because in popstate we have not data for the first time load page so we will set data there 288 var setReplaceState = function() { 289 if(vars.pushState && vars.origURL && !vars.tempPushStateOff) { 290 var data = {}; 291 var currURL = location.href; 292 293 var res = createAjaxParam(); 294 var data = res.data; 295 window.history.replaceState(data, null, currURL); 296 } 297 } 298 299 /* 300 * Pass options when class instantiated 301 */ 302 this.construct(options); 303}
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.