1(function($) { 2 window.client_storeLanding = { 3 init : function(){ 4 var freshopUi = freshop.ui; 5 6 this.setMenuActiveState(); 7 8 freshopUi.on('loaded', function(event){ 9 client_storeLanding.buildStoreOptions(storeJsonData); 10 }); 11 12 13 freshop.on('storeChanged', function(event, store){ 14 freshop.ui.setSelectedStore(store); 15 client_storeLanding.buildStoreOptions(store); 16 }); 17 } 18 ,setMenuActiveState : function(){ 19 $('#menu-main-menu').find('.nav-my-store').addClass('current-menu-item'); 20 } 21 ,buildTitle : function(isStore){ 22 var $pageWrapper = $('.single-stores'); 23 24 if(isStore){ 25 $pageWrapper.removeClass('single-stores-other-store'); 26 $pageWrapper.addClass('single-stores-my-store'); 27 } 28 else{ 29 $pageWrapper.addClass('single-stores-other-store'); 30 $pageWrapper.removeClass('single-stores-my-store'); 31 32 // Set Breadcrumb's stores link to the store locator 33 var $otherBreadcrumb = $pageWrapper.find('#breadcrumb-other-store') 34 ,$storesLink = $otherBreadcrumb.find('li:eq(1) > span > a'); 35 36 $storesLink.attr('href', fpClient.URLs.storeLocator); 37 } 38 } 39 ,buildStoreOptions : function(s){ 40 var fpStoreOptionsHtml = '' 41 ,$fpStoreOptions = $('.fp-store-options') 42 ,$fpMakeMyStore = $('.fp-make-my-store'); 43 44 if ($fpMakeMyStore.length > 0) { 45 $fpMakeMyStore.addClass('d-none'); 46 $fpStoreOptions.html(''); 47 } 48 49 var store = freshop.ui.getSelectedStore(); 50 var fpMakeMyStoreHtml = ''; 51 if(s.id && (s.id == store.id)){ 52 fpStoreOptionsHtml = fpStoreOptionsHtml + '<span class="fp-icon fp-icon-star" title="My Store"></span>'; 53 $('body').addClass('selected-store'); 54 // only show the 'Select Another Store' button if we are on the currently selected store's detail page and there are multiple stores to choose from 55 if(typeof freshop.ui.isSingleStore != 'undefined' && !freshop.ui.isSingleStore()) { 56 // Select Another Store label 57 var lblSelectAnother = 'Select Another Store'; 58 if(window.wpConfig.selectAnotherStoreLabel != null) { 59 // user defined label 60 lblSelectAnother = window.wpConfig.selectAnotherStoreLabel; 61 } else if(typeof freshop.ui.locale != 'undefined') { 62 // label from locale 63 lblSelectAnother = freshop.ui.locale('user-store-indicator-select-another', 'Select Another Store'); 64 } 65 66 // Build the 'Select Another Store' button 67 fpMakeMyStoreHtml = '<a href="' + fpClient.URLs.storeLocator + '" class="fp-btn button">' + freshop.ui.encodeForHtml(lblSelectAnother) + '</a>'; 68 $fpMakeMyStore.html(fpMakeMyStoreHtml); 69 $fpMakeMyStore.removeClass('d-none'); 70 this.buildTitle(false); 71 } else { 72 this.buildTitle(true); 73 } 74 } 75 else { 76 if(s.is_selectable){ 77 fpMakeMyStoreHtml = '<input type="button" class="fp-btn fp-btn-mystore" value="Make This My Store" data-store-id="' + freshop.ui.encodeForHtml(s.id) + '" />'; 78 $fpMakeMyStore.html(fpMakeMyStoreHtml); 79 $fpMakeMyStore.removeClass('d-none'); 80 } 81 this.buildTitle(false); 82 } 83 84 if ($fpMakeMyStore.length > 0) { 85 $fpStoreOptions.html(fpStoreOptionsHtml); 86 $fpStoreOptions.removeClass('d-none'); 87 } 88 89 $('.fp-btn-mystore').on('click', function(event){ 90 event.preventDefault(); 91 freshop.ui.setStore(s.id); 92 }); 93 } 94 }; 95 $(document) 96 .on('freshopInitialized', function () { 97 if($('.single-stores').length){
98 client_storeLanding.init(); 99 } 100 }); 101 102 $(function() { 103 $('.breadcrumb a.post-stores-archive').prop('href', '/my-store/store-locator'); 104 }); 105})(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.