1if(typeof shop === 'undefined'){ 2 alert('Internal error. Please contact support team!') 3} 4 5var region_selector_condition = false; 6 7 8$(document).off('blur', '.checkExists').on('blur', '.checkExists', function (e) { 9 var entity = $(this).data('entity-exists'); 10 var field = $(this).data('field-exists'); 11 var existingId = $(this).data('existing-id'); 12 var value = $(this).val(); 13 14 var idErrorAppend = $(this).data('error-append'); 15 var idFormSubmit = $(this).data('submit-form'); 16 17 if(entity == 'companies'){ 18 value = value.split('('); 19 value = value[0].trim(); 20 } 21 22 if(value != ''){ 23 checkIfEntityExist(entity,field,value,idErrorAppend,idFormSubmit,existingId); 24 } 25}); 26 27function checkIfEntityExist(entity,field,value,idErrorAppend,idFormSubmit,existingId){ 28 $.ajax({ 29 url: vars.baseUrl + 'Entity/validateEntity/', 30 type: 'POST', 31 data: {entity:entity,field:field,value:value,existingId:existingId} 32 }) 33 .done(function(response) { 34 if ((!response) || (response=='false')) { 35 36 switch (entity) { 37 case 'companies': 38 errorMsg = vars.companyExists; 39 break; 40 default: 41 errorMsg = vars.productExists; 42 } 43 44 $(idErrorAppend).parent('.form-inline').find(".help-block-notempty").remove(); 45 $(idErrorAppend).parent('.form-inline').addClass('has-error').append('<p class="help-block help-block-notempty">'+vars.companyExists+'</p>'); 46 $(idFormSubmit).attr('disabled',true); 47 } else { 48 if(!$(idErrorAppend).parent('.form-inline').hasClass('has-error')){ 49 $(idErrorAppend).parent('.form-inline').removeClass('has-error'); 50 $(idErrorAppend).parent('.form-inline').find(".help-block-notempty").remove(); 51 } 52 $(idFormSubmit).attr('disabled',false); 53 } 54 }) 55 .fail(function(jqXHR, textStatus, errorThrown) { 56 }) 57 .always(function() { 58 }); 59} 60 61 62function initializeLocationSelectors(countryCode){ 63 $('.region-selector').on('change', function(e){ 64 if(region_selector_condition) { 65 var region = []; 66 var val = $(this).find(":selected").val(); 67 if(!val) return; 68 region.push(val); 69 var where = $(this).data('where'); 70 71 $.ajax({
72 url: vars.baseUrl + 'FrontendCarts/getCities/', 73 type: 'POST', 74 data: {regions: region} 75 }) 76 .done(function(response, status, jqXHR) { 77 isValidJSON = true; 78 try { 79 response = $.parseJSON(response); 80 }catch(e){ 81 isValidJSON = false; 82 } 83 if(isValidJSON) { 84 var cityObj = $(".city-selector[data-where='"+ where +"']"); 85 cityObj.empty(); 86 newoption = "<option selected disabled value=''>"+vars.selectCityPlaceHolder+"</option>"; 87 cityObj.append(newoption); 88 $.each(response, function(regionid, cities) { 89 $.each(cities, function(cityid, city) { 90 newoption = new Option(city, cityid, false, false); 91 cityObj.append(newoption); 92 }); 93 }); 94 cityObj.trigger('change'); 95 var id = cityObj.attr('id'); 96 window.eventfunccity = function (id) { 97 $('#' + id).find("option[value='']").remove().trigger('change'); 98 $('body').off('DOMNodeInserted', '#select2-' + id+'-results'); 99 setTimeout(function(){ 100 $('body').on('DOMNodeInserted', '#select2-' + id+'-results', function(){eventfunccity(id);}); 101 },500); 102 var v = $('#' + id).val(); 103 if(v!=''){ 104 $('#' + id).val('').trigger('change'); 105 } 106 }; 107 $('body').on('DOMNodeInserted', '#select2-' + id+'-results', function(){eventfunccity(id);}); 108 } 109 }) 110 .fail(function(jqXHR, textStatus, errorThrown) { 111 }) 112 .always(function() { 113 }); 114 }else{ 115 e.preventDefault(); 116 } 117 }); 118 getRegions(countryCode); 119} 120 121function getRegions(countryCode){ 122 $.ajax({
123 url: vars.baseUrl + 'FrontendCarts/getRegions/', 124 type: 'POST', 125 data: {countryCode: countryCode} 126 }) 127 .done(function(response, status, jqXHR) { 128 isValidJSON = true; 129 try { 130 response = $.parseJSON(response); 131 }catch(e){ 132 isValidJSON = false; 133 } 134 if(isValidJSON) { 135 var region_selectors = $('.region-selector'); 136 $.each(region_selectors, function(index, region_selector) { 137 $.fn.select2.amd.require([ 138 'select2/selection/multiple', 139 'select2/selection/search', 140 'select2/dropdown', 141 'select2/dropdown/attachBody', 142 'select2/dropdown/closeOnSelect', 143 'select2/compat/containerCss', 144 'select2/utils', 145 'select2/compat/matcher' 146 ], function (MultipleSelection, Search, Dropdown, AttachBody, CloseOnSelect, ContainerCss, Utils,oldMatcher) { 147 var oldRemoveChoice = Search.prototype.searchRemoveChoice; 148 Search.prototype.searchRemoveChoice = function () { 149 oldRemoveChoice.apply(this, arguments); 150 this.$search.val('').trigger('click'); 151 }; 152 153 var SelectionAdapter = Utils.Decorate( 154 MultipleSelection, 155 Search 156 ); 157 158 var DropdownAdapter = Utils.Decorate( 159 Utils.Decorate( 160 Dropdown, 161 CloseOnSelect 162 ), 163 AttachBody 164 ); 165 $('#'+region_selector.id).select2( 166 { 167 maximumSelectionLength: 6, 168 dropdownAdapter: DropdownAdapter, 169 selectionAdapter: SelectionAdapter, 170 theme: "select-multiple-as-single", 171 allowClear: true, 172 templateResult: formatSizeSelect, 173 selectOnClose: true, 174 matcher: oldMatcher(matchStart) 175 } 176 ); 177 }); 178 $('#'+region_selector.id).empty(); 179 newoption = "<option class='option-placeholder' selected disabled>"+vars.selectRegionPlaceHolder+"</option>"; 180 $('#'+region_selector.id).append(newoption); 181 $.each(response, function(index2, region) { 182 if($('#'+region_selector.id).data('region-id') == index2) { 183 newoption = "<option selected class='option-selector' value='" + index2 + "'>" + region.region_name + "</option>"; 184 $('#' + region_selector.id).children('.option-placeholder').remove(); 185 } 186 else { 187 newoption = "<option class='option-selector' value='" + index2 + "'>" + region.region_name + "</option>"; 188 } 189 $('#'+region_selector.id).append(newoption); 190 }); 191 $('#'+region_selector.id).trigger('change'); 192 }); 193 region_selector_condition = true; 194 getCities(); 195 } 196 }) 197 .fail(function(jqXHR, textStatus, errorThrown) { 198 }) 199 .always(function() { 200 }); 201} 202function matchStart (term, text) { 203 if (text.toUpperCase().indexOf(term.toUpperCase()) == 0) { 204 return true; 205 } 206 207 return false; 208} 209function getCities(){ 210 var regionDOMS = $('select.region-selector');
211 var cityDOMS = $('select.city-selector'); 212 var selectedRegions = []; 213 $.each(regionDOMS, function(key, regionDOM) { 214 if($('#'+regionDOM.id).data('region-id') != 0) 215 selectedRegions.push($('#'+regionDOM.id).data('region-id')); 216 }); 217 218 219 220 // $.fn.select2.amd.require(['select2/compat/matcher'], function (oldMatcher) { 221 // $("select").select2({ 222 // matcher: oldMatcher(matchStart) 223 // }) 224 // }); 225 226 $.each(cityDOMS, function(key, cityDOM) { 227 $.fn.select2.amd.require([ 228 'select2/selection/multiple', 229 'select2/selection/search', 230 'select2/dropdown', 231 'select2/dropdown/attachBody', 232 'select2/dropdown/closeOnSelect', 233 'select2/compat/containerCss', 234 'select2/utils', 235 'select2/compat/matcher' 236 ], function (MultipleSelection, Search, Dropdown, AttachBody, CloseOnSelect, ContainerCss, Utils,oldMatcher) { 237 var oldRemoveChoice = Search.prototype.searchRemoveChoice; 238 Search.prototype.searchRemoveChoice = function () { 239 oldRemoveChoice.apply(this, arguments); 240 this.$search.val('').trigger('click'); 241 }; 242 243 var SelectionAdapter = Utils.Decorate( 244 MultipleSelection, 245 Search 246 ); 247 248 var DropdownAdapter = Utils.Decorate( 249 Utils.Decorate( 250 Dropdown, 251 CloseOnSelect 252 ), 253 AttachBody 254 ); 255 console.log('aaa'); 256 $('#'+cityDOM.id).select2( 257 { 258 maximumSelectionLength: 6, 259 dropdownAdapter: DropdownAdapter, 260 selectionAdapter: SelectionAdapter, 261 theme: "select-multiple-as-single", 262 allowClear: true, 263 templateResult: formatSizeSelect, 264 selectOnClose: true, 265 matcher: oldMatcher(matchStart) 266 267 } 268 ); 269 }); 270 }); 271 272 $.ajax({
273 url: vars.baseUrl + 'FrontendCarts/getCities/', 274 type: 'POST', 275 data: {regions: selectedRegions} 276 }) 277 .done(function(response, status, jqXHR) { 278 isValidJSON = true; 279 try { 280 response = $.parseJSON(response); 281 }catch(e){ 282 isValidJSON = false; 283 } 284 if(isValidJSON) { 285 $("select.city-selector").each(function() { 286 $(this).empty(); 287 }); 288 289 $.each(response, function(regionid, cities) { 290 var savedCityDOMS = $(".city-selector[data-region-id='"+ regionid +"']"); 291 $.each(savedCityDOMS, function(key, savedCityDOM) { 292 var selectedCity = $("#"+savedCityDOM.id).data('city-id'); 293 $.each(cities, function(cityid, city) { 294 if(selectedCity == cityid) 295 newoption = new Option(city, cityid, true, true); 296 else 297 newoption = new Option(city, cityid, false, false); 298 $("#"+savedCityDOM.id).append(newoption); 299 }); 300 $("#"+savedCityDOM.id).trigger('change'); 301 }); 302 }); 303 304 } 305 }) 306 .fail(function(jqXHR, textStatus, errorThrown) { 307 }) 308 .always(function() { 309 }); 310 311} 312 313function updateAddresses(countryCode,countryName,countryPhonePrefix){ 314 $('[class^="country_code_address_"]').hide(); 315 $('.country_code_address_'+countryCode).show(); 316 $('[class^="country_code_invoice-address_"]').hide(); 317 $('.country_code_invoice-address_'+countryCode).show(); 318 $('#country-field').val(countryName); 319 $('#country-field-invoice').val(countryName); 320 $('#country-phone-prefix').val(countryPhonePrefix); 321 if(countryCode != 'RO'){ 322 $('#checkout-postal-code').val(''); 323 $('.address_postal_code').removeClass('none'); 324 $('.company_postal_code').removeClass('none'); 325 $('.address_with_drop').hide(); 326 $('.address_no_drop').show(); 327 // $('.address_with_drop #selectRegion-address-0').val(''); 328 // $('.address_with_drop #selectCity-address-0').val(''); 329 } else { 330 $('#checkout-postal-code').val(''); 331 $('#inputRegion-address-0').val(''); 332 $('#inputCity-address-0').val(''); 333 $('.address_postal_code').addClass('none'); 334 $('.company_postal_code').addClass('none'); 335 $('.address_with_drop').show(); 336 $('.address_no_drop').hide(); 337 } 338 selectAddresses(); 339} 340 341function selectAddresses(){ 342 343} 344 345function modifyAddress() { 346 $('.edit-adress-btn-container').addClass('notimportantnone'); 347 $(".editable-address").each(function() { 348 if($(this).prop('checked')){ 349 var addressId = $(this).data('address-id'); 350 $('#modify-address-'+addressId).removeClass('notimportantnone'); 351 $('#modify-address-'+addressId + ' .edit-adress-btn-container').removeClass('notimportantnone'); 352 } 353 }); 354} 355 356function refreshAddress() { 357 $('#addAddressModal').on('hide.bs.modal', function (e) { 358 $(this).removeData('bs.modal'); 359 }); 360} 361$(document).unbind('click','.remove-message-content').bind('click','.remove-message-content',function () { 362 $('.remove-message-content').parent().remove(); 363}); 364 365$(document).off('click', '.remove-cart-product').on('click', '.remove-cart-product', function (evt) { 366 var productId = $(this).data('product-id'); 367 var prods = {}; 368 prods[productId] = {product_id : productId, quantity : 0}; 369 prodsToAddToCart = prods; 370 371 shop.cart.runOnSuccess = function(){ 372 if($('#load-add').lenght) { 373 $('#drop_cart').show(); 374 $('#load-add').hide(); 375 } 376 }; 377 378 shop.cart.replaceProduct(prods); 379}); 380 381if(shop.cart.refreshCompareList) { 382 $(document).ready(function () { 383 if($('#compareTemplateContainer').length == 1){ 384 shop.cart.compareTemplate = vars.compareRight;
385 shop.cart.refreshCompareList(); 386 } 387 388 }); 389} 390 391 392/* Cart Functions */ 393 394function closeModalIfExists(){ 395 $('.modal:not(#myModal_erp)').modal('hide'); 396} 397 398function toggleCartDropdown(){ 399 if($('#drop_cart').is(':visible') == true) { 400 $("#drop_cart").trigger('click'); 401 if($('#drop_cart_trigger').hasClass('open')) { 402 setTimeout(function(){ 403 if($('#drop_cart_trigger').hasClass('open')) { 404 $("#drop_cart").trigger('click'); 405 } 406 },1500); 407 } 408 409 } else { 410 if($('#drop_cart_mobile').is(':visible') == true) { 411 $('#drop_cart_mobile').trigger('click'); 412 setTimeout(function(){ 413 if($('#drop_cart_mobile').is(':visible') == true) { 414 $('#drop_cart_mobile').trigger('click'); 415 } 416 },1500); 417 } 418 } 419 420} 421 422$(document).on('click','.trigger-add-to-cart',function(){ 423 var addDelay =$(this).data('add-delay'); 424 if(addDelay){ 425 var removeDelay = 0; 426 }else{ 427 var removeDelay = 1; 428 } 429 var button = $(this); 430 431 if( button.hasClass('dntAdd')) { 432 433 } else { 434 shop.cart.addToCart(button,removeDelay); 435 } 436}); 437 438/* End Cart Functions */ 439 440 441/* Autocomplete Search */ 442 443function doQuickSearch(searchTerm, resetUrl, autocompleteDrop, dummy) { 444 var autocomplete_dummy = $(dummy).html(); 445 if (searchTerm == lastSearchRequest) { 446 return; 447 } 448 lastSearchRequest = searchTerm; 449 if (searchTerm != lastSearchTerm) { 450 return; 451 } 452 if (searchTerm.length > 2) { 453 $.ajax({
454 url: vars.baseUrl + "/searches/quickSearch", 455 dataType: "json", 456 data: {query: searchTerm, reset_filters_url: reset_filters_url} 457 }) 458 .done(function (response, status, jqXHR) { 459 460 var template = vars.productsAutocomplete; 461 var data = {}; 462 data.products = []; 463 data.searchUrl = response.search_url; 464 data.noProducts = response.no_products; 465 466 if(!$.isEmptyObject(response.products)){ 467 var products = response.products; 468 for (productId in products) { 469 470 var productData = {}; 471 productData.productName = products[productId].name; 472 productData.productSku = products[productId].sku; 473 productData.productImage = products[productId].main_image; 474 productData.currency = products[productId].currency; 475 productData.price = products[productId].price; 476 productData.originalPrice = products[productId].original_price; 477 productData.hasDiscount = products[productId].has_discount; 478 productData.productHref = products[productId].product_href; 479 480 data.products.push(productData); 481 } 482 } 483 484 var htmlTemplate = Mustache.to_html(template, data); 485 486 $(autocompleteDrop).html(htmlTemplate); 487 }) 488 .fail(function (jqXHR, textStatus, errorThrown) { 489 }); 490 } else { 491 $(autocompleteDrop).html(''); 492 } 493} 494 495/* End Autocomplete Search */ 496 497 498/* Product Comments */ 499 500function initializeProductComments() { 501 shop.utils.validationParentClass = '.message-cont'; 502 $('.save-comment-button').unbind('click').bind('click',function (e) { 503 var formId = $(this).data('form-id'); 504 var _thisForm = $('#' + formId); 505 var parent = $(this).data('parent'); 506 var commentId = $(this).data('id'); 507 var comment = $('#' + commentId).val(); 508 var rating = $("#rateYo").rateYo("rating"); 509 var name = $('#nume').val(); 510 var subject = $('#subject').val(); 511 512 shop.utils.validateOnSubmit(_thisForm, e); 513 if($('.has-error').length == 0){ 514 515 $('.save-comment-button').prop('disabled',true); 516 $('.add-reply-to-comment').prop('disabled',true); 517 518 saveProductComment(comment,parent,rating,name,subject); 519 $(this).attr('disabled',true); 520 } 521 }); 522 523 $("div[id^=reply-]").each(function( ) { 524 var commentId = $(this).data('comment-id'); 525 $('#addReply-' + commentId).unbind('click').bind('click', function() { 526 $('#reply-' + commentId + ' .comment_box').toggleClass('open'); 527 }); 528 }); 529 530 $(function () { 531 $("#rateYo").rateYo({ 532 halfStar: true, 533 minValue: 0, 534 maxValue: 5, 535 precision: 1, 536 starWidth: "36px", 537 normalFill: "#A0A0A0", 538 ratedFill: "#5B85BE" 539 }); 540 }); 541} 542 543/* End Product Comments */ 544 545/* Mobile Dropdown Scroll Issue + Layout listing toggle*/ 546 547$(document).ready(function () { 548 if($('#compareTemplateContainer').length == 1){ 549 shop.cart.compareTemplate = vars.compareRight; 550 shop.cart.refreshCompareList(); 551 } 552 553 if(sessionStorage.getItem('listingListView')) { 554 console.log(sessionStorage.getItem('listingListView')) 555 var productsContainer = $('.listing-prod-big-container'); 556 var listingElementsWithTooltip = $('.listing-prod-big-container [data-toggle="tooltip"]'); 557 $('#listingLayoutSelection .btn.layout-list').addClass('layout-active').siblings().removeClass('layout-active'); 558 productsContainer.addClass('listing-prod-big-container--list-view'); 559 listingElementsWithTooltip.tooltip('disable'); 560 } 561}); 562 563$(document) 564 .on('click', '.navbar:not(.mega-menu-columns) > .navbar-toggler', function() { 565 $('body').toggleClass('overlay'); 566 }) 567 .on('shown.bs.dropdown', '.navbar:not(.mega-menu-columns) #drop_cart_trigger', function () { 568 $('body').removeClass('overlay'); 569 }) 570 .on('click', '#listingLayoutSelection .btn', function () { 571 var productsContainer = $('.listing-prod-big-container'); 572 var listingElementsWithTooltip = $('.listing-prod-big-container [data-toggle="tooltip"]'); 573 $(this).addClass('layout-active').siblings().removeClass('layout-active'); 574 if($(this).hasClass('layout-list')) { 575 productsContainer.addClass('listing-prod-big-container--list-view'); 576 listingElementsWithTooltip.tooltip('disable'); 577 sessionStorage.setItem('listingListView', true); 578 } else { 579 productsContainer.removeClass('listing-prod-big-container--list-view'); 580 listingElementsWithTooltip.tooltip('enable'); 581 sessionStorage.removeItem('listingListView'); 582 } 583 584 585 }) 586; 587 588/* END Mobile Dropdown Scroll Issue + Layout listing toggle*/ 589 590$(document).on('click','.btn-delete_cart',function(){ 591 $.ajax({
592 url: vars.baseUrl + 'frontendCarts/removeFromCartAll/', 593 type: 'POST' 594 }) 595 .done(function(response) { 596 shop.cart.showCartSummary(); 597 shop.cart.viewCartV2(); 598 shop.cart.triggerCartChange(); 599 600 601 }) 602 .fail(function(jqXHR, textStatus, errorThrown) { 603 }); 604}); 605 606function showStickyFilters() { 607 $(document).off('click', '.showFilters').on('click', '.showFilters', function(){ 608 if ($('.showMobileFilters').hasClass('d-none')){ 609 var closeText = $(this).data('close'); 610 if(!closeText){ 611 closeText = 'Ascunde filtre'; 612 } 613 $(this).html(closeText); 614 $('.showMobileFilters').removeClass('d-none'); 615 $('.list-selected-filters').removeClass('d-none'); 616 $('.delete-filters').removeClass('d-none'); 617 $('body').addClass('overflow-hidden'); 618 } else { 619 var openText = $(this).data('open'); 620 if(!openText){ 621 openText = 'Filtre'; 622 } 623 $(this).html(openText); 624 $('.showMobileFilters').addClass('d-none'); 625 $('.list-selected-filters').addClass('d-none'); 626 $('.delete-filters').addClass('d-none'); 627 $('body').removeClass('overflow-hidden'); 628 } 629 }); 630}
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.