PageSourceSearch

https://laerkelunden.dk/plugins/system/t3/base-bs3/js/off-canvas.js

js laerkelunden.dk collected 2026-09-26 12:54:19 UTC 8,221 bytes, 220 lines download raw bytes

1/**
2 *------------------------------------------------------------------------------
3 * @package       T3 Framework for Joomla!
4 *------------------------------------------------------------------------------
5 * @copyright     Copyright (C) 2004-2013 JoomlArt.com. All Rights Reserved.
6 * @license       GNU General Public License version 2 or later; see LICENSE.txt
7 * @authors       JoomlArt, JoomlaBamboo, (contribute to this project at github
8 *                & Google group to become co-author)
9 * @Google group: https://groups.google.com/forum/#!forum/t3fw
10 * @Link:         http://t3-framework.org
11 *------------------------------------------------------------------------------
12 */
13jQuery (document).ready(function($){
14    function getAndroidVersion(ua) {
15        var ua = ua || navigator.userAgent;
16        var match = ua.match(/Android\s([0-9\.]*)/);
17        return match ? match[1] : false;
18    };
19
20    if (parseInt(getAndroidVersion()) == 4) {
21        $('#t3-mainnav').addClass('t3-mainnav-android');
22    }
23    var JA_isLoading = false;
24    // fix for old ie
25    if (/MSIE\s([\d.]+)/.test(navigator.userAgent) ? new Number(RegExp.$1) < 10 : false) {
26        $('html').addClass ('old-ie');
27    } else if(/constructor/i.test(window.HTMLElement)){
28        $('html').addClass('safari');
29    }
30
31    var $wrapper = $('body'),
32        $inner = $('.t3-wrapper'),
33        $toggles = $('.off-canvas-toggle'),
34        $offcanvas = $('.t3-off-canvas'),
35        $close = $('.t3-off-canvas .close'),
36        $btn=null,
37        $nav=null,
38        direction = 'left',
39        $fixed = null;
40    // no wrapper, just exit
41    if (!$wrapper.length) return ;
42
43    // add effect class for nav
44    $toggles.each (function () {
45        var $this = $(this),
46            $nav = $($this.data('nav')),
47            effect = $this.data('effect'),
48            direction = ($('html').attr('dir') == 'rtl' && $this.data('pos')!='right') || ($('html').attr('dir') != 'rtl' && $this.data('pos')=='right')  ? 'right':'left';
49        $nav.addClass (effect).addClass ('off-canvas-'+direction);
50
51        // move to outside wrapper-content
52        var inside_effect = ['off-canvas-effect-3','off-canvas-effect-16','off-canvas-effect-7','off-canvas-effect-8','off-canvas-effect-14'];
53        if ($.inArray(effect, inside_effect) == -1) {
54            $inner.before($nav);
55        } else {
56            $inner.prepend($nav);
57        }
58    });
59
60    $toggles.on('click', function(e){
61        // detect direction
62
63        stopBubble (e);
64
65        if ($wrapper.hasClass ('off-canvas-open')) {
66            oc_hide (e);
67            return false;
68        }
69
70        $btn = $(this);
71        $nav = $($btn.data('nav'));
72        if (!$fixed) $fixed = $inner.find('*').filter (function() {return $(this).css("position") === 'fixed';});
73        else $fixed = $fixed.filter (function() {return $(this).css("position") === 'fixed';}).add($inner.find('.affix'));
74
75        $nav.addClass ('off-canvas-current');
76
77        direction = ($('html').attr('dir') == 'rtl' && $btn.data('pos')!='right') || ($('html').attr('dir') != 'rtl' && $btn.data('pos')=='right')  ? 'right':'left';
78
79        // add direction class to body
80        // $('html').removeClass ('off-canvas-left off-canvas-right').addClass ('off-canvas-' + direction);
81
82        $offcanvas.height($(window).height());
83
84        // disable scroll event
85        var events = $(window).data('events');
86        if (events && events.scroll && events.scroll.length) {
87          // store current handler for scroll
88          var handlers = [];
89          for (var i=0; i<events.scroll.length; i++){
90            handlers[i] = events.scroll[i].handler;
91          }
92          $(window).data('scroll-events', handlers);
93          $(window).off ('scroll');
94        }
95        // disable scroll on page
96        var scrollTop = ($('html').scrollTop()) ? $('html').scrollTop() : $('body').scrollTop(); // Works for Chrome, Firefox, IE...
97        $('html').addClass('noscroll').css('top',-scrollTop).data('top', scrollTop);
98        $('.t3-off-canvas').css('top',scrollTop);
99
100        // make the fixed element become absolute
101        $fixed.each (function () {
102            var $this = $(this),
103                $parent = $this.parent(),
104                mtop = 0;
105            // find none static parent
106            while (!$parent.is($inner) && $parent.css("position") === 'static') $parent = $parent.parent();
107            mtop = -$parent.offset().top;
108            $this.css ({'position': 'absolute', 'margin-top': mtop});
109        });
110
111        $wrapper.scrollTop (scrollTop);
112        // update effect class
113        $wrapper[0].className = $.trim($wrapper[0].className.replace (/\s*off\-canvas\-effect\-\d+\s*
113/g, ' ')) +
114            ' ' + $btn.data('effect') + ' ' + 'off-canvas-' + direction;
115
116        setTimeout(oc_show, 50);
117
118        return false;
119    });
120    var oc_show = function () {
121        if (JA_isLoading == true) {
122            return;
123        }
124        JA_isLoading=true;
125        $wrapper.addClass ('off-canvas-open');
126        $inner.on ('click', oc_hide);
127        $close.on ('click', oc_hide);
128        $offcanvas.on ('click', handleClick);
129
130        // fix for old ie
131        if ($.browser.msie && $.browser.version < 10) {
132            var p1 = {}, p2 = {};
133            p1['padding-'+direction] = $('.t3-off-canvas').width();
134            p2[direction] = 0;
135            $inner.animate (p1);
136            $nav.animate (p2);
137        }
138        setTimeout (function (){JA_isLoading=false;}, 200);
139    };
140
141    var oc_hide = function () {
142        if (JA_isLoading == true) {
143            return;
144        }
145        JA_isLoading=true;
146
147        //remove events
148        $inner.off ('click', oc_hide);
149        $close.off ('click', oc_hide);
150        $offcanvas.off ('click', handleClick);
151
152        //delay for click action
153        setTimeout(function(){
154            $wrapper.removeClass ('off-canvas-open');
155        }, 100);
156
157        setTimeout (function (){
158            $wrapper.removeClass ($btn.data('effect')).removeClass ('off-canvas-'+direction);
159            $wrapper.scrollTop (0);
160            // enable scroll
161            $('html').removeClass ('noscroll').css('top', '');
162            $('html,body').scrollTop ($('html').data('top'));
163            $nav.removeClass ('off-canvas-current');
164            // restore fixed elements
165            $fixed.css ({'position': '', 'margin-top': ''});
166            // re-enable scroll
167            if ($(window).data('scroll-events')) {
168              var handlers = $(window).data('scroll-events');
169              for (var i=0; i<handlers.length; i++) {
170                $(window).on ('scroll', handlers[i]);
171              }
172              $(window).data('scroll-events', null);
173            }
174            JA_isLoading=false;
175        }, 700);
176
177        // fix for old ie
178        if ($('html').hasClass ('old-ie')) {
179            var p1 = {}, p2 = {};
180            p1['padding-'+direction] = 0;
181            p2[direction] = -$('.t3-off-canvas').width();
182            $inner.animate (p1);
183            $nav.animate (p2);
184        }
185
186    };
187
188    var handleClick = function (e) {        
189        if ($(e.target).closest('a').length) {
190            if (!e.target.href) return;
191            // handle the anchor link
192            var arr1 = e.target.href.split('#'),
193                arr2 = location.href.split('#');
194            if (arr1[0] == arr2[0] && arr1.length > 1 && arr1[1].length) {
195                oc_hide();
196                setTimeout(function(){
197                    var anchor = $("a[name='"+ arr1[1] +"']");
198                    if (!anchor.length) anchor = $('#' + arr1[1]);
199                    if (anchor.length) 
200                        $('html,body').animate({scrollTop: anchor.offset().top},'slow');
201                }, 1000);
202            }
203            // prevent only if anchor same page.
204            if (e.target.href.search('#') !== -1) return;
205        }
206        stopBubble(e);
207        return true;
208    }
209
210    var stopBubble = function (e) {
211        e.stopPropagation();
212    }
213
214    // preload fixed items
215    $(window).on('load',function() {
216      setTimeout(function(){
217        $fixed = $inner.find('*').filter (function() {return $(this).css("position") === 'fixed';});
218      }, 100);
219    });
220})

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.