PageSourceSearch

https://hubscher.org/roland/javascripts/foundation/foundation.js

js hubscher.org collected 2026-10-02 10:30:07 UTC 10,751 bytes, 389 lines download raw bytes

1var _____WB$wombat$assign$function_____=function(name){return (self._wb_wombat && self._wb_wombat.local_init && self._wb_wombat.local_init(name))||self[name];};if(!self.__WB_pmw){self.__WB_pmw=function(obj){this.__WB_source=obj;return this;}}{
2let window = _____WB$wombat$assign$function_____("window");
3let self = _____WB$wombat$assign$function_____("self");
4let document = _____WB$wombat$assign$function_____("document");
5let location = _____WB$wombat$assign$function_____("location");
6let top = _____WB$wombat$assign$function_____("top");
7let parent = _____WB$wombat$assign$function_____("parent");
8let frames = _____WB$wombat$assign$function_____("frames");
9let opens = _____WB$wombat$assign$function_____("opens");
10/*
11 * Foundation Responsive Library
12 * http://foundation.zurb.com
13 * Copyright 2013, ZURB
14 * Free to use under the MIT license.
15 * http://www.opensource.org/licenses/mit-license.php
16*/
17
18/*jslint unparam: true, browser: true, indent: 2 */
19
20// Accommodate running jQuery or Zepto in noConflict() mode by
21// using an anonymous function to redefine the $ shorthand name.
22// See http://docs.jquery.com/Using_jQuery_with_Other_Libraries
23// and http://zeptojs.com/
24var libFuncName = null;
25if (typeof jQuery === "undefined" &&
26    typeof Zepto === "undefined" &&
27    typeof $ === "function") {
28    libFuncName = $;
29} else if (typeof jQuery === "function") {
30    libFuncName = jQuery;
31} else if (typeof Zepto === "function") {
32    libFuncName = Zepto;
33} else {
34    throw new TypeError();
35}
36
37(function ($) {
38
39(function () {
40  // add dusty browser stuff
41  if (!Array.prototype.filter) {
42    Array.prototype.filter = function(fun /*, thisp */) {
43      "use strict";
44   
45      if (this == null) {
46        throw new TypeError();
47      }
48   
49      var t = Object(this),
50          len = t.length >>> 0;
51      if (typeof fun != "function") {
52        try {
53          throw new TypeError();
54        } catch (e) {
55          return;
56        }
57      }
58   
59      var res = [],
60          thisp = arguments[1];
61      for (var i = 0; i < len; i++) {
62        if (i in t) {
63          var val = t[i]; // in case fun mutates this
64          if (fun && fun.call(thisp, val, i, t)) {
65            res.push(val);
66          }
67        }
68      }
69   
70      return res;
71    };
72
73    if (!Function.prototype.bind) {
74      Function.prototype.bind = function (oThis) {
75        if (typeof this !== "function") {
76          // closest thing possible to the ECMAScript 5 internal IsCallable function
77          throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
78        }
79     
80        var aArgs = Array.prototype.slice.call(arguments, 1), 
81            fToBind = this, 
82            fNOP = function () {},
83            fBound = function () {
84              return fToBind.apply(this instanceof fNOP && oThis
85                 ? this
86                 : oThis,
87               aArgs.concat(Array.prototype.slice.call(arguments)));
88            };
89     
90        fNOP.prototype = this.prototype;
91        fBound.prototype = new fNOP();
92     
93        return fBound;
94      };
95    }
96  }
97
98  // fake stop() for zepto.
99  $.fn.stop = $.fn.stop || function() {
100    return this;
101  };
102}());
103
104;(function (window, document, undefined) {
105  'use strict';
106
107  window.Foundation = {
108    name : 'Foundation',
109
110    version : '4.1.0',
111
112    // global Foundation cache object
113    cache : {},
114
115    init : function (scope, libraries, method, options, response, /* internal */ nc) {
116      var library_arr,
117          args = [scope, method, options, response],
118          responses = [],
119          nc = nc || false;
120          
121      // disable library error catching,
122      // used for development only
123      if (nc) this.nc = nc;
124
125
126      // check RTL
127      this.rtl = /rtl/i.test($('html').attr('dir'));
128
129      // set foundation global scope
130      this.scope = scope || this.scope;
131
132      if (libraries && typeof libraries === 'string') {
133        if (/off/i.test(libraries)) return this.off();
134
135        library_arr = libraries.split(' ');
136
137        if (library_arr.length > 0) {
138          for (var i = library_arr.length - 1; i >= 0; i--) {
139            responses.push(this.init_lib(library_arr[i], args));
140          }
141        }
142      } else {
143        for (var lib in this.libs) {
144          responses.push(this.init_lib(lib, args));
145        }
146      }
147
148      // if first argument is callback, add to args
149      if (typeof libraries === 'function') {
150        args.unshift(libraries);
151      }
152
153      return this.response_obj(responses, args);
154    },
155
156    response_obj : function (response_arr, args) {
157      for (var i = 0, len = args.length; i < len; i++) {
158        if (typeof args[i] === 'function') {
159          return args[i]({
160            errors: response_arr.filter(function (s) {
161              if (typeof s === 'string') return s;
162            })
163          });
164        }
165      }
166
167      return response_arr;
168    },
169
170    init_lib : function (lib, args) {
171      return this.trap(function () {
172        if (this.libs.hasOwnProperty(lib)) {
173          this.patch(this.libs[lib]);
174          return this.libs[lib].init.apply(this.libs[lib], args);
175        }
176      }.bind(this), lib);
177    },
178
179    trap : function (fun, lib) {
180      if (!this.nc) {
181        try {
182          return fun();
183        } catch (e) {
184          return this.error({name: lib, message: 'could not be initialized', more: e.name + ' ' + e.message});
185        }
186      }
187
188      return fun();
189    },
190
191    patch : function (lib) {
192      this.fix_outer(lib);
193      lib.scope = this.scope;
194      lib.rtl = this.rtl;
195    },
196
197    inherit : function (scope, methods) {
198      var methods_arr = methods.split(' ');
199
200      for (var i = methods_arr.length - 1; i >= 0; i--) {
201        if (this.lib_methods.hasOwnProperty(methods_arr[i])) {
202          this.libs[scope.name][methods_arr[i]] = this.lib_methods[methods_arr[i]];
203        }
204      }
205    },
206
207    random_str : function (length) {
208      var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz'.split('');
209      
210      if (!length) {
211          length = Math.floor(Math.random() * chars.length);
212      }
213      
214      var str = '';
215      for (var i = 0; i < length; i++) {
216          str += chars[Math.floor(Math.random() * chars.length)];
217      }
218      return str;
219    },
220
221    libs : {},
222
223    // methods that can be inherited in libraries
224    lib_methods : {
225      set_data : function (node, data) {
226        // this.name references the name of the library calling this method
227        var id = [this.name,+new Date(),Foundation.random_str(5)].join('-');
228
229        Foundation.cache[id] = data;
230        node.attr('data-' + this.name + '-id', id);
231        return data;
232      },
233
234      get_data : function (node) {
235        return Foundation.cache[node.attr('data-' + this.name + '-id')];
236      },
237
238      remove_data : function (node) {
239        if (node) {
240          delete Foundation.cache[node.attr('data-' + this.name + '-id')];
241          node.attr('data-' + this.name + '-id', '');
242        } else {
243          $('[data-' + this.name + '-id]').each(function () {
244            delete Foundation.cache[$(this).attr('data-' + this.name + '-id')];
245            $(this).attr('data-' + this.name + '-id', '');
246          });
247        }
248      },
249
250      throttle : function(fun, delay) {
251        var timer = null;
252        return function () {
253          var context = this, args = arguments;
254          clearTimeout(timer);
255          timer = setTimeout(function () {
256            fun.apply(context, args);
257          }, delay);
258        };
259      },
260
261      // parses data-options attribute on nodes and turns
262      // them into an object
263      data_options : function (el) {
264        var opts = {}, ii, p,
265            opts_arr = (el.attr('data-options') || ':').split(';'),
266            opts_len = opts_arr.length;
267
268        function isNumber (o) {
269          return ! isNaN (o-0) && o !== null && o !== "" && o !== false && o !== true;
270        }
271
272        function trim(str) {
273          if (typeof str === 'string') return $.trim(str);
274          return str;
275        }
276
277        // parse options
278        for (ii = opts_len - 1; ii >= 0; ii--) {
279          p = opts_arr[ii].split(':');
280
281          if (/true/i.test(p[1])) p[1] = true;
282          if (/false/i.test(p[1])) p[1] = false;
283          if (isNumber(p[1])) p[1] = parseInt(p[1], 10);
284
285          if (p.length === 2 && p[0].length > 0) {
286            opts[trim(p[0])] = trim(p[1]);
287          }
288        }
289
290        return opts;
291      },
292
293      delay : function (fun, delay) {
294        return setTimeout(fun, delay);
295      },
296
297      // animated scrolling
298      scrollTo : function (el, to, duration) {
299        if (duration < 0) return;
300        var difference = to - $(window).scrollTop();
301        var perTick = difference / duration * 10;
302
303        this.scrollToTimerCache = setTimeout(function() {
304          if (!isNaN(parseInt(perTick, 10))) {
305            window.scrollTo(0, $(window).scrollTop() + perTick);
306            this.scrollTo(el, to, duration - 10);
307          }
308        }.bind(this), 10);
309      },
310
311      // not supported in core Zepto
312      scrollLeft : function (el) {
313        if (!el.length) return;
314        return ('scrollLeft' in el[0]) ? el[0].scrollLeft : el[0].pageXOffset;
315      },
316
317      // test for empty object or array
318      empty : function (obj) {
319        if (obj.length && obj.length > 0)    return false;
320        if (obj.length && obj.length === 0)  return true;
321
322        for (var key in obj) {
323          if (hasOwnProperty.call(obj, key))    return false;
324        }
325
326        return true;
327      }
328    },
329
330    fix_outer : function (lib) {
331      lib.outerHeight = function (el, bool) {
332        if (typeof Zepto === 'function') {
333          return el.height();
334        }
335
336        if (typeof bool !== 'undefined') {
337          return el.outerHeight(bool);
338        }
339
340        return el.outerHeight();
341      };
342
343      lib.outerWidth = function (el) {
344        if (typeof Zepto === 'function') {
345          return el.width();
346        }
347
348        if (typeof bool !== 'undefined') {
349          return el.outerWidth(bool);
350        }
351
352        return el.outerWidth();
353      };
354    },
355
356    error : function (error) {
357      return error.name + ' ' + error.message + '; ' + error.more;
358    },
359
360    // remove all foundation events.
361    off: function () {
362      $(this.scope).off('.fndtn');
363      $(window).off('.fndtn');
364      return true;
365    },
366
367    zj : function () {
368      try {
369        return Zepto;
370      } catch (e) {
371        return jQuery;
372      }
373    }()
374  },
375
376  $.fn.foundation = function () {
377    var args = Array.prototype.slice.call(arguments, 0);
378
379    return this.each(function () {
380      Foundation.init.apply(Foundation, [this].concat(args));
381      return this;
382    });
383  };
384
385}(this, this.document));
386
387})(libFuncName);
388
389}

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.