foundation-rails 5.0.1.0

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 (136) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +29 -0
  6. data/Rakefile +1 -0
  7. data/app/controllers/foundation/rails/styleguide_controller.rb +10 -0
  8. data/app/views/foundation/rails/styleguide/show.html.erb +134 -0
  9. data/config/routes.rb +3 -0
  10. data/foundation-rails.gemspec +25 -0
  11. data/lib/foundation-rails.rb +1 -0
  12. data/lib/foundation/rails.rb +3 -0
  13. data/lib/foundation/rails/engine.rb +7 -0
  14. data/lib/foundation/rails/generators/install_generator.rb +56 -0
  15. data/lib/foundation/rails/templates/application.html.erb +19 -0
  16. data/lib/foundation/rails/templates/application.html.haml +18 -0
  17. data/lib/foundation/rails/templates/application.html.slim +17 -0
  18. data/lib/foundation/rails/version.rb +5 -0
  19. data/test/dummy/.gitignore +16 -0
  20. data/test/dummy/Gemfile +47 -0
  21. data/test/dummy/README.rdoc +28 -0
  22. data/test/dummy/Rakefile +6 -0
  23. data/test/dummy/app/assets/images/.keep +0 -0
  24. data/test/dummy/app/assets/javascripts/application.js +8 -0
  25. data/test/dummy/app/assets/stylesheets/application.css +4 -0
  26. data/test/dummy/app/assets/stylesheets/foundation_and_overrides.scss +4 -0
  27. data/test/dummy/app/controllers/application_controller.rb +5 -0
  28. data/test/dummy/app/controllers/concerns/.keep +0 -0
  29. data/test/dummy/app/controllers/styleguide_controller.rb +4 -0
  30. data/test/dummy/app/helpers/application_helper.rb +2 -0
  31. data/test/dummy/app/helpers/styleguide_helper.rb +2 -0
  32. data/test/dummy/app/mailers/.keep +0 -0
  33. data/test/dummy/app/models/.keep +0 -0
  34. data/test/dummy/app/models/concerns/.keep +0 -0
  35. data/test/dummy/app/views/layouts/application.html.erb +19 -0
  36. data/test/dummy/app/views/styleguide/show.html.erb +109 -0
  37. data/test/dummy/bin/bundle +3 -0
  38. data/test/dummy/bin/rails +4 -0
  39. data/test/dummy/bin/rake +4 -0
  40. data/test/dummy/config.ru +4 -0
  41. data/test/dummy/config/application.rb +23 -0
  42. data/test/dummy/config/boot.rb +4 -0
  43. data/test/dummy/config/database.yml +25 -0
  44. data/test/dummy/config/environment.rb +5 -0
  45. data/test/dummy/config/environments/development.rb +29 -0
  46. data/test/dummy/config/environments/production.rb +80 -0
  47. data/test/dummy/config/environments/test.rb +36 -0
  48. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  49. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  50. data/test/dummy/config/initializers/inflections.rb +16 -0
  51. data/test/dummy/config/initializers/mime_types.rb +5 -0
  52. data/test/dummy/config/initializers/secret_token.rb +12 -0
  53. data/test/dummy/config/initializers/session_store.rb +3 -0
  54. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  55. data/test/dummy/config/locales/en.yml +23 -0
  56. data/test/dummy/config/routes.rb +3 -0
  57. data/test/dummy/db/seeds.rb +7 -0
  58. data/test/dummy/lib/assets/.keep +0 -0
  59. data/test/dummy/lib/tasks/.keep +0 -0
  60. data/test/dummy/log/.keep +0 -0
  61. data/test/dummy/public/404.html +58 -0
  62. data/test/dummy/public/422.html +58 -0
  63. data/test/dummy/public/500.html +57 -0
  64. data/test/dummy/public/favicon.ico +0 -0
  65. data/test/dummy/public/robots.txt +5 -0
  66. data/test/dummy/test/controllers/.keep +0 -0
  67. data/test/dummy/test/controllers/styleguide_controller_test.rb +9 -0
  68. data/test/dummy/test/fixtures/.keep +0 -0
  69. data/test/dummy/test/helpers/.keep +0 -0
  70. data/test/dummy/test/helpers/styleguide_helper_test.rb +4 -0
  71. data/test/dummy/test/integration/.keep +0 -0
  72. data/test/dummy/test/mailers/.keep +0 -0
  73. data/test/dummy/test/models/.keep +0 -0
  74. data/test/dummy/test/test_helper.rb +15 -0
  75. data/test/dummy/vendor/assets/javascripts/.keep +0 -0
  76. data/test/dummy/vendor/assets/stylesheets/.keep +0 -0
  77. data/vendor/_settings.scss +992 -0
  78. data/vendor/assets/javascripts/foundation.js +15 -0
  79. data/vendor/assets/javascripts/foundation/foundation.abide.js +201 -0
  80. data/vendor/assets/javascripts/foundation/foundation.accordion.js +41 -0
  81. data/vendor/assets/javascripts/foundation/foundation.alert.js +34 -0
  82. data/vendor/assets/javascripts/foundation/foundation.clearing.js +450 -0
  83. data/vendor/assets/javascripts/foundation/foundation.dropdown.js +184 -0
  84. data/vendor/assets/javascripts/foundation/foundation.interchange.js +304 -0
  85. data/vendor/assets/javascripts/foundation/foundation.joyride.js +839 -0
  86. data/vendor/assets/javascripts/foundation/foundation.js +416 -0
  87. data/vendor/assets/javascripts/foundation/foundation.magellan.js +118 -0
  88. data/vendor/assets/javascripts/foundation/foundation.offcanvas.js +37 -0
  89. data/vendor/assets/javascripts/foundation/foundation.orbit.js +434 -0
  90. data/vendor/assets/javascripts/foundation/foundation.reveal.js +347 -0
  91. data/vendor/assets/javascripts/foundation/foundation.tab.js +37 -0
  92. data/vendor/assets/javascripts/foundation/foundation.tooltip.js +202 -0
  93. data/vendor/assets/javascripts/foundation/foundation.topbar.js +380 -0
  94. data/vendor/assets/javascripts/vendor/modernizr.js +4 -0
  95. data/vendor/assets/stylesheets/foundation.scss +38 -0
  96. data/vendor/assets/stylesheets/foundation/_functions.scss +75 -0
  97. data/vendor/assets/stylesheets/foundation/_settings.scss +992 -0
  98. data/vendor/assets/stylesheets/foundation/components/_accordion.scss +49 -0
  99. data/vendor/assets/stylesheets/foundation/components/_alert-boxes.scss +113 -0
  100. data/vendor/assets/stylesheets/foundation/components/_block-grid.scss +83 -0
  101. data/vendor/assets/stylesheets/foundation/components/_breadcrumbs.scss +123 -0
  102. data/vendor/assets/stylesheets/foundation/components/_button-groups.scss +97 -0
  103. data/vendor/assets/stylesheets/foundation/components/_buttons.scss +234 -0
  104. data/vendor/assets/stylesheets/foundation/components/_clearing.scss +233 -0
  105. data/vendor/assets/stylesheets/foundation/components/_dropdown-buttons.scss +125 -0
  106. data/vendor/assets/stylesheets/foundation/components/_dropdown.scss +159 -0
  107. data/vendor/assets/stylesheets/foundation/components/_flex-video.scss +47 -0
  108. data/vendor/assets/stylesheets/foundation/components/_forms.scss +472 -0
  109. data/vendor/assets/stylesheets/foundation/components/_functions.scss +70 -0
  110. data/vendor/assets/stylesheets/foundation/components/_global.scss +387 -0
  111. data/vendor/assets/stylesheets/foundation/components/_grid.scss +234 -0
  112. data/vendor/assets/stylesheets/foundation/components/_inline-lists.scss +52 -0
  113. data/vendor/assets/stylesheets/foundation/components/_joyride.scss +220 -0
  114. data/vendor/assets/stylesheets/foundation/components/_keystrokes.scss +57 -0
  115. data/vendor/assets/stylesheets/foundation/components/_labels.scss +100 -0
  116. data/vendor/assets/stylesheets/foundation/components/_magellan.scss +30 -0
  117. data/vendor/assets/stylesheets/foundation/components/_offcanvas.scss +360 -0
  118. data/vendor/assets/stylesheets/foundation/components/_orbit.scss +353 -0
  119. data/vendor/assets/stylesheets/foundation/components/_pagination.scss +145 -0
  120. data/vendor/assets/stylesheets/foundation/components/_panels.scss +87 -0
  121. data/vendor/assets/stylesheets/foundation/components/_pricing-tables.scss +146 -0
  122. data/vendor/assets/stylesheets/foundation/components/_progress-bars.scss +75 -0
  123. data/vendor/assets/stylesheets/foundation/components/_reveal.scss +165 -0
  124. data/vendor/assets/stylesheets/foundation/components/_side-nav.scss +83 -0
  125. data/vendor/assets/stylesheets/foundation/components/_split-buttons.scss +187 -0
  126. data/vendor/assets/stylesheets/foundation/components/_sub-nav.scss +118 -0
  127. data/vendor/assets/stylesheets/foundation/components/_switch.scss +314 -0
  128. data/vendor/assets/stylesheets/foundation/components/_tables.scss +93 -0
  129. data/vendor/assets/stylesheets/foundation/components/_tabs.scss +95 -0
  130. data/vendor/assets/stylesheets/foundation/components/_thumbs.scss +71 -0
  131. data/vendor/assets/stylesheets/foundation/components/_tooltips.scss +121 -0
  132. data/vendor/assets/stylesheets/foundation/components/_top-bar.scss +590 -0
  133. data/vendor/assets/stylesheets/foundation/components/_type.scss +447 -0
  134. data/vendor/assets/stylesheets/foundation/components/_visibility.scss +661 -0
  135. data/vendor/assets/stylesheets/normalize.scss +410 -0
  136. metadata +292 -0
@@ -0,0 +1,347 @@
1
+ ;(function ($, window, document, undefined) {
2
+ 'use strict';
3
+
4
+ Foundation.libs.reveal = {
5
+ name : 'reveal',
6
+
7
+ version : '5.0.0',
8
+
9
+ locked : false,
10
+
11
+ settings : {
12
+ animation: 'fadeAndPop',
13
+ animation_speed: 250,
14
+ close_on_background_click: true,
15
+ close_on_esc: true,
16
+ dismiss_modal_class: 'close-reveal-modal',
17
+ bg_class: 'reveal-modal-bg',
18
+ open: function(){},
19
+ opened: function(){},
20
+ close: function(){},
21
+ closed: function(){},
22
+ bg : $('.reveal-modal-bg'),
23
+ css : {
24
+ open : {
25
+ 'opacity': 0,
26
+ 'visibility': 'visible',
27
+ 'display' : 'block'
28
+ },
29
+ close : {
30
+ 'opacity': 1,
31
+ 'visibility': 'hidden',
32
+ 'display': 'none'
33
+ }
34
+ }
35
+ },
36
+
37
+ init : function (scope, method, options) {
38
+ Foundation.inherit(this, 'delay');
39
+
40
+ this.bindings(method, options);
41
+ },
42
+
43
+ events : function (scope) {
44
+ var self = this;
45
+
46
+ $('[data-reveal-id]', this.scope)
47
+ .off('.reveal')
48
+ .on('click.fndtn.reveal', function (e) {
49
+ e.preventDefault();
50
+
51
+ if (!self.locked) {
52
+ var element = $(this),
53
+ ajax = element.data('reveal-ajax');
54
+
55
+ self.locked = true;
56
+
57
+ if (typeof ajax === 'undefined') {
58
+ self.open.call(self, element);
59
+ } else {
60
+ var url = ajax === true ? element.attr('href') : ajax;
61
+
62
+ self.open.call(self, element, {url: url});
63
+ }
64
+ }
65
+ });
66
+
67
+ $(this.scope)
68
+ .off('.reveal')
69
+ .on('click.fndtn.reveal', this.close_targets(), function (e) {
70
+
71
+ e.preventDefault();
72
+
73
+ if (!self.locked) {
74
+ var settings = $('[data-reveal].open').data('reveal-init'),
75
+ bg_clicked = $(e.target)[0] === $('.' + settings.bg_class)[0];
76
+
77
+ if (bg_clicked && !settings.close_on_background_click) {
78
+ return;
79
+ }
80
+
81
+ self.locked = true;
82
+ self.close.call(self, bg_clicked ? $('[data-reveal].open') : $(this).closest('[data-reveal]'));
83
+ }
84
+ });
85
+
86
+ if($('[data-reveal]', this.scope).length > 0) {
87
+ $(this.scope)
88
+ // .off('.reveal')
89
+ .on('open.fndtn.reveal', this.settings.open)
90
+ .on('opened.fndtn.reveal', this.settings.opened)
91
+ .on('opened.fndtn.reveal', this.open_video)
92
+ .on('close.fndtn.reveal', this.settings.close)
93
+ .on('closed.fndtn.reveal', this.settings.closed)
94
+ .on('closed.fndtn.reveal', this.close_video);
95
+ } else {
96
+ $(this.scope)
97
+ // .off('.reveal')
98
+ .on('open.fndtn.reveal', '[data-reveal]', this.settings.open)
99
+ .on('opened.fndtn.reveal', '[data-reveal]', this.settings.opened)
100
+ .on('opened.fndtn.reveal', '[data-reveal]', this.open_video)
101
+ .on('close.fndtn.reveal', '[data-reveal]', this.settings.close)
102
+ .on('closed.fndtn.reveal', '[data-reveal]', this.settings.closed)
103
+ .on('closed.fndtn.reveal', '[data-reveal]', this.close_video);
104
+ }
105
+
106
+ $('body').on('keyup.fndtn.reveal', function ( event ) {
107
+ var open_modal = $('[data-reveal].open'),
108
+ settings = open_modal.data('reveal-init');
109
+ if ( event.which === 27 && settings.close_on_esc) { // 27 is the keycode for the Escape key
110
+ open_modal.foundation('reveal', 'close');
111
+ }
112
+ });
113
+
114
+ return true;
115
+ },
116
+
117
+ open : function (target, ajax_settings) {
118
+ if (target) {
119
+ if (typeof target.selector !== 'undefined') {
120
+ var modal = $('#' + target.data('reveal-id'));
121
+ } else {
122
+ var modal = $(this.scope);
123
+
124
+ ajax_settings = target;
125
+ }
126
+ } else {
127
+ var modal = $(this.scope);
128
+ }
129
+
130
+ if (!modal.hasClass('open')) {
131
+ var open_modal = $('[data-reveal].open');
132
+
133
+ if (typeof modal.data('css-top') === 'undefined') {
134
+ modal.data('css-top', parseInt(modal.css('top'), 10))
135
+ .data('offset', this.cache_offset(modal));
136
+ }
137
+
138
+ modal.trigger('open');
139
+
140
+ if (open_modal.length < 1) {
141
+ this.toggle_bg();
142
+ }
143
+
144
+ if (typeof ajax_settings === 'undefined' || !ajax_settings.url) {
145
+ this.hide(open_modal, this.settings.css.close);
146
+ this.show(modal, this.settings.css.open);
147
+ } else {
148
+ var self = this,
149
+ old_success = typeof ajax_settings.success !== 'undefined' ? ajax_settings.success : null;
150
+
151
+ $.extend(ajax_settings, {
152
+ success: function (data, textStatus, jqXHR) {
153
+ if ( $.isFunction(old_success) ) {
154
+ old_success(data, textStatus, jqXHR);
155
+ }
156
+
157
+ modal.html(data);
158
+ $(modal).foundation('section', 'reflow');
159
+
160
+ self.hide(open_modal, self.settings.css.close);
161
+ self.show(modal, self.settings.css.open);
162
+ }
163
+ });
164
+
165
+ $.ajax(ajax_settings);
166
+ }
167
+ }
168
+ },
169
+
170
+ close : function (modal) {
171
+
172
+ var modal = modal && modal.length ? modal : $(this.scope),
173
+ open_modals = $('[data-reveal].open');
174
+
175
+ if (open_modals.length > 0) {
176
+ this.locked = true;
177
+ modal.trigger('close');
178
+ this.toggle_bg();
179
+ this.hide(open_modals, this.settings.css.close);
180
+ }
181
+ },
182
+
183
+ close_targets : function () {
184
+ var base = '.' + this.settings.dismiss_modal_class;
185
+
186
+ if (this.settings.close_on_background_click) {
187
+ return base + ', .' + this.settings.bg_class;
188
+ }
189
+
190
+ return base;
191
+ },
192
+
193
+ toggle_bg : function () {
194
+ if ($('.' + this.settings.bg_class).length === 0) {
195
+ this.settings.bg = $('<div />', {'class': this.settings.bg_class})
196
+ .appendTo('body');
197
+ }
198
+
199
+ if (this.settings.bg.filter(':visible').length > 0) {
200
+ this.hide(this.settings.bg);
201
+ } else {
202
+ this.show(this.settings.bg);
203
+ }
204
+ },
205
+
206
+ show : function (el, css) {
207
+ // is modal
208
+ if (css) {
209
+ if (el.parent('body').length === 0) {
210
+ var placeholder = el.wrap('<div style="display: none;" />').parent();
211
+ el.on('closed.fndtn.reveal.wrapped', function() {
212
+ el.detach().appendTo(placeholder);
213
+ el.unwrap().unbind('closed.fndtn.reveal.wrapped');
214
+ });
215
+
216
+ el.detach().appendTo('body');
217
+ }
218
+
219
+ if (/pop/i.test(this.settings.animation)) {
220
+ css.top = $(window).scrollTop() - el.data('offset') + 'px';
221
+ var end_css = {
222
+ top: $(window).scrollTop() + el.data('css-top') + 'px',
223
+ opacity: 1
224
+ };
225
+
226
+ return this.delay(function () {
227
+ return el
228
+ .css(css)
229
+ .animate(end_css, this.settings.animation_speed, 'linear', function () {
230
+ this.locked = false;
231
+ el.trigger('opened');
232
+ }.bind(this))
233
+ .addClass('open');
234
+ }.bind(this), this.settings.animation_speed / 2);
235
+ }
236
+
237
+ if (/fade/i.test(this.settings.animation)) {
238
+ var end_css = {opacity: 1};
239
+
240
+ return this.delay(function () {
241
+ return el
242
+ .css(css)
243
+ .animate(end_css, this.settings.animation_speed, 'linear', function () {
244
+ this.locked = false;
245
+ el.trigger('opened');
246
+ }.bind(this))
247
+ .addClass('open');
248
+ }.bind(this), this.settings.animation_speed / 2);
249
+ }
250
+
251
+ return el.css(css).show().css({opacity: 1}).addClass('open').trigger('opened');
252
+ }
253
+
254
+ // should we animate the background?
255
+ if (/fade/i.test(this.settings.animation)) {
256
+ return el.fadeIn(this.settings.animation_speed / 2);
257
+ }
258
+
259
+ return el.show();
260
+ },
261
+
262
+ hide : function (el, css) {
263
+ // is modal
264
+ if (css) {
265
+ if (/pop/i.test(this.settings.animation)) {
266
+ var end_css = {
267
+ top: - $(window).scrollTop() - el.data('offset') + 'px',
268
+ opacity: 0
269
+ };
270
+
271
+ return this.delay(function () {
272
+ return el
273
+ .animate(end_css, this.settings.animation_speed, 'linear', function () {
274
+ this.locked = false;
275
+ el.css(css).trigger('closed');
276
+ }.bind(this))
277
+ .removeClass('open');
278
+ }.bind(this), this.settings.animation_speed / 2);
279
+ }
280
+
281
+ if (/fade/i.test(this.settings.animation)) {
282
+ var end_css = {opacity: 0};
283
+
284
+ return this.delay(function () {
285
+ return el
286
+ .animate(end_css, this.settings.animation_speed, 'linear', function () {
287
+ this.locked = false;
288
+ el.css(css).trigger('closed');
289
+ }.bind(this))
290
+ .removeClass('open');
291
+ }.bind(this), this.settings.animation_speed / 2);
292
+ }
293
+
294
+ return el.hide().css(css).removeClass('open').trigger('closed');
295
+ }
296
+
297
+ // should we animate the background?
298
+ if (/fade/i.test(this.settings.animation)) {
299
+ return el.fadeOut(this.settings.animation_speed / 2);
300
+ }
301
+
302
+ return el.hide();
303
+ },
304
+
305
+ close_video : function (e) {
306
+ var video = $(this).find('.flex-video'),
307
+ iframe = video.find('iframe');
308
+
309
+ if (iframe.length > 0) {
310
+ iframe.attr('data-src', iframe[0].src);
311
+ iframe.attr('src', 'about:blank');
312
+ video.hide();
313
+ }
314
+ },
315
+
316
+ open_video : function (e) {
317
+ var video = $(this).find('.flex-video'),
318
+ iframe = video.find('iframe');
319
+
320
+ if (iframe.length > 0) {
321
+ var data_src = iframe.attr('data-src');
322
+ if (typeof data_src === 'string') {
323
+ iframe[0].src = iframe.attr('data-src');
324
+ } else {
325
+ var src = iframe[0].src;
326
+ iframe[0].src = undefined;
327
+ iframe[0].src = src;
328
+ }
329
+ video.show();
330
+ }
331
+ },
332
+
333
+ cache_offset : function (modal) {
334
+ var offset = modal.show().height() + parseInt(modal.css('top'), 10);
335
+
336
+ modal.hide();
337
+
338
+ return offset;
339
+ },
340
+
341
+ off : function () {
342
+ $(this.scope).off('.fndtn.reveal');
343
+ },
344
+
345
+ reflow : function () {}
346
+ };
347
+ }(jQuery, this, this.document));
@@ -0,0 +1,37 @@
1
+ /*jslint unparam: true, browser: true, indent: 2 */
2
+ ;(function ($, window, document, undefined) {
3
+ 'use strict';
4
+
5
+ Foundation.libs.tab = {
6
+ name : 'tab',
7
+
8
+ version : '5.0.1',
9
+
10
+ settings : {
11
+ active_class: 'active'
12
+ },
13
+
14
+ init : function (scope, method, options) {
15
+ this.bindings(method, options);
16
+ },
17
+
18
+ events : function () {
19
+ $(this.scope).off('.tab').on('click.fndtn.tab', '[data-tab] > dd > a', function (e) {
20
+ e.preventDefault();
21
+
22
+ var tab = $(this).parent(),
23
+ target = $('#' + this.href.split('#')[1]),
24
+ siblings = tab.siblings(),
25
+ settings = tab.closest('[data-tab]').data('tab-init');
26
+
27
+ tab.addClass(settings.active_class);
28
+ siblings.removeClass(settings.active_class);
29
+ target.siblings().removeClass(settings.active_class).end().addClass(settings.active_class);
30
+ });
31
+ },
32
+
33
+ off : function () {},
34
+
35
+ reflow : function () {}
36
+ };
37
+ }(jQuery, this, this.document));
@@ -0,0 +1,202 @@
1
+ ;(function ($, window, document, undefined) {
2
+ 'use strict';
3
+
4
+ Foundation.libs.tooltip = {
5
+ name : 'tooltip',
6
+
7
+ version : '5.0.0',
8
+
9
+ settings : {
10
+ additional_inheritable_classes : [],
11
+ tooltip_class : '.tooltip',
12
+ append_to: 'body',
13
+ touch_close_text: 'Tap To Close',
14
+ disable_for_touch: false,
15
+ tip_template : function (selector, content) {
16
+ return '<span data-selector="' + selector + '" class="'
17
+ + Foundation.libs.tooltip.settings.tooltip_class.substring(1)
18
+ + '">' + content + '<span class="nub"></span></span>';
19
+ }
20
+ },
21
+
22
+ cache : {},
23
+
24
+ init : function (scope, method, options) {
25
+ this.bindings(method, options);
26
+ },
27
+
28
+ events : function () {
29
+ var self = this;
30
+
31
+ if (Modernizr.touch) {
32
+ $(this.scope)
33
+ .off('.tooltip')
34
+ .on('click.fndtn.tooltip touchstart.fndtn.tooltip touchend.fndtn.tooltip',
35
+ '[data-tooltip]', function (e) {
36
+ var settings = $.extend({}, self.settings, self.data_options($(this)));
37
+ if (!settings.disable_for_touch) {
38
+ e.preventDefault();
39
+ $(settings.tooltip_class).hide();
40
+ self.showOrCreateTip($(this));
41
+ }
42
+ })
43
+ .on('click.fndtn.tooltip touchstart.fndtn.tooltip touchend.fndtn.tooltip',
44
+ this.settings.tooltip_class, function (e) {
45
+ e.preventDefault();
46
+ $(this).fadeOut(150);
47
+ });
48
+ } else {
49
+ $(this.scope)
50
+ .off('.tooltip')
51
+ .on('mouseenter.fndtn.tooltip mouseleave.fndtn.tooltip',
52
+ '[data-tooltip]', function (e) {
53
+ var $this = $(this);
54
+
55
+ if (/enter|over/i.test(e.type)) {
56
+ self.showOrCreateTip($this);
57
+ } else if (e.type === 'mouseout' || e.type === 'mouseleave') {
58
+ self.hide($this);
59
+ }
60
+ });
61
+ }
62
+ },
63
+
64
+ showOrCreateTip : function ($target) {
65
+ var $tip = this.getTip($target);
66
+
67
+ if ($tip && $tip.length > 0) {
68
+ return this.show($target);
69
+ }
70
+
71
+ return this.create($target);
72
+ },
73
+
74
+ getTip : function ($target) {
75
+ var selector = this.selector($target),
76
+ tip = null;
77
+
78
+ if (selector) {
79
+ tip = $('span[data-selector="' + selector + '"]' + this.settings.tooltip_class);
80
+ }
81
+
82
+ return (typeof tip === 'object') ? tip : false;
83
+ },
84
+
85
+ selector : function ($target) {
86
+ var id = $target.attr('id'),
87
+ dataSelector = $target.attr('data-tooltip') || $target.attr('data-selector');
88
+
89
+ if ((id && id.length < 1 || !id) && typeof dataSelector != 'string') {
90
+ dataSelector = 'tooltip' + Math.random().toString(36).substring(7);
91
+ $target.attr('data-selector', dataSelector);
92
+ }
93
+
94
+ return (id && id.length > 0) ? id : dataSelector;
95
+ },
96
+
97
+ create : function ($target) {
98
+ var $tip = $(this.settings.tip_template(this.selector($target), $('<div></div>').html($target.attr('title')).html())),
99
+ classes = this.inheritable_classes($target);
100
+
101
+ $tip.addClass(classes).appendTo(this.settings.append_to);
102
+ if (Modernizr.touch) {
103
+ $tip.append('<span class="tap-to-close">'+this.settings.touch_close_text+'</span>');
104
+ }
105
+ $target.removeAttr('title').attr('title','');
106
+ this.show($target);
107
+ },
108
+
109
+ reposition : function (target, tip, classes) {
110
+ var width, nub, nubHeight, nubWidth, column, objPos;
111
+
112
+ tip.css('visibility', 'hidden').show();
113
+
114
+ width = target.data('width');
115
+ nub = tip.children('.nub');
116
+ nubHeight = nub.outerHeight();
117
+ nubWidth = nub.outerHeight();
118
+
119
+ objPos = function (obj, top, right, bottom, left, width) {
120
+ return obj.css({
121
+ 'top' : (top) ? top : 'auto',
122
+ 'bottom' : (bottom) ? bottom : 'auto',
123
+ 'left' : (left) ? left : 'auto',
124
+ 'right' : (right) ? right : 'auto',
125
+ 'width' : (width) ? width : 'auto'
126
+ }).end();
127
+ };
128
+
129
+ objPos(tip, (target.offset().top + target.outerHeight() + 10), 'auto', 'auto', target.offset().left, width);
130
+
131
+ if (this.small()) {
132
+ objPos(tip, (target.offset().top + target.outerHeight() + 10), 'auto', 'auto', 12.5, $(this.scope).width());
133
+ tip.addClass('tip-override');
134
+ objPos(nub, -nubHeight, 'auto', 'auto', target.offset().left);
135
+ } else {
136
+ var left = target.offset().left;
137
+ if (Foundation.rtl) {
138
+ left = target.offset().left + target.offset().width - tip.outerWidth();
139
+ }
140
+ objPos(tip, (target.offset().top + target.outerHeight() + 10), 'auto', 'auto', left, width);
141
+ tip.removeClass('tip-override');
142
+ if (classes && classes.indexOf('tip-top') > -1) {
143
+ objPos(tip, (target.offset().top - tip.outerHeight()), 'auto', 'auto', left, width)
144
+ .removeClass('tip-override');
145
+ } else if (classes && classes.indexOf('tip-left') > -1) {
146
+ objPos(tip, (target.offset().top + (target.outerHeight() / 2) - nubHeight*2.5), 'auto', 'auto', (target.offset().left - tip.outerWidth() - nubHeight), width)
147
+ .removeClass('tip-override');
148
+ } else if (classes && classes.indexOf('tip-right') > -1) {
149
+ objPos(tip, (target.offset().top + (target.outerHeight() / 2) - nubHeight*2.5), 'auto', 'auto', (target.offset().left + target.outerWidth() + nubHeight), width)
150
+ .removeClass('tip-override');
151
+ }
152
+ }
153
+
154
+ tip.css('visibility', 'visible').hide();
155
+ },
156
+
157
+ small : function () {
158
+ return matchMedia(Foundation.media_queries.small).matches;
159
+ },
160
+
161
+ inheritable_classes : function (target) {
162
+ var inheritables = ['tip-top', 'tip-left', 'tip-bottom', 'tip-right', 'noradius'].concat(this.settings.additional_inheritable_classes),
163
+ classes = target.attr('class'),
164
+ filtered = classes ? $.map(classes.split(' '), function (el, i) {
165
+ if ($.inArray(el, inheritables) !== -1) {
166
+ return el;
167
+ }
168
+ }).join(' ') : '';
169
+
170
+ return $.trim(filtered);
171
+ },
172
+
173
+ show : function ($target) {
174
+ var $tip = this.getTip($target);
175
+
176
+ this.reposition($target, $tip, $target.attr('class'));
177
+ $tip.fadeIn(150);
178
+ },
179
+
180
+ hide : function ($target) {
181
+ var $tip = this.getTip($target);
182
+
183
+ $tip.fadeOut(150);
184
+ },
185
+
186
+ // deprecate reload
187
+ reload : function () {
188
+ var $self = $(this);
189
+
190
+ return ($self.data('fndtn-tooltips')) ? $self.foundationTooltips('destroy').foundationTooltips('init') : $self.foundationTooltips('init');
191
+ },
192
+
193
+ off : function () {
194
+ $(this.scope).off('.fndtn.tooltip');
195
+ $(this.settings.tooltip_class).each(function (i) {
196
+ $('[data-tooltip]').get(i).attr('title', $(this).text());
197
+ }).remove();
198
+ },
199
+
200
+ reflow : function () {}
201
+ };
202
+ }(jQuery, this, this.document));