1function postSearch(page = 1){ 2 //set vars to pass to search results page 3 var keyword = $('#keyword').val(); 4 var min_price = $('#min_price').val(); 5 var max_price = $('#max_price').val(); 6 var sort = $('#sort').val(); 7 var limit = $('#limit').val(); 8 9 //empty div 10 $('#search_results').empty(); 11 12 //set doc var 13 if ($('#document_ind').prop('checked')) { 14 var document_ind = 1; 15 } else { 16 var document_ind = 0; 17 } 18 19 //set sold out var 20 if ($('#store_hide_sold_out').prop('checked')) { 21 var store_hide_sold_out = 1; 22 } else { 23 var store_hide_sold_out = 0; 24 } 25 26 //build an array of any checked categories to pass 27 var selected_categories = $('.selected_categories:checked').map(function(){ 28 return $(this).val(); 29 }).get(); 30 31 //build an array of any checked tags to pass 32 var selected_tags = $('.selected_tags:checked').map(function(){ 33 return $(this).val(); 34 }).get(); 35 36 //post to results page 37 var url = 'store_results_content.php'; 38 $.post(url, { 39 'keyword' : keyword, 40 'min_price' : min_price, 41 'max_price' : max_price, 42 'document_ind' : document_ind, 43 'store_hide_sold_out' : store_hide_sold_out, 44 'sort' : sort, 45 'org_id' : org_id, 46 'adm_id' : adm_id, 47 'adm_mem_id' : adm_mem_id, 48 'mid' : mid, 49 'page' : page, 50 'limit' : limit, 51 'selected_categories' : selected_categories, 52 'selected_tags' : selected_tags 53 }, function(data){ 54 $('#search_results').html(data); 55 56 // console.log(adm_id); 57 // console.log(adm_mem_id); 58 59 //apply img-responsive to images in cards 60 $('.store-product-container').find('img').addClass('img-responsive'); 61 }, 'json'); 62 63 //add clear icon 64 var cat_array = $.isEmptyObject(selected_categories); 65 var tag_array = $.isEmptyObject(selected_tags); 66 if (cat_array == false || tag_array == false || keyword != '' || min_price != '' || max_price != '' || document_ind > 0 || store_hide_sold_out > 0) { 67 $('#store-filter-clear').html('<a class="clear-filter">clear all filters</a>'); 68 $('#store-filter-clear').css('margin-top', '5px'); 69 } else { 70 $('#store-filter-clear').html(''); 71 $('#store-filter-clear').css('margin-top', '0px'); 72 } 73 74 $('#store_table').imagesLoaded(function() { 75 setCardHeights(); 76 setCardTopHeights(); 77 } 78 ); 79 80 //jump to top of page 81 toTheTop(); 82} 83 84//function to clear search filters 85$(document).on('click', '.clear-filter', function(){ 86 //reset all values 87 $('.selected_categories').prop('checked', false); 88 $('.selected_tags').prop('checked', false); 89 $('#document_ind').prop('checked', false); 90 $('#store_hide_sold_out').prop('checked', false); 91 $('#keyword').val(''); 92 $('#min_price').val(''); 93 $('#max_price').val(''); 94 95 //run search again 96 postSearch(); 97}); 98 99//initialize dialog 100$('#quick_view').dialog({ 101 autoOpen: false, 102 height: 'auto', 103 width: '400px', 104 modal: true, 105 title: 'Product Quick View' 106}); 107 108//close dialogs on click outside 109$('body').on('click', 'div.ui-widget-overlay', function() { 110 $('#quick_view').dialog('close'); 111 $('#promo_info').dialog('close'); 112}); 113 114//load product info into div 115$(document).on('click', '.view-product',function(){ 116 var prod_id = $(this).data('prod_id'); 117 $('#quick_view').load('store_quick_view.php?prod_id='+prod_id+add_str, function(){ 118 setTimeout(function(){ 119 quickView(); 120 }, 200); 121 }); 122}); 123 124//main function to open info dialogs 125function quickView() 126{ 127 $('#quick_view').dialog('option', 'buttons', [ 128 { 129 text: 'Close', 130 click: function(){ 131 $('#quick_view').dialog('close'); 132 $('#quick_view').empty(); 133 } 134 } 135 ]); 136 $('#quick_view').dialog('open'); 137} 138 139//enable tooltips 140$('[data-toggle="tooltip"]').tooltip(); 141 142//no script message 143$('noscript').remove(); 144$('#content').show(); 145$('.hidenoscript').show(); 146 147function loadCartIcon() 148{ 149 //load icon into div, then sync the v7 sidebar's cart badge (if this 150 //page renders the sidebar) so both cart indicators always agree. 151 //store_cart_icon.php emits the count inside .store-cart-count, or 152 //nothing when the cart is empty â parse accordingly. 153 $('.store-cart-count-container').load('store_cart_icon.php', function(){ 154 if (typeof window.mmsSidebarCartUpdate === 'function') { 155 var sidebar_ct = parseInt($(this).find('.store-cart-count').first().text(), 10) || 0; 156 window.mmsSidebarCartUpdate(sidebar_ct); 157 } 158 }); 159} 160
161//controls paginating through result set 162$(document).on('click', '.store-pagination', function(){ 163 var page = $(this).data('page'); 164 postSearch(page); 165}); 166 167$(document).on('change', '#limit', function(){ 168 postSearch(); 169}); 170 171//run search on filter changes 172$(document).on('change', '.store_filter', function(){ 173 postSearch(); 174}); 175$(document).on('change', '.store-sort-box', function(){ 176 postSearch(); 177}); 178$(document).on('click', '.keyword_submit', function(){ 179 postSearch(); 180}); 181 182$(document).on('submit', '.sto_add_to_cart', function(e){ 183 e.preventDefault(); 184}); 185 186$(document).on('submit', '.sto_add_to_cart_quick', function(e){ 187 e.preventDefault(); 188}); 189 190//submit add to cart function when enter is pressed in qty input 191$(document).on('keypress', '.sto-quantity', function (e) { 192 if (e.which == 13) { 193 //define the prod id 194 var prod_id = $(this).data('prod_id'); 195 196 //trigger cart function 197 addToCart(prod_id); 198 } 199}); 200$(document).on('keypress', '.sto-quantity-quick', function (e) { 201 if (e.which == 13) { 202 //define the prod id 203 var prod_id = $(this).data('prod_id'); 204 205 //trigger cart function 206 addToCartQuick(prod_id); 207 208 //close dialog 209 $('#quick_view').dialog('close'); 210 $('#quick_view').empty(); 211 } 212}); 213 214//ajax add to cart function 215$(document).on('click', '.store_add_to_cart', function(){ 216 //define the prod id 217 var prod_id = $(this).data('prod_id'); 218 219 //trigger cart function 220 addToCart(prod_id); 221}); 222 223function addToCart(prod_id) 224{ 225 //add ajax flag 226 $('#sto_form_'+prod_id).append('<input type="hidden" name="sto_ajax" value="X" /> '); 227 228 //define url 229 var url = 'store_cart.php'; 230 231 //post to cart page 232 $.post(url, $('#sto_form_'+prod_id).serialize(), function(data) { 233 //show gritter error or success message 234 $.gritter.add({ 235 title: data.title, 236 text: data.message, 237 sticky: false, 238 time: 2500 239 }); 240 241 //reload cart icon div 242 loadCartIcon(); 243 }, 'json'); 244} 245 246//ajax add to cart function from quick view 247$(document).on('click', '.store_add_to_cart_quick', function(){ 248 //define the prod id 249 var prod_id = $(this).data('prod_id'); 250 251 //trigger cart function 252 addToCartQuick(prod_id); 253 254 //close dialog 255 $('#quick_view').dialog('close'); 256 $('#quick_view').empty(); 257}); 258 259function addToCartQuick(prod_id) 260{ 261 //add ajax flag 262 $('#sto_form_quick_'+prod_id).append('<input type="hidden" name="sto_ajax" value="X" /> '); 263 264 //define url 265 var url = 'store_cart.php'; 266 267 //post to cart page 268 $.post(url, $('#sto_form_quick_'+prod_id).serialize(), function(data) { 269 //show gritter error or success message 270 $.gritter.add({ 271 title: data.title, 272 text: data.message, 273 sticky: false, 274 time: 2500 275 }); 276 277 //reload cart icon div 278 loadCartIcon(); 279 }, 'json'); 280} 281 282//this sets the top section of each card (image, name, price) to the same size so the description always shows at the same height 283//begin by looping through all the main slider elements 284function setCardTopHeights() 285{ 286 $('#store_table').imagesLoaded(function() { 287 $('.slider-container').each(function(slider_index, slider_element){ 288 //reset the highest count 289 var highest = 0; 290 291 //reset the count array 292 var heights = new Array(); 293 294 //now loop through the store-product-top-info divs within the slider, record the heights to an array and sort 295 $(slider_element).find('.store-product-top-info').each( function(store_top_index, store_top_element){ 296 //get height 297 $(store_top_element).css('height', 'auto'); 298 299 //push to array 300 heights.push($(store_top_element).height()); 301 302 //sort so highest number is always first 303 heights = heights.sort(sortNumber).reverse(); 304 }); 305 306 //get highest height 307 highest = heights[0]; 308 309 //loop through store-product-top-info divs within slider again and reset all heights 310 $(slider_element).find('.store-product-top-info').each( function(store_top_index, store_top_element){ 311 $(store_top_element).css('height', highest); 312 }); 313 }); 314 }); 315} 316 317function setCardTopHeightsFeatured() 318{ 319 $('.slick-slider-featured').each(function(slider_index, slider_element){ 320 //reset the highest count 321 var highest = 0; 322 323 //reset the count array 324 var heights = new Array(); 325 326 //now loop through the store-product-top-info divs within the slider, record the heights to an array and sort 327 $(slider_element).find('.store-product-top-info').each( function(store_top_index, store_top_element){ 328 //get height 329 $(store_top_element).css('height', 'auto'); 330 331 //push to array 332 heights.push($(store_top_element).height()); 333 334 //sort so highest number is always first 335 heights = heights.sort(sortNumber).reverse(); 336 }); 337 338 //get highest height 339 highest = heights[0]; 340 341 //loop through store-product-top-info divs within slider again and reset all heights 342 $(slider_element).find('.store-product-top-info').each( function(store_top_index, store_top_element){ 343 $(store_top_element).css('height', highest); 344 }); 345 }); 346} 347 348//sets the card top heights on the results page 349function setCardTopHeightsResults() 350{ 351 $('#store_table').imagesLoaded(function() { 352 for (var i = 1; i < 1000; i++) { 353 //break the loop once we run out of rows 354 if ($('.store-product-top-info-'+i).length === 0) { 355 break; 356 } 357 358 //reset the highest count 359 var highest = 0; 360 361 //reset the count array 362 var heights = new Array(); 363 364 //now loop through the store-product-top-info divs 365 $('.store-product-top-info-'+i).each(function(element_index, store_top_element){ 366 //get height 367 $(store_top_element).css('height', 'auto'); 368 369 //push to array 370 heights.push($(store_top_element).height()); 371 372 //sort so highest number is always first 373 heights = heights.sort(sortNumber).reverse(); 374 }); 375 376 //get highest height 377 highest = heights[0]; 378 379 //loop through store-product-top-info divs within slider again and reset all heights 380 $('.store-product-top-info-'+i).each(function(element_index, store_top_element){ 381 $(store_top_element).css('height', highest); 382 }); 383 } 384 }); 385} 386 387function resetCardTopHeights() 388{ 389 $('.store-product-top-info').css('height', 'auto'); 390} 391function resetCardHeights() 392{ 393 $('.sstore-product-container').css('height', 'auto'); 394} 395 396function setCardHeights() 397{ 398 $('#store_table').imagesLoaded(function() { 399 for (var i = 1; i < 1000; i++) { 400 //break the loop once we run out of rows 401 if ($('.store-product-container-'+i).length === 0) { 402 break; 403 } 404 405 //reset the highest count 406 var highest = 0; 407 408 //reset the count array 409 var heights = new Array(); 410 411 //loop through top level container elements 412 $('.store-product-container-'+i).each(function(slider_index, slider_element){ 413 //get height 414 $(slider_element).css('height', 'auto'); 415 416 //push to array 417 heights.push($(slider_element).outerHeight()); 418 419 //sort so highest number is always first 420 heights = heights.sort(sortNumber).reverse(); 421 }); 422 423 //get highest height and add some extra padding 424 highest = heights[0] + 15; 425 426 //loop through store-product-top-info divs within slider again and reset all heights 427 $('.store-product-container-'+i).each(function(slider_index, slider_element){ 428 $(slider_element).css('height', highest); 429 }); 430 } 431 }); 432} 433 434function sortNumber(a,b) 435{ 436 return a - b; 437} 438 439//this removes the text and numbers from the slider buttons 440function checkSliderText() 441{ 442 var dotNums = document.querySelectorAll(".slick-dots button"); 443 var arrowBtns = document.querySelectorAll(".slick-arrow");
444 dotNums.forEach(removeText); 445 arrowBtns.forEach(removeText); 446} 447 448function removeText(item) 449{ 450 item.innerHTML = ''; 451} 452 453//function for grid view on main store page 454function gridView() 455{ 456 //re-add the main class 457 $('.slider-container').addClass('slick-slider-cats'); 458 459 //update css for divs that need it 460 $('.slick-slider-cats .store-product-image-container').css({'float' : '', 'margin-right' : '-10px -10px 6px -10px', 'width': 'auto' }); 461 $('.slick-slider-cats .store-product-view').css({'bottom' : 0, left : 0, right: 'auto', top: 'auto'}); 462 463 //refresh 464 $('.slick-slider-cats').slick('refresh'); 465 466 //get rid of the text and numbers again 467 var dotNums = document.querySelectorAll(".slick-dots button"); 468 var arrowBtns = document.querySelectorAll(".slick-arrow"); 469 dotNums.forEach(removeText); 470 arrowBtns.forEach(removeText); 471 472 //reset the card heights 473 setTimeout(function() { 474 setCardTopHeights(); 475 }, 100); 476} 477 478//function for list view on main store page 479function listView() 480{ 481 //kill slider 482 $('.slick-slider-cats').slick('unslick'); 483 484 //update css for divs that need it 485 $('.slick-slider-cats .store-product-image-container').css({'float' : 'left', 'margin' : '0px 10px 0px 0px', 'width': '250px' }); 486 $('.slick-slider-cats .store-product-view').css({'top' : 0, right : 0, left: 'auto', bottom: 'auto'}); 487 488 //reset the card heights 489 setTimeout(function() { 490 resetCardTopHeights(); 491 }, 100); 492} 493 494//change to list view on main store page 495$(document).on('click', '.unslick', function(){ 496 //reset container heights 497 $('.store-product-top-info').css({'height':'auto'}); 498 $('.store-product-container').css({'height':'auto'}); 499 500 //run list view function 501 listView(); 502 503 //set the php session value with a helper file 504 $('.slider_view').load('store_session_view.php?slider_view=list'); 505}); 506 507//change back to grid view on main store page 508$(document).on('click', '.slick', function(){ 509 //reset container heights 510 $('.store-product-top-info').css({'height':'auto'}); 511 $('.store-product-container').css({'height':'auto'}); 512 513 //run the grid view function 514 gridView(); 515 516 //set the php session value with a helper file 517 $('.slider_view').load('store_session_view.php?slider_view=grid'); 518}); 519 520//function for grid view on search results page 521function gridViewResults() 522{ 523 //update css for divs that need it 524 $('.slick-slider-results .store-product-image-container').css({'float' : '', 'margin-right' : '-10px -10px 6px -10px', 'width': 'auto' }); 525 $('.slick-slider-results .store-product-view').css({'bottom' : 0, left : 0, right: 'auto', top: 'auto'}); 526 527 //add responsive column class back 528 $('.product-card-container').addClass('col-md-4'); 529 530 //reset the card heights 531 setTimeout(function() { 532 setCardHeights(); 533 setCardTopHeightsResults(); 534 }, 100); 535} 536 537//function for list view on search results page 538function listViewResults() 539{ 540 //remove column class 541 $('.product-card-container').removeClass('col-md-4'); 542 543 //update css for divs that need it 544 $('.slick-slider-results .store-product-image-container').css({'float' : 'left', 'margin' : '0px 10px 0px 0px', 'width': '250px' }); 545 $('.slick-slider-results .store-product-view').css({'top' : 0, right : 0, left: 'auto', bottom: 'auto'}); 546 547 //reset the card heights 548 setTimeout(function() { 549 resetCardHeights(); 550 resetCardTopHeights(); 551 }, 100); 552} 553 554//change to list view on search results page 555$(document).on('click', '.unslick_results', function(){ 556 //reset container heights 557 $('.store-product-top-info').css({'height':'auto'}); 558 $('.store-product-container').css({'height':'auto'}); 559 560 //run list view function 561 listViewResults(); 562 563 //set the php session value with a helper file 564 $('.slider_view').load('store_session_view.php?slider_view=list'); 565}); 566 567//change back to grid view on search results page 568$(document).on('click', '.slick_results', function(){ 569 //reset container heights 570 $('.store-product-top-info').css({'height':'auto'}); 571 $('.store-product-container').css({'height':'auto'}); 572 573 //run the grid view function
574 gridViewResults(); 575 576 //set the php session value with a helper file 577 $('.slider_view').load('store_session_view.php?slider_view=grid'); 578}); 579 580function toTheTop() 581{ 582 $('html, body').animate({ 583 scrollTop: 0 584 }, 'slow'); 585} 586 587//loads shipping options into contact info 588$(document).on('change', '.ship_opt', function() { 589 shippingTest(); 590}); 591function shippingTest() 592{ 593 if ($('.ship_opt:checked').val() == '1') { 594 $('.ship_depend').slideDown(); 595 } else { 596 $('.ship_depend').slideUp(); 597 } 598} 599 600//loads appropriate pickup options 601$(document).on('change', '.pickup_opt', function(){ 602 pickupTest(); 603}); 604function pickupTest() 605{ 606 if ($('.pickup_opt:checked').val() == '1') { 607 $('.pickup_depend').slideDown(); 608 } else { 609 $('.pickup_depend').slideUp(); 610 } 611}
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.