PageSourceSearch

https://www.ets-tee.de/templates/NOVA/js/bootstrap-toolkit.js?v=1.8.0

js ets-tee.de collected 2026-10-07 20:27:13 UTC 7,944 bytes, 244 lines download raw bytes

1/*!
2 * Responsive Bootstrap Toolkit
3 * Author:    Maciej Gurban
4 * License:   MIT
5 * Version:   2.6.3 (2016-06-21)
6 * Origin:    https://github.com/maciej-gurban/responsive-bootstrap-toolkit
7 */
8var ResponsiveBootstrapToolkit = (function($){
9
10    // Internal methods
11    var internal = {
12
13        /**
14         * Breakpoint detection divs for each framework version
15         */
16        detectionDivs: {
17            // Bootstrap 3
18            /*bootstrap: {
19                'xs': $('<div class="device-xs visible-xs visible-xs-block"></div>'),
20                'sm': $('<div class="device-sm visible-sm visible-sm-block"></div>'),
21                'md': $('<div class="device-md visible-md visible-md-block"></div>'),
22                'lg': $('<div class="device-lg visible-lg visible-lg-block"></div>')
23            },*/
24            bootstrap: {
25                'xs': $('<div class="device-xs d-block d-sm-none"></div>'),
26                'sm': $('<div class="device-sm d-none d-sm-block d-md-none"></div>'),
27                'md': $('<div class="device-md d-none d-md-block d-lg-none"></div>'),
28                'lg': $('<div class="device-lg d-none d-lg-block"></div>')
29            },
30            // Foundation 5
31            foundation: {
32                'small':  $('<div class="device-xs show-for-small-only"></div>'),
33                'medium': $('<div class="device-sm show-for-medium-only"></div>'),
34                'large':  $('<div class="device-md show-for-large-only"></div>'),
35                'xlarge': $('<div class="device-lg show-for-xlarge-only"></div>')
36            }
37        },
38
39        /**
40         * Append visibility divs after DOM laoded
41         */
42        applyDetectionDivs: function() {
43            $(document).ready(function(){
44                $.each(self.breakpoints, function(alias){
45                    self.breakpoints[alias].appendTo('.responsive-bootstrap-toolkit');
46                });
47            });
48        },
49
50        /**
51         * Determines whether passed string is a parsable expression
52         */
53        isAnExpression: function( str ) {
54            return (str.charAt(0) == '<' || str.charAt(0) == '>');
55        },
56
57        /**
58         * Splits the expression in into <|> [=] alias
59         */
60        splitExpression: function( str ) {
61
62            // Used operator
63            var operator = str.charAt(0);
64            // Include breakpoint equal to alias?
65            var orEqual  = (str.charAt(1) == '=') ? true : false;
66
67            /**
68             * Index at which breakpoint name starts.
69             *
70             * For:  >sm, index = 1
71             * For: >=sm, index = 2
72             */
73            var index = 1 + (orEqual ? 1 : 0);
74
75            /**
76             * The remaining part of the expression, after the operator, will be treated as the
77             * breakpoint name to compare with
78             */
79            var breakpointName = str.slice(index);
80
81            return {
82                operator:       operator,
83                orEqual:        orEqual,
84                breakpointName: breakpointName
85            };
86        },
87
88        /**
89         * Returns true if currently active breakpoint matches the expression
90         */
91        isAnyActive: function( breakpoints ) {
92            var found = false;
93            $.each(breakpoints, function( index, alias ) {
94                // Once first breakpoint matches, return true and break out of the loop
95                if( self.breakpoints[ alias ].is(':visible') ) {
96                    found = true;
97                    return false;
98                }
99            });
100            return found;
101        },
102
103        /**
104         * Determines whether current breakpoint matches the expression given
105         */
106        isMatchingExpression: function( str ) {
107
108            var expression = internal.splitExpression( str );
109
110            // Get names of all breakpoints
111            var breakpointList = Object.keys(self.breakpoints);
112
113            // Get index of sought breakpoint in the list
114            var pos = breakpointList.indexOf( expression.breakpointName );
115
116            // Breakpoint found
117            if( pos !== -1 ) {
118
119                var start = 0;
120                var end   = 0;
121
122                /**
123                 * Parsing viewport.is('<=md') we interate from smallest breakpoint ('xs') and end
124                 * at 'md' breakpoint, indicated in the expression,
125                 * That makes: start = 0, end = 2 (index of 'md' breakpoint)
126                 *
127                 * Parsing viewport.is('<md') we start at index 'xs' breakpoint, and end at
128                 * 'sm' breakpoint, one before 'md'.
129                 * Which makes: start = 0, end = 1
130                 */
131                if( expression.operator == '<' ) {
132                    start = 0;
133                    end   = expression.orEqual ? ++pos : pos;
134                }
135                /**
136                 * Parsing viewport.is('>=sm') we interate from breakpoint 'sm' and end at the end
137                 * of breakpoint list.
138                 * That makes: start = 1, end = undefined
139                 *
140                 * Parsing viewport.is('>sm') we start at breakpoint 'md' and end at the end of
141                 * breakpoint list.
142                 * Which makes: start = 2, end = undefined
143                 */
144                if( expression.operator == '>' ) {
145                    start = expression.orEqual ? pos : ++pos;
146                    end   = undefined;
147                }
148
149                var acceptedBreakpoints = breakpointList.slice(start, end);
150
151                return internal.isAnyActive( acceptedBreakpoints );
152
153            }
154        }
155
156    };
157
158    // Public methods and properties
159    var self = {
160
161        /**
162         * Determines default debouncing interval of 'changed' method
163         */
164        interval: 300,
165
166        /**
167         *
168         */
169        framework: null,
170
171        /**
172         * Breakpoint aliases, listed from smallest to biggest
173         */
174        breakpoints: null,
175
176        /**
177         * Returns true if current breakpoint matches passed alias
178         */
179        is: function( str ) {
180            if( internal.isAnExpression( str ) ) {
181                return internal.isMatchingExpression( str );
182            }
183            return self.breakpoints[ str ] && self.breakpoints[ str ].is(':visible');
184        },
185
186        /**
187         * Determines which framework-specific breakpoint detection divs to use
188         */
189        use: function( frameworkName, breakpoints ) {
190            self.framework = frameworkName.toLowerCase();
191
192            if( self.framework === 'bootstrap' || self.framework === 'foundation') {
193                self.breakpoints = internal.detectionDivs[ self.framework ];
194            } else {
195                self.breakpoints = breakpoints;
196            }
197
198            internal.applyDetectionDivs();
199        },
200
201        /**
202         * Returns current breakpoint alias
203         */
204        current: function(){
205            var name = 'unrecognized';
206            $.each(self.breakpoints, function(alias){
207                if (self.is(alias)) {
208                    name = alias;
209                }
210            });
211            return name;
212        },
213
214        /*
215         * Waits specified number of miliseconds before executing a callback
216         */
217        changed: function(fn, ms) {
218            var timer;
219            return function(){
220                clearTimeout(timer);
221                timer = setTimeout(function(){
222                    fn();
223                }, ms || self.interval);
224            };
225        }
226
227    };
228
229    // Create a placeholder
230    $(document).ready(function(){
231        $('<div class="responsive-bootstrap-toolkit"></div>').appendTo('body');
232    });
233
234    if( self.framework === null ) {
235        self.use('bootstrap');
236    }
237
238    return self;
239
240})(jQuery);
241
242if (typeof module !== 'undefined' && module.exports) {
243    module.exports = ResponsiveBootstrapToolkit;
244}

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.