semantic-ui-rails 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +26 -0
- data/Rakefile +1 -0
- data/lib/generators/semantic/install/install_generator.rb +38 -0
- data/lib/generators/semantic/install/templates/semantic-ui.js +21 -0
- data/lib/generators/semantic/install/templates/semantic-ui/collections.less +6 -0
- data/lib/generators/semantic/install/templates/semantic-ui/elements.less +11 -0
- data/lib/generators/semantic/install/templates/semantic-ui/modules.less +18 -0
- data/lib/generators/semantic/install/templates/semantic-ui/views.less +6 -0
- data/lib/semantic/ui/rails.rb +10 -0
- data/lib/semantic/ui/rails/engine.rb +8 -0
- data/lib/semantic/ui/rails/version.rb +7 -0
- data/semantic-ui-rails.gemspec +23 -0
- data/vendor/assets/fonts/icons.eot +0 -0
- data/vendor/assets/fonts/icons.svg +450 -0
- data/vendor/assets/fonts/icons.ttf +0 -0
- data/vendor/assets/fonts/icons.woff +0 -0
- data/vendor/assets/images/semantic-ui/loader-large-inverted.gif +0 -0
- data/vendor/assets/images/semantic-ui/loader-large.gif +0 -0
- data/vendor/assets/images/semantic-ui/loader-medium-inverted.gif +0 -0
- data/vendor/assets/images/semantic-ui/loader-medium.gif +0 -0
- data/vendor/assets/images/semantic-ui/loader-mini-inverted.gif +0 -0
- data/vendor/assets/images/semantic-ui/loader-mini.gif +0 -0
- data/vendor/assets/images/semantic-ui/loader-small-inverted.gif +0 -0
- data/vendor/assets/images/semantic-ui/loader-small.gif +0 -0
- data/vendor/assets/javascripts/semantic-ui/accordion.js +411 -0
- data/vendor/assets/javascripts/semantic-ui/behavior/api.js +666 -0
- data/vendor/assets/javascripts/semantic-ui/behavior/colorize.js +271 -0
- data/vendor/assets/javascripts/semantic-ui/behavior/form.js +657 -0
- data/vendor/assets/javascripts/semantic-ui/behavior/state.js +752 -0
- data/vendor/assets/javascripts/semantic-ui/carousel.js +327 -0
- data/vendor/assets/javascripts/semantic-ui/chatroom.js +766 -0
- data/vendor/assets/javascripts/semantic-ui/checkbox.js +348 -0
- data/vendor/assets/javascripts/semantic-ui/dimmer.js +525 -0
- data/vendor/assets/javascripts/semantic-ui/dropdown.js +697 -0
- data/vendor/assets/javascripts/semantic-ui/modal.js +478 -0
- data/vendor/assets/javascripts/semantic-ui/nag.js +542 -0
- data/vendor/assets/javascripts/semantic-ui/popup.js +721 -0
- data/vendor/assets/javascripts/semantic-ui/rating.js +358 -0
- data/vendor/assets/javascripts/semantic-ui/search.js +770 -0
- data/vendor/assets/javascripts/semantic-ui/shape.js +776 -0
- data/vendor/assets/javascripts/semantic-ui/sidebar.js +489 -0
- data/vendor/assets/javascripts/semantic-ui/tab.js +674 -0
- data/vendor/assets/javascripts/semantic-ui/transition.js +645 -0
- data/vendor/assets/javascripts/semantic-ui/video.js +459 -0
- data/vendor/assets/stylesheets/semantic-ui/collections/breadcrumb.less +79 -0
- data/vendor/assets/stylesheets/semantic-ui/collections/form.less +536 -0
- data/vendor/assets/stylesheets/semantic-ui/collections/grid.less +655 -0
- data/vendor/assets/stylesheets/semantic-ui/collections/menu.less +1736 -0
- data/vendor/assets/stylesheets/semantic-ui/collections/message.less +337 -0
- data/vendor/assets/stylesheets/semantic-ui/collections/table.less +526 -0
- data/vendor/assets/stylesheets/semantic-ui/elements/button.less +1294 -0
- data/vendor/assets/stylesheets/semantic-ui/elements/divider.less +200 -0
- data/vendor/assets/stylesheets/semantic-ui/elements/header.less +325 -0
- data/vendor/assets/stylesheets/semantic-ui/elements/icon.less +449 -0
- data/vendor/assets/stylesheets/semantic-ui/elements/image.less +170 -0
- data/vendor/assets/stylesheets/semantic-ui/elements/input.less +287 -0
- data/vendor/assets/stylesheets/semantic-ui/elements/label.less +805 -0
- data/vendor/assets/stylesheets/semantic-ui/elements/loader.less +178 -0
- data/vendor/assets/stylesheets/semantic-ui/elements/progress.less +353 -0
- data/vendor/assets/stylesheets/semantic-ui/elements/segment.less +465 -0
- data/vendor/assets/stylesheets/semantic-ui/elements/step.less +294 -0
- data/vendor/assets/stylesheets/semantic-ui/modules/accordion.less +135 -0
- data/vendor/assets/stylesheets/semantic-ui/modules/carousel.less +71 -0
- data/vendor/assets/stylesheets/semantic-ui/modules/chatroom.less +271 -0
- data/vendor/assets/stylesheets/semantic-ui/modules/checkbox.less +378 -0
- data/vendor/assets/stylesheets/semantic-ui/modules/dimmer.less +230 -0
- data/vendor/assets/stylesheets/semantic-ui/modules/dropdown.less +506 -0
- data/vendor/assets/stylesheets/semantic-ui/modules/extra.transition.less +1197 -0
- data/vendor/assets/stylesheets/semantic-ui/modules/modal.less +154 -0
- data/vendor/assets/stylesheets/semantic-ui/modules/nag.less +175 -0
- data/vendor/assets/stylesheets/semantic-ui/modules/popup.less +238 -0
- data/vendor/assets/stylesheets/semantic-ui/modules/rating.less +151 -0
- data/vendor/assets/stylesheets/semantic-ui/modules/reveal.less +367 -0
- data/vendor/assets/stylesheets/semantic-ui/modules/search.less +275 -0
- data/vendor/assets/stylesheets/semantic-ui/modules/shape.less +115 -0
- data/vendor/assets/stylesheets/semantic-ui/modules/sidebar.less +147 -0
- data/vendor/assets/stylesheets/semantic-ui/modules/tab.less +59 -0
- data/vendor/assets/stylesheets/semantic-ui/modules/transition.less +839 -0
- data/vendor/assets/stylesheets/semantic-ui/modules/video.less +99 -0
- data/vendor/assets/stylesheets/semantic-ui/views/comment.less +221 -0
- data/vendor/assets/stylesheets/semantic-ui/views/feed.less +151 -0
- data/vendor/assets/stylesheets/semantic-ui/views/item.less +641 -0
- data/vendor/assets/stylesheets/semantic-ui/views/list.less +491 -0
- data/vendor/assets/stylesheets/semantic-ui/views/sitemap.less +47 -0
- data/vendor/assets/stylesheets/semantic-ui/views/statistic.less +34 -0
- metadata +161 -0
@@ -0,0 +1,721 @@
|
|
1
|
+
/* ******************************
|
2
|
+
Semantic Module: Popup
|
3
|
+
Author: Jack Lukic
|
4
|
+
Notes: May 30, 2013
|
5
|
+
|
6
|
+
Simple plug-in to display popups
|
7
|
+
|
8
|
+
****************************** */
|
9
|
+
|
10
|
+
;(function ($, window, document, undefined) {
|
11
|
+
|
12
|
+
$.fn.popup = function(parameters) {
|
13
|
+
var
|
14
|
+
$allModules = $(this),
|
15
|
+
|
16
|
+
settings = ( $.isPlainObject(parameters) )
|
17
|
+
? $.extend(true, {}, $.fn.popup.settings, parameters)
|
18
|
+
: $.fn.popup.settings,
|
19
|
+
|
20
|
+
moduleSelector = $allModules.selector || '',
|
21
|
+
|
22
|
+
time = new Date().getTime(),
|
23
|
+
performance = [],
|
24
|
+
|
25
|
+
query = arguments[0],
|
26
|
+
methodInvoked = (typeof query == 'string'),
|
27
|
+
queryArguments = [].slice.call(arguments, 1),
|
28
|
+
|
29
|
+
invokedResponse
|
30
|
+
;
|
31
|
+
$allModules
|
32
|
+
.each(function() {
|
33
|
+
var
|
34
|
+
$module = $(this),
|
35
|
+
|
36
|
+
$window = $(window),
|
37
|
+
$offsetParent = $module.offsetParent(),
|
38
|
+
$popup = (settings.inline)
|
39
|
+
? $module.next(settings.selector.popup)
|
40
|
+
: $window.children(settings.selector.popup).last(),
|
41
|
+
|
42
|
+
searchDepth = 0,
|
43
|
+
|
44
|
+
eventNamespace = '.' + settings.namespace,
|
45
|
+
moduleNamespace = settings.namespace + '-module',
|
46
|
+
|
47
|
+
selector = settings.selector,
|
48
|
+
className = settings.className,
|
49
|
+
error = settings.error,
|
50
|
+
metadata = settings.metadata,
|
51
|
+
namespace = settings.namespace,
|
52
|
+
|
53
|
+
element = this,
|
54
|
+
instance = $module.data(moduleNamespace),
|
55
|
+
module
|
56
|
+
;
|
57
|
+
|
58
|
+
module = {
|
59
|
+
|
60
|
+
// binds events
|
61
|
+
initialize: function() {
|
62
|
+
module.debug('Initializing module', $module);
|
63
|
+
if(settings.on == 'hover') {
|
64
|
+
$module
|
65
|
+
.on('mouseenter' + eventNamespace, module.event.mouseenter)
|
66
|
+
.on('mouseleave' + eventNamespace, module.event.mouseleave)
|
67
|
+
;
|
68
|
+
}
|
69
|
+
else {
|
70
|
+
$module
|
71
|
+
.on(settings.on + '' + eventNamespace, module.event[settings.on])
|
72
|
+
;
|
73
|
+
}
|
74
|
+
$window
|
75
|
+
.on('resize' + eventNamespace, module.event.resize)
|
76
|
+
;
|
77
|
+
module.instantiate();
|
78
|
+
},
|
79
|
+
|
80
|
+
instantiate: function() {
|
81
|
+
module.verbose('Storing instance of module', module);
|
82
|
+
instance = module;
|
83
|
+
$module
|
84
|
+
.data(moduleNamespace, instance)
|
85
|
+
;
|
86
|
+
},
|
87
|
+
|
88
|
+
refresh: function() {
|
89
|
+
$popup = (settings.inline)
|
90
|
+
? $module.next(selector.popup)
|
91
|
+
: $window.children(selector.popup).last()
|
92
|
+
;
|
93
|
+
$offsetParent = $module.offsetParent();
|
94
|
+
},
|
95
|
+
|
96
|
+
destroy: function() {
|
97
|
+
module.debug('Destroying previous module');
|
98
|
+
$module
|
99
|
+
.off(eventNamespace)
|
100
|
+
.removeData(moduleNamespace)
|
101
|
+
;
|
102
|
+
},
|
103
|
+
|
104
|
+
event: {
|
105
|
+
mouseenter: function(event) {
|
106
|
+
var element = this;
|
107
|
+
module.timer = setTimeout(function() {
|
108
|
+
$.proxy(module.toggle, element)();
|
109
|
+
if( $(element).hasClass(className.visible) ) {
|
110
|
+
event.stopPropagation();
|
111
|
+
}
|
112
|
+
}, settings.delay);
|
113
|
+
},
|
114
|
+
mouseleave: function() {
|
115
|
+
clearTimeout(module.timer);
|
116
|
+
if( $module.is(':visible') ) {
|
117
|
+
module.hide();
|
118
|
+
}
|
119
|
+
},
|
120
|
+
click: function(event) {
|
121
|
+
$.proxy(module.toggle, this)();
|
122
|
+
if( $(this).hasClass(className.visible) ) {
|
123
|
+
event.stopPropagation();
|
124
|
+
}
|
125
|
+
},
|
126
|
+
resize: function() {
|
127
|
+
if( $popup.is(':visible') ) {
|
128
|
+
module.position();
|
129
|
+
}
|
130
|
+
}
|
131
|
+
},
|
132
|
+
|
133
|
+
// generates popup html from metadata
|
134
|
+
create: function() {
|
135
|
+
module.debug('Creating pop-up html');
|
136
|
+
var
|
137
|
+
html = $module.data(metadata.html) || settings.html,
|
138
|
+
variation = $module.data(metadata.variation) || settings.variation,
|
139
|
+
title = $module.data(metadata.title) || settings.title,
|
140
|
+
content = $module.data(metadata.content) || $module.attr('title') || settings.content
|
141
|
+
;
|
142
|
+
if(html || content || title) {
|
143
|
+
if(!html) {
|
144
|
+
html = settings.template({
|
145
|
+
title : title,
|
146
|
+
content : content
|
147
|
+
});
|
148
|
+
}
|
149
|
+
$popup = $('<div/>')
|
150
|
+
.addClass(className.popup)
|
151
|
+
.addClass(variation)
|
152
|
+
.html(html)
|
153
|
+
;
|
154
|
+
if(settings.inline) {
|
155
|
+
module.verbose('Inserting popup element inline');
|
156
|
+
$popup
|
157
|
+
.insertAfter($module)
|
158
|
+
;
|
159
|
+
}
|
160
|
+
else {
|
161
|
+
module.verbose('Appending popup element to body');
|
162
|
+
$popup
|
163
|
+
.appendTo( $('body') )
|
164
|
+
;
|
165
|
+
}
|
166
|
+
$.proxy(settings.onInit, $popup)();
|
167
|
+
}
|
168
|
+
else {
|
169
|
+
module.error(error.content);
|
170
|
+
}
|
171
|
+
},
|
172
|
+
|
173
|
+
remove: function() {
|
174
|
+
module.debug('Removing popup');
|
175
|
+
$popup
|
176
|
+
.remove()
|
177
|
+
;
|
178
|
+
},
|
179
|
+
|
180
|
+
get: {
|
181
|
+
offstagePosition: function() {
|
182
|
+
var
|
183
|
+
boundary = {
|
184
|
+
top : $(window).scrollTop(),
|
185
|
+
bottom : $(window).scrollTop() + $(window).height(),
|
186
|
+
left : 0,
|
187
|
+
right : $(window).width()
|
188
|
+
},
|
189
|
+
popup = {
|
190
|
+
width : $popup.width(),
|
191
|
+
height : $popup.outerHeight(),
|
192
|
+
position : $popup.offset()
|
193
|
+
},
|
194
|
+
offstage = {},
|
195
|
+
offstagePositions = []
|
196
|
+
;
|
197
|
+
if(popup.position) {
|
198
|
+
offstage = {
|
199
|
+
top : (popup.position.top < boundary.top),
|
200
|
+
bottom : (popup.position.top + popup.height > boundary.bottom),
|
201
|
+
right : (popup.position.left + popup.width > boundary.right),
|
202
|
+
left : (popup.position.left < boundary.left)
|
203
|
+
};
|
204
|
+
}
|
205
|
+
// return only boundaries that have been surpassed
|
206
|
+
$.each(offstage, function(direction, isOffstage) {
|
207
|
+
if(isOffstage) {
|
208
|
+
offstagePositions.push(direction);
|
209
|
+
}
|
210
|
+
});
|
211
|
+
return (offstagePositions.length > 0)
|
212
|
+
? offstagePositions.join(' ')
|
213
|
+
: false
|
214
|
+
;
|
215
|
+
},
|
216
|
+
nextPosition: function(position) {
|
217
|
+
switch(position) {
|
218
|
+
case 'top left':
|
219
|
+
position = 'bottom left';
|
220
|
+
break;
|
221
|
+
case 'bottom left':
|
222
|
+
position = 'top right';
|
223
|
+
break;
|
224
|
+
case 'top right':
|
225
|
+
position = 'bottom right';
|
226
|
+
break;
|
227
|
+
case 'bottom right':
|
228
|
+
position = 'top center';
|
229
|
+
break;
|
230
|
+
case 'top center':
|
231
|
+
position = 'bottom center';
|
232
|
+
break;
|
233
|
+
case 'bottom center':
|
234
|
+
position = 'right center';
|
235
|
+
break;
|
236
|
+
case 'right center':
|
237
|
+
position = 'left center';
|
238
|
+
break;
|
239
|
+
case 'left center':
|
240
|
+
position = 'top center';
|
241
|
+
break;
|
242
|
+
}
|
243
|
+
return position;
|
244
|
+
}
|
245
|
+
},
|
246
|
+
|
247
|
+
// determines popup state
|
248
|
+
toggle: function() {
|
249
|
+
$module = $(this);
|
250
|
+
module.debug('Toggling pop-up');
|
251
|
+
// refresh state of module
|
252
|
+
module.refresh();
|
253
|
+
if( !$module.hasClass(className.visible) ) {
|
254
|
+
module.hideAll();
|
255
|
+
module.show();
|
256
|
+
}
|
257
|
+
else {
|
258
|
+
module.hide();
|
259
|
+
}
|
260
|
+
},
|
261
|
+
|
262
|
+
position: function(position, arrowOffset) {
|
263
|
+
var
|
264
|
+
windowWidth = $(window).width(),
|
265
|
+
windowHeight = $(window).height(),
|
266
|
+
width = $module.outerWidth(),
|
267
|
+
height = $module.outerHeight(),
|
268
|
+
popupWidth = $popup.width(),
|
269
|
+
popupHeight = $popup.outerHeight(),
|
270
|
+
|
271
|
+
offset = (settings.inline)
|
272
|
+
? $module.position()
|
273
|
+
: $module.offset(),
|
274
|
+
parentWidth = (settings.inline)
|
275
|
+
? $offsetParent.outerWidth()
|
276
|
+
: $window.outerWidth(),
|
277
|
+
parentHeight = (settings.inline)
|
278
|
+
? $offsetParent.outerHeight()
|
279
|
+
: $window.outerHeight(),
|
280
|
+
|
281
|
+
positioning,
|
282
|
+
offstagePosition
|
283
|
+
;
|
284
|
+
position = position || $module.data(metadata.position) || settings.position;
|
285
|
+
arrowOffset = arrowOffset || $module.data(metadata.arrowOffset) || settings.arrowOffset;
|
286
|
+
module.debug('Calculating offset for position', position);
|
287
|
+
switch(position) {
|
288
|
+
case 'top left':
|
289
|
+
positioning = {
|
290
|
+
top : 'auto',
|
291
|
+
bottom : parentHeight - offset.top + settings.distanceAway,
|
292
|
+
left : offset.left + arrowOffset
|
293
|
+
};
|
294
|
+
break;
|
295
|
+
case 'top center':
|
296
|
+
positioning = {
|
297
|
+
bottom : parentHeight - offset.top + settings.distanceAway,
|
298
|
+
left : offset.left + (width / 2) - (popupWidth / 2) + arrowOffset,
|
299
|
+
top : 'auto',
|
300
|
+
right : 'auto'
|
301
|
+
};
|
302
|
+
break;
|
303
|
+
case 'top right':
|
304
|
+
positioning = {
|
305
|
+
bottom : parentHeight - offset.top + settings.distanceAway,
|
306
|
+
right : parentWidth - offset.left - width - arrowOffset,
|
307
|
+
top : 'auto',
|
308
|
+
left : 'auto'
|
309
|
+
};
|
310
|
+
break;
|
311
|
+
case 'left center':
|
312
|
+
positioning = {
|
313
|
+
top : offset.top + (height / 2) - (popupHeight / 2),
|
314
|
+
right : parentWidth - offset.left + settings.distanceAway - arrowOffset,
|
315
|
+
left : 'auto',
|
316
|
+
bottom : 'auto'
|
317
|
+
};
|
318
|
+
break;
|
319
|
+
case 'right center':
|
320
|
+
positioning = {
|
321
|
+
top : offset.top + (height / 2) - (popupHeight / 2),
|
322
|
+
left : offset.left + width + settings.distanceAway + arrowOffset,
|
323
|
+
bottom : 'auto',
|
324
|
+
right : 'auto'
|
325
|
+
};
|
326
|
+
break;
|
327
|
+
case 'bottom left':
|
328
|
+
positioning = {
|
329
|
+
top : offset.top + height + settings.distanceAway,
|
330
|
+
left : offset.left + arrowOffset,
|
331
|
+
bottom : 'auto',
|
332
|
+
right : 'auto'
|
333
|
+
};
|
334
|
+
break;
|
335
|
+
case 'bottom center':
|
336
|
+
positioning = {
|
337
|
+
top : offset.top + height + settings.distanceAway,
|
338
|
+
left : offset.left + (width / 2) - (popupWidth / 2) + arrowOffset,
|
339
|
+
bottom : 'auto',
|
340
|
+
right : 'auto'
|
341
|
+
};
|
342
|
+
break;
|
343
|
+
case 'bottom right':
|
344
|
+
positioning = {
|
345
|
+
top : offset.top + height + settings.distanceAway,
|
346
|
+
right : parentWidth - offset.left - width - arrowOffset,
|
347
|
+
left : 'auto',
|
348
|
+
bottom : 'auto'
|
349
|
+
};
|
350
|
+
break;
|
351
|
+
}
|
352
|
+
// true width on popup, avoid rounding error
|
353
|
+
$.extend(positioning, {
|
354
|
+
width: $popup.width() + 1
|
355
|
+
});
|
356
|
+
// tentatively place on stage
|
357
|
+
$popup
|
358
|
+
.removeAttr('style')
|
359
|
+
.removeClass('top right bottom left center')
|
360
|
+
.css(positioning)
|
361
|
+
.addClass(position)
|
362
|
+
.addClass(className.loading)
|
363
|
+
;
|
364
|
+
// check if is offstage
|
365
|
+
offstagePosition = module.get.offstagePosition();
|
366
|
+
// recursively find new positioning
|
367
|
+
if(offstagePosition) {
|
368
|
+
module.debug('Element is outside boundaries ', offstagePosition);
|
369
|
+
if(searchDepth < settings.maxSearchDepth) {
|
370
|
+
position = module.get.nextPosition(position);
|
371
|
+
searchDepth++;
|
372
|
+
module.debug('Trying new position: ', position);
|
373
|
+
return module.position(position);
|
374
|
+
}
|
375
|
+
else {
|
376
|
+
module.error(error.recursion);
|
377
|
+
searchDepth = 0;
|
378
|
+
return false;
|
379
|
+
}
|
380
|
+
}
|
381
|
+
else {
|
382
|
+
module.debug('Position is on stage', position);
|
383
|
+
searchDepth = 0;
|
384
|
+
return true;
|
385
|
+
}
|
386
|
+
},
|
387
|
+
|
388
|
+
show: function() {
|
389
|
+
module.debug('Showing pop-up', settings.transition);
|
390
|
+
if($popup.size() === 0) {
|
391
|
+
module.create();
|
392
|
+
}
|
393
|
+
module.position();
|
394
|
+
$module
|
395
|
+
.addClass(className.visible)
|
396
|
+
;
|
397
|
+
$popup
|
398
|
+
.removeClass(className.loading)
|
399
|
+
;
|
400
|
+
if(settings.transition && $.fn.transition !== undefined) {
|
401
|
+
$popup
|
402
|
+
.transition(settings.transition + ' in', settings.duration)
|
403
|
+
;
|
404
|
+
}
|
405
|
+
else {
|
406
|
+
$popup
|
407
|
+
.stop()
|
408
|
+
.fadeIn(settings.duration, settings.easing)
|
409
|
+
;
|
410
|
+
}
|
411
|
+
if(settings.on == 'click' && settings.clicktoClose) {
|
412
|
+
module.debug('Binding popup close event');
|
413
|
+
$(document)
|
414
|
+
.on('click.' + namespace, module.gracefully.hide)
|
415
|
+
;
|
416
|
+
}
|
417
|
+
$.proxy(settings.onShow, $popup)();
|
418
|
+
},
|
419
|
+
|
420
|
+
hideAll: function() {
|
421
|
+
$(selector.popup)
|
422
|
+
.filter(':visible')
|
423
|
+
.popup('hide')
|
424
|
+
;
|
425
|
+
},
|
426
|
+
|
427
|
+
hide: function() {
|
428
|
+
$module
|
429
|
+
.removeClass(className.visible)
|
430
|
+
;
|
431
|
+
if($popup.is(':visible') ) {
|
432
|
+
module.debug('Hiding pop-up');
|
433
|
+
if(settings.transition && $.fn.transition !== undefined) {
|
434
|
+
$popup
|
435
|
+
.transition(settings.transition + ' out', settings.duration)
|
436
|
+
;
|
437
|
+
}
|
438
|
+
else {
|
439
|
+
$popup
|
440
|
+
.stop()
|
441
|
+
.fadeOut(settings.duration, settings.easing)
|
442
|
+
;
|
443
|
+
}
|
444
|
+
}
|
445
|
+
if(settings.on == 'click' && settings.clicktoClose) {
|
446
|
+
$(document)
|
447
|
+
.off('click.' + namespace)
|
448
|
+
;
|
449
|
+
}
|
450
|
+
$.proxy(settings.onHide, $popup)();
|
451
|
+
if(!settings.inline) {
|
452
|
+
module.remove();
|
453
|
+
}
|
454
|
+
},
|
455
|
+
|
456
|
+
gracefully: {
|
457
|
+
hide: function(event) {
|
458
|
+
// don't close on clicks inside popup
|
459
|
+
if( $(event.target).closest(selector.popup).size() === 0) {
|
460
|
+
module.hide();
|
461
|
+
}
|
462
|
+
}
|
463
|
+
},
|
464
|
+
|
465
|
+
setting: function(name, value) {
|
466
|
+
if(value !== undefined) {
|
467
|
+
if( $.isPlainObject(name) ) {
|
468
|
+
$.extend(true, settings, name);
|
469
|
+
}
|
470
|
+
else {
|
471
|
+
settings[name] = value;
|
472
|
+
}
|
473
|
+
}
|
474
|
+
else {
|
475
|
+
return settings[name];
|
476
|
+
}
|
477
|
+
},
|
478
|
+
internal: function(name, value) {
|
479
|
+
if(value !== undefined) {
|
480
|
+
if( $.isPlainObject(name) ) {
|
481
|
+
$.extend(true, module, name);
|
482
|
+
}
|
483
|
+
else {
|
484
|
+
module[name] = value;
|
485
|
+
}
|
486
|
+
}
|
487
|
+
else {
|
488
|
+
return module[name];
|
489
|
+
}
|
490
|
+
},
|
491
|
+
debug: function() {
|
492
|
+
if(settings.debug) {
|
493
|
+
if(settings.performance) {
|
494
|
+
module.performance.log(arguments);
|
495
|
+
}
|
496
|
+
else {
|
497
|
+
module.debug = Function.prototype.bind.call(console.info, console, settings.moduleName + ':');
|
498
|
+
module.debug.apply(console, arguments);
|
499
|
+
}
|
500
|
+
}
|
501
|
+
},
|
502
|
+
verbose: function() {
|
503
|
+
if(settings.verbose && settings.debug) {
|
504
|
+
if(settings.performance) {
|
505
|
+
module.performance.log(arguments);
|
506
|
+
}
|
507
|
+
else {
|
508
|
+
module.verbose = Function.prototype.bind.call(console.info, console, settings.moduleName + ':');
|
509
|
+
module.verbose.apply(console, arguments);
|
510
|
+
}
|
511
|
+
}
|
512
|
+
},
|
513
|
+
error: function() {
|
514
|
+
module.error = Function.prototype.bind.call(console.error, console, settings.moduleName + ':');
|
515
|
+
module.error.apply(console, arguments);
|
516
|
+
},
|
517
|
+
performance: {
|
518
|
+
log: function(message) {
|
519
|
+
var
|
520
|
+
currentTime,
|
521
|
+
executionTime,
|
522
|
+
previousTime
|
523
|
+
;
|
524
|
+
if(settings.performance) {
|
525
|
+
currentTime = new Date().getTime();
|
526
|
+
previousTime = time || currentTime;
|
527
|
+
executionTime = currentTime - previousTime;
|
528
|
+
time = currentTime;
|
529
|
+
performance.push({
|
530
|
+
'Element' : element,
|
531
|
+
'Name' : message[0],
|
532
|
+
'Arguments' : [].slice.call(message, 1) || '',
|
533
|
+
'Execution Time' : executionTime
|
534
|
+
});
|
535
|
+
}
|
536
|
+
clearTimeout(module.performance.timer);
|
537
|
+
module.performance.timer = setTimeout(module.performance.display, 100);
|
538
|
+
},
|
539
|
+
display: function() {
|
540
|
+
var
|
541
|
+
title = settings.name + ':',
|
542
|
+
totalTime = 0
|
543
|
+
;
|
544
|
+
time = false;
|
545
|
+
clearTimeout(module.performance.timer);
|
546
|
+
$.each(performance, function(index, data) {
|
547
|
+
totalTime += data['Execution Time'];
|
548
|
+
});
|
549
|
+
title += ' ' + totalTime + 'ms';
|
550
|
+
if(moduleSelector) {
|
551
|
+
title += ' \'' + moduleSelector + '\'';
|
552
|
+
}
|
553
|
+
if($allModules.size() > 1) {
|
554
|
+
if($allModules.size() > 1) {
|
555
|
+
title += ' ' + '(' + $allModules.size() + ')';
|
556
|
+
}
|
557
|
+
}
|
558
|
+
if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
|
559
|
+
console.groupCollapsed(title);
|
560
|
+
if(console.table) {
|
561
|
+
console.table(performance);
|
562
|
+
}
|
563
|
+
else {
|
564
|
+
$.each(performance, function(index, data) {
|
565
|
+
console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
|
566
|
+
});
|
567
|
+
}
|
568
|
+
console.groupEnd();
|
569
|
+
}
|
570
|
+
performance = [];
|
571
|
+
}
|
572
|
+
},
|
573
|
+
invoke: function(query, passedArguments, context) {
|
574
|
+
var
|
575
|
+
maxDepth,
|
576
|
+
found,
|
577
|
+
response
|
578
|
+
;
|
579
|
+
passedArguments = passedArguments || queryArguments;
|
580
|
+
context = element || context;
|
581
|
+
if(typeof query == 'string' && instance !== undefined) {
|
582
|
+
query = query.split(/[\. ]/);
|
583
|
+
maxDepth = query.length - 1;
|
584
|
+
$.each(query, function(depth, value) {
|
585
|
+
var camelCaseValue = (depth != maxDepth)
|
586
|
+
? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
|
587
|
+
: query
|
588
|
+
;
|
589
|
+
if( $.isPlainObject( instance[value] ) && (depth != maxDepth) ) {
|
590
|
+
instance = instance[value];
|
591
|
+
}
|
592
|
+
else if( $.isPlainObject( instance[camelCaseValue] ) && (depth != maxDepth) ) {
|
593
|
+
instance = instance[camelCaseValue];
|
594
|
+
}
|
595
|
+
else if( instance[value] !== undefined ) {
|
596
|
+
found = instance[value];
|
597
|
+
return false;
|
598
|
+
}
|
599
|
+
else if( instance[camelCaseValue] !== undefined ) {
|
600
|
+
found = instance[camelCaseValue];
|
601
|
+
return false;
|
602
|
+
}
|
603
|
+
else {
|
604
|
+
module.error(error.method);
|
605
|
+
return false;
|
606
|
+
}
|
607
|
+
});
|
608
|
+
}
|
609
|
+
if ( $.isFunction( found ) ) {
|
610
|
+
response = found.apply(context, passedArguments);
|
611
|
+
}
|
612
|
+
else if(found !== undefined) {
|
613
|
+
response = found;
|
614
|
+
}
|
615
|
+
if($.isArray(invokedResponse)) {
|
616
|
+
invokedResponse.push(response);
|
617
|
+
}
|
618
|
+
else if(typeof invokedResponse == 'string') {
|
619
|
+
invokedResponse = [invokedResponse, response];
|
620
|
+
}
|
621
|
+
else if(response !== undefined) {
|
622
|
+
invokedResponse = response;
|
623
|
+
}
|
624
|
+
return found;
|
625
|
+
}
|
626
|
+
};
|
627
|
+
|
628
|
+
if(methodInvoked) {
|
629
|
+
if(instance === undefined) {
|
630
|
+
module.initialize();
|
631
|
+
}
|
632
|
+
module.invoke(query);
|
633
|
+
}
|
634
|
+
else {
|
635
|
+
if(instance !== undefined) {
|
636
|
+
module.destroy();
|
637
|
+
}
|
638
|
+
module.initialize();
|
639
|
+
}
|
640
|
+
})
|
641
|
+
;
|
642
|
+
|
643
|
+
return (invokedResponse !== undefined)
|
644
|
+
? invokedResponse
|
645
|
+
: this
|
646
|
+
;
|
647
|
+
};
|
648
|
+
|
649
|
+
$.fn.popup.settings = {
|
650
|
+
|
651
|
+
name : 'Popup',
|
652
|
+
debug : true,
|
653
|
+
verbose : true,
|
654
|
+
performance : true,
|
655
|
+
namespace : 'popup',
|
656
|
+
|
657
|
+
onInit : function(){},
|
658
|
+
onShow : function(){},
|
659
|
+
onHide : function(){},
|
660
|
+
|
661
|
+
variation : '',
|
662
|
+
content : false,
|
663
|
+
html : false,
|
664
|
+
title : false,
|
665
|
+
|
666
|
+
on : 'hover',
|
667
|
+
clicktoClose : true,
|
668
|
+
|
669
|
+
position : 'top center',
|
670
|
+
delay : 150,
|
671
|
+
inline : true,
|
672
|
+
|
673
|
+
duration : 150,
|
674
|
+
easing : 'easeOutQuint',
|
675
|
+
transition : 'scale',
|
676
|
+
|
677
|
+
distanceAway : 0,
|
678
|
+
arrowOffset : 0,
|
679
|
+
maxSearchDepth : 10,
|
680
|
+
|
681
|
+
error: {
|
682
|
+
content : 'Your popup has no content specified',
|
683
|
+
method : 'The method you called is not defined.',
|
684
|
+
recursion : 'Popup attempted to reposition element to fit, but could not find an adequate position.'
|
685
|
+
},
|
686
|
+
|
687
|
+
metadata: {
|
688
|
+
arrowOffset : 'arrowOffset',
|
689
|
+
content : 'content',
|
690
|
+
html : 'html',
|
691
|
+
position : 'position',
|
692
|
+
title : 'title',
|
693
|
+
variation : 'variation'
|
694
|
+
},
|
695
|
+
|
696
|
+
className : {
|
697
|
+
popup : 'ui popup',
|
698
|
+
visible : 'visible',
|
699
|
+
loading : 'loading'
|
700
|
+
},
|
701
|
+
|
702
|
+
selector : {
|
703
|
+
popup : '.ui.popup'
|
704
|
+
},
|
705
|
+
|
706
|
+
template: function(text) {
|
707
|
+
var html = '';
|
708
|
+
if(typeof text !== undefined) {
|
709
|
+
if(typeof text.title !== undefined && text.title) {
|
710
|
+
html += '<div class="header">' + text.title + '</div class="header">';
|
711
|
+
}
|
712
|
+
if(typeof text.content !== undefined && text.content) {
|
713
|
+
html += '<div class="content">' + text.content + '</div>';
|
714
|
+
}
|
715
|
+
}
|
716
|
+
return html;
|
717
|
+
}
|
718
|
+
|
719
|
+
};
|
720
|
+
|
721
|
+
})( jQuery, window , document );
|