foundation-rails 5.0.3.1 → 5.1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/README.md +6 -2
  4. data/bower.json +7 -0
  5. data/lib/foundation/rails/version.rb +1 -1
  6. data/update-gem.sh +13 -0
  7. data/vendor/assets/javascripts/foundation.js +2 -1
  8. data/vendor/assets/javascripts/foundation/foundation.abide.js +67 -33
  9. data/vendor/assets/javascripts/foundation/foundation.accordion.js +19 -11
  10. data/vendor/assets/javascripts/foundation/foundation.alert.js +8 -5
  11. data/vendor/assets/javascripts/foundation/foundation.clearing.js +74 -52
  12. data/vendor/assets/javascripts/foundation/foundation.dropdown.js +52 -46
  13. data/vendor/assets/javascripts/foundation/foundation.equalizer.js +63 -0
  14. data/vendor/assets/javascripts/foundation/foundation.interchange.js +47 -26
  15. data/vendor/assets/javascripts/foundation/foundation.joyride.js +42 -36
  16. data/vendor/assets/javascripts/foundation/foundation.js +286 -118
  17. data/vendor/assets/javascripts/foundation/foundation.magellan.js +139 -98
  18. data/vendor/assets/javascripts/foundation/foundation.offcanvas.js +8 -6
  19. data/vendor/assets/javascripts/foundation/foundation.orbit.js +29 -21
  20. data/vendor/assets/javascripts/foundation/foundation.reveal.js +58 -50
  21. data/vendor/assets/javascripts/foundation/foundation.tab.js +22 -10
  22. data/vendor/assets/javascripts/foundation/foundation.tooltip.js +38 -26
  23. data/vendor/assets/javascripts/foundation/foundation.topbar.js +79 -73
  24. data/vendor/assets/stylesheets/foundation/_functions.scss +37 -18
  25. data/vendor/assets/stylesheets/foundation/_settings.scss +115 -110
  26. data/vendor/assets/stylesheets/foundation/components/_block-grid.scss +14 -9
  27. data/vendor/assets/stylesheets/foundation/components/_breadcrumbs.scss +2 -2
  28. data/vendor/assets/stylesheets/foundation/components/_button-groups.scss +1 -1
  29. data/vendor/assets/stylesheets/foundation/components/_clearing.scss +13 -1
  30. data/vendor/assets/stylesheets/foundation/components/_dropdown-buttons.scss +1 -1
  31. data/vendor/assets/stylesheets/foundation/components/_flex-video.scss +1 -1
  32. data/vendor/assets/stylesheets/foundation/components/_forms.scss +23 -29
  33. data/vendor/assets/stylesheets/foundation/components/_global.scss +23 -54
  34. data/vendor/assets/stylesheets/foundation/components/_grid.scss +38 -31
  35. data/vendor/assets/stylesheets/foundation/components/_inline-lists.scss +2 -2
  36. data/vendor/assets/stylesheets/foundation/components/_joyride.scss +2 -2
  37. data/vendor/assets/stylesheets/foundation/components/_magellan.scss +2 -2
  38. data/vendor/assets/stylesheets/foundation/components/_offcanvas.scss +96 -96
  39. data/vendor/assets/stylesheets/foundation/components/_orbit.scss +3 -0
  40. data/vendor/assets/stylesheets/foundation/components/_progress-bars.scss +2 -2
  41. data/vendor/assets/stylesheets/foundation/components/_reveal.scss +8 -3
  42. data/vendor/assets/stylesheets/foundation/components/_side-nav.scss +10 -5
  43. data/vendor/assets/stylesheets/foundation/components/_sub-nav.scss +6 -3
  44. data/vendor/assets/stylesheets/foundation/components/_tabs.scss +2 -0
  45. data/vendor/assets/stylesheets/foundation/components/_tooltips.scss +11 -1
  46. data/vendor/assets/stylesheets/foundation/components/_top-bar.scss +20 -7
  47. data/vendor/assets/stylesheets/foundation/components/_type.scss +82 -4
  48. data/vendor/assets/stylesheets/foundation/components/_visibility.scss +2 -2
  49. metadata +5 -2
@@ -6,29 +6,29 @@
6
6
  Foundation.libs.joyride = {
7
7
  name : 'joyride',
8
8
 
9
- version : '5.0.3',
9
+ version : '5.1.0',
10
10
 
11
11
  defaults : {
12
- expose : false, // turn on or off the expose feature
13
- modal : true, // Whether to cover page with modal during the tour
14
- tip_location : 'bottom', // 'top' or 'bottom' in relation to parent
15
- nub_position : 'auto', // override on a per tooltip bases
16
- scroll_speed : 1500, // Page scrolling speed in milliseconds, 0 = no scroll animation
17
- scroll_animation : 'linear', // supports 'swing' and 'linear', extend with jQuery UI.
18
- timer : 0, // 0 = no timer , all other numbers = timer in milliseconds
19
- start_timer_on_click : true, // true or false - true requires clicking the first button start the timer
20
- start_offset : 0, // the index of the tooltip you want to start on (index of the li)
21
- next_button : true, // true or false to control whether a next button is used
22
- tip_animation : 'fade', // 'pop' or 'fade' in each tip
23
- pause_after : [], // array of indexes where to pause the tour after
24
- exposed : [], // array of expose elements
25
- tip_animation_fade_speed: 300, // when tipAnimation = 'fade' this is speed in milliseconds for the transition
26
- cookie_monster : false, // true or false to control whether cookies are used
27
- cookie_name : 'joyride', // Name the cookie you'll use
28
- cookie_domain : false, // Will this cookie be attached to a domain, ie. '.notableapp.com'
29
- cookie_expires : 365, // set when you would like the cookie to expire.
30
- tip_container : 'body', // Where will the tip be attached
31
- tip_location_patterns : {
12
+ expose : false, // turn on or off the expose feature
13
+ modal : true, // Whether to cover page with modal during the tour
14
+ tip_location : 'bottom', // 'top' or 'bottom' in relation to parent
15
+ nub_position : 'auto', // override on a per tooltip bases
16
+ scroll_speed : 1500, // Page scrolling speed in milliseconds, 0 = no scroll animation
17
+ scroll_animation : 'linear', // supports 'swing' and 'linear', extend with jQuery UI.
18
+ timer : 0, // 0 = no timer , all other numbers = timer in milliseconds
19
+ start_timer_on_click : true, // true or false - true requires clicking the first button start the timer
20
+ start_offset : 0, // the index of the tooltip you want to start on (index of the li)
21
+ next_button : true, // true or false to control whether a next button is used
22
+ tip_animation : 'fade', // 'pop' or 'fade' in each tip
23
+ pause_after : [], // array of indexes where to pause the tour after
24
+ exposed : [], // array of expose elements
25
+ tip_animation_fade_speed : 300, // when tipAnimation = 'fade' this is speed in milliseconds for the transition
26
+ cookie_monster : false, // true or false to control whether cookies are used
27
+ cookie_name : 'joyride', // Name the cookie you'll use
28
+ cookie_domain : false, // Will this cookie be attached to a domain, ie. '.notableapp.com'
29
+ cookie_expires : 365, // set when you would like the cookie to expire.
30
+ tip_container : 'body', // Where will the tip be attached
31
+ tip_location_patterns : {
32
32
  top: ['bottom'],
33
33
  bottom: [], // bottom should not need to be repositioned
34
34
  left: ['right', 'top', 'bottom'],
@@ -53,7 +53,7 @@
53
53
  },
54
54
 
55
55
  init : function (scope, method, options) {
56
- Foundation.inherit(this, 'throttle delay');
56
+ Foundation.inherit(this, 'throttle random_str');
57
57
 
58
58
  this.settings = this.defaults;
59
59
 
@@ -90,7 +90,7 @@
90
90
  $(window)
91
91
  .off('.joyride')
92
92
  .on('resize.fndtn.joyride', self.throttle(function () {
93
- if ($('[data-joyride]').length > 0 && self.settings.$next_tip) {
93
+ if ($('[' + self.attr_name() + ']').length > 0 && self.settings.$next_tip) {
94
94
  if (self.settings.exposed.length > 0) {
95
95
  var $els = $(self.settings.exposed);
96
96
 
@@ -112,7 +112,7 @@
112
112
 
113
113
  start : function () {
114
114
  var self = this,
115
- $this = $('[data-joyride]', this.scope),
115
+ $this = $('[' + this.attr_name() + ']', this.scope),
116
116
  integer_settings = ['timer', 'scrollSpeed', 'startOffset', 'tipAnimationFadeSpeed', 'cookieExpires'],
117
117
  int_settings_count = integer_settings.length;
118
118
 
@@ -120,7 +120,7 @@
120
120
 
121
121
  if (!this.settings.init) this.events();
122
122
 
123
- this.settings = $this.data('joyride-init');
123
+ this.settings = $this.data(this.attr_name(true) + '-init');
124
124
 
125
125
  // non configureable settings
126
126
  this.settings.$content_el = $this;
@@ -142,7 +142,8 @@
142
142
  this.settings = $.extend({}, self.defaults, self.data_options($this))
143
143
 
144
144
  // Make sure that settings parsed from data_options are integers where necessary
145
- for (var i = int_settings_count - 1; i >= 0; i--) {
145
+ var i = int_settings_count;
146
+ while (i--) {
146
147
  self.settings[integer_settings[i]] = parseInt(self.settings[integer_settings[i]], 10);
147
148
  }
148
149
  self.create({$li : $this, index : index});
@@ -176,7 +177,7 @@
176
177
  this.timer_instance(opts.index);
177
178
 
178
179
  $blank.append($(this.settings.template.wrapper));
179
- $blank.first().attr('data-index', opts.index);
180
+ $blank.first().attr(this.add_namespace('data-index'), opts.index);
180
181
  $('.joyride-content-wrapper', $blank).append(content);
181
182
 
182
183
  return $blank[0];
@@ -204,7 +205,9 @@
204
205
  },
205
206
 
206
207
  create : function (opts) {
207
- var buttonText = opts.$li.attr('data-button') || opts.$li.attr('data-text'),
208
+ console.log(opts.$li)
209
+ var buttonText = opts.$li.attr(this.add_namespace('data-button'))
210
+ || opts.$li.attr(this.add_namespace('data-text')),
208
211
  tipClass = opts.$li.attr('class'),
209
212
  $tip_content = $(this.tip_template({
210
213
  tip_class : tipClass,
@@ -273,7 +276,7 @@
273
276
 
274
277
  this.settings.$next_tip.show();
275
278
 
276
- this.delay(function () {
279
+ setTimeout(function () {
277
280
  $timer.animate({
278
281
  width: $timer.parent().width()
279
282
  }, this.settings.timer, 'linear');
@@ -295,7 +298,7 @@
295
298
  .fadeIn(this.settings.tip_animation_fade_speed)
296
299
  .show();
297
300
 
298
- this.delay(function () {
301
+ setTimeout(function () {
299
302
  $timer.animate({
300
303
  width: $timer.parent().width()
301
304
  }, this.settings.timer, 'linear');
@@ -369,8 +372,9 @@
369
372
  },
370
373
 
371
374
  set_target : function () {
372
- var cl = this.settings.$li.attr('data-class'),
373
- id = this.settings.$li.attr('data-id'),
375
+ console.log(this.add_namespace('data-class'))
376
+ var cl = this.settings.$li.attr(this.add_namespace('data-class')),
377
+ id = this.settings.$li.attr(this.add_namespace('data-id')),
374
378
  $sel = function () {
375
379
  if (id) {
376
380
  return $(document.getElementById(id));
@@ -381,6 +385,8 @@
381
385
  }
382
386
  };
383
387
 
388
+ console.log(cl, id)
389
+
384
390
  this.settings.$target = $sel();
385
391
  },
386
392
 
@@ -568,7 +574,7 @@
568
574
  el,
569
575
  origCSS,
570
576
  origClasses,
571
- randId = 'expose-'+Math.floor(Math.random()*10000);
577
+ randId = 'expose-' + this.random_str(6);
572
578
 
573
579
  if (arguments.length > 0 && arguments[0] instanceof $) {
574
580
  el = arguments[0];
@@ -701,7 +707,7 @@
701
707
  },
702
708
 
703
709
  remove_exposed: function(el){
704
- var search, count;
710
+ var search, i;
705
711
  if (el instanceof $) {
706
712
  search = el[0]
707
713
  } else if (typeof el == 'string'){
@@ -709,9 +715,9 @@
709
715
  }
710
716
 
711
717
  this.settings.exposed = this.settings.exposed || [];
712
- count = this.settings.exposed.length;
718
+ i = this.settings.exposed.length;
713
719
 
714
- for (var i=0; i < count; i++) {
720
+ while (i--) {
715
721
  if (this.settings.exposed[i] == search) {
716
722
  this.settings.exposed.splice(i, 1);
717
723
  return;
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * Foundation Responsive Library
3
3
  * http://foundation.zurb.com
4
- * Copyright 2013, ZURB
4
+ * Copyright 2014, ZURB
5
5
  * Free to use under the MIT license.
6
6
  * http://www.opensource.org/licenses/mit-license.php
7
7
  */
@@ -9,26 +9,23 @@
9
9
  (function ($, window, document, undefined) {
10
10
  'use strict';
11
11
 
12
- // Used to retrieve Foundation media queries from CSS.
13
- if($('head').has('.foundation-mq-small').length === 0) {
14
- $('head').append('<meta class="foundation-mq-small">');
15
- }
16
-
17
- if($('head').has('.foundation-mq-medium').length === 0) {
18
- $('head').append('<meta class="foundation-mq-medium">');
19
- }
12
+ var header_helpers = function (class_array) {
13
+ var i = class_array.length;
20
14
 
21
- if($('head').has('.foundation-mq-large').length === 0) {
22
- $('head').append('<meta class="foundation-mq-large">');
23
- }
24
-
25
- if($('head').has('.foundation-mq-xlarge').length === 0) {
26
- $('head').append('<meta class="foundation-mq-xlarge">');
27
- }
15
+ while (i--) {
16
+ if($('head').has('.' + class_array[i]).length === 0) {
17
+ $('head').append('<meta class="' + class_array[i] + '">');
18
+ }
19
+ }
20
+ };
28
21
 
29
- if($('head').has('.foundation-mq-xxlarge').length === 0) {
30
- $('head').append('<meta class="foundation-mq-xxlarge">');
31
- }
22
+ header_helpers([
23
+ 'foundation-mq-small',
24
+ 'foundation-mq-medium',
25
+ 'foundation-mq-large',
26
+ 'foundation-mq-xlarge',
27
+ 'foundation-mq-xxlarge',
28
+ 'foundation-data-attribute-namespace']);
32
29
 
33
30
  // Enable FastClick if present
34
31
 
@@ -46,8 +43,14 @@
46
43
  // getElementById is not available.
47
44
  var S = function (selector, context) {
48
45
  if (typeof selector === 'string') {
49
- if (context) {
50
- return $(context.querySelectorAll(selector));
46
+ if (context) {
47
+ var cont;
48
+ if (context.jquery) {
49
+ cont = context[0];
50
+ } else {
51
+ cont = context;
52
+ }
53
+ return $(cont.querySelectorAll(selector));
51
54
  }
52
55
 
53
56
  return $(document.querySelectorAll(selector));
@@ -56,6 +59,106 @@
56
59
  return $(selector, context);
57
60
  };
58
61
 
62
+ // Namespace functions.
63
+
64
+ var attr_name = function (init) {
65
+ var arr = [];
66
+ if (!init) arr.push('data');
67
+ if (this.namespace.length > 0) arr.push(this.namespace);
68
+ arr.push(this.name);
69
+
70
+ return arr.join('-');
71
+ };
72
+
73
+ var header_helpers = function (class_array) {
74
+ var i = class_array.length;
75
+
76
+ while (i--) {
77
+ if($('head').has('.' + class_array[i]).length === 0) {
78
+ $('head').append('<meta class="' + class_array[i] + '">');
79
+ }
80
+ }
81
+ };
82
+
83
+ var add_namespace = function (str) {
84
+ var parts = str.split('-'),
85
+ i = parts.length,
86
+ arr = [];
87
+
88
+ while(i--) {
89
+ if (i !== 0) {
90
+ arr.push(parts[i]);
91
+ } else {
92
+ if (this.namespace.length > 0) {
93
+ arr.push(this.namespace, parts[i]);
94
+ } else {
95
+ arr.push(parts[i]);
96
+ }
97
+ }
98
+ }
99
+
100
+ return arr.reverse().join('-');
101
+ };
102
+
103
+ // Event binding and data-options updating.
104
+
105
+ var bindings = function (method, options) {
106
+ var self = this,
107
+ should_bind_events = !S(this).data(this.attr_name(true));
108
+
109
+ if (typeof method === 'string') {
110
+ return this[method].call(this, options);
111
+ }
112
+
113
+ if (S(this.scope).is('[' + this.attr_name() +']')) {
114
+ S(this.scope).data(this.attr_name(true) + '-init', $.extend({}, this.settings, (options || method), this.data_options(S(this.scope))));
115
+
116
+ if (should_bind_events) {
117
+ this.events(this.scope);
118
+ }
119
+
120
+ } else {
121
+ S('[' + this.attr_name() +']', this.scope).each(function () {
122
+ var should_bind_events = !S(this).data(self.attr_name(true) + '-init');
123
+
124
+ S(this).data(self.attr_name(true) + '-init', $.extend({}, self.settings, (options || method), self.data_options(S(this))));
125
+
126
+ if (should_bind_events) {
127
+ self.events(this);
128
+ }
129
+ });
130
+ }
131
+ };
132
+
133
+ var single_image_loaded = function (image, callback) {
134
+ function loaded () {
135
+ callback(image[0]);
136
+ }
137
+
138
+ function bindLoad () {
139
+ this.one('load', loaded);
140
+
141
+ if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
142
+ var src = this.attr( 'src' ),
143
+ param = src.match( /\?/ ) ? '&' : '?';
144
+
145
+ param += 'random=' + (new Date()).getTime();
146
+ this.attr('src', src + param);
147
+ }
148
+ }
149
+
150
+ if (!image.attr('src')) {
151
+ loaded();
152
+ return;
153
+ }
154
+
155
+ if (image[0].complete || image[0].readyState === 4) {
156
+ loaded();
157
+ } else {
158
+ bindLoad.call(image);
159
+ }
160
+ }
161
+
59
162
  /*
60
163
  https://github.com/paulirish/matchMedia.js
61
164
  */
@@ -167,7 +270,7 @@
167
270
 
168
271
  function removeQuotes (string) {
169
272
  if (typeof string === 'string' || string instanceof String) {
170
- string = string.replace(/^[\\/'"]+|(;\s?})+|[\\/'"]+$/g, '');
273
+ string = string.replace(/^['\\/"]+|(;\s?})+|['\\/"]+$/g, '');
171
274
  }
172
275
 
173
276
  return string;
@@ -176,7 +279,7 @@
176
279
  window.Foundation = {
177
280
  name : 'Foundation',
178
281
 
179
- version : '5.0.3',
282
+ version : '5.1.0',
180
283
 
181
284
  media_queries : {
182
285
  small : S('.foundation-mq-small').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''),
@@ -188,6 +291,10 @@
188
291
 
189
292
  stylesheet : $('<style></style>').appendTo('head')[0].sheet,
190
293
 
294
+ global: {
295
+ namespace: ''
296
+ },
297
+
191
298
  init : function (scope, libraries, method, options, response) {
192
299
  var library_arr,
193
300
  args = [scope, method, options, response],
@@ -199,6 +306,8 @@
199
306
  // set foundation global scope
200
307
  this.scope = scope || this.scope;
201
308
 
309
+ this.set_namespace();
310
+
202
311
  if (libraries && typeof libraries === 'string' && !/reflow/i.test(libraries)) {
203
312
  if (this.libs.hasOwnProperty(libraries)) {
204
313
  responses.push(this.init_lib(libraries, args));
@@ -229,41 +338,66 @@
229
338
 
230
339
  patch : function (lib) {
231
340
  lib.scope = this.scope;
232
- lib['data_options'] = this.lib_methods.data_options;
233
- lib['bindings'] = this.lib_methods.bindings;
234
- lib['S'] = S;
341
+ lib.namespace = this.global.namespace;
235
342
  lib.rtl = this.rtl;
343
+ lib['data_options'] = this.utils.data_options;
344
+ lib['attr_name'] = attr_name;
345
+ lib['add_namespace'] = add_namespace;
346
+ lib['bindings'] = bindings;
347
+ lib['S'] = this.utils.S;
236
348
  },
237
349
 
238
350
  inherit : function (scope, methods) {
239
- var methods_arr = methods.split(' ');
351
+ var methods_arr = methods.split(' '),
352
+ i = methods_arr.length;
240
353
 
241
- for (var i = methods_arr.length - 1; i >= 0; i--) {
242
- if (this.lib_methods.hasOwnProperty(methods_arr[i])) {
243
- this.libs[scope.name][methods_arr[i]] = this.lib_methods[methods_arr[i]];
354
+ while (i--) {
355
+ if (this.utils.hasOwnProperty(methods_arr[i])) {
356
+ scope[methods_arr[i]] = this.utils[methods_arr[i]];
244
357
  }
245
358
  }
246
359
  },
247
360
 
248
- random_str : function (length) {
249
- var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
361
+ set_namespace: function () {
362
+ var namespace = $('.foundation-data-attribute-namespace').css('font-family');
250
363
 
251
- if (!length) {
252
- length = Math.floor(Math.random() * chars.length);
253
- }
364
+ if (/false/i.test(namespace)) return;
254
365
 
255
- var str = '';
256
- for (var i = 0; i < length; i++) {
257
- str += chars[Math.floor(Math.random() * chars.length)];
258
- }
259
- return str;
366
+ this.global.namespace = namespace;
260
367
  },
261
368
 
262
369
  libs : {},
263
370
 
264
371
  // methods that can be inherited in libraries
265
- lib_methods : {
266
- throttle : function(fun, delay) {
372
+ utils : {
373
+
374
+ // Description:
375
+ // Fast Selector wrapper returns jQuery object. Only use where getElementById
376
+ // is not available.
377
+ //
378
+ // Arguments:
379
+ // Selector (String): CSS selector describing the element(s) to be
380
+ // returned as a jQuery object.
381
+ //
382
+ // Scope (String): CSS selector describing the area to be searched. Default
383
+ // is document.
384
+ //
385
+ // Returns:
386
+ // Element (jQuery Object): jQuery object containing elements matching the
387
+ // selector within the scope.
388
+ S : S,
389
+
390
+ // Description:
391
+ // Executes a function a max of once every n milliseconds
392
+ //
393
+ // Arguments:
394
+ // Func (Function): Function to be throttled.
395
+ //
396
+ // Delay (Integer): Function execution threshold in milliseconds.
397
+ //
398
+ // Returns:
399
+ // Lazy_function (Function): Function with throttling applied.
400
+ throttle : function(func, delay) {
267
401
  var timer = null;
268
402
 
269
403
  return function () {
@@ -271,22 +405,70 @@
271
405
 
272
406
  clearTimeout(timer);
273
407
  timer = setTimeout(function () {
274
- fun.apply(context, args);
408
+ func.apply(context, args);
275
409
  }, delay);
276
410
  };
277
411
  },
278
412
 
279
- // parses data-options attribute
413
+ // Description:
414
+ // Executes a function when it stops being invoked for n seconds
415
+ // Modified version of _.debounce() http://underscorejs.org
416
+ //
417
+ // Arguments:
418
+ // Func (Function): Function to be debounced.
419
+ //
420
+ // Delay (Integer): Function execution threshold in milliseconds.
421
+ //
422
+ // Immediate (Bool): Whether the function should be called at the beginning
423
+ // of the delay instead of the end. Default is false.
424
+ //
425
+ // Returns:
426
+ // Lazy_function (Function): Function with debouncing applied.
427
+ debounce : function(func, delay, immediate) {
428
+ var timeout, result;
429
+ return function() {
430
+ var context = this, args = arguments;
431
+ var later = function() {
432
+ timeout = null;
433
+ if (!immediate) result = func.apply(context, args);
434
+ };
435
+ var callNow = immediate && !timeout;
436
+ clearTimeout(timeout);
437
+ timeout = setTimeout(later, delay);
438
+ if (callNow) result = func.apply(context, args);
439
+ return result;
440
+ };
441
+ },
442
+
443
+ // Description:
444
+ // Parses data-options attribute
445
+ //
446
+ // Arguments:
447
+ // El (jQuery Object): Element to be parsed.
448
+ //
449
+ // Returns:
450
+ // Options (Javascript Object): Contents of the element's data-options
451
+ // attribute.
280
452
  data_options : function (el) {
281
- var opts = {}, ii, p, opts_arr, opts_len,
282
- data_options = el.data('options');
453
+ var opts = {}, ii, p, opts_arr,
454
+ data_options = function (el) {
455
+ var namespace = Foundation.global.namespace;
456
+
457
+ if (namespace.length > 0) {
458
+ return el.data(namespace + '-options');
459
+ }
460
+
461
+ return el.data('options');
462
+ };
463
+
464
+ var cached_options = data_options(el);
283
465
 
284
- if (typeof data_options === 'object') {
285
- return data_options;
466
+ if (typeof cached_options === 'object') {
467
+ return cached_options;
286
468
  }
287
469
 
288
- opts_arr = (data_options || ':').split(';'),
289
- opts_len = opts_arr.length;
470
+ opts_arr = (cached_options || ':').split(';'),
471
+ ii = opts_arr.length;
290
472
 
291
473
  function isNumber (o) {
292
474
  return ! isNaN (o-0) && o !== null && o !== "" && o !== false && o !== true;
@@ -297,8 +479,7 @@
297
479
  return str;
298
480
  }
299
481
 
300
- // parse options
301
- for (ii = opts_len - 1; ii >= 0; ii--) {
482
+ while (ii--) {
302
483
  p = opts_arr[ii].split(':');
303
484
 
304
485
  if (/true/i.test(p[1])) p[1] = true;
@@ -313,22 +494,14 @@
313
494
  return opts;
314
495
  },
315
496
 
316
- delay : function (fun, delay) {
317
- return setTimeout(fun, delay);
318
- },
319
-
320
- // test for empty object or array
321
- empty : function (obj) {
322
- if (obj.length && obj.length > 0) return false;
323
- if (obj.length && obj.length === 0) return true;
324
-
325
- for (var key in obj) {
326
- if (hasOwnProperty.call(obj, key)) return false;
327
- }
328
-
329
- return true;
330
- },
331
-
497
+ // Description:
498
+ // Adds JS-recognizable media queries
499
+ //
500
+ // Arguments:
501
+ // Media (String): Key string for the media query to be stored as in
502
+ // Foundation.media_queries
503
+ //
504
+ // Class (String): Class name for the generated <meta> tag
332
505
  register_media : function(media, media_class) {
333
506
  if(Foundation.media_queries[media] === undefined) {
334
507
  $('head').append('<meta class="' + media_class + '">');
@@ -336,7 +509,15 @@
336
509
  }
337
510
  },
338
511
 
339
- addCustomRule : function(rule, media) {
512
+ // Description:
513
+ // Add custom CSS within a JS-defined media query
514
+ //
515
+ // Arguments:
516
+ // Rule (String): CSS rule to be appended to the document.
517
+ //
518
+ // Media (String): Optional media query string for the CSS rule to be
519
+ // nested under.
520
+ add_custom_rule : function(rule, media) {
340
521
  if(media === undefined) {
341
522
  Foundation.stylesheet.insertRule(rule, Foundation.stylesheet.cssRules.length);
342
523
  } else {
@@ -348,61 +529,48 @@
348
529
  }
349
530
  },
350
531
 
351
- loaded : function (image, callback) {
352
- function loaded () {
353
- callback(image[0]);
354
- }
355
-
356
- function bindLoad () {
357
- this.one('load', loaded);
358
-
359
- if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
360
- var src = this.attr( 'src' ),
361
- param = src.match( /\?/ ) ? '&' : '?';
362
-
363
- param += 'random=' + (new Date()).getTime();
364
- this.attr('src', src + param);
365
- }
366
- }
367
-
368
- if (!image.attr('src')) {
369
- loaded();
370
- return;
371
- }
532
+ // Description:
533
+ // Performs a callback function when an image is fully loaded
534
+ //
535
+ // Arguments:
536
+ // Image (jQuery Object): Image(s) to check if loaded.
537
+ //
538
+ // Callback (Function): Fundation to execute when image is fully loaded.
539
+ image_loaded : function (images, callback) {
540
+ var self = this,
541
+ unloaded = images.length;
372
542
 
373
- if (image[0].complete || image[0].readyState === 4) {
374
- loaded();
375
- } else {
376
- bindLoad.call(image);
377
- }
543
+ images.each(function(){
544
+ single_image_loaded(self.S(this),function(){
545
+ unloaded -= 1;
546
+ if(unloaded == 0){
547
+ callback(images);
548
+ }
549
+ });
550
+ });
378
551
  },
379
552
 
380
- bindings : function (method, options) {
381
- var self = this,
382
- should_bind_events = !S(this).data(this.name + '-init');
383
-
384
- if (typeof method === 'string') {
385
- return this[method].call(this, options);
553
+ // Description:
554
+ // Returns a random, alphanumeric string
555
+ //
556
+ // Arguments:
557
+ // Length (Integer): Length of string to be generated. Defaults to random
558
+ // integer.
559
+ //
560
+ // Returns:
561
+ // Rand (String): Pseudo-random, alphanumeric string.
562
+ random_str : function (length) {
563
+ var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
564
+
565
+ if (!length) {
566
+ length = Math.floor(Math.random() * chars.length);
386
567
  }
387
568
 
388
- if (S(this.scope).is('[data-' + this.name +']')) {
389
- S(this.scope).data(this.name + '-init', $.extend({}, this.settings, (options || method), this.data_options(S(this.scope))));
390
-
391
- if (should_bind_events) {
392
- this.events(this.scope);
393
- }
394
-
395
- } else {
396
- S('[data-' + this.name + ']', this.scope).each(function () {
397
- var should_bind_events = !S(this).data(self.name + '-init');
398
-
399
- S(this).data(self.name + '-init', $.extend({}, self.settings, (options || method), self.data_options(S(this))));
400
-
401
- if (should_bind_events) {
402
- self.events(this);
403
- }
404
- });
569
+ var str = '';
570
+ while (length--) {
571
+ str += chars[Math.floor(Math.random() * chars.length)];
405
572
  }
573
+ return str;
406
574
  }
407
575
  }
408
576
  };