semantic-ui-rails 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +26 -0
  6. data/Rakefile +1 -0
  7. data/lib/generators/semantic/install/install_generator.rb +38 -0
  8. data/lib/generators/semantic/install/templates/semantic-ui.js +21 -0
  9. data/lib/generators/semantic/install/templates/semantic-ui/collections.less +6 -0
  10. data/lib/generators/semantic/install/templates/semantic-ui/elements.less +11 -0
  11. data/lib/generators/semantic/install/templates/semantic-ui/modules.less +18 -0
  12. data/lib/generators/semantic/install/templates/semantic-ui/views.less +6 -0
  13. data/lib/semantic/ui/rails.rb +10 -0
  14. data/lib/semantic/ui/rails/engine.rb +8 -0
  15. data/lib/semantic/ui/rails/version.rb +7 -0
  16. data/semantic-ui-rails.gemspec +23 -0
  17. data/vendor/assets/fonts/icons.eot +0 -0
  18. data/vendor/assets/fonts/icons.svg +450 -0
  19. data/vendor/assets/fonts/icons.ttf +0 -0
  20. data/vendor/assets/fonts/icons.woff +0 -0
  21. data/vendor/assets/images/semantic-ui/loader-large-inverted.gif +0 -0
  22. data/vendor/assets/images/semantic-ui/loader-large.gif +0 -0
  23. data/vendor/assets/images/semantic-ui/loader-medium-inverted.gif +0 -0
  24. data/vendor/assets/images/semantic-ui/loader-medium.gif +0 -0
  25. data/vendor/assets/images/semantic-ui/loader-mini-inverted.gif +0 -0
  26. data/vendor/assets/images/semantic-ui/loader-mini.gif +0 -0
  27. data/vendor/assets/images/semantic-ui/loader-small-inverted.gif +0 -0
  28. data/vendor/assets/images/semantic-ui/loader-small.gif +0 -0
  29. data/vendor/assets/javascripts/semantic-ui/accordion.js +411 -0
  30. data/vendor/assets/javascripts/semantic-ui/behavior/api.js +666 -0
  31. data/vendor/assets/javascripts/semantic-ui/behavior/colorize.js +271 -0
  32. data/vendor/assets/javascripts/semantic-ui/behavior/form.js +657 -0
  33. data/vendor/assets/javascripts/semantic-ui/behavior/state.js +752 -0
  34. data/vendor/assets/javascripts/semantic-ui/carousel.js +327 -0
  35. data/vendor/assets/javascripts/semantic-ui/chatroom.js +766 -0
  36. data/vendor/assets/javascripts/semantic-ui/checkbox.js +348 -0
  37. data/vendor/assets/javascripts/semantic-ui/dimmer.js +525 -0
  38. data/vendor/assets/javascripts/semantic-ui/dropdown.js +697 -0
  39. data/vendor/assets/javascripts/semantic-ui/modal.js +478 -0
  40. data/vendor/assets/javascripts/semantic-ui/nag.js +542 -0
  41. data/vendor/assets/javascripts/semantic-ui/popup.js +721 -0
  42. data/vendor/assets/javascripts/semantic-ui/rating.js +358 -0
  43. data/vendor/assets/javascripts/semantic-ui/search.js +770 -0
  44. data/vendor/assets/javascripts/semantic-ui/shape.js +776 -0
  45. data/vendor/assets/javascripts/semantic-ui/sidebar.js +489 -0
  46. data/vendor/assets/javascripts/semantic-ui/tab.js +674 -0
  47. data/vendor/assets/javascripts/semantic-ui/transition.js +645 -0
  48. data/vendor/assets/javascripts/semantic-ui/video.js +459 -0
  49. data/vendor/assets/stylesheets/semantic-ui/collections/breadcrumb.less +79 -0
  50. data/vendor/assets/stylesheets/semantic-ui/collections/form.less +536 -0
  51. data/vendor/assets/stylesheets/semantic-ui/collections/grid.less +655 -0
  52. data/vendor/assets/stylesheets/semantic-ui/collections/menu.less +1736 -0
  53. data/vendor/assets/stylesheets/semantic-ui/collections/message.less +337 -0
  54. data/vendor/assets/stylesheets/semantic-ui/collections/table.less +526 -0
  55. data/vendor/assets/stylesheets/semantic-ui/elements/button.less +1294 -0
  56. data/vendor/assets/stylesheets/semantic-ui/elements/divider.less +200 -0
  57. data/vendor/assets/stylesheets/semantic-ui/elements/header.less +325 -0
  58. data/vendor/assets/stylesheets/semantic-ui/elements/icon.less +449 -0
  59. data/vendor/assets/stylesheets/semantic-ui/elements/image.less +170 -0
  60. data/vendor/assets/stylesheets/semantic-ui/elements/input.less +287 -0
  61. data/vendor/assets/stylesheets/semantic-ui/elements/label.less +805 -0
  62. data/vendor/assets/stylesheets/semantic-ui/elements/loader.less +178 -0
  63. data/vendor/assets/stylesheets/semantic-ui/elements/progress.less +353 -0
  64. data/vendor/assets/stylesheets/semantic-ui/elements/segment.less +465 -0
  65. data/vendor/assets/stylesheets/semantic-ui/elements/step.less +294 -0
  66. data/vendor/assets/stylesheets/semantic-ui/modules/accordion.less +135 -0
  67. data/vendor/assets/stylesheets/semantic-ui/modules/carousel.less +71 -0
  68. data/vendor/assets/stylesheets/semantic-ui/modules/chatroom.less +271 -0
  69. data/vendor/assets/stylesheets/semantic-ui/modules/checkbox.less +378 -0
  70. data/vendor/assets/stylesheets/semantic-ui/modules/dimmer.less +230 -0
  71. data/vendor/assets/stylesheets/semantic-ui/modules/dropdown.less +506 -0
  72. data/vendor/assets/stylesheets/semantic-ui/modules/extra.transition.less +1197 -0
  73. data/vendor/assets/stylesheets/semantic-ui/modules/modal.less +154 -0
  74. data/vendor/assets/stylesheets/semantic-ui/modules/nag.less +175 -0
  75. data/vendor/assets/stylesheets/semantic-ui/modules/popup.less +238 -0
  76. data/vendor/assets/stylesheets/semantic-ui/modules/rating.less +151 -0
  77. data/vendor/assets/stylesheets/semantic-ui/modules/reveal.less +367 -0
  78. data/vendor/assets/stylesheets/semantic-ui/modules/search.less +275 -0
  79. data/vendor/assets/stylesheets/semantic-ui/modules/shape.less +115 -0
  80. data/vendor/assets/stylesheets/semantic-ui/modules/sidebar.less +147 -0
  81. data/vendor/assets/stylesheets/semantic-ui/modules/tab.less +59 -0
  82. data/vendor/assets/stylesheets/semantic-ui/modules/transition.less +839 -0
  83. data/vendor/assets/stylesheets/semantic-ui/modules/video.less +99 -0
  84. data/vendor/assets/stylesheets/semantic-ui/views/comment.less +221 -0
  85. data/vendor/assets/stylesheets/semantic-ui/views/feed.less +151 -0
  86. data/vendor/assets/stylesheets/semantic-ui/views/item.less +641 -0
  87. data/vendor/assets/stylesheets/semantic-ui/views/list.less +491 -0
  88. data/vendor/assets/stylesheets/semantic-ui/views/sitemap.less +47 -0
  89. data/vendor/assets/stylesheets/semantic-ui/views/statistic.less +34 -0
  90. metadata +161 -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 );