semantic-ui-rails 0.1.0 → 0.1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/lib/generators/semantic/install/install_generator.rb +3 -3
  3. data/lib/generators/semantic/install/templates/semantic-ui.css.less +47 -0
  4. data/lib/semantic/ui/rails/version.rb +1 -1
  5. data/semantic.thor +29 -25
  6. data/vendor/assets/javascripts/semantic-ui/modules/accordion.js +7 -0
  7. data/vendor/assets/javascripts/semantic-ui/modules/chatroom.js +1 -1
  8. data/vendor/assets/javascripts/semantic-ui/modules/checkbox.js +2 -5
  9. data/vendor/assets/javascripts/semantic-ui/modules/dimmer.js +73 -49
  10. data/vendor/assets/javascripts/semantic-ui/modules/dropdown.js +135 -136
  11. data/vendor/assets/javascripts/semantic-ui/modules/modal.js +196 -125
  12. data/vendor/assets/javascripts/semantic-ui/modules/popup.js +3 -6
  13. data/vendor/assets/javascripts/semantic-ui/modules/rating.js +80 -38
  14. data/vendor/assets/javascripts/semantic-ui/modules/sidebar.js +17 -20
  15. data/vendor/assets/javascripts/semantic-ui/modules/tab.js +32 -20
  16. data/vendor/assets/javascripts/semantic-ui/modules/transition.js +2 -0
  17. data/vendor/assets/stylesheets/semantic-ui/collections/form.less +15 -2
  18. data/vendor/assets/stylesheets/semantic-ui/collections/grid.less +20 -39
  19. data/vendor/assets/stylesheets/semantic-ui/collections/menu.less +12 -12
  20. data/vendor/assets/stylesheets/semantic-ui/elements/basic.icon.less +203 -198
  21. data/vendor/assets/stylesheets/semantic-ui/elements/button.less +17 -6
  22. data/vendor/assets/stylesheets/semantic-ui/elements/header.less +49 -31
  23. data/vendor/assets/stylesheets/semantic-ui/elements/icon.less +9 -13
  24. data/vendor/assets/stylesheets/semantic-ui/elements/image.less +13 -1
  25. data/vendor/assets/stylesheets/semantic-ui/elements/input.less +1 -1
  26. data/vendor/assets/stylesheets/semantic-ui/elements/loader.less +8 -8
  27. data/vendor/assets/stylesheets/semantic-ui/modules/checkbox.less +1 -1
  28. data/vendor/assets/stylesheets/semantic-ui/modules/dimmer.less +13 -5
  29. data/vendor/assets/stylesheets/semantic-ui/modules/dropdown.less +48 -8
  30. data/vendor/assets/stylesheets/semantic-ui/modules/modal.less +72 -13
  31. data/vendor/assets/stylesheets/semantic-ui/modules/rating.less +38 -35
  32. data/vendor/assets/stylesheets/semantic-ui/modules/search.less +1 -1
  33. data/vendor/assets/stylesheets/semantic-ui/modules/tab.less +1 -1
  34. data/vendor/assets/stylesheets/semantic-ui/modules/transition.less +283 -25
  35. data/vendor/assets/stylesheets/semantic-ui/views/list.less +24 -2
  36. metadata +3 -7
  37. data/lib/generators/semantic/install/templates/semantic-ui/collections.less +0 -6
  38. data/lib/generators/semantic/install/templates/semantic-ui/elements.less +0 -12
  39. data/lib/generators/semantic/install/templates/semantic-ui/modules.less +0 -16
  40. data/lib/generators/semantic/install/templates/semantic-ui/views.less +0 -6
  41. data/vendor/assets/stylesheets/semantic-ui/views/statistic.css +0 -27
@@ -13,10 +13,11 @@
13
13
 
14
14
  $.fn.modal = function(parameters) {
15
15
  var
16
- $allModals = $(this),
17
- $document = $(document),
16
+ $allModules = $(this),
17
+ $window = $(window),
18
+ $document = $(document),
18
19
 
19
- settings = ( $.isPlainObject(parameters) )
20
+ settings = ( $.isPlainObject(parameters) )
20
21
  ? $.extend(true, {}, $.fn.modal.settings, parameters)
21
22
  : $.fn.modal.settings,
22
23
 
@@ -27,7 +28,7 @@ $.fn.modal = function(parameters) {
27
28
 
28
29
  eventNamespace = '.' + namespace,
29
30
  moduleNamespace = 'module-' + namespace,
30
- moduleSelector = $allModals.selector || '',
31
+ moduleSelector = $allModules.selector || '',
31
32
 
32
33
  time = new Date().getTime(),
33
34
  performance = [],
@@ -39,144 +40,182 @@ $.fn.modal = function(parameters) {
39
40
  invokedResponse
40
41
  ;
41
42
 
42
- $allModals
43
+
44
+ $allModules
43
45
  .each(function() {
44
46
  var
45
- $modal = $(this),
47
+ $module = $(this),
46
48
  $context = $(settings.context),
47
- $otherModals = $allModals.not($modal),
48
- $closeButton = $modal.find(selector.closeButton),
49
+ $otherModals = $allModules.not($module),
50
+ $close = $module.find(selector.close),
49
51
 
52
+ $focusedElement,
50
53
  $dimmer,
51
54
 
52
55
  element = this,
53
- instance = $modal.data(moduleNamespace),
54
- modal
56
+ instance = $module.data(moduleNamespace),
57
+ module
55
58
  ;
56
59
 
57
- modal = {
60
+ module = {
58
61
 
59
62
  initialize: function() {
60
- modal.verbose('Attaching events');
61
- $closeButton
62
- .on('click', modal.event.close)
63
+ module.verbose('Initializing dimmer', $context);
64
+
65
+ $dimmer = $context
66
+ .dimmer('add content', $module)
67
+ .dimmer('get dimmer')
63
68
  ;
64
- modal.cache.sizes();
65
-
66
- modal.verbose('Creating dimmer');
67
- $context
68
- .dimmer({
69
- closable: settings.closable,
70
- duration: settings.duration,
71
- onShow: function() {
72
- modal.add.keyboardShortcuts();
73
- $.proxy(settings.onShow, this)();
74
- },
75
- onHide: function() {
76
- if($modal.is(':visible')) {
77
- $context.off('.dimmer');
78
- modal.hide();
79
- $.proxy(settings.onHide, this)();
80
- }
81
- modal.remove.keyboardShortcuts();
82
- }
69
+
70
+ module.verbose('Attaching close events', $close);
71
+ $close
72
+ .on('click' + eventNamespace, module.event.close)
73
+ ;
74
+ $window
75
+ .on('resize', function() {
76
+ module.event.debounce(module.refresh, 50);
83
77
  })
84
78
  ;
85
- $dimmer = $context.children(selector.dimmer);
86
- if( $modal.parent()[0] !== $dimmer[0] ) {
87
- modal.debug('Moving element inside dimmer', $context);
88
- $modal = $modal
89
- .detach()
90
- .appendTo($dimmer)
91
- ;
92
- }
93
- modal.instantiate();
79
+ module.instantiate();
94
80
  },
95
81
 
96
82
  instantiate: function() {
97
- modal.verbose('Storing instance of modal');
98
- instance = modal;
99
- $modal
83
+ module.verbose('Storing instance of modal');
84
+ instance = module;
85
+ $module
100
86
  .data(moduleNamespace, instance)
101
87
  ;
102
88
  },
103
89
 
104
90
  destroy: function() {
105
- modal.verbose('Destroying previous modal');
106
- $modal
91
+ module.verbose('Destroying previous modal');
92
+ $module
107
93
  .off(eventNamespace)
108
94
  ;
109
95
  },
110
96
 
97
+ refresh: function() {
98
+ module.remove.scrolling();
99
+ module.cacheSizes();
100
+ module.set.type();
101
+ module.set.position();
102
+ },
103
+
104
+ attachEvents: function(selector, event) {
105
+ var
106
+ $toggle = $(selector)
107
+ ;
108
+ event = $.isFunction(module[event])
109
+ ? module[event]
110
+ : module.show
111
+ ;
112
+ if($toggle.size() > 0) {
113
+ module.debug('Attaching modal events to element', selector, event);
114
+ $toggle
115
+ .off(eventNamespace)
116
+ .on('click' + eventNamespace, event)
117
+ ;
118
+ }
119
+ else {
120
+ module.error(error.notFound);
121
+ }
122
+ },
123
+
111
124
  event: {
112
125
  close: function() {
113
- modal.verbose('Close button pressed');
126
+ module.verbose('Close button pressed');
114
127
  $context.dimmer('hide');
115
128
  },
129
+ debounce: function(method, delay) {
130
+ clearTimeout(module.timer);
131
+ module.timer = setTimeout(method, delay);
132
+ },
116
133
  keyboard: function(event) {
117
134
  var
118
135
  keyCode = event.which,
119
136
  escapeKey = 27
120
137
  ;
121
138
  if(keyCode == escapeKey) {
122
- modal.debug('Escape key pressed hiding modal');
139
+ module.debug('Escape key pressed hiding modal');
123
140
  $context.dimmer('hide');
124
141
  event.preventDefault();
125
142
  }
126
143
  },
127
144
  resize: function() {
128
- modal.cache.sizes();
129
- if( $modal.is(':visible') ) {
130
- modal.set.type();
131
- modal.set.position();
145
+ if( $context.dimmer('is active') ) {
146
+ module.refresh();
132
147
  }
133
148
  }
134
149
  },
135
150
 
136
151
  toggle: function() {
137
- if( modal.is.active() ) {
138
- modal.hide();
152
+ if( module.is.active() ) {
153
+ module.hide();
139
154
  }
140
155
  else {
141
- modal.show();
156
+ module.show();
142
157
  }
143
158
  },
144
159
 
145
160
  show: function() {
146
- modal.debug('Showing modal');
147
- modal.set.type();
148
- modal.set.position();
149
- modal.hideAll();
161
+ module.showDimmer();
162
+ module.cacheSizes();
163
+ module.set.position();
164
+ module.hideAll();
150
165
  if(settings.transition && $.fn.transition !== undefined) {
151
- $modal
152
- .transition(settings.transition + ' in', settings.duration, modal.set.active)
166
+ $module
167
+ .transition(settings.transition + ' in', settings.duration, function() {
168
+ module.set.active();
169
+ module.save.focus();
170
+ module.set.type();
171
+ })
153
172
  ;
154
173
  }
155
174
  else {
156
- $modal
157
- .fadeIn(settings.duration, settings.easing, modal.set.active)
175
+ $module
176
+ .fadeIn(settings.duration, settings.easing, function() {
177
+ module.set.active();
178
+ module.save.focus();
179
+ module.set.type();
180
+ })
158
181
  ;
159
182
  }
160
- modal.debug('Triggering dimmer');
183
+ module.debug('Triggering dimmer');
184
+ $.proxy(settings.onShow, element)();
185
+ },
186
+
187
+ showDimmer: function() {
188
+ module.debug('Showing modal');
189
+ module.set.dimmerSettings();
161
190
  $context.dimmer('show');
162
191
  },
192
+ hideDimmer: function() {
193
+ $context.dimmer('hide');
194
+ },
163
195
 
164
196
  hide: function() {
165
- modal.debug('Hiding modal');
197
+ module.debug('Hiding modal');
166
198
  // remove keyboard detection
167
199
  $document
168
200
  .off('keyup.' + namespace)
169
201
  ;
170
202
  if(settings.transition && $.fn.transition !== undefined) {
171
- $modal
172
- .transition(settings.transition + ' out', settings.duration, modal.remove.active)
203
+ $module
204
+ .transition(settings.transition + ' out', settings.duration, function() {
205
+ module.remove.active();
206
+ module.restore.focus();
207
+ })
173
208
  ;
174
209
  }
175
210
  else {
176
- $modal
177
- .fadeOut(settings.duration, settings.easing, modal.remove.active)
211
+ $module
212
+ .fadeOut(settings.duration, settings.easing, function() {
213
+ module.remove.active();
214
+ module.restore.focus();
215
+ })
178
216
  ;
179
217
  }
218
+ $.proxy(settings.onHide, element)();
180
219
  },
181
220
 
182
221
  hideAll: function() {
@@ -188,77 +227,110 @@ $.fn.modal = function(parameters) {
188
227
 
189
228
  add: {
190
229
  keyboardShortcuts: function() {
191
- modal.verbose('Adding keyboard shortcuts');
230
+ module.verbose('Adding keyboard shortcuts');
192
231
  $document
193
- .on('keyup' + eventNamespace, modal.event.keyboard)
232
+ .on('keyup' + eventNamespace, module.event.keyboard)
194
233
  ;
195
234
  }
196
235
  },
197
236
 
237
+ save: {
238
+ focus: function() {
239
+ $focusedElement = $(document.activeElement).blur();
240
+ }
241
+ },
242
+
243
+ restore: {
244
+ focus: function() {
245
+ $focusedElement.focus();
246
+ }
247
+ },
248
+
198
249
  remove: {
199
250
  active: function() {
200
- $modal.removeClass(className.active);
251
+ $module.removeClass(className.active);
201
252
  },
202
253
  keyboardShortcuts: function() {
203
- modal.verbose('Removing keyboard shortcuts');
254
+ module.verbose('Removing keyboard shortcuts');
204
255
  $document
205
256
  .off('keyup' + eventNamespace)
206
257
  ;
258
+ },
259
+ scrolling: function() {
260
+ $dimmer.removeClass(className.scrolling);
261
+ $module.removeClass(className.scrolling);
207
262
  }
208
263
  },
209
264
 
210
- cache: {
211
- sizes: function() {
212
- modal.cache = {
213
- height : $modal.outerHeight() + settings.offset,
214
- contextHeight : (settings.context == 'body')
215
- ? $(window).height()
216
- : $context.height()
217
- };
218
- console.log($modal);
219
- modal.debug('Caching modal and container sizes', modal.cache);
220
- }
265
+ cacheSizes: function() {
266
+ module.cache = {
267
+ height : $module.outerHeight() + settings.offset,
268
+ contextHeight : (settings.context == 'body')
269
+ ? $(window).height()
270
+ : $context.height()
271
+ };
272
+ module.debug('Caching modal and container sizes', module.cache);
221
273
  },
222
274
 
223
275
  can: {
224
276
  fit: function() {
225
- return (modal.cache.height < modal.cache.contextHeight);
277
+ return (module.cache.height < module.cache.contextHeight);
226
278
  }
227
279
  },
228
280
 
229
281
  is: {
230
282
  active: function() {
231
- return $modal.hasClass(className.active);
283
+ return $module.hasClass(className.active);
232
284
  }
233
285
  },
234
286
 
235
287
  set: {
236
288
  active: function() {
237
- $modal.addClass('active');
289
+ $module.addClass(className.active);
290
+ },
291
+ dimmerSettings: function() {
292
+ module.debug('Setting dimmer settings', settings.closable);
293
+ $context
294
+ .dimmer('setting', 'closable', settings.closable)
295
+ .dimmer('setting', 'duration', settings.duration * 0.75)
296
+ .dimmer('setting', 'onShow' , module.add.keyboardShortcuts)
297
+ .dimmer('setting', 'onHide', function() {
298
+ module.hide();
299
+ module.remove.keyboardShortcuts();
300
+ })
301
+ .dimmer('destroy')
302
+ .dimmer('initialize')
303
+ ;
304
+ },
305
+ scrolling: function() {
306
+ $dimmer.addClass(className.scrolling);
307
+ $module.addClass(className.scrolling);
238
308
  },
239
309
  type: function() {
240
- if(modal.can.fit()) {
241
- modal.verbose('Modal fits on screen');
242
- $modal.removeClass(className.scrolling);
310
+ if(module.can.fit()) {
311
+ module.verbose('Modal fits on screen');
312
+ module.remove.scrolling();
243
313
  }
244
314
  else {
245
- modal.verbose('Modal cannot fit on screen setting to scrolling');
246
- $modal.addClass(className.scrolling);
315
+ module.verbose('Modal cannot fit on screen setting to scrolling');
316
+ module.set.scrolling();
247
317
  }
248
318
  },
249
319
  position: function() {
250
- modal.verbose('Centering modal on page', modal.cache.height / 2);
251
- if(modal.can.fit()) {
252
- $modal
320
+ module.verbose('Centering modal on page', module.cache, module.cache.height / 2);
321
+ if(module.can.fit()) {
322
+ $module
253
323
  .css({
254
- marginTop: -(modal.cache.height / 2)
324
+ top: '',
325
+ marginTop: -(module.cache.height / 2)
255
326
  })
256
327
  ;
257
328
  }
258
329
  else {
259
- $modal
330
+ $module
260
331
  .css({
261
- top: $context.prop('scrollTop')
332
+ marginTop : '1em',
333
+ top : $document.scrollTop()
262
334
  })
263
335
  ;
264
336
  }
@@ -281,41 +353,41 @@ $.fn.modal = function(parameters) {
281
353
  internal: function(name, value) {
282
354
  if(value !== undefined) {
283
355
  if( $.isPlainObject(name) ) {
284
- $.extend(true, modal, name);
356
+ $.extend(true, module, name);
285
357
  }
286
358
  else {
287
- modal[name] = value;
359
+ module[name] = value;
288
360
  }
289
361
  }
290
362
  else {
291
- return modal[name];
363
+ return module[name];
292
364
  }
293
365
  },
294
366
  debug: function() {
295
367
  if(settings.debug) {
296
368
  if(settings.performance) {
297
- modal.performance.log(arguments);
369
+ module.performance.log(arguments);
298
370
  }
299
371
  else {
300
- modal.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
301
- modal.debug.apply(console, arguments);
372
+ module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
373
+ module.debug.apply(console, arguments);
302
374
  }
303
375
  }
304
376
  },
305
377
  verbose: function() {
306
378
  if(settings.verbose && settings.debug) {
307
379
  if(settings.performance) {
308
- modal.performance.log(arguments);
380
+ module.performance.log(arguments);
309
381
  }
310
382
  else {
311
- modal.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
312
- modal.verbose.apply(console, arguments);
383
+ module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
384
+ module.verbose.apply(console, arguments);
313
385
  }
314
386
  }
315
387
  },
316
388
  error: function() {
317
- modal.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
318
- modal.error.apply(console, arguments);
389
+ module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
390
+ module.error.apply(console, arguments);
319
391
  },
320
392
  performance: {
321
393
  log: function(message) {
@@ -336,8 +408,8 @@ $.fn.modal = function(parameters) {
336
408
  'Execution Time' : executionTime
337
409
  });
338
410
  }
339
- clearTimeout(modal.performance.timer);
340
- modal.performance.timer = setTimeout(modal.performance.display, 100);
411
+ clearTimeout(module.performance.timer);
412
+ module.performance.timer = setTimeout(module.performance.display, 100);
341
413
  },
342
414
  display: function() {
343
415
  var
@@ -345,7 +417,7 @@ $.fn.modal = function(parameters) {
345
417
  totalTime = 0
346
418
  ;
347
419
  time = false;
348
- clearTimeout(modal.performance.timer);
420
+ clearTimeout(module.performance.timer);
349
421
  $.each(performance, function(index, data) {
350
422
  totalTime += data['Execution Time'];
351
423
  });
@@ -399,7 +471,7 @@ $.fn.modal = function(parameters) {
399
471
  return false;
400
472
  }
401
473
  else {
402
- modal.error(error.method);
474
+ module.error(error.method);
403
475
  return false;
404
476
  }
405
477
  });
@@ -425,15 +497,15 @@ $.fn.modal = function(parameters) {
425
497
 
426
498
  if(methodInvoked) {
427
499
  if(instance === undefined) {
428
- modal.initialize();
500
+ module.initialize();
429
501
  }
430
- invokedResponse = modal.invoke(query);
502
+ module.invoke(query);
431
503
  }
432
504
  else {
433
505
  if(instance !== undefined) {
434
- modal.destroy();
506
+ module.destroy();
435
507
  }
436
- modal.initialize();
508
+ module.initialize();
437
509
  }
438
510
  })
439
511
  ;
@@ -452,25 +524,24 @@ $.fn.modal.settings = {
452
524
  debug : true,
453
525
  performance : true,
454
526
 
455
- offset : 0,
456
- transition : 'scale',
457
- duration : 500,
458
- easing : 'easeOutExpo',
459
-
460
527
  closable : true,
461
528
  context : 'body',
529
+ duration : 600,
530
+ easing : 'easeOutExpo',
531
+ offset : 0,
532
+ transition : 'scale',
462
533
 
463
534
  onShow : function(){},
464
535
  onHide : function(){},
465
536
 
466
537
  selector : {
467
- closeButton : '.close, .actions .button',
468
- dimmer: '.ui.dimmer'
538
+ close : '.close, .actions .button'
469
539
  },
470
540
  error : {
471
541
  method : 'The method you called is not defined.'
472
542
  },
473
543
  className : {
544
+ active : 'active',
474
545
  scrolling : 'scrolling'
475
546
  },
476
547
  };