opsask 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.yardoc/checksums +4 -0
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +75 -0
- data/LICENSE +13 -0
- data/Rakefile +30 -0
- data/Readme.md +3 -0
- data/VERSION +1 -0
- data/bin/opsask +4 -0
- data/lib/opsask/app.rb +540 -0
- data/lib/opsask/main.rb +54 -0
- data/lib/opsask/metadata.rb +29 -0
- data/lib/opsask.rb +3 -0
- data/opsask.gemspec +29 -0
- data/public/css/foundation.css +5068 -0
- data/public/css/foundation.min.css +1 -0
- data/public/css/normalize.css +410 -0
- data/public/css/style.css +152 -0
- data/public/favicon.ico +0 -0
- data/public/fonts/DINMittelschriftStd.woff +0 -0
- data/public/img/.gitkeep +1 -0
- data/public/js/foundation/foundation.abide.js +256 -0
- data/public/js/foundation/foundation.accordion.js +49 -0
- data/public/js/foundation/foundation.alert.js +37 -0
- data/public/js/foundation/foundation.clearing.js +485 -0
- data/public/js/foundation/foundation.dropdown.js +208 -0
- data/public/js/foundation/foundation.equalizer.js +64 -0
- data/public/js/foundation/foundation.interchange.js +326 -0
- data/public/js/foundation/foundation.joyride.js +848 -0
- data/public/js/foundation/foundation.js +587 -0
- data/public/js/foundation/foundation.magellan.js +171 -0
- data/public/js/foundation/foundation.offcanvas.js +39 -0
- data/public/js/foundation/foundation.orbit.js +464 -0
- data/public/js/foundation/foundation.reveal.js +399 -0
- data/public/js/foundation/foundation.tab.js +58 -0
- data/public/js/foundation/foundation.tooltip.js +215 -0
- data/public/js/foundation/foundation.topbar.js +387 -0
- data/public/js/foundation/jquery.cookie.js +8 -0
- data/public/js/foundation.min.js +10 -0
- data/public/js/opsask.js +19 -0
- data/public/js/vendor/fastclick.js +9 -0
- data/public/js/vendor/jquery.cookie.js +8 -0
- data/public/js/vendor/jquery.js +26 -0
- data/public/js/vendor/modernizr.js +8 -0
- data/public/js/vendor/placeholder.js +2 -0
- data/tasks/generate-email-summary.rb +73 -0
- data/tasks/send-email-summary.sh +13 -0
- data/views/_components.erb +6 -0
- data/views/_count.erb +11 -0
- data/views/_flash.erb +3 -0
- data/views/_form.erb +37 -0
- data/views/_queue.erb +16 -0
- data/views/agile.erb +6 -0
- data/views/glance.erb +19 -0
- data/views/index.erb +27 -0
- data/views/layout.erb +43 -0
- data/views/stragglers.erb +6 -0
- data/views/untracked.erb +6 -0
- metadata +217 -0
@@ -0,0 +1,399 @@
|
|
1
|
+
;(function ($, window, document, undefined) {
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
Foundation.libs.reveal = {
|
5
|
+
name : 'reveal',
|
6
|
+
|
7
|
+
version : '5.1.1',
|
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
|
+
$.extend(true, this.settings, method, options);
|
39
|
+
this.bindings(method, options);
|
40
|
+
},
|
41
|
+
|
42
|
+
events : function (scope) {
|
43
|
+
var self = this,
|
44
|
+
S = self.S;
|
45
|
+
|
46
|
+
S(this.scope)
|
47
|
+
.off('.reveal')
|
48
|
+
.on('click.fndtn.reveal', '[' + this.add_namespace('data-reveal-id') + ']', function (e) {
|
49
|
+
e.preventDefault();
|
50
|
+
|
51
|
+
if (!self.locked) {
|
52
|
+
var element = S(this),
|
53
|
+
ajax = element.data(self.data_attr('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
|
+
S(document)
|
68
|
+
.on('click.fndtn.reveal', this.close_targets(), function (e) {
|
69
|
+
|
70
|
+
e.preventDefault();
|
71
|
+
|
72
|
+
if (!self.locked) {
|
73
|
+
var settings = S('[' + self.attr_name() + '].open').data(self.attr_name(true) + '-init'),
|
74
|
+
bg_clicked = S(e.target)[0] === S('.' + settings.bg_class)[0];
|
75
|
+
|
76
|
+
if (bg_clicked && !settings.close_on_background_click) {
|
77
|
+
return;
|
78
|
+
}
|
79
|
+
|
80
|
+
self.locked = true;
|
81
|
+
self.close.call(self, bg_clicked ? S('[' + self.attr_name() + '].open') : S(this).closest('[' + self.attr_name() + ']'));
|
82
|
+
}
|
83
|
+
});
|
84
|
+
|
85
|
+
if(S('[' + self.attr_name() + ']', this.scope).length > 0) {
|
86
|
+
S(this.scope)
|
87
|
+
// .off('.reveal')
|
88
|
+
.on('open.fndtn.reveal', this.settings.open)
|
89
|
+
.on('opened.fndtn.reveal', this.settings.opened)
|
90
|
+
.on('opened.fndtn.reveal', this.open_video)
|
91
|
+
.on('close.fndtn.reveal', this.settings.close)
|
92
|
+
.on('closed.fndtn.reveal', this.settings.closed)
|
93
|
+
.on('closed.fndtn.reveal', this.close_video);
|
94
|
+
} else {
|
95
|
+
S(this.scope)
|
96
|
+
// .off('.reveal')
|
97
|
+
.on('open.fndtn.reveal', '[' + self.attr_name() + ']', this.settings.open)
|
98
|
+
.on('opened.fndtn.reveal', '[' + self.attr_name() + ']', this.settings.opened)
|
99
|
+
.on('opened.fndtn.reveal', '[' + self.attr_name() + ']', this.open_video)
|
100
|
+
.on('close.fndtn.reveal', '[' + self.attr_name() + ']', this.settings.close)
|
101
|
+
.on('closed.fndtn.reveal', '[' + self.attr_name() + ']', this.settings.closed)
|
102
|
+
.on('closed.fndtn.reveal', '[' + self.attr_name() + ']', this.close_video);
|
103
|
+
}
|
104
|
+
|
105
|
+
return true;
|
106
|
+
},
|
107
|
+
|
108
|
+
// PATCH #3: turning on key up capture only when a reveal window is open
|
109
|
+
key_up_on : function (scope) {
|
110
|
+
var self = this;
|
111
|
+
|
112
|
+
// PATCH #1: fixing multiple keyup event trigger from single key press
|
113
|
+
self.S('body').off('keyup.fndtn.reveal').on('keyup.fndtn.reveal', function ( event ) {
|
114
|
+
var open_modal = self.S('[' + self.attr_name() + '].open'),
|
115
|
+
settings = open_modal.data(self.attr_name(true) + '-init');
|
116
|
+
// PATCH #2: making sure that the close event can be called only while unlocked,
|
117
|
+
// so that multiple keyup.fndtn.reveal events don't prevent clean closing of the reveal window.
|
118
|
+
if ( settings && event.which === 27 && settings.close_on_esc && !self.locked) { // 27 is the keycode for the Escape key
|
119
|
+
self.close.call(self, open_modal);
|
120
|
+
}
|
121
|
+
});
|
122
|
+
|
123
|
+
return true;
|
124
|
+
},
|
125
|
+
|
126
|
+
// PATCH #3: turning on key up capture only when a reveal window is open
|
127
|
+
key_up_off : function (scope) {
|
128
|
+
this.S('body').off('keyup.fndtn.reveal');
|
129
|
+
return true;
|
130
|
+
},
|
131
|
+
|
132
|
+
open : function (target, ajax_settings) {
|
133
|
+
var self = this;
|
134
|
+
if (target) {
|
135
|
+
if (typeof target.selector !== 'undefined') {
|
136
|
+
var modal = self.S('#' + target.data(self.data_attr('reveal-id')));
|
137
|
+
} else {
|
138
|
+
var modal = self.S(this.scope);
|
139
|
+
|
140
|
+
ajax_settings = target;
|
141
|
+
}
|
142
|
+
} else {
|
143
|
+
var modal = self.S(this.scope);
|
144
|
+
}
|
145
|
+
|
146
|
+
var settings = modal.data(self.attr_name(true) + '-init');
|
147
|
+
|
148
|
+
if (!modal.hasClass('open')) {
|
149
|
+
var open_modal = self.S('[' + self.attr_name() + '].open');
|
150
|
+
|
151
|
+
if (typeof modal.data('css-top') === 'undefined') {
|
152
|
+
modal.data('css-top', parseInt(modal.css('top'), 10))
|
153
|
+
.data('offset', this.cache_offset(modal));
|
154
|
+
}
|
155
|
+
|
156
|
+
this.key_up_on(modal); // PATCH #3: turning on key up capture only when a reveal window is open
|
157
|
+
modal.trigger('open');
|
158
|
+
|
159
|
+
if (open_modal.length < 1) {
|
160
|
+
this.toggle_bg(modal);
|
161
|
+
}
|
162
|
+
|
163
|
+
if (typeof ajax_settings === 'string') {
|
164
|
+
ajax_settings = {
|
165
|
+
url: ajax_settings
|
166
|
+
};
|
167
|
+
}
|
168
|
+
|
169
|
+
if (typeof ajax_settings === 'undefined' || !ajax_settings.url) {
|
170
|
+
if (open_modal.length > 0) {
|
171
|
+
var open_modal_settings = open_modal.data(self.attr_name(true) + '-init');
|
172
|
+
this.hide(open_modal, open_modal_settings.css.close);
|
173
|
+
}
|
174
|
+
|
175
|
+
this.show(modal, settings.css.open);
|
176
|
+
} else {
|
177
|
+
var old_success = typeof ajax_settings.success !== 'undefined' ? ajax_settings.success : null;
|
178
|
+
|
179
|
+
$.extend(ajax_settings, {
|
180
|
+
success: function (data, textStatus, jqXHR) {
|
181
|
+
if ( $.isFunction(old_success) ) {
|
182
|
+
old_success(data, textStatus, jqXHR);
|
183
|
+
}
|
184
|
+
|
185
|
+
modal.html(data);
|
186
|
+
self.S(modal).foundation('section', 'reflow');
|
187
|
+
|
188
|
+
if (open_modal.length > 0) {
|
189
|
+
var open_modal_settings = open_modal.data(self.attr_name(true));
|
190
|
+
self.hide(open_modal, open_modal_settings.css.close);
|
191
|
+
}
|
192
|
+
self.show(modal, settings.css.open);
|
193
|
+
}
|
194
|
+
});
|
195
|
+
|
196
|
+
$.ajax(ajax_settings);
|
197
|
+
}
|
198
|
+
}
|
199
|
+
},
|
200
|
+
|
201
|
+
close : function (modal) {
|
202
|
+
var modal = modal && modal.length ? modal : this.S(this.scope),
|
203
|
+
open_modals = this.S('[' + this.attr_name() + '].open'),
|
204
|
+
settings = modal.data(this.attr_name(true) + '-init');
|
205
|
+
|
206
|
+
if (open_modals.length > 0) {
|
207
|
+
this.locked = true;
|
208
|
+
this.key_up_off(modal); // PATCH #3: turning on key up capture only when a reveal window is open
|
209
|
+
modal.trigger('close');
|
210
|
+
this.toggle_bg(modal);
|
211
|
+
this.hide(open_modals, settings.css.close, settings);
|
212
|
+
}
|
213
|
+
},
|
214
|
+
|
215
|
+
close_targets : function () {
|
216
|
+
var base = '.' + this.settings.dismiss_modal_class;
|
217
|
+
|
218
|
+
if (this.settings.close_on_background_click) {
|
219
|
+
return base + ', .' + this.settings.bg_class;
|
220
|
+
}
|
221
|
+
|
222
|
+
return base;
|
223
|
+
},
|
224
|
+
|
225
|
+
toggle_bg : function (modal) {
|
226
|
+
var settings = modal.data(this.attr_name(true));
|
227
|
+
|
228
|
+
if (this.S('.' + this.settings.bg_class).length === 0) {
|
229
|
+
this.settings.bg = $('<div />', {'class': this.settings.bg_class})
|
230
|
+
.appendTo('body');
|
231
|
+
}
|
232
|
+
|
233
|
+
if (this.settings.bg.filter(':visible').length > 0) {
|
234
|
+
this.hide(this.settings.bg);
|
235
|
+
} else {
|
236
|
+
this.show(this.settings.bg);
|
237
|
+
}
|
238
|
+
},
|
239
|
+
|
240
|
+
show : function (el, css) {
|
241
|
+
// is modal
|
242
|
+
if (css) {
|
243
|
+
var settings = el.data(this.attr_name(true) + '-init');
|
244
|
+
if (el.parent('body').length === 0) {
|
245
|
+
var placeholder = el.wrap('<div style="display: none;" />').parent(),
|
246
|
+
rootElement = this.settings.rootElement || 'body';
|
247
|
+
|
248
|
+
el.on('closed.fndtn.reveal.wrapped', function() {
|
249
|
+
el.detach().appendTo(placeholder);
|
250
|
+
el.unwrap().unbind('closed.fndtn.reveal.wrapped');
|
251
|
+
});
|
252
|
+
|
253
|
+
el.detach().appendTo(rootElement);
|
254
|
+
}
|
255
|
+
|
256
|
+
if (/pop/i.test(settings.animation)) {
|
257
|
+
css.top = $(window).scrollTop() - el.data('offset') + 'px';
|
258
|
+
var end_css = {
|
259
|
+
top: $(window).scrollTop() + el.data('css-top') + 'px',
|
260
|
+
opacity: 1
|
261
|
+
};
|
262
|
+
|
263
|
+
return setTimeout(function () {
|
264
|
+
return el
|
265
|
+
.css(css)
|
266
|
+
.animate(end_css, settings.animation_speed, 'linear', function () {
|
267
|
+
this.locked = false;
|
268
|
+
el.trigger('opened');
|
269
|
+
}.bind(this))
|
270
|
+
.addClass('open');
|
271
|
+
}.bind(this), settings.animation_speed / 2);
|
272
|
+
}
|
273
|
+
|
274
|
+
if (/fade/i.test(settings.animation)) {
|
275
|
+
var end_css = {opacity: 1};
|
276
|
+
|
277
|
+
return setTimeout(function () {
|
278
|
+
return el
|
279
|
+
.css(css)
|
280
|
+
.animate(end_css, settings.animation_speed, 'linear', function () {
|
281
|
+
this.locked = false;
|
282
|
+
el.trigger('opened');
|
283
|
+
}.bind(this))
|
284
|
+
.addClass('open');
|
285
|
+
}.bind(this), settings.animation_speed / 2);
|
286
|
+
}
|
287
|
+
|
288
|
+
return el.css(css).show().css({opacity: 1}).addClass('open').trigger('opened');
|
289
|
+
}
|
290
|
+
|
291
|
+
var settings = this.settings;
|
292
|
+
|
293
|
+
// should we animate the background?
|
294
|
+
if (/fade/i.test(settings.animation)) {
|
295
|
+
return el.fadeIn(settings.animation_speed / 2);
|
296
|
+
}
|
297
|
+
|
298
|
+
this.locked = false;
|
299
|
+
|
300
|
+
return el.show();
|
301
|
+
},
|
302
|
+
|
303
|
+
hide : function (el, css) {
|
304
|
+
// is modal
|
305
|
+
if (css) {
|
306
|
+
var settings = el.data(this.attr_name(true) + '-init');
|
307
|
+
if (/pop/i.test(settings.animation)) {
|
308
|
+
var end_css = {
|
309
|
+
top: - $(window).scrollTop() - el.data('offset') + 'px',
|
310
|
+
opacity: 0
|
311
|
+
};
|
312
|
+
|
313
|
+
return setTimeout(function () {
|
314
|
+
return el
|
315
|
+
.animate(end_css, settings.animation_speed, 'linear', function () {
|
316
|
+
this.locked = false;
|
317
|
+
el.css(css).trigger('closed');
|
318
|
+
}.bind(this))
|
319
|
+
.removeClass('open');
|
320
|
+
}.bind(this), settings.animation_speed / 2);
|
321
|
+
}
|
322
|
+
|
323
|
+
if (/fade/i.test(settings.animation)) {
|
324
|
+
var end_css = {opacity: 0};
|
325
|
+
|
326
|
+
return setTimeout(function () {
|
327
|
+
return el
|
328
|
+
.animate(end_css, settings.animation_speed, 'linear', function () {
|
329
|
+
this.locked = false;
|
330
|
+
el.css(css).trigger('closed');
|
331
|
+
}.bind(this))
|
332
|
+
.removeClass('open');
|
333
|
+
}.bind(this), settings.animation_speed / 2);
|
334
|
+
}
|
335
|
+
|
336
|
+
return el.hide().css(css).removeClass('open').trigger('closed');
|
337
|
+
}
|
338
|
+
|
339
|
+
var settings = this.settings;
|
340
|
+
|
341
|
+
// should we animate the background?
|
342
|
+
if (/fade/i.test(settings.animation)) {
|
343
|
+
return el.fadeOut(settings.animation_speed / 2);
|
344
|
+
}
|
345
|
+
|
346
|
+
return el.hide();
|
347
|
+
},
|
348
|
+
|
349
|
+
close_video : function (e) {
|
350
|
+
var video = $('.flex-video', e.target),
|
351
|
+
iframe = $('iframe', video);
|
352
|
+
|
353
|
+
if (iframe.length > 0) {
|
354
|
+
iframe.attr('data-src', iframe[0].src);
|
355
|
+
iframe.attr('src', 'about:blank');
|
356
|
+
video.hide();
|
357
|
+
}
|
358
|
+
},
|
359
|
+
|
360
|
+
open_video : function (e) {
|
361
|
+
var video = $('.flex-video', e.target),
|
362
|
+
iframe = video.find('iframe');
|
363
|
+
|
364
|
+
if (iframe.length > 0) {
|
365
|
+
var data_src = iframe.attr('data-src');
|
366
|
+
if (typeof data_src === 'string') {
|
367
|
+
iframe[0].src = iframe.attr('data-src');
|
368
|
+
} else {
|
369
|
+
var src = iframe[0].src;
|
370
|
+
iframe[0].src = undefined;
|
371
|
+
iframe[0].src = src;
|
372
|
+
}
|
373
|
+
video.show();
|
374
|
+
}
|
375
|
+
},
|
376
|
+
|
377
|
+
data_attr: function (str) {
|
378
|
+
if (this.namespace.length > 0) {
|
379
|
+
return this.namespace + '-' + str;
|
380
|
+
}
|
381
|
+
|
382
|
+
return str;
|
383
|
+
},
|
384
|
+
|
385
|
+
cache_offset : function (modal) {
|
386
|
+
var offset = modal.show().height() + parseInt(modal.css('top'), 10);
|
387
|
+
|
388
|
+
modal.hide();
|
389
|
+
|
390
|
+
return offset;
|
391
|
+
},
|
392
|
+
|
393
|
+
off : function () {
|
394
|
+
$(this.scope).off('.fndtn.reveal');
|
395
|
+
},
|
396
|
+
|
397
|
+
reflow : function () {}
|
398
|
+
};
|
399
|
+
}(jQuery, this, this.document));
|
@@ -0,0 +1,58 @@
|
|
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.1.1',
|
9
|
+
|
10
|
+
settings : {
|
11
|
+
active_class: 'active',
|
12
|
+
callback : function () {}
|
13
|
+
},
|
14
|
+
|
15
|
+
init : function (scope, method, options) {
|
16
|
+
this.bindings(method, options);
|
17
|
+
},
|
18
|
+
|
19
|
+
events : function () {
|
20
|
+
var self = this,
|
21
|
+
S = this.S;
|
22
|
+
|
23
|
+
S(this.scope).off('.tab').on('click.fndtn.tab', '[' + this.attr_name() + '] > dd > a', function (e) {
|
24
|
+
e.preventDefault();
|
25
|
+
e.stopPropagation();
|
26
|
+
|
27
|
+
var tab = S(this).parent(),
|
28
|
+
tabs = tab.closest('[' + self.attr_name() + ']'),
|
29
|
+
target = S('#' + this.href.split('#')[1]),
|
30
|
+
siblings = tab.siblings(),
|
31
|
+
settings = tabs.data(self.attr_name(true) + '-init');
|
32
|
+
|
33
|
+
// allow usage of data-tab-content attribute instead of href
|
34
|
+
if (S(this).data(self.data_attr('tab-content'))) {
|
35
|
+
target = S('#' + S(this).data(self.data_attr('tab-content')).split('#')[1]);
|
36
|
+
}
|
37
|
+
|
38
|
+
tab.addClass(settings.active_class).triggerHandler('opened');
|
39
|
+
siblings.removeClass(settings.active_class);
|
40
|
+
target.siblings().removeClass(settings.active_class).end().addClass(settings.active_class);
|
41
|
+
settings.callback(tab);
|
42
|
+
tabs.triggerHandler('toggled', [tab]);
|
43
|
+
});
|
44
|
+
},
|
45
|
+
|
46
|
+
data_attr: function (str) {
|
47
|
+
if (this.namespace.length > 0) {
|
48
|
+
return this.namespace + '-' + str;
|
49
|
+
}
|
50
|
+
|
51
|
+
return str;
|
52
|
+
},
|
53
|
+
|
54
|
+
off : function () {},
|
55
|
+
|
56
|
+
reflow : function () {}
|
57
|
+
};
|
58
|
+
}(jQuery, this, this.document));
|
@@ -0,0 +1,215 @@
|
|
1
|
+
;(function ($, window, document, undefined) {
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
Foundation.libs.tooltip = {
|
5
|
+
name : 'tooltip',
|
6
|
+
|
7
|
+
version : '5.1.1',
|
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
|
+
hover_delay: 200,
|
16
|
+
tip_template : function (selector, content) {
|
17
|
+
return '<span data-selector="' + selector + '" class="'
|
18
|
+
+ Foundation.libs.tooltip.settings.tooltip_class.substring(1)
|
19
|
+
+ '">' + content + '<span class="nub"></span></span>';
|
20
|
+
}
|
21
|
+
},
|
22
|
+
|
23
|
+
cache : {},
|
24
|
+
|
25
|
+
init : function (scope, method, options) {
|
26
|
+
Foundation.inherit(this, 'random_str');
|
27
|
+
this.bindings(method, options);
|
28
|
+
},
|
29
|
+
|
30
|
+
events : function () {
|
31
|
+
var self = this,
|
32
|
+
S = self.S;
|
33
|
+
|
34
|
+
if (Modernizr.touch) {
|
35
|
+
S(document)
|
36
|
+
.off('.tooltip')
|
37
|
+
.on('click.fndtn.tooltip touchstart.fndtn.tooltip touchend.fndtn.tooltip',
|
38
|
+
'[' + this.attr_name() + ']:not(a)', function (e) {
|
39
|
+
var settings = $.extend({}, self.settings, self.data_options(S(this)));
|
40
|
+
if (!settings.disable_for_touch) {
|
41
|
+
e.preventDefault();
|
42
|
+
S(settings.tooltip_class).hide();
|
43
|
+
self.showOrCreateTip(S(this));
|
44
|
+
}
|
45
|
+
})
|
46
|
+
.on('click.fndtn.tooltip touchstart.fndtn.tooltip touchend.fndtn.tooltip',
|
47
|
+
this.settings.tooltip_class, function (e) {
|
48
|
+
e.preventDefault();
|
49
|
+
S(this).fadeOut(150);
|
50
|
+
});
|
51
|
+
} else {
|
52
|
+
S(document)
|
53
|
+
.off('.tooltip')
|
54
|
+
.on('mouseenter.fndtn.tooltip mouseleave.fndtn.tooltip',
|
55
|
+
'[' + this.attr_name() + ']', function (e) {
|
56
|
+
var $this = S(this);
|
57
|
+
|
58
|
+
if (/enter|over/i.test(e.type)) {
|
59
|
+
this.timer = setTimeout(function () {
|
60
|
+
var tip = self.showOrCreateTip($this);
|
61
|
+
}.bind(this), self.settings.hover_delay);
|
62
|
+
} else if (e.type === 'mouseout' || e.type === 'mouseleave') {
|
63
|
+
clearTimeout(this.timer);
|
64
|
+
self.hide($this);
|
65
|
+
}
|
66
|
+
});
|
67
|
+
}
|
68
|
+
},
|
69
|
+
|
70
|
+
showOrCreateTip : function ($target) {
|
71
|
+
var $tip = this.getTip($target);
|
72
|
+
|
73
|
+
if ($tip && $tip.length > 0) {
|
74
|
+
return this.show($target);
|
75
|
+
}
|
76
|
+
|
77
|
+
return this.create($target);
|
78
|
+
},
|
79
|
+
|
80
|
+
getTip : function ($target) {
|
81
|
+
var selector = this.selector($target),
|
82
|
+
tip = null;
|
83
|
+
|
84
|
+
if (selector) {
|
85
|
+
tip = this.S('span[data-selector="' + selector + '"]' + this.settings.tooltip_class);
|
86
|
+
}
|
87
|
+
|
88
|
+
return (typeof tip === 'object') ? tip : false;
|
89
|
+
},
|
90
|
+
|
91
|
+
selector : function ($target) {
|
92
|
+
var id = $target.attr('id'),
|
93
|
+
dataSelector = $target.attr(this.attr_name()) || $target.attr('data-selector');
|
94
|
+
|
95
|
+
if ((id && id.length < 1 || !id) && typeof dataSelector != 'string') {
|
96
|
+
dataSelector = 'tooltip' + this.random_str(6);
|
97
|
+
$target.attr('data-selector', dataSelector);
|
98
|
+
}
|
99
|
+
|
100
|
+
return (id && id.length > 0) ? id : dataSelector;
|
101
|
+
},
|
102
|
+
|
103
|
+
create : function ($target) {
|
104
|
+
var $tip = $(this.settings.tip_template(this.selector($target), $('<div></div>').html($target.attr('title')).html())),
|
105
|
+
classes = this.inheritable_classes($target);
|
106
|
+
|
107
|
+
$tip.addClass(classes).appendTo(this.settings.append_to);
|
108
|
+
if (Modernizr.touch) {
|
109
|
+
$tip.append('<span class="tap-to-close">'+this.settings.touch_close_text+'</span>');
|
110
|
+
}
|
111
|
+
$target.removeAttr('title').attr('title','');
|
112
|
+
this.show($target);
|
113
|
+
},
|
114
|
+
|
115
|
+
reposition : function (target, tip, classes) {
|
116
|
+
var width, nub, nubHeight, nubWidth, column, objPos;
|
117
|
+
|
118
|
+
tip.css('visibility', 'hidden').show();
|
119
|
+
|
120
|
+
width = target.data('width');
|
121
|
+
nub = tip.children('.nub');
|
122
|
+
nubHeight = nub.outerHeight();
|
123
|
+
nubWidth = nub.outerHeight();
|
124
|
+
|
125
|
+
if(this.small()) {
|
126
|
+
tip.css({'width' : '100%' });
|
127
|
+
} else {
|
128
|
+
tip.css({'width' : (width) ? width : 'auto'});
|
129
|
+
}
|
130
|
+
|
131
|
+
objPos = function (obj, top, right, bottom, left, width) {
|
132
|
+
return obj.css({
|
133
|
+
'top' : (top) ? top : 'auto',
|
134
|
+
'bottom' : (bottom) ? bottom : 'auto',
|
135
|
+
'left' : (left) ? left : 'auto',
|
136
|
+
'right' : (right) ? right : 'auto'
|
137
|
+
}).end();
|
138
|
+
};
|
139
|
+
|
140
|
+
objPos(tip, (target.offset().top + target.outerHeight() + 10), 'auto', 'auto', target.offset().left);
|
141
|
+
|
142
|
+
if (this.small()) {
|
143
|
+
objPos(tip, (target.offset().top + target.outerHeight() + 10), 'auto', 'auto', 12.5, this.S(this.scope).width());
|
144
|
+
tip.addClass('tip-override');
|
145
|
+
objPos(nub, -nubHeight, 'auto', 'auto', target.offset().left + 10);
|
146
|
+
} else {
|
147
|
+
var left = target.offset().left;
|
148
|
+
if (Foundation.rtl) {
|
149
|
+
left = target.offset().left + target.outerWidth() - tip.outerWidth();
|
150
|
+
}
|
151
|
+
|
152
|
+
objPos(tip, (target.offset().top + target.outerHeight() + 10), 'auto', 'auto', left);
|
153
|
+
tip.removeClass('tip-override');
|
154
|
+
nub.removeAttr( 'style' );
|
155
|
+
if (classes && classes.indexOf('tip-top') > -1) {
|
156
|
+
objPos(tip, (target.offset().top - tip.outerHeight() - 10), 'auto', 'auto', left)
|
157
|
+
.removeClass('tip-override');
|
158
|
+
} else if (classes && classes.indexOf('tip-left') > -1) {
|
159
|
+
objPos(tip, (target.offset().top + (target.outerHeight() / 2) - (tip.outerHeight() / 2)), 'auto', 'auto', (target.offset().left - tip.outerWidth() - nubHeight))
|
160
|
+
.removeClass('tip-override');
|
161
|
+
} else if (classes && classes.indexOf('tip-right') > -1) {
|
162
|
+
objPos(tip, (target.offset().top + (target.outerHeight() / 2) - (tip.outerHeight() / 2)), 'auto', 'auto', (target.offset().left + target.outerWidth() + nubHeight))
|
163
|
+
.removeClass('tip-override');
|
164
|
+
}
|
165
|
+
}
|
166
|
+
|
167
|
+
tip.css('visibility', 'visible').hide();
|
168
|
+
},
|
169
|
+
|
170
|
+
small : function () {
|
171
|
+
return matchMedia(Foundation.media_queries.small).matches;
|
172
|
+
},
|
173
|
+
|
174
|
+
inheritable_classes : function (target) {
|
175
|
+
var inheritables = ['tip-top', 'tip-left', 'tip-bottom', 'tip-right', 'radius', 'round'].concat(this.settings.additional_inheritable_classes),
|
176
|
+
classes = target.attr('class'),
|
177
|
+
filtered = classes ? $.map(classes.split(' '), function (el, i) {
|
178
|
+
if ($.inArray(el, inheritables) !== -1) {
|
179
|
+
return el;
|
180
|
+
}
|
181
|
+
}).join(' ') : '';
|
182
|
+
|
183
|
+
return $.trim(filtered);
|
184
|
+
},
|
185
|
+
|
186
|
+
show : function ($target) {
|
187
|
+
var $tip = this.getTip($target);
|
188
|
+
|
189
|
+
this.reposition($target, $tip, $target.attr('class'));
|
190
|
+
return $tip.fadeIn(150);
|
191
|
+
},
|
192
|
+
|
193
|
+
hide : function ($target) {
|
194
|
+
var $tip = this.getTip($target);
|
195
|
+
|
196
|
+
return $tip.fadeOut(150);
|
197
|
+
},
|
198
|
+
|
199
|
+
// deprecate reload
|
200
|
+
reload : function () {
|
201
|
+
var $self = $(this);
|
202
|
+
|
203
|
+
return ($self.data('fndtn-tooltips')) ? $self.foundationTooltips('destroy').foundationTooltips('init') : $self.foundationTooltips('init');
|
204
|
+
},
|
205
|
+
|
206
|
+
off : function () {
|
207
|
+
this.S(this.scope).off('.fndtn.tooltip');
|
208
|
+
this.S(this.settings.tooltip_class).each(function (i) {
|
209
|
+
$('[' + this.attr_name() + ']').get(i).attr('title', $(this).text());
|
210
|
+
}).remove();
|
211
|
+
},
|
212
|
+
|
213
|
+
reflow : function () {}
|
214
|
+
};
|
215
|
+
}(jQuery, this, this.document));
|