1(function($) { 2 3 /** 4 * Scripts relating to adding/removing the "loading" class which some themes use 5 */ 6 7 $('body').on('click', '.somdn-download-button:not(.somdn-checkbox-submit), .somdn-download-archive', function (e) { 8 $(this).addClass('loading'); 9 }); 10 11 $('body').on('click', '.somdn-download-button, .somdn-download-archive', function (e) { 12 var element = $(this); 13 setTimeout( 14 function() { 15 if (element.hasClass('loading')) { 16 element.removeClass('loading'); 17 //console.log('element.removeClass'); 18 } 19 }, 20 2000); 21 }); 22 23 /**********************************************************************/ 24 25 /** 26 * Scripts relating to download buttons that are actually anchor elements 27 */ 28 29 $('body').on('click', 'a.somdn-download-archive', function (e) { 30 e.stopImmediatePropagation(); 31 var form = $(this).closest('form.somdn-archive-download-form'); 32 form.submit(); 33 return false; 34 }); 35 36 $('body').on('click', '.somdn-download-link', function (e) { 37 e.stopImmediatePropagation(); 38 var form = $(this).closest('form'); 39 form.submit(); 40 return false; 41 }); 42 43 /**********************************************************************/ 44 45 /** 46 * Scripts relating to the multiple file checkbox form 47 */ 48 49 $('body').on('click', '.somdn-checkbox-form .somdn-checkbox-submit', function (e) { 50 var form = $(this).closest('form'); 51 if ($(form).find('input[type="checkbox"]:checked').length == 0) { 52 e.preventDefault(); 53 $('.somdn-form-validate').css('display', 'block'); 54 } else { 55 $('.somdn-form-validate').css('display', 'none'); 56 $(this).addClass('loading'); 57 } 58 }); 59 60 $('body').on('click', '.somdn-select-all-wrap input[type="checkbox"]', function (e) { 61 var c = this.checked; 62 var form = $(this).closest('form'); 63 $(form).find('.somdn-checkboxes-wrap input[type="checkbox"]').prop('checked', c); 64 }); 65 66 $('body').on('click', '.somdn-checkbox-form .somdn-checkbox-form-checkbox', function (e) { 67 var form = $(this).closest('form'); 68 var checkboxes = $(form).find('.somdn-checkbox-form-checkbox'); 69 var checked_count = $(form).find('.somdn-checkbox-form-checkbox:checked').length;// How many checkboxes currently checked 70 var count = checkboxes.length;// How many checkboxes in total 71 if (checked_count < count) { 72 $(form).find('.somdn-checkbox-all').prop('checked', false); 73 } else { 74 $(form).find('.somdn-checkbox-all').prop('checked', true); 75 } 76 }); 77 78 /**********************************************************************/ 79 80 /** 81 * Quick View scripts 82 */ 83 84 $('body').on('click', '.somdn-qview-link', function (e) { 85 var prod_wrap = $(this).closest('li.product'); 86 if (qview_active()) { 87 e.preventDefault(); 88 somdn_open_qview(prod_wrap, event); 89 } else { 90 // Do nothing 91 } 92 }); 93 94 /** 95 * Check if Quick View is active globally 96 * 97 * @return bool 98 */ 99 function qview_active() { 100 var qview_enabled = somdn_script_params.somdn_qview_active; 101 if (qview_enabled) { 102 return true; 103 } else { 104 return false; 105 } 106 } 107 108 /** 109 * Check if Quick View is active on the current page 110 * 111 * @return bool 112 */ 113 function qview_active_page(form) { 114 var qview_enabled = somdn_script_params.somdn_qview_active; 115 if (qview_enabled) { 116 return true; 117 } else { 118 return false; 119 } 120 } 121 122 /** 123 * Open the Quick View modal 124 */ 125 function somdn_open_qview(prod_wrap, event) { 126 127 //$(prod_wrap).addClass('somdn-form-email-capture'); 128 129 var the_qview_wrap = $(prod_wrap).find('.somdn-qview-wrap'); 130 131 $('body').addClass('somdn-qview-open'); 132 $(the_qview_wrap).addClass('open'); 133 134 $('body').trigger('somdn_open_qview', [ prod_wrap, event ]); 135 136 } 137 138 /** 139 * Close the Quick View modal 140 */ 141 function somdn_close_qview(prod_wrap, event) { 142 143 //$(prod_wrap).removeClass('somdn-form-email-capture'); 144 $(prod_wrap).find('.somdn-checkbox-form-checkbox, .somdn-checkbox-all').prop('checked', false); 145 $(prod_wrap).find('.somdn-qview-wrap').removeClass('open'); 146 $('body').removeClass('somdn-qview-open'); 147 148 $('body').trigger('somdn_close_qview', [ prod_wrap, event ]); 149 150 } 151 152 /** 153 * Two events that close the Quick View modal 154 * 1. Clicking the X in the top right corner of the modal
155 * 2. Clicking anywhere outside the modal when it is open 156 */ 157 $('body').on('click', '.somdn-qview-wrap .somdn-qview-close', function (event) { 158 var prod_wrap = $(this).closest('li.product'); 159 somdn_close_qview(prod_wrap, event); 160 }); 161 162 $(document).on('click', '.somdn-qview-wrap', function(event) { 163 var prod_wrap = $(this).closest('li.product'); 164 somdn_close_qview(prod_wrap, event); 165 }).on('click', '.somdn-qview-window', function(e) { 166 e.stopPropagation(); 167 }); 168 169 /**********************************************************************/ 170 171})(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.