PageSourceSearch

https://www.yorktownecabinetry.com/wp-content/themes/yorktownecabinetry/js/scripts.js?ver=1.0.0

js yorktownecabinetry.com collected 2026-10-08 06:08:49 UTC 22,202 bytes, 614 lines download raw bytes

1jQuery(document).ready(function () {
2    
3
4    var myMenu = jQuery("#main_nav");
5    if (myMenu.length > 0) {
6        myMenu.menu({
7            position: {
8                my: 'left top',
9                at: 'left bottom'
10            }
11        }).children().show("fast");
12
13        jQuery('.ui-menu').on('mouseleave', function (aEvent) {
14            jQuery("#main_nav").menu("collapseAll", null, true);
15        });
16
17        //for if the cursor is still in the menu div, but not on a menu option
18        jQuery('.ui-menu-item').on('mouseleave', function (aEvent) {
19            jQuery("#main_nav").menu("collapseAll", null, true);
20        });
21
22
23        myMenu.slicknav({
24            label: 'MENU',
25            parentTag: 'span',
26            allowParentLinks: false,
27            closeOnClick: true
28        });
29
30        //inject back button into the menu
31        jQuery('.slicknav_menu').append('<div id="mobileBack" class=""><a href="javascript:history.go(-1)">Back</a></div>');
32
33        /**
34         * Mobile Menu Adjustment 
35         *	- If top category link is clicked and menu is not open, expand the menu. 
36         *	- If top category link is clicked and menu is open, navigate to the link
37         */
38        jQuery('li.slicknav_parent > span.slicknav_item a').click(function (aEvent) {
39            aEvent.preventDefault();
40
41            var myClosestSlickNavParent = jQuery(aEvent.target).closest(".slicknav_parent");
42
43            if (myClosestSlickNavParent.hasClass("slicknav_open")) {
44                var myTargetLink = jQuery(aEvent.target).attr('href');
45                if (!myTargetLink) {
46                    // try to find the closest
47                    var myClosestLink = jQuery(aEvent.target).closest("a");
48                    myTargetLink = myClosestLink.attr('href');
49
50                    if (!myTargetLink) {
51                        return;
52                    } //if
53                } //if
54
55                window.location.href = myTargetLink;
56            } //if: open menu
57        });
58    } //if: menu object is available
59
60    //Location title inserted with js
61    jQuery("<h3>Location Finder</h3>").insertBefore("#wpsl-wrap #wpsl-search-wrap");
62
63    /*======================
64        Accordion
65    ======================*/
66    jQuery('.verticalTab .resp-tabs-container').each(function(){
67        $main = jQuery(this);
68        $main.find('.resp-accordion').click(function(){
69           if(!jQuery(this).hasClass('resp-tab-active')){
70                var target = jQuery(this).attr('aria-controls');
71                $main.find('.resp-tab-active').removeClass('resp-tab-active');
72                jQuery(this).addClass('resp-tab-active');
73                $main.find('.resp-tab-content-active').removeClass('resp-tab-content-active').slideUp(500);
74                $main.find('[aria-labelledby='+target+']').addClass('resp-tab-content-active').slideDown(500);
75            }else{
76                jQuery(this).toggleClass('resp-tab-active');
77                var target = jQuery(this).attr('aria-controls');
78                $main.find('[aria-labelledby='+target+']').slideToggle(500);
79            }
80        });
81    });
82
83    /*====================
84        14-11-2018
85    ===================*/
86    (function( $ ){
87       myfunction = function() {
88          $activeClass = jQuery('.materials li img.active').attr('data-class');
89        $catName = jQuery('.materials li img.active').attr('title');
90        //alert($catName);
91        jQuery('#material_selected .materialShown').text($catName);
92        jQuery('#showInCat').text($catName);
93        jQuery('.finishesWrapper').hide();
94        jQuery('.doorViewer .zoomViewerLink').hide();
95        jQuery('.finishesWrapper.'+$activeClass).show();
96        jQuery('.doorViewer .zoomViewerLink.'+$activeClass).show();
97       }; 
98    })( jQuery );
99    
100    myfunction();
101    jQuery('img.material_chip').on('click', function(){
102        jQuery('.materials li img.active').removeClass('active');
103        jQuery(this).addClass('active');
104        myfunction();
105        //scroll to id
106        LKFinishDetailDisplayJS.scrollToId("material_selected", 500);
107    });    
108
109    jQuery('.filter_toggler').on('click', function(){
110        jQuery(this).toggleClass('open');
111        jQuery(this).closest('.content_section').toggleClass('closeFilter');
112    });
113
114    //duplicated to avoid CSS overlap - same functionality as directly above.
115    jQuery('.filter_toggle').on('click', function(){
116
117        jQuery(this).toggleClass('open');
118        jQuery(this).closest('.content_section').toggleClass('closeFilter');
119    });
120
121    jQuery('.he-gallery.finish-gallery .product_image, .style-slider .style-image').mou
121seenter(function(){
122        jQuery(this).addClass('full');
123    });
124
125    jQuery('.he-gallery.finish-gallery .product_image, .style-slider .style-image').mouseleave(function(){
126        jQuery(this).removeClass('full');
127    });
128
129    jQuery('.sidbarSlider').slick({
130      dots: false,
131      prevArrow: jQuery('span.carouselPrev'),
132        nextArrow: jQuery('span.carouselNext'),
133      infinite: true,
134      speed: 300,
135      slidesToShow: 1,
136      adaptiveHeight: true
137    });
138
139    jQuery('.customSlideControl').insertAfter('.sidbarSlider .slick-list.draggable');
140
141    jQuery('#widget_left_nav_toggle').click(function(){
142
143
144        //collapse all sub items if we're currently closed so they're not open when we open
145        jQuery('form#productsFacets').find('.content_section').each(function(){
146            var $this = jQuery(this);
147            $this.find('.open').click();
148        });
149
150        jQuery(this).toggleClass('opened');
151        jQuery('#widget_left_nav').toggleClass('opened');
152    });
153});
154
155
156LKFinishDetailDisplayJS = 
157{
158    init:function()
159    {
160        //material selection and display of appropriate finish chips
161        
162        jQuery('.finish').click(function() 
163        {
164            var myFinishClick = jQuery(this);
165            var myFinishChip = myFinishClick.children('img.finish_chip');
166            
167            jQuery(document).trigger('finish_selected', 
168            {
169                'text' : myFinishChip.attr('alt'),
170                'id': myFinishChip.attr('id')
171            });
172            
173            var materialShown = jQuery(this).parent().attr('class');
174            var wrapperWidth = jQuery(this).parent('.finishes').width(); 
175            var chipWidth = jQuery('.finish_chip', this).data("chip-width");
176            var chipsPerRow = Math.floor(wrapperWidth/chipWidth); 
177            var numberOfChips = jQuery(this).parent().children('.finish').length;
178            var chipClicked = jQuery(this).index();
179            var sectionClicked = jQuery(this).parent().parent().attr('id');
180            var numberInRow = chipClicked % chipsPerRow;
181            var howManyLeft = chipsPerRow - numberInRow;
182            var nextBreakPoint = chipClicked + howManyLeft-1;
183            if (nextBreakPoint >= numberOfChips) {
184                var nextBreakPoint = numberOfChips-1;
185            }
186            var lgImageWidth = chipsPerRow * (chipWidth); 
187            var imageSource = jQuery('.finish_chip', this).attr('big-image');
188            var lgImageWidthCrop = Math.ceil(lgImageWidth * 2);
189            var lgImageHeightCrop = Math.ceil(chipWidth * 5);
190            var smImageWidthReplace = 'wid='+chipWidth
191            var lgImageWidthReplace = 'wid='+lgImageWidth;
192            var lgImageSource = imageSource.replace(smImageWidthReplace,lgImageWidthReplace) ;
193        
194            var materialShown = materialShown.replace(/\s+/g, '.');
195            var captionCopy = '<strong>' + jQuery('.finish_chip', this).attr('title') + '</strong>' + '<br>' + jQuery('.finish_chip', this).data("finish-description");
196            
197            jQuery('.focusChip').slideUp(100);
198            jQuery('.focusChip').delay(150).remove();
199            
200            if(!jQuery(this).hasClass('finishNoImage')) {
201                jQuery('#' + sectionClicked + ' .' + materialShown + ' .finish').eq(nextBreakPoint)
202                    .after('<div class="focusChip ' + chipClicked +
203                    '" style="width: ' + lgImageWidth + 'px; background-image: url(' + imageSource + ');">' +
204                    '<img src="' + lgImageSource + '">' +
205                    '<div class="focusChipClose"></div>' +
206                    '<p class="chipCaption">' + captionCopy + '</p>' +
207                    '</div>');
208                jQuery(this).addClass('active');
209            }
210            jQuery('.finish').not(this).removeClass('active');
211            
212            
213            //if enabled, update s7 viewer with finish's full image
214            if(jQuery('.finish_chip', this).data('full-image')) {
215                jQuery('#shownInDescription').html('<p>Now Showing: ' + jQuery('.finish_chip', this).attr('title') + '</p>');
216                //LKScene7SetupJS.flyoutViewer.setAsset("Elkay/" + jQuery(this).attr('id').toString()); 
217                if(typeof LKScene7SetupJS != 'undefined')
218                {
219                    LKScene7SetupJS.BasicZoomViewer.setAsset("Elkay/" + jQuery('.finish_chip', this).data('full-image').toString());
220                }
221            }
222            
223            if(jQuery('#doorSampleAddToCart').length > 0 && jQuery('#chipSampleAddToCart').length > 0) {
224                // reset
225                jQuery('#doorSampleAddToCart').closest('.oneHalfColumn').hide();
226                jQuery('#chipSampleAddToCart').closest('.oneHalfColumn').hide();
227                
228                if(jQuery('.finish_chip', this).hasClass('chip-sample')) {
229                    jQuery('#chipSampleAddToCart').closest('.oneHalfColumn').show();
230                }
231                if(jQuery('.finish_chip', this).hasClass('door-sample')) {
232                    jQuery('#doorSampleAddToCart').closest('.oneHalfColumn').show();
233                }
234            }
235            
236        });
237        jQuery('.finishes').delegate('.focusChip .focusChipClose', 'click', function() {
238            jQuery(this).parent('.focusChip').slideUp(500);
239            jQuery('.finish.active').delay(250).removeClass('active');
240        });
241        jQuery('.finishes').delegate('.chipCaption', 'click', function() {
242            jQuery(this).switchClass("chipCaption", "chipCaptionClosed", 300);
243        });
244        jQuery('.finishes').delegate('.chipCaptionClosed', 'click', function() {
245            jQuery(this).switchClass("chipCaptionClosed", "chipCaption", 300);
246        });
247    }//init
248    ,
249    
250    scrollToId: function(id, speed) 
251    {
252        var container = jQuery('#' + id);
253        if(container.length > 0 && container != null)
254        {
255            jQuery('html, body').animate({
256                scrollTop: container.offset().top
257            }, speed); //speed defaults to 400 if not provided
258            jQuery(window).scrollTop(container.offset().top);
259        }
260    }
261
262}//LKFinishDetailDisplayJS      
263
264//Setup for initial viewer
265jQuery(document).ready(function() 
266{
267    LKFinishDetailDisplayJS.init();
268
269    jQuery('.close').on('click', function(){
270        jQuery("#mailForm").css("display", "none");
271        jQuery("body").removeClass('modalOpen');
272    });
273
274    jQuery('.socialMail').click(function(){
275        jQuery("#mailForm").css("display", "block");
276        jQuery("body").addClass('modalOpen');
277    });
278    
279    /*============== Meta title and Description to the Mailer ===========*/
280    var metaTitle = jQuery('title').text();
281    var metaDescription = jQuery('meta[name=description]').attr("content");
282    if(typeof metaDescription != "undefined"){
283        metaDescription = metaDescription.replace(/%/g, "");
284    }
285    if(typeof metaTitle != "undefined"){
286        metaTitle = metaTitle.replace(/%/g, "");
287    }
288
289    var pageUrl      = window.location.href;
290    jQuery('.metaTitle input').attr('value', metaTitle);
291    jQuery('.metaDescription input').attr('value', metaDescription);
292    jQuery('.currentPageLink input').attr('value', pageUrl);
293    /*============== Meta title and Description to the Mailer End ===========*/
294    
295    if(typeof LKScene7SetupJS != 'undefined')
296    {
297        var fullImage = jQuery('.material_chip.active').attr('id');
298        LKScene7SetupJS.setupProductDetails(fullImage);
299    }//if
300});
301
302(function($) {
303var equalheightItems = [];
304    equalheight = function(container){
305
306    var currentTallest = 0,
307         currentRowStart = 0,
308         rowDivs = new Array(),
309         $el,
310         topPosition = 0;
311     $(container).each(function() {
312
313       $el = $(this);
314       $($el).height('auto')
315       topPostion = $el.position().top;
316
317       if (currentRowStart != topPostion) {
318         for (currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) {
319           rowDivs[currentDiv].height(currentTallest);
320         }
321         rowDivs.length = 0; // empty the array
322         currentRowStart = topPostion;
323         currentTallest = $el.height();
324         rowDivs.push($el);
325       } else {
326         rowDivs.push($el);
327         currentTallest = (currentTallest < $el.height()) ? ($el.height()) : (currentTallest);
328      }
329       for (currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) {
330         rowDivs[currentDiv].height(currentTallest);
331       }
332     });
333    }
334    // Window Load
335    $(window).load(function(){
336      equalheightItems.forEach(function(item){
337        equalheight(item);
338      });
339    });
340
341    // Window Resize
342    $(window).resize(function(){
343      equalheightItems.forEach(function(item){
344        equalheight(item);
345      });
346      // menu_padding();
347    });
348
349    equalheightItems.push('.grid_mode .grid4ColumnLayout');
350    equalheightItems.push('.defAttrContentPaneCat');
351})(jQuery);
352
353/*==================== Menu touch ====================*/
354jQuery(document).ready(function()
355    {
356        if(Modernizr.touch)
357        {
358            // flag element for touch 
359            jQuery('ul#main_nav li.ui-menu-item').addClass('lk-touch-supported');
360            // bind touch-click event on the relevant menu item
361            jQuery('ul#main_nav li.lk-touch-supported').on("touchstart",  function(aEvent)
362            {   
363                var mySubMenu = jQuery(this).children('ul.ui-menu');
364                if(mySubMenu.length > 0 && !mySubMenu.is(':visible') )
365                {
366                    aEvent.preventDefault();
367                    jQuery(this).click();
368                }//if: jquery ui menu item is clicked there is there currently no visible submenu - open it
369                else
370                {
371                }//else: jquery ui menu item is clicked and either there is no open submenu or submenu at all
372            });
373            
374            jQuery(document).on('touchstart', function(event) 
375            { 
376                if (!jQuery(event.target).closest('ul#main_nav').length) 
377                {
378                    jQuery('ul#main_nav').menu("collapseAll", null, true );
379                }//if
380            });
381        }//if: Modernizr has detected touch capability
382    });
383/*==================== Menu touch End ====================*/
384
385
386var currentFilters = {};
387
388function updateURLParameter(url, param, paramVal){
389    var newAdditionalURL = "";
390    var tempArray = url.split("?");
391    var baseURL = tempArray[0];
392    var additionalURL = tempArray[1];
393    var temp = "";
394    if (additionalURL) {
395        tempArray = additionalURL.split("&");
396        for (var i=0; i<tempArray.length; i++){
397            if(tempArray[i].split('=')[0] != param){
398                newAdditionalURL += temp + tempArray[i];
399                temp = "&";
400            }
401        }
402    }
403
404    var rows_txt = temp + "" + param + "=" + paramVal;
405    return baseURL + "?" + newAdditionalURL + rows_txt;
406}
407function removeAllFilters(){
408    var tempArray = window.location.href.split("?");
409    var baseURL = tempArray[0];
410    var additionalURL = tempArray[1];
411    if (additionalURL) {
412        tempArray = additionalURL.split("&");
413        for (var i=0; i<tempArray.length; i++){
414            if(tempArray[i].split('=')[0] == 'pp'){
415                return baseURL+'?'+tempArray[i];
416            }
417        }
418    }
419    return baseURL;
420}
421(function($) {
422    function getFilters(){
423        var filters = {};
424        $('.facet_input:checked').each(function(){
425            var filter_key = $(this).attr('name');
426
427            if($(this).hasClass('sort-option')){
428                debugger;
429                return false;
430            }
431
432            if(!$.isArray(filters[filter_key])){
433                filters[filter_key] = [];
434            }
435            if($.inArray($(this).val(), filters[filter_key]) == -1){
436                filters[filter_key].push($(this).val());
437            }
438        });
439        currentFilters = filters;
440        return filters;
441    }
442    function runFilters(){
443        setTimeout(function(){
444            var filters = getFilters();
445            var filterUrl = window.location.href;
446            var foundFilters = false;
447            var orderBy = '';
448
449            filterUrl = removeAllFilters();
450            console.log(filterUrl);
451            Object.keys(filters).forEach(function(key) {
452                foundFilters = true;
453                filterUrl = updateURLParameter(filterUrl,key,filters[key].join());
454            });
455            if(foundFilters){
456                filterUrl = updateURLParameter(filterUrl,'filters','true');
457                filterUrl = updateURLParameter(filterUrl,'paged','1');
458            }
459
460            var curr = new URL(window.location.href);
461            if(curr.searchParams.get('orderby')){
462                filterUrl = updateURLParameter(filterUrl,'orderby',curr.searchParams.get('orderby'));
463            }
464
465
466            // console.log(filterUrl);
467            window.location = filterUrl;
468        },100);
469    }
470    getFilters();
471    $('.facet_label').click(function(){
472        $input = $(this).siblings('.facet_input');
473        if($input.prop('checked')){
474            var type = $input.attr('name');
475            var value = $input.attr('value');
476            $('.selected_attributes .facet_input[name='+type+'][value="'+value+'"]').prop('checked',fal
476se);
477        }
478
479        //handle our mobile sort by embeded in filters menu
480        if($input.hasClass('sort-item')){
481            refreshSort($input.attr('value'));
482            return false;
483        }
484
485        runFilters();
486    });
487    $('.remove_filter').click(function(){
488        var type = $(this).data('type');
489        var value = $(this).data('value');
490        $('.facet_input[name='+type+'][value="'+value+'"]').prop('checked',false);
491        runFilters();
492    })
493    $('.clear_all').click(function(){
494        $('.facet_input:checked').prop('checked',false);
495        runFilters();
496    })
497    $('.pagingDropdown').change(function(){
498        var url = window.location.href;
499        url = updateURLParameter(url,'paged','1');
500        url = updateURLParameter(url,'pp',$(this).val());
501        window.location = url;
502    });
503
504    $('.section_list ul').each(function(){
505        var count = $(this).find('li').length;
506        //if we're in the new gallery pages, dont add this
507        if($(this).parents('.he-gallery').length){
508            return;
509        }
510        if(count > 7){
511            // var label = $(this).parents('.section_list').find('h3').find('span').html();
512            var moreLabel = 'Show All';
513            var lessLabel = 'Show Fewer';
514            var $itemsToHide = $(this).find('li:gt(6)');
515            $itemsToHide.hide();
516            $(this).append('<li class="showmore"><a href="javascript:;">'+moreLabel+'</a></li>');
517            $(this).find('.showmore a').click(function(){
518                if($(this).hasClass('active')){
519                    $itemsToHide.hide();
520                    $(this).removeClass('active');
521                    $(this).html(moreLabel);
522                }else{
523                    $itemsToHide.show();
524                    $(this).addClass('active');
525                    $(this).html(lessLabel);
526                }               
527            });
528        }
529    });
530
531    $('.close-filter-mobile, .show-all-results a, .view-results-button').on('click', function () {
532        $('#widget_left_nav_toggle').click();
533        var $gallery = $('.he-gallery');
534        if($gallery.length) {
535            window.scrollTo(0,$gallery.position().top);
536        }
537    });
538
539    $('select[name="orderby"]').on('change', function () {
540
541        refreshSort($(this).val());
542    });
543
544    /**
545     * reload the current page with added filter "orderby" value
546     * @param sortVal
547     */
548    function refreshSort(sortVal){
549
550        var currentUrl = window.location.href;
551        currentUrl = new URL(currentUrl);
552        currentUrl.searchParams.set('orderby', sortVal);
553        window.location.href = currentUrl.toString();
554    }
555
556    
557})(jQuery);
558
559navigator.sayswho= (function(){
560    var ua= navigator.userAgent, tem, 
561    M= ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
562    if(/trident/i.test(M[1])){
563        tem=  /\brv[ :]+(\d+)/g.exec(ua) || [];
564        return 'IE '+(tem[1] || '');
565    }
566    if(M[1]=== 'Chrome'){
567        tem= ua.match(/\b(OPR|Edge)\/(\d+)/);
568        if(tem!= null) return tem.slice(1).join(' ').replace('OPR', 'Opera');
569    }
570    M= M[2]? [M[1], M[2]]: [navigator.appName, navigator.appVersion, '-?'];
571    if((tem= ua.match(/version\/(\d+)/i))!= null) M.splice(1, 1, tem[1]);
572    return M.join(' ');
573})();
574
575$bodyClass = navigator.sayswho; // outputs: `Chrome 62`
576jQuery('body').addClass($bodyClass);
577if($bodyClass == 'Safari 9'){
578    jQuery('body').addClass('Safari-9');
579}
580if($bodyClass == 'Safari 10'){
581    jQuery('body').addClass('Safari-10');
582}
583
584jQuery(document).ready(function( $ ) {
585
586
587    $('.gallery-slide').on('click', function(){
588        event.preventDefault();
589        var link = $(this).data('link');
590        if(link.length)
591            window.location.href = link;
592    });
593
594    $(".ubermenu-responsive-toggle").on("click", function() {
595
596        if($('.searcher-wrapper').is(':visible')){
597            $('.searcher-wrapper').slideUp('fast');
598        }else {
599            $('.searcher-wrapper').show();
600        }
601    });
602
603    $('.explore-whats-new').click(function(event){
604
605        event.preventDefault();
606        var $link = $(this).find('a');
607        if($link.length){
608            window.location.href = $link.attr('href');
609        }
610    });
611});
612
613
614

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.