1jQuery( function( $ ) { 2 3 //when variation_id changes, take appropriate action on quotelist button (show/hide) 4 $('[name|="variation_id"]').change(function() { 5 6 if($('[name|="variation_id"]').val()!='') { 7 8 //find whether it is already exists in quotelist 9 var data = {action: 'find_prod_in_qlist'}; 10 data['prod_id'] = $('[name|="product_id"]').val(); 11 data['variation_id'] = $('[name|="variation_id"]').val(); 12 13 $.post( dvin_wcql_ajax_url, data, function( response ) { 14 15 if(response == "true") { 16 17 $('.quotelistadd_prodpage').css('display','none'); 18 $('.quotelistexistsbrowse_prodpage').css('display','block'); 19 $('.quotelistaddedbrowse_prodpage').css('display','none'); 20 21 } else { 22 23 $('.quotelistadd_prodpage').css('display','block'); 24 $('.quotelistexistsbrowse_prodpage').css('display','none'); 25 $('.quotelistaddedbrowse_prodpage').css('display','none'); 26 27 } 28 29 }); 30 31 $('.quotelistaddresponse').html(''); 32 33 if(dvin_wcql_disable_insteadof_hide_button == "true") 34 $('.addquotelistbutton_prodpage').removeClass( 'disabled' ).addClass( 'enabled' ); 35 } else { 36 $('.quotelistadd_prodpage').css('display','block'); 37 $('.quotelistexistsbrowse_prodpage').css('display','none'); 38 $('.quotelistaddedbrowse_prodpage').css('display','none'); 39 40 if(dvin_wcql_disable_insteadof_hide_button == "true") 41 $('.addquotelistbutton_prodpage').removeClass( 'enabled' ).addClass( 'disabled' ); 42 else 43 $('.quotelistadd_prodpage').css('display','none'); 44 $('.quotelistexistsbrowse_prodpage').fadeOut(); 45 } 46 47 }); 48 //Ajax remove from qlist 49 $( document ).on( 'click', '.removeproductqlist', function(e) { 50 var $thisbutton = $( this ); 51 if ( ! $thisbutton.attr( 'data-product_id' ) ) 52 return true; 53 var data = {action: 'remove_from_qlist'}; 54 $.each( $thisbutton.data(), function( key, value ) { 55 data[key] = value; 56 }); 57 // Trigger event 58 $( 'body' ).trigger( 'remove_from_qlist', [ $thisbutton, data ] ); 59 // Ajax action 60 $.post( dvin_wcql_ajax_url, data, function( response ) { 61 if ( ! response ) 62 return; 63 $( this ).closest('tr').remove(); 64 location.reload(true); 65 66 }); 67}); 68 // Ajax add to qlist from shop 69 $( document ).on( 'click', '.addquotelistbutton_prodpage', function(e) { 70 71 var $this = $( this ); 72 73 if ( $this.is('.disabled') ) { 74 event.preventDefault(); 75 return false; 76 } 77 78 var data = {action: 'add_to_qlist_from_prodpage'}; 79 80 // AJAX add to cart request 81 var $thisbutton = $( this ); 82 83 //check for the data attribute 84 if ( ! $thisbutton.attr( 'data-product_id' ) ) 85 return true; 86 87 //get the data into the array 88 $.each( $thisbutton.data(), function( key, value ) { 89 data[key] = value; 90 }); 91 92 if($('form.cart').length){ 93 if($thisbutton.closest('form.cart').serialize()!='') { 94 data['form_serialize_data']=$thisbutton.closest('form.cart').serialize(); 95 } else if($thisbutton.closest('.addquotelistlink').prev("form.cart").serialize()!='') { 96 data['form_serialize_data']=$thisbutton.closest('.addquotelistlink').prev("form.cart").serialize(); 97 } else { 98 data['form_serialize_data']=$('form.cart').serialize(); 99 } 100 } 101 102 //check if element(widget DIV) exists and no redirect...need refresh 103 if(dvin_quotelist_refresh_afteradd_url !='') { 104 data['widget_refresh'] = "false"; 105 data['count_refresh'] = "false"; 106 } else { 107 if($('div#quotelist-widget').length >0) 108 data['widget_refresh'] = "true"; 109 else 110 data['widget_refresh'] = "false"; 111 if($('div#dvin-quotelist-count').length >0) 112 data['count_refresh'] = "true"; 113 else 114 data['count_refresh'] = "false"; 115 } 116 // Trigger event 117 $( 'body' ).trigger( 'adding_to_qlist', [ $thisbutton, data ] ); 118 $thisbutton.parent().parent().parent().find('.ajax-loading-img').fadeIn(); 119 // Ajax action 120 $.post( dvin_wcql_ajax_url, data, function( response ) { 121 if ( !response ) 122 return; 123 var loading = $('.ajax-loading-img'); 124 loading.fadeOut(); 125 fragments = response.fragments; 126 // Replace fragments 127 if ( fragments ) { 128 $.each( fragments, function( key, value ) { 129 $( key ).replaceWith( value ); 130 }); 131 } 132 133 //if refresh, no need to hide or display message 134 if(dvin_quotelist_refresh_afteradd_url !='') { 135 window.location = dvin_quotelist_refresh_afteradd_url; 136 } else { 137 138 $thisbutton.parent().parent().parent().children('.removefromprodpage').css('display','none'); // 139 $thisbutton.parent().parent().parent().children('.quotelistaddedbrowse_prodpage').css('display','block'); 140 141 if(dvin_wcql_addons == '1') { 142 $('.quotelistaddedbrowse_prodpage').fadeOut(4000); 143 } else { 144 $thisbutton.parent().parent().parent().children('.quotelistadd_prodpage').css('display','none'); 145 $('a.removefromprodpage').attr("data-product_id",response.product_id); 146 } 147 return true; 148 } 149 }); 150 return false; 151 }); 152 // Ajax add to qlist from shop 153 $( document ).on( 'click', '.addquotelistbutton', function(e) { 154 // AJAX add to cart request 155 var $thisbutton = $( this ); 156 if ( $thisbutton.is( '.product_type_simple' ) || $thisbutton.is( '.product_type_external' )) {
157 if ( ! $thisbutton.attr( 'data-product_id' ) ) 158 return true; 159 var data = {action: 'add_to_qlist'}; 160 $.each( $thisbutton.data(), function( key, value ) { 161 data[key] = value; 162 }); 163 //check if element(widget DIV) exists and no redirect...need refresh 164 if(dvin_quotelist_refresh_afteradd_url !='') { 165 data['widget_refresh'] = "false"; 166 data['count_refresh'] = "false"; 167 } else { 168 if($('div#quotelist-widget').length >0) 169 data['widget_refresh'] = "true"; 170 if($('div#dvin-quotelist-count').length >0) 171 data['count_refresh'] = "true"; 172 } 173 // Trigger event 174 $( 'body' ).trigger( 'adding_to_qlist', [ $thisbutton, data ] ); 175 $('#'+$thisbutton.attr( 'data-product_id')).find('.ajax-loading-img').fadeIn(); 176 // Ajax action 177 $.post( dvin_wcql_ajax_url, data, function( response ) { 178 if ( ! response ) 179 return; 180 181 var loading = $('#'+$thisbutton.attr( 'data-product_id')).children('.ajax-loading-img'); 182 loading.fadeOut(); 183 184 //if refresh, no need to hide or display message 185 if(dvin_quotelist_refresh_afteradd_url =='') { 186 187 fragments = response.fragments; 188 // Replace fragments 189 if ( fragments ) { 190 $.each( fragments, function( key, value ) { 191 $( key ).replaceWith( value ); 192 }); 193 } 194 195 $('#'+data['product_id']).children('.quotelistadd').css('display','none'); 196 $('#'+data['product_id']).children('.quotelistaddedbrowse').css('display','block'); 197 } else { 198 window.location = dvin_quotelist_refresh_afteradd_url; 199 return; 200 } 201 }); 202 return false; 203 } 204 return true; 205 }); 206 // Ajax remove product from product page 207 $( document ).on( 'click', '.removefromprodpage', function(e) { 208 var data = {action: 'remove_from_page'}; 209 210 // AJAX add to cart request 211 var $thisbutton = $( this ); 212 213 //check for the data attribute 214 if ( ! $thisbutton.attr( 'data-product_id' ) ) 215 return true; 216 217 //get variation data 218 if($('[name|="variation_id"]').length && $('[name|="variation_id"]').val() >0) { 219 var_id = $('[name|="variation_id"]').val(); 220 $thisbutton.attr( 'data-product_id', var_id); 221 } 222 223 //get the data into the array 224 $.each( $thisbutton.data(), function( key, value ) { 225 data[key] = value; 226 }); 227 228 229 230 if($('div#quotelist-widget').length >0) 231 data['widget_refresh'] = "true"; 232 else 233 data['widget_refresh'] = "false"; 234 if($('div#dvin-quotelist-count').length >0) 235 data['count_refresh'] = "true"; 236 else 237 data['count_refresh'] = "false"; 238 239 // Trigger event 240 $( 'body' ).trigger( 'remove_from_qlist', [ $thisbutton, data ] ); 241 // Ajax action 242 $.post( dvin_wcql_ajax_url, data, function( response ) { 243 if ( ! response ) 244 return; 245 fragments = response.fragments; 246 // Replace fragments 247 if ( fragments ) { 248 $.each( fragments, function( key, value ) { 249 $( key ).replaceWith( value ); 250 }); 251 } 252 253 $thisbutton.parent().parent().children('.quotelistadd_prodpage').css('display','block'); 254 $thisbutton.parent().parent().children('.quotelistaddedbrowse_prodpage').css('display','none'); 255 $thisbutton.parent().parent().children('.quotelistexistsbrowse_prodpage').css('display','none'); 256 257 }); 258 return false; 259 }); 260 261 //if list has some products 262 if($('#dvin-quotelist-count').length>0) { 263 //if DIV for count exists, update it 264 $('#dvin-quotelist-count').html(dvin_quotelist_count); 265 } 266 if($('div#quotelist-widget').length>0) { 267 refresh_quotelist_widget(); 268 } 269 270}); 271 272function ajax_req_update_quote() { 273 serialized_data = jQuery( "input[name^='cart']" ).serialize()+'&action=update_list'; 274 jQuery.ajax({ 275 type: 'POST', 276 url: dvin_wcql_ajax_url, 277 data: serialized_data, 278 success: function( response ) { 279 location.reload(true); 280 } 281 });
282} 283//handles ajax call post form 284function call_ajax_submitform_to_admin(url) { 285 286 var data = {action: 'send_request'}; 287 data['form_serialize_data']=jQuery('.qlist').serialize(); 288 289 if(data['form_serialize_data']=='') 290 return; 291 else 292 jQuery('.ajax-loading-img').fadeIn(); 293 294 if(jQuery('div#quotelist-widget').length >0) 295 data['widget_refresh'] = "true"; 296 else 297 data['widget_refresh'] = "false"; 298 if(jQuery('div#dvin-quotelist-count').length >0) 299 data['count_refresh'] = "true"; 300 else 301 data['count_refresh'] = "false"; 302 // Ajax action 303 jQuery.post( dvin_wcql_ajax_url, data, function( response ) { 304 if ( ! response ) 305 return; 306 var msg = jQuery('#dvin-message-popup'); 307 var loading = jQuery('.ajax-loading-img'); 308 loading.fadeOut(); 309 if(response.status == "success") { 310 fragments = response.fragments; 311 // Replace fragments 312 if ( fragments ) { 313 jQuery.each( fragments, function( key, value ) { 314 jQuery( key ).replaceWith( value ); 315 }); 316 } 317 jQuery('.shop_table').remove(); 318 jQuery('#formtable').remove(); 319 jQuery('#dvin_wcql_details').css('display','none'); 320 jQuery('#dvin_wcql_success_msg').css('display','block'); 321 jQuery('#dvin_messages').html(' '); 322 jQuery('html, body').animate({ scrollTop: 0 }, 'slow'); 323 jQuery('#dvin_message').html(''); 324 } else if(response.status == "redirect"){ 325 window.location = response.redirect_url; 326 return; 327 } else if(response.status == "error") { 328 jQuery('#dvin_messages').html(response.msg); 329 } 330 msg.fadeIn(); 331 window.setTimeout(function(){ 332 msg.fadeOut(); 333 }, 2000); 334 }); 335} 336function refresh_quotelist_widget() { 337 338 var data = {action: 'wcql_widget_refresh'}; 339 data['widget_refresh'] = "true"; 340 data['count_refresh'] = "true"; 341 // Ajax action 342 jQuery.post( dvin_wcql_ajax_url, data, function( response ) { 343 if ( ! response ) 344 return; 345 if(response.status == "success") { 346 fragments = response.fragments; 347 // Replace fragments 348 if ( fragments ) { 349 jQuery.each( fragments, function( key, value ) { 350 jQuery( key ).replaceWith( value ); 351 }); 352 } 353 } 354 }); 355}
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.