1// Ask for price open popup or send email functions 2var ciaskprice = { 3 'makeAskforPrice': function() { 4 var product_id = $('#product input[name=\'product_id\']').val(); 5 6 /*$('#button-cart').attr('disabled', true); 7 $("[onclick*=\"cart.add").attr('disabled', true);*/ 8 9 $.ajax({ 10 url: 'index.php?route=extension/ciaskprice/replacebutton', 11 dataType: 'json', 12 success: function(json) { 13 if (json['success']) { 14 if(json['askforprice_button']) { 15 var askforprice_button = json['askforprice_button']; 16 } else { 17 var askforprice_button = ''; 18 } 19 20 if(json['askforprice_products']) { 21 var askforprice_products = json['askforprice_products']; 22 $.each(askforprice_products, function(key, value) { 23 /*============================ Listing Pages =====================================*/ 24 /* In all pages add to cart button replace with ask for price */ 25 $("[onclick*=\"cart.add(\'"+ value['product_id'] +"\'\"]").html('<i class="fa fa-question-circle"></i> <span class="btn-text">'+ askforprice_button +'</span>').val(askforprice_button).removeAttr('onclick').attr('onclick', 'ciaskprice.open(\''+ value['product_id'] +'\')').attr('data-original-title', askforprice_button).attr('data-loading-text', '').addClass('button-ciaskprice button-ciaskprice'+ value['product_id']); 26 27 // Journal Theme 28 $("[onclick*=\"addToCart(\'"+ value['product_id'] +"\'\"]").parent().removeClass('cart'); 29 $("[onclick*=\"addToCart(\'"+ value['product_id'] +"\'\"]").html('<i class="fa fa-question-circle"></i> <span class="btn-text">'+ askforprice_button +'</span>').val(askforprice_button).removeAttr('onclick').attr('onclick', 'ciaskprice.open(\''+ value['product_id'] +'\')').attr('data-original-title', askforprice_button).attr('data-loading-text', '').addClass('button-ciaskprice button-ciaskprice'+ value['product_id']); 30 31 $('.side-product .button-ciaskprice').html('<i class="fa fa-question-circle"></i>'); 32 33 // Remove Product Price Div 34 $("[onclick*=\"ciaskprice.open(\'"+ value['product_id'] +"\'\"]").parents('.product-thumb').find('.price').remove(); 35 36 $('.button-ciaskprice'+ value['product_id']).parents('.product-layout').addClass('has-ciaskprice'); 37 38 /*============================ Product Page =====================================*/ 39 /* In product page add to cart button replace with ask for price */ 40 if(product_id == value['product_id']) { 41 if($('#button-cart').is("input")) { 42 $('#button-cart').addClass('button-ciaskprice button-ciaskprice'+ value['product_id']).off('click').attr('onclick', 'ciaskprice.open(\''+ value['product_id'] +'\')').val(askforprice_button); 43 } else { 44 $('#button-cart').addClass('button-ciaskprice button-ciaskprice'+ value['product_id']).off('click').attr('onclick', 'ciaskprice.open(\''+ value['product_id'] +'\')').html('<i class="fa fa-question-circle"></i> '+ askforprice_button); 45 } 46 } 47 }); 48 } 49 } 50 51 /*$('#button-cart').attr('disabled', false); 52 $("[onclick*=\"cart.add").attr('disabled', false); 53 $("[onclick*=\"ciaskprice.open").attr('disabled', false);*/ 54 } 55 }); 56 }, 57 'open': function(product_id, quantity) { 58 $.ajax({ 59 url: 'index.php?route=extension/ciaskprice/open', 60 type: 'post', 61 data: 'product_id=' + product_id + '&quantity=' + (typeof(quantity) != 'undefined' ? quantity : 1), 62 dataType: 'json', 63 beforeSend: function() { 64 $('.button-ciaskprice'+ product_id).attr('disabled', true); 65 }, 66 complete: function() { 67 $('.button-ciaskprice'+ product_id).attr('disabled', false); 68 }, 69 success: function(json) { 70 $('#ciaskpriceModal').remove(); 71 72 if(json['redirect']) { 73 location = json['redirect']; 74 } else if(json['html']) { 75 $('body').append(json['html']); 76 77 $('#ciaskpriceModal').modal('show'); 78 } 79 } 80 }); 81 }, 82 'send': function(product_id) { 83 $.ajax({
84 url: 'index.php?route=extension/ciaskprice/send&product_id='+ product_id, 85 dataType: 'json', 86 data: $('#ciaskpriceModal input[name="name"], #ciaskpriceModal input[name="email"], #ciaskpriceModal input[name="telephone"], #ciaskpriceModal input[name="quantity"], #ciaskpriceModal textarea[name="comment"], #ciaskpriceModal select, #ciaskpriceModal input[type=\'hidden\'], #ciaskpriceModal textarea, #ciaskpriceModal input, #ciaskpriceModal input[type=\'radio\']:checked, #ciaskpriceModal input[type=\'checkbox\']:checked, #product input[type=\'text\'], #product input[type=\'hidden\'], #product input[type=\'radio\']:checked, #product input[type=\'checkbox\']:checked, #product select, #product textarea').serialize(), 87 type: 'post', 88 beforeSend: function() { 89 $('#ciaskpriceModal .button-ciaskprice').button('loading'); 90 $('.loader_ci').addClass('ci_active'); 91 }, 92 complete: function() { 93 $('#ciaskpriceModal .button-ciaskprice').button('reset'); 94 }, 95 success: function(json) { 96 $('.loader_ci').removeClass('ci_active'); 97 $('#ciaskpriceModal .text-danger, #ciaskpriceModal .alert').remove(); 98 $('#ciaskpriceModal .form-group, #ciaskpriceModal .cifield-group').removeClass('has-error'); 99 100 if(json['captcha']) { 101 $('#ciaskpriceModal .cicaptcha').html(json['captcha']); 102 } 103 104 if (json['error']) { 105 if(json['error']['error_name']) { 106 $('#ciaskpriceModal input[name="name"]').after('<div class="text-danger">'+ json['error']['error_name'] +'</div>'); 107 } 108 109 if(json['error']['error_email']) { 110 $('#ciaskpriceModal input[name="email"]').after('<div class="text-danger">'+ json['error']['error_email'] +'</div>'); 111 } 112 113 if(json['error']['error_quantity']) { 114 $('#ciaskpriceModal input[name="quantity"]').after('<div class="text-danger">'+ json['error']['error_quantity'] +'</div>'); 115 } 116 117 if(json['error']['error_telephone']) { 118 $('#ciaskpriceModal input[name="telephone"]').after('<div class="text-danger">'+ json['error']['error_telephone'] +'</div>'); 119 } 120 121 if(json['error']['warning']) { 122 $('#ciaskpriceModal .termcondition_text').after('<div class="alert alert-danger warning"><i class="fa fa-exclamation-circle "></i> '+ json['error']['warning'] +'</div>'); 123 } 124 125 if(json['error']['error_comment']) { 126 $('#ciaskpriceModal textarea[name="comment"]').after('<div class="text-danger">'+ json['error']['error_comment'] +'</div>'); 127 } 128 129 if (json['error']['field']) { 130 for (i in json['error']['field']) { 131 var element = $('#ciaskpriceModal #input-field' + i.replace('_', '-')); 132 if (element.parent().hasClass('input-group')) { 133 element.parent().after('<div class="text-danger">' + json['error']['field'][i] + '</div>'); 134 } else { 135 element.after('<div class="text-danger">' + json['error']['field'][i] + '</div>'); 136 } 137 } 138 } 139 140 // Highlight any found errors 141 $('#ciaskpriceModal .text-danger').parent().addClass('has-error'); 142 } 143 144 if(json['success']) { 145 $('#ciaskpriceModal .modal-body').html(json['success']); 146 } 147 } 148 }); 149 } 150} 151 152$(document).ajaxComplete(function(a, b, c) { 153 if(c['url'] == 'index.php?route=checkout/cart/add') { 154 if(b['responseJSON']) { 155 if(b['responseJSON']['ciaskprice']) { 156 if(b['responseJSON']['ciaskprice']['addcart_warning']) { 157 // alert(b['responseJSON']['ciaskprice']['addcart_warning']); 158 159 $('#ErrorAlertCiAskPrice').remove(); 160 161 var html = ''; 162 html += '<div id="ErrorAlertCiAskPrice" style="top:20%;" class="modal fade" role="dialog">'; 163 html += '<div class="modal-dialog">'; 164 html += '<div class="modal-content">'; 165 html += '<div class="modal-body">'; 166 html += '<div class="alert alert-danger" style="margin:0;">'; 167 html += '<a href="#" class="close" data-dismiss="modal">×</a>'; 168 html += b['responseJSON']['ciaskprice']['addcart_warning']['message']; 169 html += '</div>'; 170 html += '</div>'; 171 html += '</div>'; 172 html += '</div>'; 173 html += '</div>'; 174 175 $('html body').append(html); 176 177 $('#ErrorAlertCiAskPrice').modal('show'); 178 } 179 } 180 } 181 } 182}); 183 184 185 186 187/* ============================== */ 188$(document).ready(function () { 189/* Country Popup */ 190$(document).delegate('#ciaskpriceModal .country_id', 'change', function() { 191 var text_select = $('#ciaskpriceModal .ciask_text_select').text(); 192 var text_none = $('#ciaskpriceModal .ciask_text_none').text(); 193 194 $.ajax({
195 url: 'index.php?route=account/account/country&country_id=' + this.value, 196 dataType: 'json', 197 beforeSend: function() { 198 $('#ciaskpriceModal .country_id').after(' <i class="fa fa-circle-o-notch fa-spin"></i>'); 199 }, 200 complete: function() { 201 $('.fa-spin').remove(); 202 }, 203 success: function(json) { 204 html = '<option value="">'+ text_select +'</option>'; 205 206 if (json['zone'] && json['zone'] != '') { 207 for (i = 0; i < json['zone'].length; i++) { 208 html += '<option value="' + json['zone'][i]['zone_id'] + '"'; 209 html += '>' + json['zone'][i]['name'] + '</option>'; 210 } 211 } else { 212 html += '<option value="0" selected="selected">'+ text_none +'</option>'; 213 } 214 215 $('#ciaskpriceModal .zone_id').html(html); 216 } 217 }); 218}); 219$('#ciaskpriceModal .country_id').trigger('change'); 220 221if (typeof Journal != 'undefined' && typeof Journal['infiniteScrollStatus'] != 'undefined' && $.ias && $('.main-products').length && typeof Journal.infiniteScrollInstance != 'undefined') { 222 Journal.infiniteScrollInstance.on('rendered', function (data) { 223 ciaskprice.makeAskforPrice(); 224 }); 225 226 Journal.infiniteScrollInstance.on('ready', function (data) { 227 ciaskprice.makeAskforPrice(); 228 }); 229} 230}); 231 232/* Remove File */ 233function deleteAskPriceZoneFile(mynode) { 234 $(mynode).parent().parent().removeClass('dz-started'); 235 $(mynode).parent().parent().parent().find('.text-message').remove(); 236 $(mynode).parent().parent().parent().find('input').val(''); 237 $(mynode).parent().remove(); 238}
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.