PageSourceSearch

https://futurecinema.ca/wp-content/plugins/squelch-tabs-and-accord…/js/squelch-tabs-and-accordions.js?x37502

js futurecinema.ca collected 2026-10-04 22:52:22 UTC 35,571 bytes, 869 lines download raw bytes

1
2/*  Copyright (c) 2013 Nicola Hibbert  (http://nicolahibbert.com/liteaccordion-v2/)
3    Extensions (c) 2013 Matt Lowe; Added support for jQuery UI theming
4
5    Permission is hereby granted, free of charge, to any person obtaining
6    a copy of this software and associated documentation files (the
7    "Software"), to deal in the Software without restriction, including
8    without limitation the rights to use, copy, modify, merge, publish,
9    distribute, sublicense, and/or sell copies of the Software, and to
10    permit persons to whom the Software is furnished to do so, subject to
11    the following conditions:
12
13    The above copyright notice and this permission notice shall be
14    included in all copies or substantial portions of the Software.
15
16    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20    LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21    OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22    WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
24*/
25;(function($) {
26
27    var LiteAccordion = function(elem, options) {
28
29        var defaults = {
30            containerWidth : 960,                   // fixed (px)
31            containerHeight : 320,                  // fixed (px)
32            headerWidth : 48,                       // fixed (px)
33
34            activateOn : 'click',                   // click or mouseover
35            firstSlide : 1,                         // displays slide (n) on page load
36            slideSpeed : 800,                       // slide animation speed
37            onTriggerSlide : function(e) {},        // callback on slide activate
38            onSlideAnimComplete : function() {},    // callback on slide anim complete
39
40            autoPlay : false,                       // automatically cycle through slides
41            pauseOnHover : false,                   // pause on hover
42            cycleSpeed : 6000,                      // time between slide cycles
43            easing : 'swing',                       // custom easing function
44
45            theme : 'jqueryui',                     // jqueryui, basic, dark, light, or stitch
46            rounded : false,                        // square or rounded corners
47            enumerateSlides : false,                // put numbers on slides
48            linkable : false                        // link slides via hash
49        },
50
51        // merge defaults with options in new settings object
52            settings = $.extend({}, defaults, options),
53
54        // 'globals'
55            slides = elem.children('ol').children('li'),
56            header = slides.children(':first-child'),
57            slideLen = slides.length,
58            slideWidth = settings.containerWidth - slideLen * settings.headerWidth,
59
60        // public methods
61            methods = {
62
63                // start elem animation
64                play : function(index) {
65                    var next = core.nextSlide(index && index);
66
67                    if (core.playing) return;
68
69                    // start autoplay
70                    core.playing = setInterval(function() {
71                        header.eq(next()).trigger('click.liteAccordion');
72                    }, settings.cycleSpeed);
73                },
74
75                // stop elem animation
76                stop : function() {
77                    clearInterval(core.playing);
78                    core.playing = 0;
79                },
80
81                // trigger next slide
82                next : function() {
83                    methods.stop();
84                    header.eq(core.currentSlide === slideLen - 1 ? 0 : core.currentSlide + 1).trigger('click.liteAccordion');
85                },
86
87                // trigger previous slide
88                prev : function() {
89                    methods.stop();
90                    header.eq(core.currentSlide - 1).trigger('click.liteAccordion');
91                },
92
93                // destroy plugin instance
94                destroy : function() {
95                    // stop autoplay
96                    methods.stop();
97
98                    // remove hashchange event bound to window
99                    $(window).off('.liteAccordion');
100
101                    // remove generated styles, classes, data, events
102                    elem
103                        .attr('style', '')
104                        .removeClass('liteAccordion basic dark light stitch')
105                        .removeData('liteAccordion')
106                        .off('.liteAccordion')
107                        .find('li > :first-child')
108                        .off('.liteAccordion')
109                        .filter('.selected')
110                        .removeClass('selected')
111                        .end()
112                        .find('b')
113                        .remove();
114
115                    slides
116                        .removeClass('slide')
117                        .children()
118                        .attr('style', '');
119                },
120
121                // poke around the internals (NOT CHAINABLE)
122                debug : function() {
123                    return {
124                        elem : elem,
125                        defaults : defaults,
126                        settings : settings,
127                        methods : methods,
128                        core : core
129                    };
130                }
131            },
132
133        // core utility and animation methods
134            core = {
135
136                // set style properties
137                setStyles : function() {
138                    // set container height and width, theme and corner style
139                    elem
140                        .width(settings.containerWidth)
141                        .height(settings.containerHeight)
142                        .addClass('liteAccordion')
143                        .addClass(settings.rounded && 'rounded')
144                        .addClass(settings.theme);
145
146                    // jquery UI compatibility
147                    if ('jqueryui' == settings.theme) {
148                        elem
149                            .addClass('ui-accordion')
150                            .addClass('ui-widget');
151                        elem
152                            .find('h3')
153                                .addClass('ui-helper-reset')
154                                .find('span')
155                                    .addClass('ui-accordion-header')
156                                    .addClass('ui-state-default')
157                                    .addClass('ui-corner-all');
158                        elem.find('h3').next()
159                            .addClass('ui-corner-all')
160                            .addClass('ui-widget-content');
161                    }
162
163                    // set slide heights
164                    slides
165                        .addClass('slide')
166                        .children(':first-child')
167                        .height(settings.headerWidth);
168
169                    // set slide positions
170                    core.setSlidePositions();
171                },
172
173                // set initial positions for each slide
174                setSlidePositions : function() {
175                    var selected = header.filter('.selected');
176
177                    // account for already selected slide
178                    if (!selected.length)
179                        header.eq(settings.firstSlide - 1).addClass('selected');
180
181                    header.each(function(index) {
182                        var $this = $(this),
183                            left = index * settings.headerWidth,
184                            margin = header.first().next(),
185                            offset = parseInt(margin.css('marginLeft'), 10) || parseInt(margin.css('marginRight'), 10) || 0;
186
187                        // compensate for already selected slide on resize
188                        if (selected.length) {
189                            if (index > header.index(selected)) left += slideWidth;
190                        } else {
191                            if (index >= settings.firstSlide) left += slideWidth;
192                        }
193
194                        // set each slide position
195                        $this
196                            .css('left', left)
197                            .width(settings.containerHeight)
198                            .next()
199                                .width(slideWidth - offset)
200                                .css({ left : left, paddingLeft : settings.headerWidth });
201
202                        // add number to bottom of tab
203                        settings.enumerateSlides && $this.append('<b>' + (index + 1) + '</b>');
204
205                    });
206                },
207
208                // bind events
209                bindEvents : function() {
210                    // bind click and mouseover events
211                    if (settings.activateOn === 'click') {
212                        header.on('click.liteAccordion', core.triggerSlide);
213                    } else if (settings.activateOn === 'mouseover') {
214                        header.on('click.liteAccordion mouseover.liteAccordion', core.triggerSlide);
215                    }
216
217                    // bind hashchange event
218                    if (settings.linkable) {
219                        $(window).on('hashchange.liteAccordion', function(e) {
220                            var url = slides.filter(function() {
221                                return $(this).attr('data-slide-name') === window.location.hash.split('#')[1];
222                            });
223
224                            // if slide name exists
225                            if (url.length) {
226                                // trigger slide
227                                core.triggerSlide.call(url.children('h3')[0], e);
228                            }
229                        });
230                    }
231
232                    // pause on hover (can't use custom events with $.hover())
233                    if (settings.pauseOnHover && settings.autoPlay) {
234                        elem
235                            .on('mouseover.liteAccordion', function() {
236                                core.playing && methods.stop();
237                            })
238                            .on('mouseout.liteAccordion', function() {
239                                !core.playing && methods.play(core.currentSlide);
240                            });
241                    }
242                },
243
244                // counter for autoPlay (zero index firstSlide on init)
245                currentSlide : settings.firstSlide - 1,
246
247                // next slide index
248                nextSlide : function(index) {
249                    var next = index + 1 || core.currentSlide + 1;
250
251                    // closure
252                    return function() {
253                        return next++ % slideLen;
254                    };
255                },
256
257                // holds interval counter
258                playing : 0,
259
260                slideAnimCompleteFlag : false,
261
262                // trigger slide animation
263                triggerSlide : function(e) {
264                    var $this = $(this),
265                        tab = {
266                            elem : $this,
267                            index : header.index($this),
268                            next : $this.next(),
269                            prev : $this.parent().prev().children('h3'),
270                            parent : $this.parent()
271                        };
272
273                    // current hash not correct?
274                    if (settings.linkable && tab.parent.attr('data-slide-name')) {
275                        if (tab.parent.attr('data-slide-name') !== window.location.hash.split('#')[1]) {
276                            // exit early and try again (prevents double trigger (issue #60))
277                            return window.location.hash = '#' + tab.parent.attr('data-slide-name');
278                        }
279                    }
280
281                    // update core.currentSlide
282                    core.currentSlide = tab.index;
283
284                    // reset onSlideAnimComplete callback flag
285                    core.slideAnimCompleteFlag = false;
286
287                    // trigger callback in context of sibling div (jQuery wrapped)
288                    settings.onTriggerSlide.call(tab.next, $this);
289
290                    // animate
291                    if ($this.hasClass('selected') && $this.position().left < slideWidth / 2) {
292                        // animate single selected tab
293                        core.animSlide.call(tab);
294                    } else {
295                        // animate groups
296                        core.animSlideGroup(tab);
297                    }
298
299                    // stop autoplay, reset current slide index in core.nextSlide closure
300                    if (settings.autoPlay) {
301                        methods.stop();
302                        methods.play(header.index(header.filter('.selected')));
303                    }
304                },
305
306                animSlide : function(triggerTab) {
307                    var _this = this;
308
309                    // set pos for single selected tab
310                    if (typeof this.pos === 'undefined') this.pos = slideWidth;
311
312                    // remove, then add selected class
313                    header.removeClass('selected').filter(this.elem).addClass('selected');
314
315                    // if slide index not zero
316                    if (!!this.index) {
317                        this.elem
318                            .add(this.next)
319                            .stop(true)
320                            .animate({
321                                left : this.pos + this.index * settings.headerWidth
322                            },
323                                settings.slideSpeed,
324                                settings.easing,
325                                function() {
326                                    // flag ensures that fn is only called one time per triggerSlide
327                                    if (!core.slideAnimCompleteFlag) {
328                                        // trigger onSlideAnimComplete callback in context of sibling div (jQuery wrapped)
329                                        settings.onSlideAnimComplete.call(triggerTab ? triggerTab.next : _this.prev.next());
330                                        core.slideAnimCompleteFlag = true;
331                                    }
332                                });
333
334                            // remove, then add selected class
335                            header.removeClass('selected').filter(this.prev).addClass('selected');
336
337                    }
338                },
339
340                // animates left and right groups of slides
341                animSlideGroup : function(triggerTab) {
342                    var group = ['left', 'right'];
343
344                    $.each(group, function(index, side) {
345                        var filterExpr, left;
346
347                        if (side === 'left')  {
348                            filterExpr = ':lt(' + (triggerTab.index + 1) + ')';
349                            left = 0;
350                        } else {
351                            filterExpr = ':gt(' + triggerTab.index + ')';
352                            left = slideWidth;
353                        }
354
355                        slides
356                            .filter(filterExpr)
357                            .children('h3')
358                            .each(function() {
359                                var $this = $(this),
360                                    tab = {
361                                        elem : $this,
362                                        index : header.index($this),
363                                        next : $this.next(),
364                                        prev : $this.parent().prev().children('h3'),
365                                        pos : left
366                                    };
367
368                                // trigger item anim, pass original trigger context for callback fn
369                                core.animSlide.call(tab, triggerTab);
370                            });
371
372                    });
373
374                    // remove, then add selected class
375                    header.removeClass('selected').filter(triggerTab.elem).addClass('selected');
376                },
377
378                ieClass : function(version) {
379                    if (version < 7) methods.destroy();
380                    if (version >= 10) return;
381                    if (version === 7 || version === 8) {
382                        slides.each(function(index) {
383                            $(this).addClass('slide-' + index);
384                        });
385                    }
386
387                    elem.addClass('ie ie' + version);
388                },
389
390                init : function() {
391                    var ua = navigator.userAgent,
392                        index = ua.indexOf('MSIE');
393
394                    // test for ie
395                    if (index !== -1) {
396                        ua = ua.slice(index + 5, index + 7);
397                        core.ieClass(+ua);
398                    }
399
400                    // init styles and events
401                    core.setStyles();
402                    core.bindEvents();
403
404                    // check slide speed is not faster than cycle speed
405                    if (settings.cycleSpeed < settings.slideSpeed) settings.cycleSpeed = settings.slideSpeed;
406
407                    // init autoplay
408                    settings.autoPlay && methods.play();
409                }
410            };
411
412        // init plugin
413        core.init();
414
415        // expose methods
416        return methods;
417
418    };
419
420    $.fn.liteAccordion = function(method) {
421        var elem = this,
422            instance = elem.data('liteAccordion');
423
424        // if creating a new instance
425        if (typeof method === 'object' || !method) {
426            return elem.each(function() {
427                var liteAccordion;
428
429                // if plugin already instantiated, return
430                if (instance) return;
431
432                // otherwise create a new instance
433                liteAccordion = new LiteAccordion(elem, method);
434                elem.data('liteAccordion', liteAccordion);
435            });
436
437        // otherwise, call method on current instance
438        } else if (typeof method === 'string' && instance[method]) {
439            // debug method isn't chainable b/c we need the debug object to be returned
440            if (method === 'debug') {
441                return instance[method].call(elem);
442            } else { // the rest of the methods are chainable though
443                instance[method].call(elem);
444                return elem;
445            }
446        }
447    };
448
449})(jQuery);
450
451
452
453/*  Copyright 2013  Matt Lowe / Squelch Design  (http://squelch.it/  ... email: [email protected])
454
455    This program is free software; you can redistribute it and/or modify
456    it under the terms of the GNU General Public License, version 2, as
457    published by the Free Software Foundation, except where stated.
458
459    This program is distributed in the hope that it will be useful,
460    but WITHOUT ANY WARRANTY; without even the implied warranty of
461    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
462    GNU General Public License for more details.
463
464    You should have received a copy of the GNU General Public License
465    along with this program; if not, write to the Free Software
466    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
467
468*/
469;(function($) {
470    $.fn.openSquelchToggle = function(i) {
471
472        var settings = $(this).data('settings');
473        var $toggles = this.children('div');
474        var $headers = this.children('h3');
475        var $pane    = $toggles.eq(i);
476        var $header  = $headers.eq(i);
477
478        if (settings.theme == 'blank') {
479            $header.find('span.ui-icon').addClass('ui-icon-triangle-1-e ui-icon-triangle-1-s');
480        } else if (settings.theme == 'jqueryui') {
481            $header.addClass('ui-accordion-header-active ui-state-active ui-corner-top ui-corner-all');
482            $header.find('span.ui-icon').addClass('ui-icon-triangle-1-e ui-icon-triangle-1-s');
483        } else {
484            $header.addClass('squelch-taas-toggle-shortcode-header-active');
485        }
486
487        $pane.slideToggle(settings.speed);
488    }
489
490
491
492    $.fn.squelchToggles = function(options) {
493
494        var defaults = {
495            speed:      800,
496            active:     false,
497            theme:      'jqueryui'
498        };
499
500        var settings = $.extend({}, defaults, options);
501        var $toggle  = this;
502        var $toggles = this.children('div');
503        var $headers = this.children('h3');
504
505        $(this).data('settings', settings);
506
507        // Add the jQuery UI accordion classes when needed
508        if (settings.theme == 'blank') {
509            $headers.each(function(){
510                $(this).prepend('<span class="ui-icon ui-icon-triangle-1-e"></span>');
511            });
512        } else if (settings.theme == 'jqueryui') {
513            $toggle.addClass('ui-widget ui-accordion ui-widget ui-helper-reset');
514            $toggles.addClass('ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom');
515            $headers.each(function() {
516                $(this).addClass('ui-accordion-header ui-helper-reset ui-state-default ui-corner-all ui-accordion-icons');
517                $(this).attr('role', 'tab');
518                $(this).attr('aria-selected', 'false' );
519                $(this).prepend('<span class="ui-accordion-header-icon ui-icon ui-icon-triangle-1-e"></span>');
520            });
521        }
522
523        $toggles.hide();
524        $toggle.addClass(settings.theme);
525
526        // Add the actions:
527
528        // hover
529        $headers.hover(function() {
530            if (settings.theme == 'jqueryui') {
531                $(this).addClass('ui-state-hover');
532            }
533            $(this).addClass('squelch-taas-toggle-shortcode-header-hover');
534        }, function() {
535            if (settings.theme == 'jqueryui') {
536                $(this).removeClass('ui-state-hover');
537            }
538            $(this).removeClass('squelch-taas-toggle-shortcode-header-hover');
539        });
540
541        // click
542        $headers.click(function(ev) {
543            if (settings.theme == 'blank') {
544                $(this).find('span.ui-icon').toggleClass('ui-icon-triangle-1-e ui-icon-triangle-1-s');
545            } else if (settings.theme == 'jqueryui') {
546                $(this).toggleClass('ui-accordion-header-active ui-state-active ui-corner-top ui-corner-all');
547                $(this).find('span.ui-icon').toggleClass('ui-icon-triangle-1-e ui-icon-triangle-1-s');
548            } else {
549                $(this).toggleClass('squelch-taas-toggle-shortcode-header-active');
550            }
551
552            $(this).next().slideToggle(settings.speed);
553
554            ev.preventDefault();
555            return false;
556        });
557
558        // Set active pane
559        if ((settings.active !== false) && (settings.active != 'false') && (typeof(settings.active) == 'string')) {
560            // active can be comma-separated to activate more than one pane
561            var allActive = settings.active.split(/[, ]/);
562            $.each( allActive, function(index, value) {
563                var active = parseInt(value);
564
565                if (!isNaN(active)) {
566                    $headers.eq(value).click();
567                }
568            });
569        }
570
571        return $toggle;
572    };
573})(jQuery);
574
575
576
577;(function($) {
578
579    /**
580     * Given any target, smoothly scrolls the page to make that item visible.
581     *
582     * @param target jQuery obj|jquery search string What to scroll to
583     * @param callback Function to call back to on completion (optional)
584     */
585    var scrollToTarget = function( target, callback ) {
586
587        var offset = Math.round( $(target).eq(0).offset().top - 200 );
588
589        if ( $('#wpadminbar').length ) {
590            offset -= $('#wpadminbar').length;
591        }
592
593        // Only execute the animation if it is needed
594        if ($(window).scrollTop() !== offset) {
595
596            $('html, body').animate({
597                scrollTop: offset
598            }, 1000, 'swing', function() {
599
600                if (typeof( callback ) === 'function') {
601                    callback();
602
603                    // Prevent the callback being called twice (as we animate on TWO elements, html and body)
604                    callback = null;
605                }
606
607            });
608
609        } else {
610
611            // No animation needed, but do call the callback (if set)
612            if (typeof( callback ) === 'function') { callback(); }
613
614        }
615
616    };
617
618
619
620    $(document).ready(function() {
621
622        // Create accordions
623        $(".squelch-taas-accordion").each(function() {
624
625            var dataActive      = parseInt($(this).attr( 'data-active' ));
626            var dataDisabled    = $(this).attr( 'data-disabled'     )   == 'true' ? true : false;
627            var dataAutoHeight  = $(this).attr( 'data-autoheight'   )   == 'true' ? true : false;
628            var dataCollapsible = $(this).attr( 'data-collapsible'  )   == 'true' ? true : false;
629
630            var dataHeightStyle = dataAutoHeight ? 'auto' : 'content';
631
632            $(this).accordion({
633                disabled:       dataDisabled,
634                active:         dataActive,
635                heightStyle:    dataHeightStyle,
636                collapsible:    dataCollapsible
637            });
638        });
639
640
641        // Create hAccordions
642        $(".squelch-taas-haccordion").each(function() {
643
644            var dataWidth           = parseInt($(this).attr( 'data-width'       ));
645            var dataHeight          = parseInt($(this).attr( 'data-height'      ));
646            var dataHWidth          = parseInt($(this).attr( 'data-h-width'     ));
647
648            var dataActivateOn      = $(this).attr( 'data-activate-on'           );
649            var dataActive          = parseInt($(this).attr( 'data-active'      ));
650            var dataSpeed           = parseInt($(this).attr( 'data-speed'       ));
651
652            var dataAutoPlay        = $(this).attr( 'data-autoplay'         )   == 'true' ? true : false;
653            var dataPauseOnHover    = $(this).attr( 'data-pauseonhover'     )   == 'true' ? true : false;
654            var dataCycleSpeed      = parseInt($(this).attr( 'data-cyclespeed'  ));
655
656            var dataTheme           = $(this).attr( 'data-theme'                 );
657            var dataRounded         = $(this).attr( 'data-rounded'               );
658            var dataEnumerate       = $(this).attr( 'data-enumerate'        )   == 'true' ? true : false;
659
660            //TODO? Or drop support for this attribute?
661            //var dataDisabled        = $(this).attr( 'data-disabled'         )   == 'true' ? true : false;
662
663            $(this).liteAccordion({
664                containerWidth:     dataWidth,
665                containerHeight:    dataHeight,
666                headerWidth:        dataHWidth,
667
668                activateOn:         dataActivateOn,
669                firstSlide:         dataActive,
670                slideSpeed:         dataSpeed,
671
672                autoPlay:           dataAutoPlay,
673                pauseOnHover:       dataPauseOnHover,
674                cycleSpeed:         dataCycleSpeed,
675
676                theme:              dataTheme,
677                rounded:            dataRounded,
678                enumerateSlides:    dataEnumerate,
679
680                onTriggerSlide:     function(tab) {
681                    if ('jqueryui' === dataTheme) {
682                        $(tab).parents('.squelch-taas-haccordion').eq(0).find('.ui-state-active').removeClass('ui-state-active');
683                        $(tab).find('span').addClass('ui-state-active');
684                    }
685                }
686            });
687            if ('jqueryui' === dataTheme) $(this).find('.selected span').addClass('ui-state-active');
688        });
689
690
691        // Create tabs
692        $(".squelch-taas-tab-group").each(function() {
693            var dataDisabled    = $(this).attr( 'data-disabled'     )   == 'true' ? true : false;
694            var dataCollapsible = $(this).attr( 'data-collapsible'  )   == 'true' ? true : false;
695            var dataActive      = parseInt($(this).attr( 'data-active' ));
696            var dataEvent       = $(this).attr( 'data-event' );
697
698            $(this).tabs({
699                disabled:       dataDisabled,
700                collapsible:    dataCollapsible,
701                active:         dataActive,
702                event:          dataEvent
703            });
704        });
705
706
707        // Create toggles
708        $(".squelch-taas-toggle").each(function() {
709            var dataSpeed   = $(this).attr( 'data-speed'  );
710            var dataActive  = $(this).attr( 'data-active' );
711            var dataTheme   = $(this).attr( 'data-theme'  );
712
713            $(this).squelchToggles({
714                speed:  dataSpeed,
715                active: dataActive,
716                theme:  dataTheme
717            });
718        });
719
720
721        // Track changes in tabs / toggles / accordions / haccordions via the URL
722        if (! squelch_taas_options.disable_magic_url) {
723            $(  '.squelch-taas-tab > a,'+
724                '.squelch-taas-toggle > h3,'+
725                '.squelch-taas-toggle > h3 > a,'+
726                '.squelch-taas-accordion > h3,'+
727                '.squelch-taas-accordion > h3 > a,'+
728                '.squelch-taas-haccordion > ol > li > h3 > span')
729                .click(function(ev) {
730
731                // Find out which page fragment to use (haccordions are different to everything else)
732                var url = '';
733
734                if (this.tagName.toUpperCase() == 'SPAN') {
735                    // Assume it's an haccordion
736                    url = document.location.origin + document.location.pathname + '#'+$(this).parents('h3').eq(0).attr('id');
737                    //console.log(document.location);
738                } else if (this.tagName.toUpperCase() == 'H3') {
739                    url = $(this).children('a').get(0).href;
740                } else {
741                    url = this.href;
742                }
743
744                // Update the URL with the new fragment so that links to this page will link directly to the correct tab / accordion
745                if (history.replaceState) history.replaceState({}, '', url);
746
747            });
748        }
749
750
751        // On page load, if a fragment is present, tie it to a specific tab / toggle / accordion / haccordion
752        if (document.location.hash && document.getElementById(document.location.hash.replace('#', ''))) {
753            // Find the content panel the fragment refers to
754            var panel = $(document.location.hash);
755
756
757            // Tab -----------------------------------------------------------------------------------------------------
758            if ($(panel).hasClass('ui-tabs-panel')) {
759                var parentDiv = $(panel).parents('div').eq(0);
760                var tabGroup  = $(panel).parents('.squelch-taas-tab-group');
761
762                $(parentDiv).find('div.ui-tabs-panel').each(function(i, elem) {
763                    if ($(this).attr('id') == panel.attr('id')) {
764                        setTimeout(function() {
765                            scrollToTarget( $(tabGroup), function() {
766                                // Found the panel at index "i": Now tell jQuery UI to open that tab
767                                tabGroup.tabs( "option", "active", i );
768                            } );
769                        }, 250);
770                    }
771                });
772            }
773
774
775            // Toggle --------------------------------------------------------------------------------------------------
776            if ($(panel).hasClass('squelch-taas-toggle-shortcode-content')) {
777                var parentDiv = $(panel).parents('div.squelch-taas-toggle').eq(0);
778
779                $(parentDiv).find('div.ui-accordion-content').each(function(i, elem) {
780                    if ($(this).attr('id') == panel.attr('id')) {
781                        // Found the panel at index "i": Now tell Squelch Toggles to open that toggle panel
782                        parentDiv.openSquelchToggle( i );
783                    }
784                });
785
786            }
787
788
789            // Accordion -----------------------------------------------------------------------------------------------
790            if ($(panel).hasClass('squelch-taas-accordion-shortcode-content')) {
791                var parentDiv = $(panel).parents('div').eq(0);
792                $(parentDiv).find('div.ui-accordion-content').each(function(i, elem) {
793                    if ($(this).attr('id') == panel.attr('id')) {
794                        // Found the panel at index "i": Now tell jQuery UI to open that accordion panel
795                        parentDiv.accordion( "option", "active", i );
796                    }
797                });
798            }
799
800
801            // Horizontal accordion ------------------------------------------------------------------------------------
802            if ($(panel).hasClass('squelch-taas-haccordion-shortcode')) {
803                // TODO
804            }
805        }
806
807
808
809        // Click handler for arbitrary links to tabs within the page
810        $('a[href]')
811                .not('.squelch-taas-accordion > h3')
812                .not('.squelch-taas-accordion > h3 > a')
813                .not('.squelch-taas-toggle > h3')
814                .not('.squelch-taas-toggle > h3 > a')
815                .not('.squelch-taas-tab > a')
816                .click(function(ev) {
817            if (this.hash) {
818
819                // Verify whether this link is a target to the SAME PAGE first (if it looks like an external link, leave it alone)
820                if (this.pathname == window.location.pathname) {
821
822                    // Find the tabs / accordions this link should go to on THIS PAGE
823                    var $targets = $('a[href="'+this.hash+'"]').not(this);
824
825                    // Verify each of those targets is a tab/toggle/accordion/haccordion
826                    $targets.each(function(i, target) {
827
828                        if ($(target).hasClass('ui-tabs-anchor')) {
829                            // Tabs
830                            scrollToTarget( target, function() {
831                                $(target).click();
832                            } );
833                            ev.preventDefault();
834
835                        } else if ($(target).parent().hasClass('squelch-taas-toggle-shortcode-header')) {
836                            // Toggles
837                            scrollToTarget( $(target).parent(), function() {
838                                $(target).click();
839                            } );
840                            ev.preventDefault();
841
842                        } else if ($(target).parent().hasClass('ui-accordion-header')) {
843                            // Accordions
844                            scrollToTarget( $(target).parent().parent().eq(0), function() {
845                                $(target).click();
846                            } );
847                            ev.preventDefault();
848
849                        } else if ($(target).hasClass('squelch-taas-haccordion-shortcode')) {
850                            // Horizontal accordion
851                            scrollToTarget( target, function() {
852                                $(target).click();
853                            } );
854                            ev.preventDefault();
855
856                        }
857
858                    });
859
860
861                }
862            }
863        });
864
865    });
866
867})(jQuery);
868
869

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.