1/** 2 * Product Options javascript 3 * 4 * @category CMS 5 * @package Shout 6 * @subpackage Store 7 * @copyright ? 8 * @license ? 9 * @author Chris Glass <[email protected]> 10 * @since Thurs, Sept 9, 2004 11 * @version $Id$ 12 */ 13 14var productoptions = new Array(); 15var inc = 1; 16 17/** 18* ProductOption 19* 20* @param string name 21* @param int type 22*/ 23function ProductOption(name, type) 24{ 25 this.id = inc; 26 this.name = name; 27 this.values = new Array(); 28 this.active = true; 29 this.dbId = 0; 30 this.type = type; 31 this.value = ""; 32 this.added = false; 33 this.required = true; 34 this.set = 1; 35 36 inc++; 37} 38 39window.changeOptionFilters = function changeOptionFilters(triggerElement) 40{ 41 var $container = jQuery(triggerElement).closest('.product_browse'); 42 // We traverse up from the trigger element to find the clustered group of products we're going to filter. 43 var categories = jQuery.map( 44 jQuery(triggerElement) 45 .closest('.product_browse') 46 .find('select[name*=filter_option].product_browse-category_filter') 47 ,function(element) 48 { 49 return ".category-"+jQuery(element).val(); 50 } 51 ); 52 53 var sort = $container.find('.product_browse-sort').val(); 54 55 var browseProducts = $container.find('.product_browse-product').get(); 56 57 browseProducts = browseProducts.sort(function(a, b) 58 { 59 var priceA = jQuery(a).find('input[name=price]').val(); 60 var priceB = jQuery(b).find('input[name=price]').val(); 61 62 return (priceA < priceB) ? -1 : (priceA > priceB) ? 1 : 0; 63 }); 64 65 if (sort == 'desc') 66 { 67 browseProducts = browseProducts.reverse(); 68 } 69 70 var $itemContainer = $container.find('.product_browse-items'); 71 72 jQuery.each(browseProducts, function() 73 { 74 $itemContainer.append(this); 75 }); 76 77 if (categories.length) 78 { 79 $container.find('.product_browse-product').hide(); 80 81 // An and style query via the way we're joining the classes above (no spaces so we're saying show 82 // only categories that match .category-665.category-555 83 $container.find('.product_browse-product').filter(categories.join('')).show(); 84 } 85}; 86 87(function($) 88{ 89 $(document).ready(function() 90 { 91 var gallery_obj = null, 92 gallery_type = null, 93 gallery_imgs = []; 94 95 var lookupGallery = function() 96 { 97 var gallery_div = $('body.product div[id^="shout-gallery-"]'); 98 99 if (!gallery_div.length) 100 { 101 return; 102 } 103 104 gallery_div = gallery_div.eq(0); // always use first gallery 105 106 if (gallery_div.hasClass('shout-gallery-galleria') && (gallery_div.data('galleria') !== undefined)) 107 { 108 gallery_obj = gallery_div.data('galleria'); 109 gallery_type = 'galleria'; 110 } 111 else if (gallery_div.hasClass('shout-gallery-bootstrap') && (gallery_div.data('bs.carousel') !== undefined)) 112 { 113 gallery_obj = gallery_div.data('bs.carousel'); 114 gallery_type = 'bootstrap'; 115 } 116 else if (gallery_div.hasClass('shout-gallery-lightbox')) 117 { 118 gallery_obj = gallery_div; 119 gallery_type = 'lightbox'; 120 } 121 }; 122 123 setTimeout(function() 124 { 125 lookupGallery(); 126 }, 0); 127 128// $('.product_option-field__control').each(function() 129// { 130// $(this).change(function() 131 $('.product-options.section-wrapper').on('change', '.product_option-field__control', function() 132 { 133 var image_id = $(this).find(':selected, :checked').data('image_id'); 134 135 if (!gallery_obj) 136 { 137 lookupGallery(); 138 } 139 140 if (gallery_obj && image_id) 141 { 142 switch (gallery_type) 143 { 144 case 'galleria': 145 for (var i = 0; i < gallery_obj.getDataLength(); i++) 146 { 147 var current_image_id = gallery_obj.getData(i).original.attributes['data-id'].value; 148 149 if (current_image_id == image_id) 150 { 151 gallery_obj.show(i); 152 break; 153 } 154 } 155 break; 156 157 case 'bootstrap': 158 if (!gallery_obj.$items) 159 { 160 break; 161 } 162 163 for (var i = 0; i < gallery_obj.$items.length; i++) 164 { 165 var current_image_id = $(gallery_obj.$items[i]).data('id'); 166 167 if (current_image_id == image_id) 168 { 169 gallery_obj.$element.carousel(i); 170 break; 171 } 172 } 173 break; 174 } 175 } 176 }); 177// }); 178 }); 179})(jQuery);
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.