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,348 @@
|
|
1
|
+
/* ******************************
|
2
|
+
Semantic Module: Checkbox
|
3
|
+
Author: Jack Lukic
|
4
|
+
Notes: First Commit March 25, 2013
|
5
|
+
|
6
|
+
Simple plug-in which maintains the state for ui checkbox
|
7
|
+
This can be done without javascript, only in instances
|
8
|
+
where each checkbox is assigned a unique ID. This provides a separate
|
9
|
+
programmatic option when that is not possible.
|
10
|
+
|
11
|
+
****************************** */
|
12
|
+
|
13
|
+
;(function ( $, window, document, undefined ) {
|
14
|
+
|
15
|
+
$.fn.checkbox = function(parameters) {
|
16
|
+
var
|
17
|
+
$allModules = $(this),
|
18
|
+
|
19
|
+
settings = $.extend(true, {}, $.fn.checkbox.settings, parameters),
|
20
|
+
|
21
|
+
className = settings.className,
|
22
|
+
namespace = settings.namespace,
|
23
|
+
error = settings.error,
|
24
|
+
|
25
|
+
eventNamespace = '.' + namespace,
|
26
|
+
moduleNamespace = 'module-' + namespace,
|
27
|
+
|
28
|
+
moduleSelector = $allModules.selector || '',
|
29
|
+
|
30
|
+
time = new Date().getTime(),
|
31
|
+
performance = [],
|
32
|
+
|
33
|
+
query = arguments[0],
|
34
|
+
methodInvoked = (typeof query == 'string'),
|
35
|
+
queryArguments = [].slice.call(arguments, 1),
|
36
|
+
invokedResponse
|
37
|
+
;
|
38
|
+
|
39
|
+
$allModules
|
40
|
+
.each(function() {
|
41
|
+
var
|
42
|
+
$module = $(this),
|
43
|
+
$label = $(this).next(settings.selector.label).first(),
|
44
|
+
$input = $(this).find(settings.selector.input),
|
45
|
+
|
46
|
+
selector = $module.selector || '',
|
47
|
+
instance = $module.data(moduleNamespace),
|
48
|
+
|
49
|
+
element = this,
|
50
|
+
module
|
51
|
+
;
|
52
|
+
|
53
|
+
module = {
|
54
|
+
|
55
|
+
initialize: function() {
|
56
|
+
module.verbose('Initializing checkbox', settings);
|
57
|
+
if(settings.context && selector !== '') {
|
58
|
+
module.verbose('Adding delegated events');
|
59
|
+
$(element, settings.context)
|
60
|
+
.on(selector, 'click' + eventNamespace, module.toggle)
|
61
|
+
.on(selector + ' + ' + settings.selector.label, 'click' + eventNamespace, module.toggle)
|
62
|
+
;
|
63
|
+
}
|
64
|
+
else {
|
65
|
+
$module
|
66
|
+
.on('click' + eventNamespace, module.toggle)
|
67
|
+
.data(moduleNamespace, module)
|
68
|
+
;
|
69
|
+
$label
|
70
|
+
.on('click' + eventNamespace, module.toggle)
|
71
|
+
;
|
72
|
+
}
|
73
|
+
module.instantiate();
|
74
|
+
},
|
75
|
+
|
76
|
+
instantiate: function() {
|
77
|
+
module.verbose('Storing instance of module', module);
|
78
|
+
instance = module;
|
79
|
+
$module
|
80
|
+
.data(moduleNamespace, module)
|
81
|
+
;
|
82
|
+
},
|
83
|
+
|
84
|
+
destroy: function() {
|
85
|
+
module.verbose('Destroying previous module');
|
86
|
+
$module
|
87
|
+
.off(eventNamespace)
|
88
|
+
.removeData(moduleNamespace)
|
89
|
+
;
|
90
|
+
},
|
91
|
+
|
92
|
+
is: {
|
93
|
+
radio: function() {
|
94
|
+
return $module.hasClass(className.radio);
|
95
|
+
}
|
96
|
+
},
|
97
|
+
|
98
|
+
can: {
|
99
|
+
disable: function() {
|
100
|
+
return (typeof settings.required === 'boolean')
|
101
|
+
? settings.required
|
102
|
+
: !module.is.radio()
|
103
|
+
;
|
104
|
+
}
|
105
|
+
},
|
106
|
+
|
107
|
+
enable: function() {
|
108
|
+
module.debug('Enabling checkbox');
|
109
|
+
$input
|
110
|
+
.prop('checked', true)
|
111
|
+
;
|
112
|
+
$.proxy(settings.onChange, $input.get())();
|
113
|
+
$.proxy(settings.onEnable, $input.get())();
|
114
|
+
},
|
115
|
+
|
116
|
+
disable: function() {
|
117
|
+
module.debug('Disabling checkbox');
|
118
|
+
$input
|
119
|
+
.prop('checked', false)
|
120
|
+
;
|
121
|
+
$.proxy(settings.onChange, $input.get())();
|
122
|
+
$.proxy(settings.onDisable, $input.get())();
|
123
|
+
},
|
124
|
+
|
125
|
+
toggle: function(event) {
|
126
|
+
module.verbose('Determining new checkbox state');
|
127
|
+
if($input.prop('checked') === undefined || !$input.prop('checked')) {
|
128
|
+
module.enable();
|
129
|
+
}
|
130
|
+
else if( module.can.disable() ) {
|
131
|
+
module.disable();
|
132
|
+
}
|
133
|
+
},
|
134
|
+
setting: function(name, value) {
|
135
|
+
if(value !== undefined) {
|
136
|
+
if( $.isPlainObject(name) ) {
|
137
|
+
$.extend(true, settings, name);
|
138
|
+
}
|
139
|
+
else {
|
140
|
+
settings[name] = value;
|
141
|
+
}
|
142
|
+
}
|
143
|
+
else {
|
144
|
+
return settings[name];
|
145
|
+
}
|
146
|
+
},
|
147
|
+
internal: function(name, value) {
|
148
|
+
if(value !== undefined) {
|
149
|
+
if( $.isPlainObject(name) ) {
|
150
|
+
$.extend(true, module, name);
|
151
|
+
}
|
152
|
+
else {
|
153
|
+
module[name] = value;
|
154
|
+
}
|
155
|
+
}
|
156
|
+
else {
|
157
|
+
return module[name];
|
158
|
+
}
|
159
|
+
},
|
160
|
+
debug: function() {
|
161
|
+
if(settings.debug) {
|
162
|
+
if(settings.performance) {
|
163
|
+
module.performance.log(arguments);
|
164
|
+
}
|
165
|
+
else {
|
166
|
+
module.debug = Function.prototype.bind.call(console.info, console, settings.moduleName + ':');
|
167
|
+
module.debug.apply(console, arguments);
|
168
|
+
}
|
169
|
+
}
|
170
|
+
},
|
171
|
+
verbose: function() {
|
172
|
+
if(settings.verbose && settings.debug) {
|
173
|
+
if(settings.performance) {
|
174
|
+
module.performance.log(arguments);
|
175
|
+
}
|
176
|
+
else {
|
177
|
+
module.verbose = Function.prototype.bind.call(console.info, console, settings.moduleName + ':');
|
178
|
+
module.verbose.apply(console, arguments);
|
179
|
+
}
|
180
|
+
}
|
181
|
+
},
|
182
|
+
error: function() {
|
183
|
+
module.error = Function.prototype.bind.call(console.error, console, settings.moduleName + ':');
|
184
|
+
module.error.apply(console, arguments);
|
185
|
+
},
|
186
|
+
performance: {
|
187
|
+
log: function(message) {
|
188
|
+
var
|
189
|
+
currentTime,
|
190
|
+
executionTime,
|
191
|
+
previousTime
|
192
|
+
;
|
193
|
+
if(settings.performance) {
|
194
|
+
currentTime = new Date().getTime();
|
195
|
+
previousTime = time || currentTime;
|
196
|
+
executionTime = currentTime - previousTime;
|
197
|
+
time = currentTime;
|
198
|
+
performance.push({
|
199
|
+
'Element' : element,
|
200
|
+
'Name' : message[0],
|
201
|
+
'Arguments' : [].slice.call(message, 1) || '',
|
202
|
+
'Execution Time' : executionTime
|
203
|
+
});
|
204
|
+
}
|
205
|
+
clearTimeout(module.performance.timer);
|
206
|
+
module.performance.timer = setTimeout(module.performance.display, 100);
|
207
|
+
},
|
208
|
+
display: function() {
|
209
|
+
var
|
210
|
+
title = settings.name + ':',
|
211
|
+
totalTime = 0
|
212
|
+
;
|
213
|
+
time = false;
|
214
|
+
clearTimeout(module.performance.timer);
|
215
|
+
$.each(performance, function(index, data) {
|
216
|
+
totalTime += data['Execution Time'];
|
217
|
+
});
|
218
|
+
title += ' ' + totalTime + 'ms';
|
219
|
+
if(moduleSelector) {
|
220
|
+
title += ' \'' + moduleSelector + '\'';
|
221
|
+
}
|
222
|
+
if($allModules.size() > 1) {
|
223
|
+
title += ' ' + '(' + $allModules.size() + ')';
|
224
|
+
}
|
225
|
+
if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
|
226
|
+
console.groupCollapsed(title);
|
227
|
+
if(console.table) {
|
228
|
+
console.table(performance);
|
229
|
+
}
|
230
|
+
else {
|
231
|
+
$.each(performance, function(index, data) {
|
232
|
+
console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
|
233
|
+
});
|
234
|
+
}
|
235
|
+
console.groupEnd();
|
236
|
+
}
|
237
|
+
performance = [];
|
238
|
+
}
|
239
|
+
},
|
240
|
+
invoke: function(query, passedArguments, context) {
|
241
|
+
var
|
242
|
+
maxDepth,
|
243
|
+
found,
|
244
|
+
response
|
245
|
+
;
|
246
|
+
passedArguments = passedArguments || queryArguments;
|
247
|
+
context = element || context;
|
248
|
+
if(typeof query == 'string' && instance !== undefined) {
|
249
|
+
query = query.split(/[\. ]/);
|
250
|
+
maxDepth = query.length - 1;
|
251
|
+
$.each(query, function(depth, value) {
|
252
|
+
var camelCaseValue = (depth != maxDepth)
|
253
|
+
? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
|
254
|
+
: query
|
255
|
+
;
|
256
|
+
if( $.isPlainObject( instance[value] ) && (depth != maxDepth) ) {
|
257
|
+
instance = instance[value];
|
258
|
+
}
|
259
|
+
else if( $.isPlainObject( instance[camelCaseValue] ) && (depth != maxDepth) ) {
|
260
|
+
instance = instance[camelCaseValue];
|
261
|
+
}
|
262
|
+
else if( instance[value] !== undefined ) {
|
263
|
+
found = instance[value];
|
264
|
+
return false;
|
265
|
+
}
|
266
|
+
else if( instance[camelCaseValue] !== undefined ) {
|
267
|
+
found = instance[camelCaseValue];
|
268
|
+
return false;
|
269
|
+
}
|
270
|
+
else {
|
271
|
+
module.error(error.method);
|
272
|
+
return false;
|
273
|
+
}
|
274
|
+
});
|
275
|
+
}
|
276
|
+
if ( $.isFunction( found ) ) {
|
277
|
+
response = found.apply(context, passedArguments);
|
278
|
+
}
|
279
|
+
else if(found !== undefined) {
|
280
|
+
response = found;
|
281
|
+
}
|
282
|
+
if($.isArray(invokedResponse)) {
|
283
|
+
invokedResponse.push(response);
|
284
|
+
}
|
285
|
+
else if(typeof invokedResponse == 'string') {
|
286
|
+
invokedResponse = [invokedResponse, response];
|
287
|
+
}
|
288
|
+
else if(response !== undefined) {
|
289
|
+
invokedResponse = response;
|
290
|
+
}
|
291
|
+
return found;
|
292
|
+
}
|
293
|
+
};
|
294
|
+
|
295
|
+
if(methodInvoked) {
|
296
|
+
if(instance === undefined) {
|
297
|
+
module.initialize();
|
298
|
+
}
|
299
|
+
module.invoke(query);
|
300
|
+
}
|
301
|
+
else {
|
302
|
+
if(instance !== undefined) {
|
303
|
+
module.destroy();
|
304
|
+
}
|
305
|
+
module.initialize();
|
306
|
+
}
|
307
|
+
})
|
308
|
+
;
|
309
|
+
|
310
|
+
return (invokedResponse !== undefined)
|
311
|
+
? invokedResponse
|
312
|
+
: this
|
313
|
+
;
|
314
|
+
};
|
315
|
+
|
316
|
+
$.fn.checkbox.settings = {
|
317
|
+
|
318
|
+
name : 'Checkbox',
|
319
|
+
namespace : 'checkbox',
|
320
|
+
|
321
|
+
verbose : true,
|
322
|
+
debug : true,
|
323
|
+
performance : true,
|
324
|
+
|
325
|
+
// delegated event context
|
326
|
+
context : false,
|
327
|
+
required : 'auto',
|
328
|
+
|
329
|
+
onChange : function(){},
|
330
|
+
onEnable : function(){},
|
331
|
+
onDisable : function(){},
|
332
|
+
|
333
|
+
error : {
|
334
|
+
method : 'The method you called is not defined.'
|
335
|
+
},
|
336
|
+
|
337
|
+
selector : {
|
338
|
+
input : 'input',
|
339
|
+
label : 'label'
|
340
|
+
},
|
341
|
+
|
342
|
+
className : {
|
343
|
+
radio : 'radio'
|
344
|
+
}
|
345
|
+
|
346
|
+
};
|
347
|
+
|
348
|
+
})( jQuery, window , document );
|
@@ -0,0 +1,525 @@
|
|
1
|
+
/* ******************************
|
2
|
+
Semantic Module: Dimmer
|
3
|
+
Author: Jack Lukic
|
4
|
+
Notes: First Commit May 30, 2013
|
5
|
+
|
6
|
+
Simple plug-in which maintains the state for ui dimmer
|
7
|
+
|
8
|
+
****************************** */
|
9
|
+
|
10
|
+
;(function ( $, window, document, undefined ) {
|
11
|
+
|
12
|
+
$.fn.dimmer = function(parameters) {
|
13
|
+
var
|
14
|
+
$allModules = $(this),
|
15
|
+
|
16
|
+
settings = ( $.isPlainObject(parameters) )
|
17
|
+
? $.extend(true, {}, $.fn.dimmer.settings, parameters)
|
18
|
+
: $.fn.dimmer.settings,
|
19
|
+
|
20
|
+
selector = settings.selector,
|
21
|
+
namespace = settings.namespace,
|
22
|
+
className = settings.className,
|
23
|
+
error = settings.error,
|
24
|
+
|
25
|
+
eventNamespace = '.' + namespace,
|
26
|
+
moduleNamespace = 'module-' + namespace,
|
27
|
+
moduleSelector = $allModules.selector || '',
|
28
|
+
|
29
|
+
time = new Date().getTime(),
|
30
|
+
performance = [],
|
31
|
+
|
32
|
+
query = arguments[0],
|
33
|
+
methodInvoked = (typeof query == 'string'),
|
34
|
+
queryArguments = [].slice.call(arguments, 1),
|
35
|
+
clickEvent = ('ontouchstart' in document.documentElement)
|
36
|
+
? 'touchstart'
|
37
|
+
: 'click',
|
38
|
+
|
39
|
+
invokedResponse
|
40
|
+
;
|
41
|
+
|
42
|
+
$allModules
|
43
|
+
.each(function() {
|
44
|
+
var
|
45
|
+
$module = $(this),
|
46
|
+
$dimmer = $module.children(selector.dimmer).first(),
|
47
|
+
|
48
|
+
element = this,
|
49
|
+
instance = $dimmer.data(moduleNamespace),
|
50
|
+
module
|
51
|
+
;
|
52
|
+
|
53
|
+
module = {
|
54
|
+
|
55
|
+
initialize: function() {
|
56
|
+
if( module.is.dimmer() ) {
|
57
|
+
$dimmer = $module;
|
58
|
+
$module = $dimmer.parent();
|
59
|
+
module.debug('Module initialized as dimmer', settings);
|
60
|
+
}
|
61
|
+
else {
|
62
|
+
if( module.has.dimmer() ) {
|
63
|
+
$dimmer = $module.children(selector.dimmer).first();
|
64
|
+
module.debug('Module initialized with found dimmer', settings);
|
65
|
+
}
|
66
|
+
else {
|
67
|
+
module.create();
|
68
|
+
module.debug('Module initialized with created dimmer', settings);
|
69
|
+
}
|
70
|
+
if(settings.on == 'hover') {
|
71
|
+
$module
|
72
|
+
.on('mouseenter' + eventNamespace, module.show)
|
73
|
+
.on('mouseleave' + eventNamespace, module.hide)
|
74
|
+
;
|
75
|
+
}
|
76
|
+
else if(settings.on == 'click') {
|
77
|
+
$module
|
78
|
+
.on(clickEvent + eventNamespace, module.toggle)
|
79
|
+
;
|
80
|
+
}
|
81
|
+
}
|
82
|
+
if(settings.closable) {
|
83
|
+
$dimmer
|
84
|
+
.on(clickEvent, module.event.click)
|
85
|
+
;
|
86
|
+
}
|
87
|
+
module.set.dimmable();
|
88
|
+
module.instantiate();
|
89
|
+
},
|
90
|
+
|
91
|
+
instantiate: function() {
|
92
|
+
module.verbose('Storing instance of module');
|
93
|
+
instance = module;
|
94
|
+
$dimmer
|
95
|
+
.data(moduleNamespace, instance)
|
96
|
+
;
|
97
|
+
},
|
98
|
+
|
99
|
+
destroy: function() {
|
100
|
+
module.verbose('Destroying previous module');
|
101
|
+
$module
|
102
|
+
.off(eventNamespace)
|
103
|
+
;
|
104
|
+
},
|
105
|
+
|
106
|
+
event: {
|
107
|
+
|
108
|
+
click: function(event) {
|
109
|
+
module.verbose('Determining if event occured on dimmer', event);
|
110
|
+
if( $dimmer.find(event.target).size() === 0 || $(event.target).is(selector.content) ) {
|
111
|
+
module.hide();
|
112
|
+
event.stopImmediatePropagation();
|
113
|
+
}
|
114
|
+
}
|
115
|
+
|
116
|
+
},
|
117
|
+
|
118
|
+
create: function() {
|
119
|
+
$dimmer = settings.template.dimmer();
|
120
|
+
$dimmer
|
121
|
+
.appendTo($module)
|
122
|
+
;
|
123
|
+
if(module.is.page()) {
|
124
|
+
module.set.pageDimmer();
|
125
|
+
}
|
126
|
+
},
|
127
|
+
|
128
|
+
animate: {
|
129
|
+
show: function(callback) {
|
130
|
+
callback = callback || function(){};
|
131
|
+
module.set.dimmed();
|
132
|
+
if($.fn.transition !== undefined) {
|
133
|
+
$dimmer
|
134
|
+
.transition(settings.transition + ' in', settings.duration, function() {
|
135
|
+
module.set.active();
|
136
|
+
callback();
|
137
|
+
})
|
138
|
+
;
|
139
|
+
}
|
140
|
+
else {
|
141
|
+
module.verbose('Showing dimmer animation with javascript');
|
142
|
+
$dimmer
|
143
|
+
.stop()
|
144
|
+
.css({
|
145
|
+
opacity : 0,
|
146
|
+
width : '100%',
|
147
|
+
height : '100%'
|
148
|
+
})
|
149
|
+
.fadeTo(settings.duration, 1, function() {
|
150
|
+
$dimmer.removeAttr('style');
|
151
|
+
module.set.active();
|
152
|
+
callback();
|
153
|
+
})
|
154
|
+
;
|
155
|
+
}
|
156
|
+
},
|
157
|
+
hide: function(callback) {
|
158
|
+
callback = callback || function(){};
|
159
|
+
module.remove.dimmed();
|
160
|
+
if($.fn.transition !== undefined) {
|
161
|
+
module.verbose('Hiding dimmer with css');
|
162
|
+
$dimmer
|
163
|
+
.transition(settings.transition + ' out', settings.duration, function() {
|
164
|
+
module.remove.active();
|
165
|
+
callback();
|
166
|
+
})
|
167
|
+
;
|
168
|
+
}
|
169
|
+
else {
|
170
|
+
module.verbose('Hiding dimmer with javascript');
|
171
|
+
$dimmer
|
172
|
+
.stop()
|
173
|
+
.fadeOut(settings.duration, function() {
|
174
|
+
$dimmer.removeAttr('style');
|
175
|
+
module.remove.active();
|
176
|
+
callback();
|
177
|
+
})
|
178
|
+
;
|
179
|
+
}
|
180
|
+
}
|
181
|
+
},
|
182
|
+
|
183
|
+
has: {
|
184
|
+
dimmer: function() {
|
185
|
+
return ( $module.children(selector.dimmer).size() > 0 );
|
186
|
+
}
|
187
|
+
},
|
188
|
+
|
189
|
+
is: {
|
190
|
+
active: function() {
|
191
|
+
return $dimmer.hasClass(className.active);
|
192
|
+
},
|
193
|
+
animating: function() {
|
194
|
+
return ( $dimmer.hasClass(className.show) || $dimmer.hasClass(className.hide) || $dimmer.is(':animated') );
|
195
|
+
},
|
196
|
+
dimmer: function() {
|
197
|
+
return $module.is(selector.dimmer);
|
198
|
+
},
|
199
|
+
page: function () {
|
200
|
+
return $module.is('body');
|
201
|
+
},
|
202
|
+
dimmable: function() {
|
203
|
+
return $module.is(selector.dimmable);
|
204
|
+
},
|
205
|
+
enabled: function() {
|
206
|
+
return !$module.hasClass(className.disabled);
|
207
|
+
},
|
208
|
+
disabled: function() {
|
209
|
+
return $module.hasClass(className.disabled);
|
210
|
+
},
|
211
|
+
pageDimmer: function() {
|
212
|
+
return $dimmer.hasClass(className.pageDimmer);
|
213
|
+
}
|
214
|
+
},
|
215
|
+
|
216
|
+
can: {
|
217
|
+
show: function() {
|
218
|
+
return !$dimmer.hasClass(className.disabled);
|
219
|
+
}
|
220
|
+
},
|
221
|
+
|
222
|
+
set: {
|
223
|
+
active: function() {
|
224
|
+
$dimmer
|
225
|
+
.removeClass(className.transition)
|
226
|
+
.addClass(className.active)
|
227
|
+
;
|
228
|
+
},
|
229
|
+
dimmable: function() {
|
230
|
+
$module
|
231
|
+
.addClass(className.dimmable)
|
232
|
+
;
|
233
|
+
},
|
234
|
+
dimmed: function() {
|
235
|
+
$module.addClass(className.dimmed);
|
236
|
+
},
|
237
|
+
pageDimmer: function() {
|
238
|
+
$dimmer.addClass(className.pageDimmer);
|
239
|
+
},
|
240
|
+
disabled: function() {
|
241
|
+
$dimmer.addClass(className.disabled);
|
242
|
+
}
|
243
|
+
},
|
244
|
+
|
245
|
+
remove: {
|
246
|
+
active: function() {
|
247
|
+
$dimmer
|
248
|
+
.removeClass(className.transition)
|
249
|
+
.removeClass(className.active)
|
250
|
+
;
|
251
|
+
},
|
252
|
+
dimmed: function() {
|
253
|
+
$module.removeClass(className.dimmed);
|
254
|
+
},
|
255
|
+
disabled: function() {
|
256
|
+
$dimmer.removeClass(className.disabled);
|
257
|
+
}
|
258
|
+
},
|
259
|
+
|
260
|
+
show: function(callback) {
|
261
|
+
module.debug('Showing dimmer', $dimmer);
|
262
|
+
if( (!module.is.active() || module.is.animating() ) && module.is.enabled() ) {
|
263
|
+
module.animate.show(callback);
|
264
|
+
$.proxy(settings.onShow, element)();
|
265
|
+
$.proxy(settings.onChange, element)();
|
266
|
+
}
|
267
|
+
else {
|
268
|
+
module.debug('Dimmer is already shown or disabled');
|
269
|
+
}
|
270
|
+
},
|
271
|
+
|
272
|
+
hide: function(callback) {
|
273
|
+
if( module.is.active() || module.is.animating() ) {
|
274
|
+
module.debug('Hiding dimmer', $dimmer);
|
275
|
+
module.animate.hide(callback);
|
276
|
+
$.proxy(settings.onHide, element)();
|
277
|
+
$.proxy(settings.onChange, element)();
|
278
|
+
}
|
279
|
+
else {
|
280
|
+
module.debug('Dimmer is not visible');
|
281
|
+
}
|
282
|
+
},
|
283
|
+
|
284
|
+
toggle: function() {
|
285
|
+
module.verbose('Toggling dimmer visibility', $dimmer);
|
286
|
+
if( !module.is.active() ) {
|
287
|
+
module.show();
|
288
|
+
}
|
289
|
+
else {
|
290
|
+
module.hide();
|
291
|
+
}
|
292
|
+
},
|
293
|
+
|
294
|
+
setting: function(name, value) {
|
295
|
+
if(value !== undefined) {
|
296
|
+
if( $.isPlainObject(name) ) {
|
297
|
+
$.extend(true, settings, name);
|
298
|
+
}
|
299
|
+
else {
|
300
|
+
settings[name] = value;
|
301
|
+
}
|
302
|
+
}
|
303
|
+
else {
|
304
|
+
return settings[name];
|
305
|
+
}
|
306
|
+
},
|
307
|
+
internal: function(name, value) {
|
308
|
+
if(value !== undefined) {
|
309
|
+
if( $.isPlainObject(name) ) {
|
310
|
+
$.extend(true, module, name);
|
311
|
+
}
|
312
|
+
else {
|
313
|
+
module[name] = value;
|
314
|
+
}
|
315
|
+
}
|
316
|
+
else {
|
317
|
+
return module[name];
|
318
|
+
}
|
319
|
+
},
|
320
|
+
debug: function() {
|
321
|
+
if(settings.debug) {
|
322
|
+
if(settings.performance) {
|
323
|
+
module.performance.log(arguments);
|
324
|
+
}
|
325
|
+
else {
|
326
|
+
module.debug = Function.prototype.bind.call(console.info, console, settings.moduleName + ':');
|
327
|
+
module.debug.apply(console, arguments);
|
328
|
+
}
|
329
|
+
}
|
330
|
+
},
|
331
|
+
verbose: function() {
|
332
|
+
if(settings.verbose && settings.debug) {
|
333
|
+
if(settings.performance) {
|
334
|
+
module.performance.log(arguments);
|
335
|
+
}
|
336
|
+
else {
|
337
|
+
module.verbose = Function.prototype.bind.call(console.info, console, settings.moduleName + ':');
|
338
|
+
module.verbose.apply(console, arguments);
|
339
|
+
}
|
340
|
+
}
|
341
|
+
},
|
342
|
+
error: function() {
|
343
|
+
module.error = Function.prototype.bind.call(console.error, console, settings.moduleName + ':');
|
344
|
+
module.error.apply(console, arguments);
|
345
|
+
},
|
346
|
+
performance: {
|
347
|
+
log: function(message) {
|
348
|
+
var
|
349
|
+
currentTime,
|
350
|
+
executionTime,
|
351
|
+
previousTime
|
352
|
+
;
|
353
|
+
if(settings.performance) {
|
354
|
+
currentTime = new Date().getTime();
|
355
|
+
previousTime = time || currentTime;
|
356
|
+
executionTime = currentTime - previousTime;
|
357
|
+
time = currentTime;
|
358
|
+
performance.push({
|
359
|
+
'Element' : element,
|
360
|
+
'Name' : message[0],
|
361
|
+
'Arguments' : [].slice.call(message, 1) || '',
|
362
|
+
'Execution Time' : executionTime
|
363
|
+
});
|
364
|
+
}
|
365
|
+
clearTimeout(module.performance.timer);
|
366
|
+
module.performance.timer = setTimeout(module.performance.display, 100);
|
367
|
+
},
|
368
|
+
display: function() {
|
369
|
+
var
|
370
|
+
title = settings.name + ':',
|
371
|
+
totalTime = 0
|
372
|
+
;
|
373
|
+
time = false;
|
374
|
+
clearTimeout(module.performance.timer);
|
375
|
+
$.each(performance, function(index, data) {
|
376
|
+
totalTime += data['Execution Time'];
|
377
|
+
});
|
378
|
+
title += ' ' + totalTime + 'ms';
|
379
|
+
if(moduleSelector) {
|
380
|
+
title += ' \'' + moduleSelector + '\'';
|
381
|
+
}
|
382
|
+
if($allModules.size() > 1) {
|
383
|
+
title += ' ' + '(' + $allModules.size() + ')';
|
384
|
+
}
|
385
|
+
if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
|
386
|
+
console.groupCollapsed(title);
|
387
|
+
if(console.table) {
|
388
|
+
console.table(performance);
|
389
|
+
}
|
390
|
+
else {
|
391
|
+
$.each(performance, function(index, data) {
|
392
|
+
console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
|
393
|
+
});
|
394
|
+
}
|
395
|
+
console.groupEnd();
|
396
|
+
}
|
397
|
+
performance = [];
|
398
|
+
}
|
399
|
+
},
|
400
|
+
invoke: function(query, passedArguments, context) {
|
401
|
+
var
|
402
|
+
maxDepth,
|
403
|
+
found,
|
404
|
+
response
|
405
|
+
;
|
406
|
+
passedArguments = passedArguments || queryArguments;
|
407
|
+
context = element || context;
|
408
|
+
if(typeof query == 'string' && instance !== undefined) {
|
409
|
+
query = query.split(/[\. ]/);
|
410
|
+
maxDepth = query.length - 1;
|
411
|
+
$.each(query, function(depth, value) {
|
412
|
+
var camelCaseValue = (depth != maxDepth)
|
413
|
+
? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
|
414
|
+
: query
|
415
|
+
;
|
416
|
+
if( $.isPlainObject( instance[value] ) && (depth != maxDepth) ) {
|
417
|
+
instance = instance[value];
|
418
|
+
}
|
419
|
+
else if( $.isPlainObject( instance[camelCaseValue] ) && (depth != maxDepth) ) {
|
420
|
+
instance = instance[camelCaseValue];
|
421
|
+
}
|
422
|
+
else if( instance[value] !== undefined ) {
|
423
|
+
found = instance[value];
|
424
|
+
return false;
|
425
|
+
}
|
426
|
+
else if( instance[camelCaseValue] !== undefined ) {
|
427
|
+
found = instance[camelCaseValue];
|
428
|
+
return false;
|
429
|
+
}
|
430
|
+
else {
|
431
|
+
module.error(error.method);
|
432
|
+
return false;
|
433
|
+
}
|
434
|
+
});
|
435
|
+
}
|
436
|
+
if ( $.isFunction( found ) ) {
|
437
|
+
response = found.apply(context, passedArguments);
|
438
|
+
}
|
439
|
+
else if(found !== undefined) {
|
440
|
+
response = found;
|
441
|
+
}
|
442
|
+
if($.isArray(invokedResponse)) {
|
443
|
+
invokedResponse.push(response);
|
444
|
+
}
|
445
|
+
else if(typeof invokedResponse == 'string') {
|
446
|
+
invokedResponse = [invokedResponse, response];
|
447
|
+
}
|
448
|
+
else if(response !== undefined) {
|
449
|
+
invokedResponse = response;
|
450
|
+
}
|
451
|
+
return found;
|
452
|
+
}
|
453
|
+
};
|
454
|
+
|
455
|
+
if(methodInvoked) {
|
456
|
+
if(instance === undefined) {
|
457
|
+
module.initialize();
|
458
|
+
}
|
459
|
+
module.invoke(query);
|
460
|
+
}
|
461
|
+
else {
|
462
|
+
if(instance !== undefined) {
|
463
|
+
module.destroy();
|
464
|
+
}
|
465
|
+
module.initialize();
|
466
|
+
}
|
467
|
+
})
|
468
|
+
;
|
469
|
+
|
470
|
+
return (invokedResponse !== undefined)
|
471
|
+
? invokedResponse
|
472
|
+
: this
|
473
|
+
;
|
474
|
+
};
|
475
|
+
|
476
|
+
$.fn.dimmer.settings = {
|
477
|
+
|
478
|
+
name : 'Dimmer',
|
479
|
+
namespace : 'dimmer',
|
480
|
+
|
481
|
+
verbose : true,
|
482
|
+
debug : true,
|
483
|
+
performance : true,
|
484
|
+
|
485
|
+
transition : 'fade',
|
486
|
+
|
487
|
+
on : false,
|
488
|
+
closable : true,
|
489
|
+
duration : 500,
|
490
|
+
|
491
|
+
onChange : function(){},
|
492
|
+
onShow : function(){},
|
493
|
+
onHide : function(){},
|
494
|
+
|
495
|
+
error : {
|
496
|
+
method : 'The method you called is not defined.'
|
497
|
+
},
|
498
|
+
|
499
|
+
selector: {
|
500
|
+
dimmable : '.ui.dimmable',
|
501
|
+
dimmer : '.ui.dimmer',
|
502
|
+
content : '.ui.dimmer > .content, .ui.dimmer > .content > .center'
|
503
|
+
},
|
504
|
+
|
505
|
+
template: {
|
506
|
+
dimmer: function() {
|
507
|
+
return $('<div />').attr('class', 'ui dimmer');
|
508
|
+
}
|
509
|
+
},
|
510
|
+
|
511
|
+
className : {
|
512
|
+
active : 'active',
|
513
|
+
animating : 'animating',
|
514
|
+
dimmable : 'ui dimmable',
|
515
|
+
dimmed : 'dimmed',
|
516
|
+
disabled : 'disabled',
|
517
|
+
pageDimmer : 'page',
|
518
|
+
hide : 'hide',
|
519
|
+
show : 'show',
|
520
|
+
transition : 'transition hidden visible'
|
521
|
+
}
|
522
|
+
|
523
|
+
};
|
524
|
+
|
525
|
+
})( jQuery, window , document );
|