semantic_ui_rails 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE +20 -0
  5. data/README.md +4 -0
  6. data/Rakefile +1 -0
  7. data/app/assets/fonts/semantic/icons.eot +0 -0
  8. data/app/assets/fonts/semantic/icons.svg +450 -0
  9. data/app/assets/fonts/semantic/icons.ttf +0 -0
  10. data/app/assets/fonts/semantic/icons.woff +0 -0
  11. data/app/assets/images/semantic/loader-large-inverted.gif +0 -0
  12. data/app/assets/images/semantic/loader-large.gif +0 -0
  13. data/app/assets/images/semantic/loader-medium-inverted.gif +0 -0
  14. data/app/assets/images/semantic/loader-medium.gif +0 -0
  15. data/app/assets/images/semantic/loader-mini-inverted.gif +0 -0
  16. data/app/assets/images/semantic/loader-mini.gif +0 -0
  17. data/app/assets/images/semantic/loader-small-inverted.gif +0 -0
  18. data/app/assets/images/semantic/loader-small.gif +0 -0
  19. data/app/assets/javascript/semantic/accordion.js +411 -0
  20. data/app/assets/javascript/semantic/behavior/api.js +666 -0
  21. data/app/assets/javascript/semantic/behavior/colorize.js +271 -0
  22. data/app/assets/javascript/semantic/behavior/form.js +703 -0
  23. data/app/assets/javascript/semantic/behavior/state.js +752 -0
  24. data/app/assets/javascript/semantic/chatroom.js +766 -0
  25. data/app/assets/javascript/semantic/checkbox.js +348 -0
  26. data/app/assets/javascript/semantic/dimmer.js +524 -0
  27. data/app/assets/javascript/semantic/dropdown.js +707 -0
  28. data/app/assets/javascript/semantic/modal.js +478 -0
  29. data/app/assets/javascript/semantic/nag.js +542 -0
  30. data/app/assets/javascript/semantic/popup.js +721 -0
  31. data/app/assets/javascript/semantic/rating.js +358 -0
  32. data/app/assets/javascript/semantic/search.js +769 -0
  33. data/app/assets/javascript/semantic/shape.js +776 -0
  34. data/app/assets/javascript/semantic/sidebar.js +489 -0
  35. data/app/assets/javascript/semantic/tab.js +674 -0
  36. data/app/assets/javascript/semantic/transition.js +650 -0
  37. data/app/assets/javascript/semantic/video.js +459 -0
  38. data/app/assets/stylesheets/semantic/accordion.css +97 -0
  39. data/app/assets/stylesheets/semantic/breadcrumb.css +66 -0
  40. data/app/assets/stylesheets/semantic/button.css +993 -0
  41. data/app/assets/stylesheets/semantic/chatroom.css +242 -0
  42. data/app/assets/stylesheets/semantic/checkbox.css +300 -0
  43. data/app/assets/stylesheets/semantic/comment.css +178 -0
  44. data/app/assets/stylesheets/semantic/dimmer.css +185 -0
  45. data/app/assets/stylesheets/semantic/divider.css +155 -0
  46. data/app/assets/stylesheets/semantic/dropdown.css +415 -0
  47. data/app/assets/stylesheets/semantic/feed.css +126 -0
  48. data/app/assets/stylesheets/semantic/form.css +427 -0
  49. data/app/assets/stylesheets/semantic/grid.css +561 -0
  50. data/app/assets/stylesheets/semantic/header.css +277 -0
  51. data/app/assets/stylesheets/semantic/icon.css +811 -0
  52. data/app/assets/stylesheets/semantic/image.css +143 -0
  53. data/app/assets/stylesheets/semantic/input.css +225 -0
  54. data/app/assets/stylesheets/semantic/item.css +564 -0
  55. data/app/assets/stylesheets/semantic/label.css +687 -0
  56. data/app/assets/stylesheets/semantic/list.css +418 -0
  57. data/app/assets/stylesheets/semantic/loader.css +148 -0
  58. data/app/assets/stylesheets/semantic/menu.css +1409 -0
  59. data/app/assets/stylesheets/semantic/message.css +242 -0
  60. data/app/assets/stylesheets/semantic/modal.css +123 -0
  61. data/app/assets/stylesheets/semantic/nag.css +130 -0
  62. data/app/assets/stylesheets/semantic/popup.css +209 -0
  63. data/app/assets/stylesheets/semantic/progress.css +257 -0
  64. data/app/assets/stylesheets/semantic/rating.css +120 -0
  65. data/app/assets/stylesheets/semantic/reveal.css +283 -0
  66. data/app/assets/stylesheets/semantic/search.css +222 -0
  67. data/app/assets/stylesheets/semantic/segment.css +362 -0
  68. data/app/assets/stylesheets/semantic/shape.css +87 -0
  69. data/app/assets/stylesheets/semantic/sidebar.css +100 -0
  70. data/app/assets/stylesheets/semantic/step.css +240 -0
  71. data/app/assets/stylesheets/semantic/tab.css +52 -0
  72. data/app/assets/stylesheets/semantic/table.css +468 -0
  73. data/app/assets/stylesheets/semantic/transition.css +867 -0
  74. data/app/assets/stylesheets/semantic/video.css +81 -0
  75. data/lib/semantic_ui_rails/version.rb +3 -0
  76. data/lib/semantic_ui_rails.rb +7 -0
  77. data/semantic_ui_rails.gemspec +23 -0
  78. metadata +149 -0
@@ -0,0 +1,478 @@
1
+ /* ******************************
2
+ Modal
3
+ Author: Jack Lukic
4
+ Notes: First Commit May 14, 2012
5
+
6
+ Manages modal state and
7
+ stage dimming
8
+
9
+ ****************************** */
10
+
11
+ ;(function ( $, window, document, undefined ) {
12
+
13
+ $.fn.modal = function(parameters) {
14
+ var
15
+ $allModals = $(this),
16
+ $document = $(document),
17
+
18
+ settings = ( $.isPlainObject(parameters) )
19
+ ? $.extend(true, {}, $.fn.modal.settings, parameters)
20
+ : $.fn.modal.settings,
21
+
22
+ selector = settings.selector,
23
+ className = settings.className,
24
+ namespace = settings.namespace,
25
+ error = settings.error,
26
+
27
+ eventNamespace = '.' + namespace,
28
+ moduleNamespace = 'module-' + namespace,
29
+ moduleSelector = $allModals.selector || '',
30
+
31
+ time = new Date().getTime(),
32
+ performance = [],
33
+
34
+ query = arguments[0],
35
+ methodInvoked = (typeof query == 'string'),
36
+ queryArguments = [].slice.call(arguments, 1),
37
+
38
+ invokedResponse
39
+ ;
40
+
41
+ $allModals
42
+ .each(function() {
43
+ var
44
+ $modal = $(this),
45
+ $context = $(settings.context),
46
+ $otherModals = $allModals.not($modal),
47
+ $closeButton = $modal.find(selector.closeButton),
48
+
49
+ $dimmer,
50
+
51
+ element = this,
52
+ instance = $modal.data(moduleNamespace),
53
+ modal
54
+ ;
55
+
56
+ modal = {
57
+
58
+ initialize: function() {
59
+ modal.verbose('Attaching events');
60
+ $closeButton
61
+ .on('click', modal.event.close)
62
+ ;
63
+ modal.cache.sizes();
64
+
65
+ modal.verbose('Creating dimmer');
66
+ $context
67
+ .dimmer({
68
+ closable: settings.closable,
69
+ duration: settings.duration,
70
+ onShow: function() {
71
+ modal.add.keyboardShortcuts();
72
+ $.proxy(settings.onShow, this)();
73
+ },
74
+ onHide: function() {
75
+ if($modal.is(':visible')) {
76
+ $context.off('.dimmer');
77
+ modal.hide();
78
+ $.proxy(settings.onHide, this)();
79
+ }
80
+ modal.remove.keyboardShortcuts();
81
+ }
82
+ })
83
+ ;
84
+ $dimmer = $context.children(selector.dimmer);
85
+ if( $modal.parent()[0] !== $dimmer[0] ) {
86
+ modal.debug('Moving element inside dimmer', $context);
87
+ $modal = $modal
88
+ .detach()
89
+ .appendTo($dimmer)
90
+ ;
91
+ }
92
+ modal.instantiate();
93
+ },
94
+
95
+ instantiate: function() {
96
+ modal.verbose('Storing instance of modal');
97
+ instance = modal;
98
+ $modal
99
+ .data(moduleNamespace, instance)
100
+ ;
101
+ },
102
+
103
+ destroy: function() {
104
+ modal.verbose('Destroying previous modal');
105
+ $modal
106
+ .off(eventNamespace)
107
+ ;
108
+ },
109
+
110
+ event: {
111
+ close: function() {
112
+ modal.verbose('Close button pressed');
113
+ $context.dimmer('hide');
114
+ },
115
+ keyboard: function(event) {
116
+ var
117
+ keyCode = event.which,
118
+ escapeKey = 27
119
+ ;
120
+ if(keyCode == escapeKey) {
121
+ modal.debug('Escape key pressed hiding modal');
122
+ $context.dimmer('hide');
123
+ event.preventDefault();
124
+ }
125
+ },
126
+ resize: function() {
127
+ modal.cache.sizes();
128
+ if( $modal.is(':visible') ) {
129
+ modal.set.type();
130
+ modal.set.position();
131
+ }
132
+ }
133
+ },
134
+
135
+ toggle: function() {
136
+ if( modal.is.active() ) {
137
+ modal.hide();
138
+ }
139
+ else {
140
+ modal.show();
141
+ }
142
+ },
143
+
144
+ show: function() {
145
+ modal.debug('Showing modal');
146
+ modal.set.type();
147
+ modal.set.position();
148
+ modal.hideAll();
149
+ if(settings.transition && $.fn.transition !== undefined) {
150
+ $modal
151
+ .transition(settings.transition + ' in', settings.duration, modal.set.active)
152
+ ;
153
+ }
154
+ else {
155
+ $modal
156
+ .fadeIn(settings.duration, settings.easing, modal.set.active)
157
+ ;
158
+ }
159
+ modal.debug('Triggering dimmer');
160
+ $context.dimmer('show');
161
+ },
162
+
163
+ hide: function() {
164
+ modal.debug('Hiding modal');
165
+ // remove keyboard detection
166
+ $document
167
+ .off('keyup.' + namespace)
168
+ ;
169
+ if(settings.transition && $.fn.transition !== undefined) {
170
+ $modal
171
+ .transition(settings.transition + ' out', settings.duration, modal.remove.active)
172
+ ;
173
+ }
174
+ else {
175
+ $modal
176
+ .fadeOut(settings.duration, settings.easing, modal.remove.active)
177
+ ;
178
+ }
179
+ },
180
+
181
+ hideAll: function() {
182
+ $otherModals
183
+ .filter(':visible')
184
+ .modal('hide')
185
+ ;
186
+ },
187
+
188
+ add: {
189
+ keyboardShortcuts: function() {
190
+ modal.verbose('Adding keyboard shortcuts');
191
+ $document
192
+ .on('keyup' + eventNamespace, modal.event.keyboard)
193
+ ;
194
+ }
195
+ },
196
+
197
+ remove: {
198
+ active: function() {
199
+ $modal.removeClass(className.active);
200
+ },
201
+ keyboardShortcuts: function() {
202
+ modal.verbose('Removing keyboard shortcuts');
203
+ $document
204
+ .off('keyup' + eventNamespace)
205
+ ;
206
+ }
207
+ },
208
+
209
+ cache: {
210
+ sizes: function() {
211
+ modal.cache = {
212
+ height : $modal.outerHeight() + settings.offset,
213
+ contextHeight : (settings.context == 'body')
214
+ ? $(window).height()
215
+ : $context.height()
216
+ };
217
+ console.log($modal);
218
+ modal.debug('Caching modal and container sizes', modal.cache);
219
+ }
220
+ },
221
+
222
+ can: {
223
+ fit: function() {
224
+ return (modal.cache.height < modal.cache.contextHeight);
225
+ }
226
+ },
227
+
228
+ is: {
229
+ active: function() {
230
+ return $modal.hasClass(className.active);
231
+ }
232
+ },
233
+
234
+ set: {
235
+ active: function() {
236
+ $modal.addClass('active');
237
+ },
238
+ type: function() {
239
+ if(modal.can.fit()) {
240
+ modal.verbose('Modal fits on screen');
241
+ $modal.removeClass(className.scrolling);
242
+ }
243
+ else {
244
+ modal.verbose('Modal cannot fit on screen setting to scrolling');
245
+ $modal.addClass(className.scrolling);
246
+ }
247
+ },
248
+ position: function() {
249
+ modal.verbose('Centering modal on page', modal.cache.height / 2);
250
+ if(modal.can.fit()) {
251
+ $modal
252
+ .css({
253
+ marginTop: -(modal.cache.height / 2)
254
+ })
255
+ ;
256
+ }
257
+ else {
258
+ $modal
259
+ .css({
260
+ top: $context.prop('scrollTop')
261
+ })
262
+ ;
263
+ }
264
+ }
265
+ },
266
+
267
+ setting: function(name, value) {
268
+ if(value !== undefined) {
269
+ if( $.isPlainObject(name) ) {
270
+ $.extend(true, settings, name);
271
+ }
272
+ else {
273
+ settings[name] = value;
274
+ }
275
+ }
276
+ else {
277
+ return settings[name];
278
+ }
279
+ },
280
+ internal: function(name, value) {
281
+ if(value !== undefined) {
282
+ if( $.isPlainObject(name) ) {
283
+ $.extend(true, modal, name);
284
+ }
285
+ else {
286
+ modal[name] = value;
287
+ }
288
+ }
289
+ else {
290
+ return modal[name];
291
+ }
292
+ },
293
+ debug: function() {
294
+ if(settings.debug) {
295
+ if(settings.performance) {
296
+ modal.performance.log(arguments);
297
+ }
298
+ else {
299
+ modal.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
300
+ modal.debug.apply(console, arguments);
301
+ }
302
+ }
303
+ },
304
+ verbose: function() {
305
+ if(settings.verbose && settings.debug) {
306
+ if(settings.performance) {
307
+ modal.performance.log(arguments);
308
+ }
309
+ else {
310
+ modal.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
311
+ modal.verbose.apply(console, arguments);
312
+ }
313
+ }
314
+ },
315
+ error: function() {
316
+ modal.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
317
+ modal.error.apply(console, arguments);
318
+ },
319
+ performance: {
320
+ log: function(message) {
321
+ var
322
+ currentTime,
323
+ executionTime,
324
+ previousTime
325
+ ;
326
+ if(settings.performance) {
327
+ currentTime = new Date().getTime();
328
+ previousTime = time || currentTime;
329
+ executionTime = currentTime - previousTime;
330
+ time = currentTime;
331
+ performance.push({
332
+ 'Element' : element,
333
+ 'Name' : message[0],
334
+ 'Arguments' : [].slice.call(message, 1) || '',
335
+ 'Execution Time' : executionTime
336
+ });
337
+ }
338
+ clearTimeout(modal.performance.timer);
339
+ modal.performance.timer = setTimeout(modal.performance.display, 100);
340
+ },
341
+ display: function() {
342
+ var
343
+ title = settings.name + ':',
344
+ totalTime = 0
345
+ ;
346
+ time = false;
347
+ clearTimeout(modal.performance.timer);
348
+ $.each(performance, function(index, data) {
349
+ totalTime += data['Execution Time'];
350
+ });
351
+ title += ' ' + totalTime + 'ms';
352
+ if(moduleSelector) {
353
+ title += ' \'' + moduleSelector + '\'';
354
+ }
355
+ if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
356
+ console.groupCollapsed(title);
357
+ if(console.table) {
358
+ console.table(performance);
359
+ }
360
+ else {
361
+ $.each(performance, function(index, data) {
362
+ console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
363
+ });
364
+ }
365
+ console.groupEnd();
366
+ }
367
+ performance = [];
368
+ }
369
+ },
370
+ invoke: function(query, passedArguments, context) {
371
+ var
372
+ maxDepth,
373
+ found,
374
+ response
375
+ ;
376
+ passedArguments = passedArguments || queryArguments;
377
+ context = element || context;
378
+ if(typeof query == 'string' && instance !== undefined) {
379
+ query = query.split(/[\. ]/);
380
+ maxDepth = query.length - 1;
381
+ $.each(query, function(depth, value) {
382
+ var camelCaseValue = (depth != maxDepth)
383
+ ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
384
+ : query
385
+ ;
386
+ if( $.isPlainObject( instance[value] ) && (depth != maxDepth) ) {
387
+ instance = instance[value];
388
+ }
389
+ else if( $.isPlainObject( instance[camelCaseValue] ) && (depth != maxDepth) ) {
390
+ instance = instance[camelCaseValue];
391
+ }
392
+ else if( instance[value] !== undefined ) {
393
+ found = instance[value];
394
+ return false;
395
+ }
396
+ else if( instance[camelCaseValue] !== undefined ) {
397
+ found = instance[camelCaseValue];
398
+ return false;
399
+ }
400
+ else {
401
+ modal.error(error.method);
402
+ return false;
403
+ }
404
+ });
405
+ }
406
+ if ( $.isFunction( found ) ) {
407
+ response = found.apply(context, passedArguments);
408
+ }
409
+ else if(found !== undefined) {
410
+ response = found;
411
+ }
412
+ if($.isArray(invokedResponse)) {
413
+ invokedResponse.push(response);
414
+ }
415
+ else if(typeof invokedResponse == 'string') {
416
+ invokedResponse = [invokedResponse, response];
417
+ }
418
+ else if(response !== undefined) {
419
+ invokedResponse = response;
420
+ }
421
+ return found;
422
+ }
423
+ };
424
+
425
+ if(methodInvoked) {
426
+ if(instance === undefined) {
427
+ modal.initialize();
428
+ }
429
+ invokedResponse = modal.invoke(query);
430
+ }
431
+ else {
432
+ if(instance !== undefined) {
433
+ modal.destroy();
434
+ }
435
+ modal.initialize();
436
+ }
437
+ })
438
+ ;
439
+
440
+ return (invokedResponse !== undefined)
441
+ ? invokedResponse
442
+ : this
443
+ ;
444
+ };
445
+
446
+ $.fn.modal.settings = {
447
+
448
+ name : 'Modal',
449
+ namespace : 'modal',
450
+ verbose : true,
451
+ debug : true,
452
+ performance : true,
453
+
454
+ offset : 0,
455
+ transition : 'scale',
456
+ duration : 500,
457
+ easing : 'easeOutExpo',
458
+
459
+ closable : true,
460
+ context : 'body',
461
+
462
+ onShow : function(){},
463
+ onHide : function(){},
464
+
465
+ selector : {
466
+ closeButton : '.close, .actions .button',
467
+ dimmer: '.ui.dimmer'
468
+ },
469
+ error : {
470
+ method : 'The method you called is not defined.'
471
+ },
472
+ className : {
473
+ scrolling : 'scrolling'
474
+ },
475
+ };
476
+
477
+
478
+ })( jQuery, window , document );