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,411 @@
1
+ /* ******************************
2
+ Accordion
3
+ Author: Jack Lukic
4
+ Notes: First Commit July 19, 2012
5
+
6
+ Simple accordion design
7
+ ****************************** */
8
+
9
+ ;(function ($, window, document, undefined) {
10
+
11
+ $.fn.accordion = function(parameters) {
12
+ var
13
+ $allModules = $(this),
14
+
15
+ settings = ( $.isPlainObject(parameters) )
16
+ ? $.extend(true, {}, $.fn.accordion.settings, parameters)
17
+ : $.fn.accordion.settings,
18
+
19
+ className = settings.className,
20
+ namespace = settings.namespace,
21
+ selector = settings.selector,
22
+ error = settings.error,
23
+
24
+ eventNamespace = '.' + namespace,
25
+ moduleNamespace = 'module-' + namespace,
26
+ moduleSelector = $allModules.selector || '',
27
+
28
+ time = new Date().getTime(),
29
+ performance = [],
30
+
31
+ query = arguments[0],
32
+ methodInvoked = (typeof query == 'string'),
33
+ queryArguments = [].slice.call(arguments, 1),
34
+ invokedResponse
35
+ ;
36
+ $allModules
37
+ .each(function() {
38
+ var
39
+ $module = $(this),
40
+ $title = $module.find(selector.title),
41
+ $icon = $module.find(selector.icon),
42
+ $content = $module.find(selector.content),
43
+
44
+ element = this,
45
+ instance = $module.data(moduleNamespace),
46
+ module
47
+ ;
48
+
49
+ module = {
50
+
51
+ initialize: function() {
52
+ module.debug('Initializing accordion with bound events', $module);
53
+ // initializing
54
+ $title
55
+ .on('click' + eventNamespace, module.event.click)
56
+ ;
57
+ module.instantiate();
58
+ },
59
+
60
+ instantiate: function() {
61
+ $module
62
+ .data(moduleNamespace, module)
63
+ ;
64
+ },
65
+
66
+ destroy: function() {
67
+ module.debug('Destroying previous accordion for', $module);
68
+ $module
69
+ .removeData(moduleNamespace)
70
+ ;
71
+ $title
72
+ .off(eventNamespace)
73
+ ;
74
+ },
75
+
76
+ event: {
77
+ click: function() {
78
+ module.verbose('Title clicked', this);
79
+ var
80
+ $activeTitle = $(this),
81
+ index = $title.index($activeTitle)
82
+ ;
83
+ module.toggle(index);
84
+ },
85
+ resetStyle: function() {
86
+ module.verbose('Resetting styles on element', this);
87
+ $(this)
88
+ .removeAttr('style')
89
+ .children()
90
+ .removeAttr('style')
91
+ ;
92
+ }
93
+ },
94
+
95
+ toggle: function(index) {
96
+ module.debug('Toggling content content at index', index);
97
+ var
98
+ $activeTitle = $title.eq(index),
99
+ $activeContent = $activeTitle.next($content),
100
+ contentIsOpen = $activeContent.is(':visible')
101
+ ;
102
+ if(contentIsOpen) {
103
+ if(settings.collapsible) {
104
+ module.close(index);
105
+ }
106
+ else {
107
+ module.debug('Cannot close accordion content collapsing is disabled');
108
+ }
109
+ }
110
+ else {
111
+ module.open(index);
112
+ }
113
+ },
114
+
115
+ open: function(index) {
116
+ var
117
+ $activeTitle = $title.eq(index),
118
+ $activeContent = $activeTitle.next($content),
119
+ $previousTitle = $title.filter('.' + className.active),
120
+ $previousContent = $previousTitle.next($title),
121
+ contentIsOpen = ($previousTitle.size() > 0)
122
+ ;
123
+ if( !$activeContent.is(':animated') ) {
124
+ module.debug('Opening accordion content', $activeTitle);
125
+ if(settings.exclusive && contentIsOpen) {
126
+ $previousTitle
127
+ .removeClass(className.active)
128
+ ;
129
+ $previousContent
130
+ .stop()
131
+ .children()
132
+ .animate({
133
+ opacity: 0
134
+ }, settings.speed, module.event.resetStyle)
135
+ .end()
136
+ .slideUp(settings.speed , settings.easing, function() {
137
+ $previousContent
138
+ .removeClass(className.active)
139
+ .removeAttr('style')
140
+ .children()
141
+ .removeAttr('style')
142
+ ;
143
+ })
144
+ ;
145
+ }
146
+ $activeTitle
147
+ .addClass(className.active)
148
+ ;
149
+ $activeContent
150
+ .stop()
151
+ .children()
152
+ .removeAttr('style')
153
+ .end()
154
+ .slideDown(settings.speed, settings.easing, function() {
155
+ $activeContent
156
+ .addClass(className.active)
157
+ .removeAttr('style')
158
+ ;
159
+ $.proxy(settings.onOpen, $activeContent)();
160
+ $.proxy(settings.onChange, $activeContent)();
161
+ })
162
+ ;
163
+ }
164
+ },
165
+
166
+ close: function(index) {
167
+ var
168
+ $activeTitle = $title.eq(index),
169
+ $activeContent = $activeTitle.next($content)
170
+ ;
171
+ module.debug('Closing accordion content', $activeTitle);
172
+ $activeTitle
173
+ .removeClass(className.active)
174
+ ;
175
+ $activeContent
176
+ .removeClass(className.active)
177
+ .show()
178
+ .stop()
179
+ .children()
180
+ .animate({
181
+ opacity: 0
182
+ }, settings.speed, module.event.resetStyle)
183
+ .end()
184
+ .slideUp(settings.speed, settings.easing, function(){
185
+ $activeContent
186
+ .removeAttr('style')
187
+ ;
188
+ $.proxy(settings.onClose, $activeContent)();
189
+ $.proxy(settings.onChange, $activeContent)();
190
+ })
191
+ ;
192
+ },
193
+
194
+ setting: function(name, value) {
195
+ module.debug('Changing setting', name, value);
196
+ if(value !== undefined) {
197
+ if( $.isPlainObject(name) ) {
198
+ $.extend(true, settings, name);
199
+ }
200
+ else {
201
+ settings[name] = value;
202
+ }
203
+ }
204
+ else {
205
+ return settings[name];
206
+ }
207
+ },
208
+ internal: function(name, value) {
209
+ module.debug('Changing internal', name, value);
210
+ if(value !== undefined) {
211
+ if( $.isPlainObject(name) ) {
212
+ $.extend(true, module, name);
213
+ }
214
+ else {
215
+ module[name] = value;
216
+ }
217
+ }
218
+ else {
219
+ return module[name];
220
+ }
221
+ },
222
+ debug: function() {
223
+ if(settings.debug) {
224
+ if(settings.performance) {
225
+ module.performance.log(arguments);
226
+ }
227
+ else {
228
+ module.debug = Function.prototype.bind.call(console.info, console, settings.moduleName + ':');
229
+ module.debug.apply(console, arguments);
230
+ }
231
+ }
232
+ },
233
+ verbose: function() {
234
+ if(settings.verbose && settings.debug) {
235
+ if(settings.performance) {
236
+ module.performance.log(arguments);
237
+ }
238
+ else {
239
+ module.verbose = Function.prototype.bind.call(console.info, console, settings.moduleName + ':');
240
+ module.verbose.apply(console, arguments);
241
+ }
242
+ }
243
+ },
244
+ error: function() {
245
+ module.error = Function.prototype.bind.call(console.error, console, settings.moduleName + ':');
246
+ module.error.apply(console, arguments);
247
+ },
248
+ performance: {
249
+ log: function(message) {
250
+ var
251
+ currentTime,
252
+ executionTime,
253
+ previousTime
254
+ ;
255
+ if(settings.performance) {
256
+ currentTime = new Date().getTime();
257
+ previousTime = time || currentTime;
258
+ executionTime = currentTime - previousTime;
259
+ time = currentTime;
260
+ performance.push({
261
+ 'Element' : element,
262
+ 'Name' : message[0],
263
+ 'Arguments' : [].slice.call(message, 1) || '',
264
+ 'Execution Time' : executionTime
265
+ });
266
+ }
267
+ clearTimeout(module.performance.timer);
268
+ module.performance.timer = setTimeout(module.performance.display, 100);
269
+ },
270
+ display: function() {
271
+ var
272
+ title = settings.name + ':',
273
+ totalTime = 0
274
+ ;
275
+ time = false;
276
+ clearTimeout(module.performance.timer);
277
+ $.each(performance, function(index, data) {
278
+ totalTime += data['Execution Time'];
279
+ });
280
+ title += ' ' + totalTime + 'ms';
281
+ if(moduleSelector) {
282
+ title += ' \'' + moduleSelector + '\'';
283
+ }
284
+ if($allModules.size() > 1) {
285
+ title += ' ' + '(' + $allModules.size() + ')';
286
+ }
287
+ if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
288
+ console.groupCollapsed(title);
289
+ if(console.table) {
290
+ console.table(performance);
291
+ }
292
+ else {
293
+ $.each(performance, function(index, data) {
294
+ console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
295
+ });
296
+ }
297
+ console.groupEnd();
298
+ }
299
+ performance = [];
300
+ }
301
+ },
302
+ invoke: function(query, passedArguments, context) {
303
+ var
304
+ maxDepth,
305
+ found,
306
+ response
307
+ ;
308
+ passedArguments = passedArguments || queryArguments;
309
+ context = element || context;
310
+ if(typeof query == 'string' && instance !== undefined) {
311
+ query = query.split(/[\. ]/);
312
+ maxDepth = query.length - 1;
313
+ $.each(query, function(depth, value) {
314
+ var camelCaseValue = (depth != maxDepth)
315
+ ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
316
+ : query
317
+ ;
318
+ if( $.isPlainObject( instance[value] ) && (depth != maxDepth) ) {
319
+ instance = instance[value];
320
+ }
321
+ else if( $.isPlainObject( instance[camelCaseValue] ) && (depth != maxDepth) ) {
322
+ instance = instance[camelCaseValue];
323
+ }
324
+ else if( instance[value] !== undefined ) {
325
+ found = instance[value];
326
+ return false;
327
+ }
328
+ else if( instance[camelCaseValue] !== undefined ) {
329
+ found = instance[camelCaseValue];
330
+ return false;
331
+ }
332
+ else {
333
+ module.error(error.method);
334
+ return false;
335
+ }
336
+ });
337
+ }
338
+ if ( $.isFunction( found ) ) {
339
+ response = found.apply(context, passedArguments);
340
+ }
341
+ else if(found !== undefined) {
342
+ response = found;
343
+ }
344
+ if($.isArray(invokedResponse)) {
345
+ invokedResponse.push(response);
346
+ }
347
+ else if(typeof invokedResponse == 'string') {
348
+ invokedResponse = [invokedResponse, response];
349
+ }
350
+ else if(response !== undefined) {
351
+ invokedResponse = response;
352
+ }
353
+ return found;
354
+ }
355
+ };
356
+ if(methodInvoked) {
357
+ if(instance === undefined) {
358
+ module.initialize();
359
+ }
360
+ module.invoke(query);
361
+ }
362
+ else {
363
+ if(instance !== undefined) {
364
+ module.destroy();
365
+ }
366
+ module.initialize();
367
+ }
368
+ })
369
+ ;
370
+ return (invokedResponse !== undefined)
371
+ ? invokedResponse
372
+ : this
373
+ ;
374
+ };
375
+
376
+ $.fn.accordion.settings = {
377
+ name : 'Accordion',
378
+ namespace : 'accordion',
379
+
380
+ debug : true,
381
+ verbose : true,
382
+ performance : true,
383
+
384
+ exclusive : true,
385
+ collapsible : true,
386
+
387
+ onOpen : function(){},
388
+ onClose : function(){},
389
+ onChange : function(){},
390
+
391
+ error: {
392
+ method : 'The method you called is not defined'
393
+ },
394
+
395
+ className : {
396
+ active : 'active',
397
+ hover : 'hover'
398
+ },
399
+
400
+ selector : {
401
+ title : '.title',
402
+ icon : '.icon',
403
+ content : '.content'
404
+ },
405
+
406
+ speed : 500,
407
+ easing : 'easeInOutQuint'
408
+
409
+ };
410
+
411
+ })( jQuery, window , document );