pbw 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/MIT-LICENSE +1 -1
- data/Rakefile +7 -0
- data/app/controllers/pbw/application_controller.rb +9 -3
- data/app/controllers/pbw/areas_controller.rb +7 -0
- data/app/controllers/pbw/base_models_controller.rb +106 -0
- data/app/controllers/pbw/capabilities_controller.rb +7 -0
- data/app/controllers/pbw/constraints_controller.rb +7 -0
- data/app/controllers/pbw/item_containers_controller.rb +7 -0
- data/app/controllers/pbw/item_conversions_controller.rb +7 -0
- data/app/controllers/pbw/item_transfers_controller.rb +7 -0
- data/app/controllers/pbw/items_controller.rb +7 -0
- data/app/controllers/pbw/processes_controller.rb +7 -0
- data/app/controllers/pbw/roles_controller.rb +5 -2
- data/app/controllers/pbw/tokens_controller.rb +7 -0
- data/app/controllers/pbw/triggers_controller.rb +7 -0
- data/app/controllers/pbw/user_tokens_controller.rb +7 -0
- data/app/models/pbw/area.rb +17 -0
- data/app/models/pbw/capability.rb +5 -0
- data/app/models/pbw/constraint.rb +6 -0
- data/app/models/pbw/item.rb +15 -0
- data/app/models/pbw/item_container.rb +12 -0
- data/app/models/pbw/item_conversion.rb +9 -0
- data/app/models/pbw/item_transfer.rb +9 -0
- data/app/models/pbw/permission.rb +1 -0
- data/app/models/pbw/process.rb +10 -0
- data/app/models/pbw/role.rb +1 -0
- data/app/models/pbw/rule.rb +11 -0
- data/app/models/pbw/token.rb +16 -0
- data/app/models/pbw/trigger.rb +7 -0
- data/app/models/pbw/user.rb +7 -5
- data/app/models/pbw/user_token.rb +16 -0
- data/app/views/layouts/pbw/application.html.erb +41 -8
- data/config/initializers/devise.rb +80 -4
- data/config/locales/devise.en.yml +59 -0
- data/config/routes.rb +11 -0
- data/lib/generators/pbw/install/install_generator.rb +9 -1
- data/lib/generators/pbw/install/templates/application.html.erb +47 -0
- data/lib/pbw/engine.rb +33 -13
- data/lib/pbw/version.rb +1 -1
- data/public/Foundation-MIT-LICENSE.txt +20 -0
- data/public/config.rb +26 -0
- data/public/humans.txt +8 -0
- data/public/javascripts/foundation/foundation.alerts.js +52 -0
- data/public/javascripts/foundation/foundation.clearing.js +516 -0
- data/public/javascripts/foundation/foundation.cookie.js +74 -0
- data/public/javascripts/foundation/foundation.dropdown.js +178 -0
- data/public/javascripts/foundation/foundation.forms.js +525 -0
- data/public/javascripts/foundation/foundation.interchange.js +271 -0
- data/public/javascripts/foundation/foundation.joyride.js +844 -0
- data/public/javascripts/foundation/foundation.js +447 -0
- data/public/javascripts/foundation/foundation.magellan.js +134 -0
- data/public/javascripts/foundation/foundation.orbit.js +390 -0
- data/public/javascripts/foundation/foundation.placeholder.js +179 -0
- data/public/javascripts/foundation/foundation.reveal.js +330 -0
- data/public/javascripts/foundation/foundation.section.js +422 -0
- data/public/javascripts/foundation/foundation.tooltips.js +208 -0
- data/public/javascripts/foundation/foundation.topbar.js +303 -0
- data/public/javascripts/vendor/custom.modernizr.js +4 -0
- data/public/javascripts/vendor/jquery.js +9807 -0
- data/public/javascripts/vendor/zepto.js +2000 -0
- data/public/robots.txt +4 -0
- data/public/sass/_normalize.scss +402 -0
- data/public/sass/_settings.scss +1271 -0
- data/public/sass/app.scss +48 -0
- data/public/stylesheets/app.css +6686 -0
- metadata +82 -4
- data/app/assets/javascripts/pbw/application.js +0 -13
- data/app/assets/stylesheets/pbw/application.css +0 -13
@@ -0,0 +1,422 @@
|
|
1
|
+
/*jslint unparam: true, browser: true, indent: 2 */
|
2
|
+
|
3
|
+
;(function ($, window, document, undefined) {
|
4
|
+
'use strict';
|
5
|
+
|
6
|
+
Foundation.libs.section = {
|
7
|
+
name: 'section',
|
8
|
+
|
9
|
+
version : '4.2.3',
|
10
|
+
|
11
|
+
settings : {
|
12
|
+
deep_linking: false,
|
13
|
+
small_breakpoint: 768,
|
14
|
+
one_up: true,
|
15
|
+
section_selector : '[data-section]',
|
16
|
+
region_selector : 'section, .section, [data-section-region]',
|
17
|
+
title_selector : '.title, [data-section-title]',
|
18
|
+
active_region_selector : 'section.active, .section.active, .active[data-section-region]',
|
19
|
+
content_selector : '.content, [data-section-content]',
|
20
|
+
nav_selector : '[data-section="vertical-nav"], [data-section="horizontal-nav"]',
|
21
|
+
callback: function (){}
|
22
|
+
},
|
23
|
+
|
24
|
+
init : function (scope, method, options) {
|
25
|
+
var self = this;
|
26
|
+
Foundation.inherit(this, 'throttle data_options position_right offset_right');
|
27
|
+
|
28
|
+
if (typeof method === 'object') {
|
29
|
+
$.extend(true, self.settings, method);
|
30
|
+
}
|
31
|
+
|
32
|
+
if (typeof method !== 'string') {
|
33
|
+
this.set_active_from_hash();
|
34
|
+
this.events();
|
35
|
+
|
36
|
+
return true;
|
37
|
+
} else {
|
38
|
+
return this[method].call(this, options);
|
39
|
+
}
|
40
|
+
},
|
41
|
+
|
42
|
+
events : function () {
|
43
|
+
var self = this;
|
44
|
+
|
45
|
+
$(this.scope)
|
46
|
+
.on('click.fndtn.section', '[data-section] .title, [data-section] [data-section-title]', function (e) {
|
47
|
+
var $this = $(this),
|
48
|
+
section = $this.closest(self.settings.region_selector);
|
49
|
+
|
50
|
+
if (section.children(self.settings.content_selector).length > 0) {
|
51
|
+
self.toggle_active.call(this, e, self);
|
52
|
+
self.reflow();
|
53
|
+
}
|
54
|
+
});
|
55
|
+
|
56
|
+
$(window)
|
57
|
+
.on('resize.fndtn.section', self.throttle(function () {
|
58
|
+
self.resize.call(this);
|
59
|
+
}, 30))
|
60
|
+
.on('hashchange', function () {
|
61
|
+
if (!self.settings.toggled){
|
62
|
+
self.set_active_from_hash();
|
63
|
+
$(this).trigger('resize');
|
64
|
+
}
|
65
|
+
}).trigger('resize');
|
66
|
+
|
67
|
+
$(document)
|
68
|
+
.on('click.fndtn.section', function (e) {
|
69
|
+
if ($(e.target).closest(self.settings.title_selector).length < 1) {
|
70
|
+
$(self.settings.nav_selector)
|
71
|
+
.children(self.settings.region_selector)
|
72
|
+
.removeClass('active')
|
73
|
+
.attr('style', '');
|
74
|
+
}
|
75
|
+
});
|
76
|
+
|
77
|
+
},
|
78
|
+
|
79
|
+
toggle_active : function (e, self) {
|
80
|
+
var $this = $(this),
|
81
|
+
self = Foundation.libs.section,
|
82
|
+
region = $this.closest(self.settings.region_selector),
|
83
|
+
content = $this.siblings(self.settings.content_selector),
|
84
|
+
parent = region.parent(),
|
85
|
+
settings = $.extend({}, self.settings, self.data_options(parent)),
|
86
|
+
prev_active_section = parent
|
87
|
+
.children(self.settings.active_region_selector);
|
88
|
+
|
89
|
+
self.settings.toggled = true;
|
90
|
+
|
91
|
+
if (!settings.deep_linking && content.length > 0) {
|
92
|
+
e.preventDefault();
|
93
|
+
}
|
94
|
+
|
95
|
+
if (region.hasClass('active')) {
|
96
|
+
// this is causing the style flash.
|
97
|
+
if (self.small(parent)
|
98
|
+
|| self.is_vertical_nav(parent)
|
99
|
+
|| self.is_horizontal_nav(parent)
|
100
|
+
|| self.is_accordion(parent)) {
|
101
|
+
if (prev_active_section[0] !== region[0]
|
102
|
+
|| (prev_active_section[0] === region[0] && !settings.one_up)) {
|
103
|
+
region
|
104
|
+
.removeClass('active')
|
105
|
+
.attr('style', '');
|
106
|
+
}
|
107
|
+
}
|
108
|
+
} else {
|
109
|
+
var prev_active_section = parent
|
110
|
+
.children(self.settings.active_region_selector),
|
111
|
+
title_height = self.outerHeight(region
|
112
|
+
.children(self.settings.title_selector));
|
113
|
+
|
114
|
+
if (self.small(parent) || settings.one_up) {
|
115
|
+
|
116
|
+
if (self.small(parent)) {
|
117
|
+
prev_active_section.attr('style', '');
|
118
|
+
} else {
|
119
|
+
prev_active_section.attr('style',
|
120
|
+
'visibility: hidden; padding-top: '+title_height+'px;');
|
121
|
+
}
|
122
|
+
}
|
123
|
+
|
124
|
+
if (self.small(parent)) {
|
125
|
+
region.attr('style', '');
|
126
|
+
} else {
|
127
|
+
region.css('padding-top', title_height);
|
128
|
+
}
|
129
|
+
|
130
|
+
region.addClass('active');
|
131
|
+
|
132
|
+
if (prev_active_section.length > 0) {
|
133
|
+
prev_active_section
|
134
|
+
.removeClass('active')
|
135
|
+
.attr('style', '');
|
136
|
+
}
|
137
|
+
|
138
|
+
// Toggle the content display attribute. This is done to
|
139
|
+
// ensure accurate outerWidth measurements that account for
|
140
|
+
// the scrollbar.
|
141
|
+
if (self.is_vertical_tabs(parent)) {
|
142
|
+
content.css('display', 'block');
|
143
|
+
|
144
|
+
if (prev_active_section !== null) {
|
145
|
+
prev_active_section
|
146
|
+
.children(self.settings.content_selector)
|
147
|
+
.css('display', 'none');
|
148
|
+
}
|
149
|
+
}
|
150
|
+
}
|
151
|
+
|
152
|
+
setTimeout(function () {
|
153
|
+
self.settings.toggled = false;
|
154
|
+
}, 300);
|
155
|
+
|
156
|
+
settings.callback();
|
157
|
+
},
|
158
|
+
|
159
|
+
resize : function () {
|
160
|
+
var self = Foundation.libs.section,
|
161
|
+
sections = $(self.settings.section_selector);
|
162
|
+
|
163
|
+
sections.each(function() {
|
164
|
+
var $this = $(this),
|
165
|
+
active_section = $this
|
166
|
+
.children(self.settings.active_region_selector),
|
167
|
+
settings = $.extend({}, self.settings, self.data_options($this));
|
168
|
+
|
169
|
+
if (active_section.length > 1) {
|
170
|
+
active_section
|
171
|
+
.not(':first')
|
172
|
+
.removeClass('active')
|
173
|
+
.attr('style', '');
|
174
|
+
} else if (active_section.length < 1
|
175
|
+
&& !self.is_vertical_nav($this)
|
176
|
+
&& !self.is_horizontal_nav($this)
|
177
|
+
&& !self.is_accordion($this)) {
|
178
|
+
|
179
|
+
var first = $this.children(self.settings.region_selector).first();
|
180
|
+
|
181
|
+
if (settings.one_up || !self.small($this)) {
|
182
|
+
first.addClass('active');
|
183
|
+
}
|
184
|
+
|
185
|
+
if (self.small($this)) {
|
186
|
+
first.attr('style', '');
|
187
|
+
} else {
|
188
|
+
first.css('padding-top', self.outerHeight(first
|
189
|
+
.children(self.settings.title_selector)));
|
190
|
+
}
|
191
|
+
}
|
192
|
+
|
193
|
+
if (self.small($this)) {
|
194
|
+
active_section.attr('style', '');
|
195
|
+
} else {
|
196
|
+
active_section.css('padding-top', self.outerHeight(active_section
|
197
|
+
.children(self.settings.title_selector)));
|
198
|
+
}
|
199
|
+
|
200
|
+
self.position_titles($this);
|
201
|
+
|
202
|
+
if ( (self.is_horizontal_nav($this) && !self.small($this))
|
203
|
+
|| self.is_vertical_tabs($this) && !self.small($this)) {
|
204
|
+
self.position_content($this);
|
205
|
+
} else {
|
206
|
+
self.position_content($this, false);
|
207
|
+
}
|
208
|
+
});
|
209
|
+
},
|
210
|
+
|
211
|
+
is_vertical_nav : function (el) {
|
212
|
+
return /vertical-nav/i.test(el.data('section'));
|
213
|
+
},
|
214
|
+
|
215
|
+
is_horizontal_nav : function (el) {
|
216
|
+
return /horizontal-nav/i.test(el.data('section'));
|
217
|
+
},
|
218
|
+
|
219
|
+
is_accordion : function (el) {
|
220
|
+
return /accordion/i.test(el.data('section'));
|
221
|
+
},
|
222
|
+
|
223
|
+
is_horizontal_tabs : function (el) {
|
224
|
+
return /^tabs$/i.test(el.data('section'));
|
225
|
+
},
|
226
|
+
|
227
|
+
is_vertical_tabs : function (el) {
|
228
|
+
return /vertical-tabs/i.test(el.data('section'));
|
229
|
+
},
|
230
|
+
|
231
|
+
set_active_from_hash : function () {
|
232
|
+
var hash = window.location.hash.substring(1),
|
233
|
+
sections = $('[data-section]'),
|
234
|
+
self = this;
|
235
|
+
sections.each(function () {
|
236
|
+
var section = $(this),
|
237
|
+
settings = $.extend({}, self.settings, self.data_options(section));
|
238
|
+
|
239
|
+
if (hash.length > 0 && settings.deep_linking) {
|
240
|
+
var regions = section
|
241
|
+
.children(self.settings.region_selector)
|
242
|
+
.attr('style', '')
|
243
|
+
.removeClass('active');
|
244
|
+
|
245
|
+
var hash_regions = regions.map(function () {
|
246
|
+
var content = $(self.settings.content_selector, this),
|
247
|
+
content_slug = content.data('slug');
|
248
|
+
|
249
|
+
if (new RegExp(content_slug, 'i').test(hash))
|
250
|
+
return content;
|
251
|
+
});
|
252
|
+
|
253
|
+
|
254
|
+
var count = hash_regions.length;
|
255
|
+
|
256
|
+
for (var i = count - 1; i >= 0; i--) {
|
257
|
+
$(hash_regions[i]).parent().addClass('active');
|
258
|
+
}
|
259
|
+
}
|
260
|
+
});
|
261
|
+
},
|
262
|
+
|
263
|
+
position_titles : function (section, off) {
|
264
|
+
var self = this,
|
265
|
+
titles = section
|
266
|
+
.children(this.settings.region_selector)
|
267
|
+
.map(function () {
|
268
|
+
return $(this).children(self.settings.title_selector);
|
269
|
+
}),
|
270
|
+
previous_width = 0,
|
271
|
+
previous_height = 0,
|
272
|
+
self = this;
|
273
|
+
|
274
|
+
if (typeof off === 'boolean') {
|
275
|
+
titles.attr('style', '');
|
276
|
+
|
277
|
+
} else {
|
278
|
+
titles.each(function () {
|
279
|
+
if (self.is_vertical_tabs(section)) {
|
280
|
+
$(this).css('top', previous_height);
|
281
|
+
previous_height += self.outerHeight($(this));
|
282
|
+
} else {
|
283
|
+
if (!self.rtl) {
|
284
|
+
$(this).css('left', previous_width);
|
285
|
+
} else {
|
286
|
+
$(this).css('right', previous_width);
|
287
|
+
}
|
288
|
+
previous_width += self.outerWidth($(this));
|
289
|
+
}
|
290
|
+
});
|
291
|
+
}
|
292
|
+
},
|
293
|
+
|
294
|
+
position_content : function (section, off) {
|
295
|
+
var self = this,
|
296
|
+
regions = section.children(self.settings.region_selector),
|
297
|
+
titles = regions
|
298
|
+
.map(function () {
|
299
|
+
return $(this).children(self.settings.title_selector);
|
300
|
+
}),
|
301
|
+
content = regions
|
302
|
+
.map(function () {
|
303
|
+
return $(this).children(self.settings.content_selector);
|
304
|
+
});
|
305
|
+
|
306
|
+
if (typeof off === 'boolean') {
|
307
|
+
content.attr('style', '');
|
308
|
+
section.attr('style', '');
|
309
|
+
|
310
|
+
// Reset the minHeight and maxWidth values (only applicable to
|
311
|
+
// vertical tabs)
|
312
|
+
content.css('minHeight', '');
|
313
|
+
content.css('maxWidth', '');
|
314
|
+
} else {
|
315
|
+
if (self.is_vertical_tabs(section)
|
316
|
+
&& !self.small(section)) {
|
317
|
+
var content_min_height = 0,
|
318
|
+
content_min_width = Number.MAX_VALUE,
|
319
|
+
title_width = null;
|
320
|
+
|
321
|
+
regions.each(function () {
|
322
|
+
var region = $(this),
|
323
|
+
title = region.children(self.settings.title_selector),
|
324
|
+
content = region.children(self.settings.content_selector),
|
325
|
+
content_width = 0;
|
326
|
+
|
327
|
+
title_width = self.outerWidth(title);
|
328
|
+
content_width = self.outerWidth(section) - title_width;
|
329
|
+
|
330
|
+
if (content_width < content_min_width) {
|
331
|
+
content_min_width = content_width;
|
332
|
+
}
|
333
|
+
|
334
|
+
// Increment the minimum height of the content region
|
335
|
+
// to align with the height of the titles.
|
336
|
+
content_min_height += self.outerHeight(title);
|
337
|
+
|
338
|
+
// Set all of the inactive tabs to 'display: none'
|
339
|
+
// The CSS sets all of the tabs as 'display: block'
|
340
|
+
// in order to account for scrollbars when measuring the width
|
341
|
+
// of the content regions.
|
342
|
+
if (!$(this).hasClass('active')) {
|
343
|
+
content.css('display', 'none');
|
344
|
+
}
|
345
|
+
});
|
346
|
+
|
347
|
+
regions.each(function () {
|
348
|
+
var content = $(this).children(self.settings.content_selector);
|
349
|
+
content.css('minHeight', content_min_height);
|
350
|
+
|
351
|
+
// Remove 2 pixels to account for the right-shift in the CSS
|
352
|
+
content.css('maxWidth', content_min_width - 2);
|
353
|
+
});
|
354
|
+
|
355
|
+
} else {
|
356
|
+
regions.each(function () {
|
357
|
+
var region = $(this),
|
358
|
+
title = region.children(self.settings.title_selector),
|
359
|
+
content = region.children(self.settings.content_selector);
|
360
|
+
if (!self.rtl) {
|
361
|
+
content
|
362
|
+
.css({left: title.position().left - 1,
|
363
|
+
top: self.outerHeight(title) - 2});
|
364
|
+
} else {
|
365
|
+
content
|
366
|
+
.css({right: self.position_right(title) + 1,
|
367
|
+
top: self.outerHeight(title) - 2});
|
368
|
+
}
|
369
|
+
});
|
370
|
+
|
371
|
+
// temporary work around for Zepto outerheight calculation issues.
|
372
|
+
if (typeof Zepto === 'function') {
|
373
|
+
section.height(this.outerHeight($(titles[0])));
|
374
|
+
} else {
|
375
|
+
section.height(this.outerHeight($(titles[0])) - 2);
|
376
|
+
}
|
377
|
+
}
|
378
|
+
}
|
379
|
+
},
|
380
|
+
|
381
|
+
position_right : function (el) {
|
382
|
+
var self = this,
|
383
|
+
section = el.closest(this.settings.section_selector),
|
384
|
+
regions = section.children(this.settings.region_selector),
|
385
|
+
section_width = el.closest(this.settings.section_selector).width(),
|
386
|
+
offset = regions
|
387
|
+
.map(function () {
|
388
|
+
return $(this).children(self.settings.title_selector);
|
389
|
+
}).length;
|
390
|
+
return (section_width - el.position().left - el.width() * (el.index() + 1) - offset);
|
391
|
+
},
|
392
|
+
|
393
|
+
reflow : function (scope) {
|
394
|
+
var scope = scope || document;
|
395
|
+
$(this.settings.section_selector, scope).trigger('resize');
|
396
|
+
},
|
397
|
+
|
398
|
+
small : function (el) {
|
399
|
+
var settings = $.extend({}, this.settings, this.data_options(el));
|
400
|
+
|
401
|
+
if (this.is_horizontal_tabs(el)) {
|
402
|
+
return false;
|
403
|
+
}
|
404
|
+
if (el && this.is_accordion(el)) {
|
405
|
+
return true;
|
406
|
+
}
|
407
|
+
if ($('html').hasClass('lt-ie9')) {
|
408
|
+
return true;
|
409
|
+
}
|
410
|
+
if ($('html').hasClass('ie8compat')) {
|
411
|
+
return true;
|
412
|
+
}
|
413
|
+
return $(this.scope).width() < settings.small_breakpoint;
|
414
|
+
},
|
415
|
+
|
416
|
+
off : function () {
|
417
|
+
$(this.scope).off('.fndtn.section');
|
418
|
+
$(window).off('.fndtn.section');
|
419
|
+
$(document).off('.fndtn.section')
|
420
|
+
}
|
421
|
+
};
|
422
|
+
}(Foundation.zj, this, this.document));
|
@@ -0,0 +1,208 @@
|
|
1
|
+
/*jslint unparam: true, browser: true, indent: 2 */
|
2
|
+
|
3
|
+
;(function ($, window, document, undefined) {
|
4
|
+
'use strict';
|
5
|
+
|
6
|
+
Foundation.libs.tooltips = {
|
7
|
+
name: 'tooltips',
|
8
|
+
|
9
|
+
version : '4.2.2',
|
10
|
+
|
11
|
+
settings : {
|
12
|
+
selector : '.has-tip',
|
13
|
+
additionalInheritableClasses : [],
|
14
|
+
tooltipClass : '.tooltip',
|
15
|
+
appendTo: 'body',
|
16
|
+
'disable-for-touch': false,
|
17
|
+
tipTemplate : function (selector, content) {
|
18
|
+
return '<span data-selector="' + selector + '" class="'
|
19
|
+
+ Foundation.libs.tooltips.settings.tooltipClass.substring(1)
|
20
|
+
+ '">' + content + '<span class="nub"></span></span>';
|
21
|
+
}
|
22
|
+
},
|
23
|
+
|
24
|
+
cache : {},
|
25
|
+
|
26
|
+
init : function (scope, method, options) {
|
27
|
+
Foundation.inherit(this, 'data_options');
|
28
|
+
var self = this;
|
29
|
+
|
30
|
+
if (typeof method === 'object') {
|
31
|
+
$.extend(true, this.settings, method);
|
32
|
+
} else if (typeof options !== 'undefined') {
|
33
|
+
$.extend(true, this.settings, options);
|
34
|
+
}
|
35
|
+
|
36
|
+
if (typeof method !== 'string') {
|
37
|
+
if (Modernizr.touch) {
|
38
|
+
$(this.scope)
|
39
|
+
.on('click.fndtn.tooltip touchstart.fndtn.tooltip touchend.fndtn.tooltip',
|
40
|
+
'[data-tooltip]', function (e) {
|
41
|
+
var settings = $.extend({}, self.settings, self.data_options($(this)));
|
42
|
+
if (!settings['disable-for-touch']) {
|
43
|
+
e.preventDefault();
|
44
|
+
$(settings.tooltipClass).hide();
|
45
|
+
self.showOrCreateTip($(this));
|
46
|
+
}
|
47
|
+
})
|
48
|
+
.on('click.fndtn.tooltip touchstart.fndtn.tooltip touchend.fndtn.tooltip',
|
49
|
+
this.settings.tooltipClass, function (e) {
|
50
|
+
e.preventDefault();
|
51
|
+
$(this).fadeOut(150);
|
52
|
+
});
|
53
|
+
} else {
|
54
|
+
$(this.scope)
|
55
|
+
.on('mouseenter.fndtn.tooltip mouseleave.fndtn.tooltip',
|
56
|
+
'[data-tooltip]', function (e) {
|
57
|
+
var $this = $(this);
|
58
|
+
|
59
|
+
if (/enter|over/i.test(e.type)) {
|
60
|
+
self.showOrCreateTip($this);
|
61
|
+
} else if (e.type === 'mouseout' || e.type === 'mouseleave') {
|
62
|
+
self.hide($this);
|
63
|
+
}
|
64
|
+
});
|
65
|
+
}
|
66
|
+
|
67
|
+
// $(this.scope).data('fndtn-tooltips', true);
|
68
|
+
} else {
|
69
|
+
return this[method].call(this, options);
|
70
|
+
}
|
71
|
+
|
72
|
+
},
|
73
|
+
|
74
|
+
showOrCreateTip : function ($target) {
|
75
|
+
var $tip = this.getTip($target);
|
76
|
+
|
77
|
+
if ($tip && $tip.length > 0) {
|
78
|
+
return this.show($target);
|
79
|
+
}
|
80
|
+
|
81
|
+
return this.create($target);
|
82
|
+
},
|
83
|
+
|
84
|
+
getTip : function ($target) {
|
85
|
+
var selector = this.selector($target),
|
86
|
+
tip = null;
|
87
|
+
|
88
|
+
if (selector) {
|
89
|
+
tip = $('span[data-selector="' + selector + '"]' + this.settings.tooltipClass);
|
90
|
+
}
|
91
|
+
|
92
|
+
return (typeof tip === 'object') ? tip : false;
|
93
|
+
},
|
94
|
+
|
95
|
+
selector : function ($target) {
|
96
|
+
var id = $target.attr('id'),
|
97
|
+
dataSelector = $target.attr('data-tooltip') || $target.attr('data-selector');
|
98
|
+
|
99
|
+
if ((id && id.length < 1 || !id) && typeof dataSelector != 'string') {
|
100
|
+
dataSelector = 'tooltip' + Math.random().toString(36).substring(7);
|
101
|
+
$target.attr('data-selector', dataSelector);
|
102
|
+
}
|
103
|
+
|
104
|
+
return (id && id.length > 0) ? id : dataSelector;
|
105
|
+
},
|
106
|
+
|
107
|
+
create : function ($target) {
|
108
|
+
var $tip = $(this.settings.tipTemplate(this.selector($target), $('<div></div>').html($target.attr('title')).html())),
|
109
|
+
classes = this.inheritable_classes($target);
|
110
|
+
|
111
|
+
$tip.addClass(classes).appendTo(this.settings.appendTo);
|
112
|
+
if (Modernizr.touch) {
|
113
|
+
$tip.append('<span class="tap-to-close">tap to close </span>');
|
114
|
+
}
|
115
|
+
$target.removeAttr('title').attr('title','');
|
116
|
+
this.show($target);
|
117
|
+
},
|
118
|
+
|
119
|
+
reposition : function (target, tip, classes) {
|
120
|
+
var width, nub, nubHeight, nubWidth, column, objPos;
|
121
|
+
|
122
|
+
tip.css('visibility', 'hidden').show();
|
123
|
+
|
124
|
+
width = target.data('width');
|
125
|
+
nub = tip.children('.nub');
|
126
|
+
nubHeight = this.outerHeight(nub);
|
127
|
+
nubWidth = this.outerHeight(nub);
|
128
|
+
|
129
|
+
objPos = function (obj, top, right, bottom, left, width) {
|
130
|
+
return obj.css({
|
131
|
+
'top' : (top) ? top : 'auto',
|
132
|
+
'bottom' : (bottom) ? bottom : 'auto',
|
133
|
+
'left' : (left) ? left : 'auto',
|
134
|
+
'right' : (right) ? right : 'auto',
|
135
|
+
'width' : (width) ? width : 'auto'
|
136
|
+
}).end();
|
137
|
+
};
|
138
|
+
|
139
|
+
objPos(tip, (target.offset().top + this.outerHeight(target) + 10), 'auto', 'auto', target.offset().left, width);
|
140
|
+
|
141
|
+
if ($(window).width() < 767) {
|
142
|
+
objPos(tip, (target.offset().top + this.outerHeight(target) + 10), 'auto', 'auto', 12.5, $(this.scope).width());
|
143
|
+
tip.addClass('tip-override');
|
144
|
+
objPos(nub, -nubHeight, 'auto', 'auto', target.offset().left);
|
145
|
+
} else {
|
146
|
+
var left = target.offset().left;
|
147
|
+
if (Foundation.rtl) {
|
148
|
+
left = target.offset().left + target.offset().width - this.outerWidth(tip);
|
149
|
+
}
|
150
|
+
objPos(tip, (target.offset().top + this.outerHeight(target) + 10), 'auto', 'auto', left, width);
|
151
|
+
tip.removeClass('tip-override');
|
152
|
+
if (classes && classes.indexOf('tip-top') > -1) {
|
153
|
+
objPos(tip, (target.offset().top - this.outerHeight(tip)), 'auto', 'auto', left, width)
|
154
|
+
.removeClass('tip-override');
|
155
|
+
} else if (classes && classes.indexOf('tip-left') > -1) {
|
156
|
+
objPos(tip, (target.offset().top + (this.outerHeight(target) / 2) - nubHeight*2.5), 'auto', 'auto', (target.offset().left - this.outerWidth(tip) - nubHeight), width)
|
157
|
+
.removeClass('tip-override');
|
158
|
+
} else if (classes && classes.indexOf('tip-right') > -1) {
|
159
|
+
objPos(tip, (target.offset().top + (this.outerHeight(target) / 2) - nubHeight*2.5), 'auto', 'auto', (target.offset().left + this.outerWidth(target) + nubHeight), width)
|
160
|
+
.removeClass('tip-override');
|
161
|
+
}
|
162
|
+
}
|
163
|
+
|
164
|
+
tip.css('visibility', 'visible').hide();
|
165
|
+
},
|
166
|
+
|
167
|
+
inheritable_classes : function (target) {
|
168
|
+
var inheritables = ['tip-top', 'tip-left', 'tip-bottom', 'tip-right', 'noradius'].concat(this.settings.additionalInheritableClasses),
|
169
|
+
classes = target.attr('class'),
|
170
|
+
filtered = classes ? $.map(classes.split(' '), function (el, i) {
|
171
|
+
if ($.inArray(el, inheritables) !== -1) {
|
172
|
+
return el;
|
173
|
+
}
|
174
|
+
}).join(' ') : '';
|
175
|
+
|
176
|
+
return $.trim(filtered);
|
177
|
+
},
|
178
|
+
|
179
|
+
show : function ($target) {
|
180
|
+
var $tip = this.getTip($target);
|
181
|
+
|
182
|
+
this.reposition($target, $tip, $target.attr('class'));
|
183
|
+
$tip.fadeIn(150);
|
184
|
+
},
|
185
|
+
|
186
|
+
hide : function ($target) {
|
187
|
+
var $tip = this.getTip($target);
|
188
|
+
|
189
|
+
$tip.fadeOut(150);
|
190
|
+
},
|
191
|
+
|
192
|
+
// deprecate reload
|
193
|
+
reload : function () {
|
194
|
+
var $self = $(this);
|
195
|
+
|
196
|
+
return ($self.data('fndtn-tooltips')) ? $self.foundationTooltips('destroy').foundationTooltips('init') : $self.foundationTooltips('init');
|
197
|
+
},
|
198
|
+
|
199
|
+
off : function () {
|
200
|
+
$(this.scope).off('.fndtn.tooltip');
|
201
|
+
$(this.settings.tooltipClass).each(function (i) {
|
202
|
+
$('[data-tooltip]').get(i).attr('title', $(this).text());
|
203
|
+
}).remove();
|
204
|
+
},
|
205
|
+
|
206
|
+
reflow : function () {}
|
207
|
+
};
|
208
|
+
}(Foundation.zj, this, this.document));
|