semantic_ui_rails 0.0.2

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 (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,542 @@
1
+ /* ******************************
2
+ Nag
3
+ Author: Jack Lukic
4
+ Notes: First Commit July 19, 2012
5
+
6
+ Simple fixed position nag
7
+ ****************************** */
8
+
9
+ ;(function ($, window, document, undefined) {
10
+
11
+ $.fn.nag = function(parameters) {
12
+ var
13
+ $allModules = $(this),
14
+ settings = $.extend(true, {}, $.fn.nag.settings, parameters),
15
+
16
+ className = settings.className,
17
+ selector = settings.selector,
18
+ error = settings.error,
19
+ namespace = settings.namespace,
20
+
21
+ eventNamespace = '.' + namespace,
22
+ moduleNamespace = namespace + '-module',
23
+ moduleSelector = $allModules.selector || '',
24
+
25
+ time = new Date().getTime(),
26
+ performance = [],
27
+
28
+ query = arguments[0],
29
+ methodInvoked = (typeof query == 'string'),
30
+ queryArguments = [].slice.call(arguments, 1),
31
+ invokedResponse
32
+ ;
33
+ $(this)
34
+ .each(function() {
35
+ var
36
+ $module = $(this),
37
+
38
+ $close = $module.find(selector.close),
39
+ $context = $(settings.context),
40
+
41
+
42
+ element = this,
43
+ instance = $module.data(moduleNamespace),
44
+
45
+ moduleOffset,
46
+ moduleHeight,
47
+
48
+ contextWidth,
49
+ contextHeight,
50
+ contextOffset,
51
+
52
+ yOffset,
53
+ yPosition,
54
+
55
+ timer,
56
+ module,
57
+
58
+ requestAnimationFrame = window.requestAnimationFrame
59
+ || window.mozRequestAnimationFrame
60
+ || window.webkitRequestAnimationFrame
61
+ || window.msRequestAnimationFrame
62
+ || function(callback) { setTimeout(callback, 0); }
63
+ ;
64
+ module = {
65
+
66
+ initialize: function() {
67
+ module.verbose('Initializing element');
68
+ // calculate module offset once
69
+ moduleOffset = $module.offset();
70
+ moduleHeight = $module.outerHeight();
71
+ contextWidth = $context.outerWidth();
72
+ contextHeight = $context.outerHeight();
73
+ contextOffset = $context.offset();
74
+
75
+ $module
76
+ .data(moduleNamespace, module)
77
+ ;
78
+ $close
79
+ .on('click' + eventNamespace, module.dismiss)
80
+ ;
81
+ // lets avoid javascript if we dont need to reposition
82
+ if(settings.context == window && settings.position == 'fixed') {
83
+ $module
84
+ .addClass(className.fixed)
85
+ ;
86
+ }
87
+ if(settings.sticky) {
88
+ module.verbose('Adding scroll events');
89
+ // retrigger on scroll for absolute
90
+ if(settings.position == 'absolute') {
91
+ $context
92
+ .on('scroll' + eventNamespace, module.event.scroll)
93
+ .on('resize' + eventNamespace, module.event.scroll)
94
+ ;
95
+ }
96
+ // fixed is always relative to window
97
+ else {
98
+ $(window)
99
+ .on('scroll' + eventNamespace, module.event.scroll)
100
+ .on('resize' + eventNamespace, module.event.scroll)
101
+ ;
102
+ }
103
+ // fire once to position on init
104
+ $.proxy(module.event.scroll, this)();
105
+ }
106
+
107
+ if(settings.displayTime > 0) {
108
+ setTimeout(module.hide, settings.displayTime);
109
+ }
110
+ if(module.should.show()) {
111
+ if( !$module.is(':visible') ) {
112
+ module.show();
113
+ }
114
+ }
115
+ else {
116
+ module.hide();
117
+ }
118
+ },
119
+
120
+ destroy: function() {
121
+ module.verbose('Destroying instance');
122
+ $module
123
+ .removeData(moduleNamespace)
124
+ .off(eventNamespace)
125
+ ;
126
+ if(settings.sticky) {
127
+ $context
128
+ .off(eventNamespace)
129
+ ;
130
+ }
131
+ },
132
+
133
+ refresh: function() {
134
+ module.debug('Refreshing cached calculations');
135
+ moduleOffset = $module.offset();
136
+ moduleHeight = $module.outerHeight();
137
+ contextWidth = $context.outerWidth();
138
+ contextHeight = $context.outerHeight();
139
+ contextOffset = $context.offset();
140
+ },
141
+
142
+ show: function() {
143
+ module.debug('Showing nag', settings.animation.show);
144
+ if(settings.animation.show == 'fade') {
145
+ $module
146
+ .fadeIn(settings.duration, settings.easing)
147
+ ;
148
+ }
149
+ else {
150
+ $module
151
+ .slideDown(settings.duration, settings.easing)
152
+ ;
153
+ }
154
+ },
155
+
156
+ hide: function() {
157
+ module.debug('Showing nag', settings.animation.hide);
158
+ if(settings.animation.show == 'fade') {
159
+ $module
160
+ .fadeIn(settings.duration, settings.easing)
161
+ ;
162
+ }
163
+ else {
164
+ $module
165
+ .slideUp(settings.duration, settings.easing)
166
+ ;
167
+ }
168
+ },
169
+
170
+ onHide: function() {
171
+ module.debug('Removing nag', settings.animation.hide);
172
+ $module.remove();
173
+ if (settings.onHide) {
174
+ settings.onHide();
175
+ }
176
+ },
177
+
178
+ stick: function() {
179
+ module.refresh();
180
+
181
+ if(settings.position == 'fixed') {
182
+ var
183
+ windowScroll = $(window).prop('pageYOffset') || $(window).scrollTop(),
184
+ fixedOffset = ( $module.hasClass(className.bottom) )
185
+ ? contextOffset.top + (contextHeight - moduleHeight) - windowScroll
186
+ : contextOffset.top - windowScroll
187
+ ;
188
+ $module
189
+ .css({
190
+ position : 'fixed',
191
+ top : fixedOffset,
192
+ left : contextOffset.left,
193
+ width : contextWidth - settings.scrollBarWidth
194
+ })
195
+ ;
196
+ }
197
+ else {
198
+ $module
199
+ .css({
200
+ top : yPosition
201
+ })
202
+ ;
203
+ }
204
+ },
205
+ unStick: function() {
206
+ $module
207
+ .css({
208
+ top : ''
209
+ })
210
+ ;
211
+ },
212
+ dismiss: function(event) {
213
+ if(settings.storageMethod) {
214
+ module.storage.set(settings.storedKey, settings.storedValue);
215
+ }
216
+ module.hide();
217
+ event.stopImmediatePropagation();
218
+ event.preventDefault();
219
+ },
220
+
221
+ should: {
222
+ show: function() {
223
+ if(settings.persist) {
224
+ module.debug('Persistent nag is set, can show nag');
225
+ return true;
226
+ }
227
+ if(module.storage.get(settings.storedKey) != settings.storedValue) {
228
+ module.debug('Stored value is not set, can show nag', module.storage.get(settings.storedKey));
229
+ return true;
230
+ }
231
+ module.debug('Stored value is set, cannot show nag', module.storage.get(settings.storedKey));
232
+ return false;
233
+ },
234
+ stick: function() {
235
+ yOffset = $context.prop('pageYOffset') || $context.scrollTop();
236
+ yPosition = ( $module.hasClass(className.bottom) )
237
+ ? (contextHeight - $module.outerHeight() ) + yOffset
238
+ : yOffset
239
+ ;
240
+ // absolute position calculated when y offset met
241
+ if(yPosition > moduleOffset.top) {
242
+ return true;
243
+ }
244
+ else if(settings.position == 'fixed') {
245
+ return true;
246
+ }
247
+ return false;
248
+ }
249
+ },
250
+
251
+ storage: {
252
+
253
+ set: function(key, value) {
254
+ module.debug('Setting stored value', key, value, settings.storageMethod);
255
+ if(settings.storageMethod == 'local' && window.store !== undefined) {
256
+ window.store.set(key, value);
257
+ }
258
+ // store by cookie
259
+ else if($.cookie !== undefined) {
260
+ $.cookie(key, value);
261
+ }
262
+ else {
263
+ module.error(error.noStorage);
264
+ }
265
+ },
266
+ get: function(key) {
267
+ module.debug('Getting stored value', key, settings.storageMethod);
268
+ if(settings.storageMethod == 'local' && window.store !== undefined) {
269
+ return window.store.get(key);
270
+ }
271
+ // get by cookie
272
+ else if($.cookie !== undefined) {
273
+ return $.cookie(key);
274
+ }
275
+ else {
276
+ module.error(error.noStorage);
277
+ }
278
+ }
279
+
280
+ },
281
+
282
+ event: {
283
+ scroll: function() {
284
+ if(timer !== undefined) {
285
+ clearTimeout(timer);
286
+ }
287
+ timer = setTimeout(function() {
288
+ if(module.should.stick() ) {
289
+ requestAnimationFrame(module.stick);
290
+ }
291
+ else {
292
+ module.unStick();
293
+ }
294
+ }, settings.lag);
295
+ }
296
+ },
297
+ setting: function(name, value) {
298
+ module.debug('Changing setting', name, value);
299
+ if(value !== undefined) {
300
+ if( $.isPlainObject(name) ) {
301
+ $.extend(true, settings, name);
302
+ }
303
+ else {
304
+ settings[name] = value;
305
+ }
306
+ }
307
+ else {
308
+ return settings[name];
309
+ }
310
+ },
311
+ internal: function(name, value) {
312
+ module.debug('Changing internal', name, value);
313
+ if(value !== undefined) {
314
+ if( $.isPlainObject(name) ) {
315
+ $.extend(true, module, name);
316
+ }
317
+ else {
318
+ module[name] = value;
319
+ }
320
+ }
321
+ else {
322
+ return module[name];
323
+ }
324
+ },
325
+ debug: function() {
326
+ if(settings.debug) {
327
+ if(settings.performance) {
328
+ module.performance.log(arguments);
329
+ }
330
+ else {
331
+ module.debug = Function.prototype.bind.call(console.info, console, settings.moduleName + ':');
332
+ module.debug.apply(console, arguments);
333
+ }
334
+ }
335
+ },
336
+ verbose: function() {
337
+ if(settings.verbose && settings.debug) {
338
+ if(settings.performance) {
339
+ module.performance.log(arguments);
340
+ }
341
+ else {
342
+ module.verbose = Function.prototype.bind.call(console.info, console, settings.moduleName + ':');
343
+ module.verbose.apply(console, arguments);
344
+ }
345
+ }
346
+ },
347
+ error: function() {
348
+ module.error = Function.prototype.bind.call(console.error, console, settings.moduleName + ':');
349
+ module.error.apply(console, arguments);
350
+ },
351
+ performance: {
352
+ log: function(message) {
353
+ var
354
+ currentTime,
355
+ executionTime,
356
+ previousTime
357
+ ;
358
+ if(settings.performance) {
359
+ currentTime = new Date().getTime();
360
+ previousTime = time || currentTime;
361
+ executionTime = currentTime - previousTime;
362
+ time = currentTime;
363
+ performance.push({
364
+ 'Element' : element,
365
+ 'Name' : message[0],
366
+ 'Arguments' : [].slice.call(message, 1) || '',
367
+ 'Execution Time' : executionTime
368
+ });
369
+ }
370
+ clearTimeout(module.performance.timer);
371
+ module.performance.timer = setTimeout(module.performance.display, 100);
372
+ },
373
+ display: function() {
374
+ var
375
+ title = settings.name + ':',
376
+ totalTime = 0
377
+ ;
378
+ time = false;
379
+ clearTimeout(module.performance.timer);
380
+ $.each(performance, function(index, data) {
381
+ totalTime += data['Execution Time'];
382
+ });
383
+ title += ' ' + totalTime + 'ms';
384
+ if(moduleSelector) {
385
+ title += ' \'' + moduleSelector + '\'';
386
+ }
387
+ if($allModules.size() > 1) {
388
+ title += ' ' + '(' + $allModules.size() + ')';
389
+ }
390
+ if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
391
+ console.groupCollapsed(title);
392
+ if(console.table) {
393
+ console.table(performance);
394
+ }
395
+ else {
396
+ $.each(performance, function(index, data) {
397
+ console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
398
+ });
399
+ }
400
+ console.groupEnd();
401
+ }
402
+ performance = [];
403
+ }
404
+ },
405
+ invoke: function(query, passedArguments, context) {
406
+ var
407
+ maxDepth,
408
+ found,
409
+ response
410
+ ;
411
+ passedArguments = passedArguments || queryArguments;
412
+ context = element || context;
413
+ if(typeof query == 'string' && instance !== undefined) {
414
+ query = query.split(/[\. ]/);
415
+ maxDepth = query.length - 1;
416
+ $.each(query, function(depth, value) {
417
+ var camelCaseValue = (depth != maxDepth)
418
+ ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
419
+ : query
420
+ ;
421
+ if( $.isPlainObject( instance[value] ) && (depth != maxDepth) ) {
422
+ instance = instance[value];
423
+ }
424
+ else if( $.isPlainObject( instance[camelCaseValue] ) && (depth != maxDepth) ) {
425
+ instance = instance[camelCaseValue];
426
+ }
427
+ else if( instance[value] !== undefined ) {
428
+ found = instance[value];
429
+ return false;
430
+ }
431
+ else if( instance[camelCaseValue] !== undefined ) {
432
+ found = instance[camelCaseValue];
433
+ return false;
434
+ }
435
+ else {
436
+ module.error(error.method);
437
+ return false;
438
+ }
439
+ });
440
+ }
441
+ if ( $.isFunction( found ) ) {
442
+ response = found.apply(context, passedArguments);
443
+ }
444
+ else if(found !== undefined) {
445
+ response = found;
446
+ }
447
+ if($.isArray(invokedResponse)) {
448
+ invokedResponse.push(response);
449
+ }
450
+ else if(typeof invokedResponse == 'string') {
451
+ invokedResponse = [invokedResponse, response];
452
+ }
453
+ else if(response !== undefined) {
454
+ invokedResponse = response;
455
+ }
456
+ return found;
457
+ }
458
+ };
459
+ if(methodInvoked) {
460
+ if(instance === undefined) {
461
+ module.initialize();
462
+ }
463
+ module.invoke(query);
464
+ }
465
+ else {
466
+ if(instance !== undefined) {
467
+ module.destroy();
468
+ }
469
+ module.initialize();
470
+ }
471
+
472
+ })
473
+ ;
474
+ return (invokedResponse !== undefined)
475
+ ? invokedResponse
476
+ : this
477
+ ;
478
+ };
479
+
480
+ $.fn.nag.settings = {
481
+
482
+ name : 'Nag',
483
+
484
+ verbose : true,
485
+ debug : true,
486
+ performance : true,
487
+
488
+ namespace : 'Nag',
489
+
490
+ // allows cookie to be overriden
491
+ persist : false,
492
+
493
+ // set to zero to manually dismiss, otherwise hides on its own
494
+ displayTime : 0,
495
+
496
+ animation : {
497
+ show: 'slide',
498
+ hide: 'slide'
499
+ },
500
+
501
+ // method of stickyness
502
+ position : 'fixed',
503
+ scrollBarWidth : 18,
504
+
505
+ // type of storage to use
506
+ storageMethod : 'cookie',
507
+
508
+ // value to store in dismissed localstorage/cookie
509
+ storedKey : 'nag',
510
+ storedValue : 'dismiss',
511
+
512
+ // need to calculate stickyness on scroll
513
+ sticky : false,
514
+
515
+ // how often to check scroll event
516
+ lag : 0,
517
+
518
+ // context for scroll event
519
+ context : window,
520
+
521
+ error: {
522
+ noStorage : 'Neither $.cookie or store is defined. A storage solution is required for storing state',
523
+ method : 'The method you called is not defined.'
524
+ },
525
+
526
+ className : {
527
+ bottom : 'bottom',
528
+ fixed : 'fixed'
529
+ },
530
+
531
+ selector : {
532
+ close: '.icon.close'
533
+ },
534
+
535
+ speed : 500,
536
+ easing : 'easeOutQuad',
537
+
538
+ onHide: function() {}
539
+
540
+ };
541
+
542
+ })( jQuery, window , document );