semantic_ui_rails 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +20 -0
- data/README.md +4 -0
- data/Rakefile +1 -0
- data/app/assets/fonts/semantic/icons.eot +0 -0
- data/app/assets/fonts/semantic/icons.svg +450 -0
- data/app/assets/fonts/semantic/icons.ttf +0 -0
- data/app/assets/fonts/semantic/icons.woff +0 -0
- data/app/assets/images/semantic/loader-large-inverted.gif +0 -0
- data/app/assets/images/semantic/loader-large.gif +0 -0
- data/app/assets/images/semantic/loader-medium-inverted.gif +0 -0
- data/app/assets/images/semantic/loader-medium.gif +0 -0
- data/app/assets/images/semantic/loader-mini-inverted.gif +0 -0
- data/app/assets/images/semantic/loader-mini.gif +0 -0
- data/app/assets/images/semantic/loader-small-inverted.gif +0 -0
- data/app/assets/images/semantic/loader-small.gif +0 -0
- data/app/assets/javascript/semantic/accordion.js +411 -0
- data/app/assets/javascript/semantic/behavior/api.js +666 -0
- data/app/assets/javascript/semantic/behavior/colorize.js +271 -0
- data/app/assets/javascript/semantic/behavior/form.js +703 -0
- data/app/assets/javascript/semantic/behavior/state.js +752 -0
- data/app/assets/javascript/semantic/chatroom.js +766 -0
- data/app/assets/javascript/semantic/checkbox.js +348 -0
- data/app/assets/javascript/semantic/dimmer.js +524 -0
- data/app/assets/javascript/semantic/dropdown.js +707 -0
- data/app/assets/javascript/semantic/modal.js +478 -0
- data/app/assets/javascript/semantic/nag.js +542 -0
- data/app/assets/javascript/semantic/popup.js +721 -0
- data/app/assets/javascript/semantic/rating.js +358 -0
- data/app/assets/javascript/semantic/search.js +769 -0
- data/app/assets/javascript/semantic/shape.js +776 -0
- data/app/assets/javascript/semantic/sidebar.js +489 -0
- data/app/assets/javascript/semantic/tab.js +674 -0
- data/app/assets/javascript/semantic/transition.js +650 -0
- data/app/assets/javascript/semantic/video.js +459 -0
- data/app/assets/stylesheets/semantic/accordion.css +97 -0
- data/app/assets/stylesheets/semantic/breadcrumb.css +66 -0
- data/app/assets/stylesheets/semantic/button.css +993 -0
- data/app/assets/stylesheets/semantic/chatroom.css +242 -0
- data/app/assets/stylesheets/semantic/checkbox.css +300 -0
- data/app/assets/stylesheets/semantic/comment.css +178 -0
- data/app/assets/stylesheets/semantic/dimmer.css +185 -0
- data/app/assets/stylesheets/semantic/divider.css +155 -0
- data/app/assets/stylesheets/semantic/dropdown.css +415 -0
- data/app/assets/stylesheets/semantic/feed.css +126 -0
- data/app/assets/stylesheets/semantic/form.css +427 -0
- data/app/assets/stylesheets/semantic/grid.css +561 -0
- data/app/assets/stylesheets/semantic/header.css +277 -0
- data/app/assets/stylesheets/semantic/icon.css +811 -0
- data/app/assets/stylesheets/semantic/image.css +143 -0
- data/app/assets/stylesheets/semantic/input.css +225 -0
- data/app/assets/stylesheets/semantic/item.css +564 -0
- data/app/assets/stylesheets/semantic/label.css +687 -0
- data/app/assets/stylesheets/semantic/list.css +418 -0
- data/app/assets/stylesheets/semantic/loader.css +148 -0
- data/app/assets/stylesheets/semantic/menu.css +1409 -0
- data/app/assets/stylesheets/semantic/message.css +242 -0
- data/app/assets/stylesheets/semantic/modal.css +123 -0
- data/app/assets/stylesheets/semantic/nag.css +130 -0
- data/app/assets/stylesheets/semantic/popup.css +209 -0
- data/app/assets/stylesheets/semantic/progress.css +257 -0
- data/app/assets/stylesheets/semantic/rating.css +120 -0
- data/app/assets/stylesheets/semantic/reveal.css +283 -0
- data/app/assets/stylesheets/semantic/search.css +222 -0
- data/app/assets/stylesheets/semantic/segment.css +362 -0
- data/app/assets/stylesheets/semantic/shape.css +87 -0
- data/app/assets/stylesheets/semantic/sidebar.css +100 -0
- data/app/assets/stylesheets/semantic/step.css +240 -0
- data/app/assets/stylesheets/semantic/tab.css +52 -0
- data/app/assets/stylesheets/semantic/table.css +468 -0
- data/app/assets/stylesheets/semantic/transition.css +867 -0
- data/app/assets/stylesheets/semantic/video.css +81 -0
- data/lib/semantic_ui_rails/version.rb +3 -0
- data/lib/semantic_ui_rails.rb +7 -0
- data/semantic_ui_rails.gemspec +23 -0
- metadata +149 -0
@@ -0,0 +1,358 @@
|
|
1
|
+
/* ******************************
|
2
|
+
Star Review
|
3
|
+
Author: Jack Lukic
|
4
|
+
Notes: First Commit Sep 04, 2012
|
5
|
+
|
6
|
+
Simple rating module
|
7
|
+
****************************** */
|
8
|
+
|
9
|
+
;(function ($, window, document, undefined) {
|
10
|
+
|
11
|
+
$.fn.rating = function(parameters) {
|
12
|
+
var
|
13
|
+
$allModules = $(this),
|
14
|
+
moduleSelector = $allModules.selector || '',
|
15
|
+
|
16
|
+
settings = $.extend(true, {}, $.fn.rating.settings, parameters),
|
17
|
+
|
18
|
+
namespace = settings.namespace,
|
19
|
+
className = settings.className,
|
20
|
+
metadata = settings.metadata,
|
21
|
+
selector = settings.selector,
|
22
|
+
error = settings.error,
|
23
|
+
|
24
|
+
eventNamespace = '.' + namespace,
|
25
|
+
moduleNamespace = 'module-' + namespace,
|
26
|
+
|
27
|
+
time = new Date().getTime(),
|
28
|
+
performance = [],
|
29
|
+
|
30
|
+
query = arguments[0],
|
31
|
+
methodInvoked = (typeof query == 'string'),
|
32
|
+
queryArguments = [].slice.call(arguments, 1),
|
33
|
+
invokedResponse
|
34
|
+
;
|
35
|
+
$allModules
|
36
|
+
.each(function() {
|
37
|
+
var
|
38
|
+
$module = $(this),
|
39
|
+
$icon = $module.find(selector.icon),
|
40
|
+
|
41
|
+
element = this,
|
42
|
+
instance = $module.data(moduleNamespace),
|
43
|
+
module
|
44
|
+
;
|
45
|
+
|
46
|
+
module = {
|
47
|
+
|
48
|
+
initialize: function() {
|
49
|
+
module.verbose('Initializing rating module');
|
50
|
+
if(settings.interactive) {
|
51
|
+
$icon
|
52
|
+
.bind('mouseenter' + eventNamespace, module.event.mouseenter)
|
53
|
+
.bind('mouseleave' + eventNamespace, module.event.mouseleave)
|
54
|
+
.bind('click' + eventNamespace, module.event.click)
|
55
|
+
;
|
56
|
+
}
|
57
|
+
if(settings.initialRating) {
|
58
|
+
module.debug('Setting initial rating');
|
59
|
+
module.setRating(settings.initialRating);
|
60
|
+
}
|
61
|
+
if( $module.data(metadata.rating) ) {
|
62
|
+
module.debug('Rating found in metadata');
|
63
|
+
module.setRating( $module.data(metadata.rating) );
|
64
|
+
}
|
65
|
+
$module
|
66
|
+
.addClass(className.active)
|
67
|
+
;
|
68
|
+
module.instantiate();
|
69
|
+
},
|
70
|
+
|
71
|
+
instantiate: function() {
|
72
|
+
module.verbose('Instantiating module', settings);
|
73
|
+
$module
|
74
|
+
.data(moduleNamespace, module)
|
75
|
+
;
|
76
|
+
},
|
77
|
+
|
78
|
+
destroy: function() {
|
79
|
+
$module
|
80
|
+
.removeData(moduleNamespace)
|
81
|
+
;
|
82
|
+
$icon
|
83
|
+
.off(eventNamespace)
|
84
|
+
;
|
85
|
+
},
|
86
|
+
|
87
|
+
setRating: function(rating) {
|
88
|
+
var
|
89
|
+
$activeIcon = $icon.eq(rating - 1)
|
90
|
+
;
|
91
|
+
module.verbose('Setting current rating to', rating);
|
92
|
+
$module
|
93
|
+
.removeClass(className.hover)
|
94
|
+
;
|
95
|
+
$icon
|
96
|
+
.removeClass(className.hover)
|
97
|
+
;
|
98
|
+
$activeIcon
|
99
|
+
.nextAll()
|
100
|
+
.removeClass(className.active)
|
101
|
+
;
|
102
|
+
$activeIcon
|
103
|
+
.addClass(className.active)
|
104
|
+
.prevAll()
|
105
|
+
.addClass(className.active)
|
106
|
+
;
|
107
|
+
$.proxy(settings.onRate, element)();
|
108
|
+
},
|
109
|
+
|
110
|
+
event: {
|
111
|
+
mouseenter: function() {
|
112
|
+
var
|
113
|
+
$activeIcon = $(this)
|
114
|
+
;
|
115
|
+
$activeIcon
|
116
|
+
.nextAll()
|
117
|
+
.removeClass(className.hover)
|
118
|
+
;
|
119
|
+
$module
|
120
|
+
.addClass(className.hover)
|
121
|
+
;
|
122
|
+
$activeIcon
|
123
|
+
.addClass(className.hover)
|
124
|
+
.prevAll()
|
125
|
+
.addClass(className.hover)
|
126
|
+
;
|
127
|
+
},
|
128
|
+
mouseleave: function() {
|
129
|
+
$module
|
130
|
+
.removeClass(className.hover)
|
131
|
+
;
|
132
|
+
$icon
|
133
|
+
.removeClass(className.hover)
|
134
|
+
;
|
135
|
+
},
|
136
|
+
click: function() {
|
137
|
+
var
|
138
|
+
$activeIcon = $(this)
|
139
|
+
;
|
140
|
+
module.setRating( $icon.index($activeIcon) + 1);
|
141
|
+
}
|
142
|
+
},
|
143
|
+
setting: function(name, value) {
|
144
|
+
if(value !== undefined) {
|
145
|
+
if( $.isPlainObject(name) ) {
|
146
|
+
$.extend(true, settings, name);
|
147
|
+
}
|
148
|
+
else {
|
149
|
+
settings[name] = value;
|
150
|
+
}
|
151
|
+
}
|
152
|
+
else {
|
153
|
+
return settings[name];
|
154
|
+
}
|
155
|
+
},
|
156
|
+
internal: function(name, value) {
|
157
|
+
if(value !== undefined) {
|
158
|
+
if( $.isPlainObject(name) ) {
|
159
|
+
$.extend(true, module, name);
|
160
|
+
}
|
161
|
+
else {
|
162
|
+
module[name] = value;
|
163
|
+
}
|
164
|
+
}
|
165
|
+
else {
|
166
|
+
return module[name];
|
167
|
+
}
|
168
|
+
},
|
169
|
+
debug: function() {
|
170
|
+
if(settings.debug) {
|
171
|
+
if(settings.performance) {
|
172
|
+
module.performance.log(arguments);
|
173
|
+
}
|
174
|
+
else {
|
175
|
+
module.debug = Function.prototype.bind.call(console.info, console, settings.moduleName + ':');
|
176
|
+
module.debug.apply(console, arguments);
|
177
|
+
}
|
178
|
+
}
|
179
|
+
},
|
180
|
+
verbose: function() {
|
181
|
+
if(settings.verbose && settings.debug) {
|
182
|
+
if(settings.performance) {
|
183
|
+
module.performance.log(arguments);
|
184
|
+
}
|
185
|
+
else {
|
186
|
+
module.verbose = Function.prototype.bind.call(console.info, console, settings.moduleName + ':');
|
187
|
+
module.verbose.apply(console, arguments);
|
188
|
+
}
|
189
|
+
}
|
190
|
+
},
|
191
|
+
error: function() {
|
192
|
+
module.error = Function.prototype.bind.call(console.error, console, settings.moduleName + ':');
|
193
|
+
module.error.apply(console, arguments);
|
194
|
+
},
|
195
|
+
performance: {
|
196
|
+
log: function(message) {
|
197
|
+
var
|
198
|
+
currentTime,
|
199
|
+
executionTime,
|
200
|
+
previousTime
|
201
|
+
;
|
202
|
+
if(settings.performance) {
|
203
|
+
currentTime = new Date().getTime();
|
204
|
+
previousTime = time || currentTime;
|
205
|
+
executionTime = currentTime - previousTime;
|
206
|
+
time = currentTime;
|
207
|
+
performance.push({
|
208
|
+
'Element' : element,
|
209
|
+
'Name' : message[0],
|
210
|
+
'Arguments' : [].slice.call(message, 1) || '',
|
211
|
+
'Execution Time' : executionTime
|
212
|
+
});
|
213
|
+
}
|
214
|
+
clearTimeout(module.performance.timer);
|
215
|
+
module.performance.timer = setTimeout(module.performance.display, 100);
|
216
|
+
},
|
217
|
+
display: function() {
|
218
|
+
var
|
219
|
+
title = settings.name + ':',
|
220
|
+
totalTime = 0
|
221
|
+
;
|
222
|
+
time = false;
|
223
|
+
clearTimeout(module.performance.timer);
|
224
|
+
$.each(performance, function(index, data) {
|
225
|
+
totalTime += data['Execution Time'];
|
226
|
+
});
|
227
|
+
title += ' ' + totalTime + 'ms';
|
228
|
+
if(moduleSelector) {
|
229
|
+
title += ' \'' + moduleSelector + '\'';
|
230
|
+
}
|
231
|
+
if($allModules.size() > 1) {
|
232
|
+
title += ' ' + '(' + $allModules.size() + ')';
|
233
|
+
}
|
234
|
+
if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
|
235
|
+
console.groupCollapsed(title);
|
236
|
+
if(console.table) {
|
237
|
+
console.table(performance);
|
238
|
+
}
|
239
|
+
else {
|
240
|
+
$.each(performance, function(index, data) {
|
241
|
+
console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
|
242
|
+
});
|
243
|
+
}
|
244
|
+
console.groupEnd();
|
245
|
+
}
|
246
|
+
performance = [];
|
247
|
+
}
|
248
|
+
},
|
249
|
+
invoke: function(query, passedArguments, context) {
|
250
|
+
var
|
251
|
+
maxDepth,
|
252
|
+
found,
|
253
|
+
response
|
254
|
+
;
|
255
|
+
passedArguments = passedArguments || queryArguments;
|
256
|
+
context = element || context;
|
257
|
+
if(typeof query == 'string' && instance !== undefined) {
|
258
|
+
query = query.split(/[\. ]/);
|
259
|
+
maxDepth = query.length - 1;
|
260
|
+
$.each(query, function(depth, value) {
|
261
|
+
var camelCaseValue = (depth != maxDepth)
|
262
|
+
? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
|
263
|
+
: query
|
264
|
+
;
|
265
|
+
if( $.isPlainObject( instance[value] ) && (depth != maxDepth) ) {
|
266
|
+
instance = instance[value];
|
267
|
+
}
|
268
|
+
else if( $.isPlainObject( instance[camelCaseValue] ) && (depth != maxDepth) ) {
|
269
|
+
instance = instance[camelCaseValue];
|
270
|
+
}
|
271
|
+
else if( instance[value] !== undefined ) {
|
272
|
+
found = instance[value];
|
273
|
+
return false;
|
274
|
+
}
|
275
|
+
else if( instance[camelCaseValue] !== undefined ) {
|
276
|
+
found = instance[camelCaseValue];
|
277
|
+
return false;
|
278
|
+
}
|
279
|
+
else {
|
280
|
+
module.error(error.method);
|
281
|
+
return false;
|
282
|
+
}
|
283
|
+
});
|
284
|
+
}
|
285
|
+
if ( $.isFunction( found ) ) {
|
286
|
+
response = found.apply(context, passedArguments);
|
287
|
+
}
|
288
|
+
else if(found !== undefined) {
|
289
|
+
response = found;
|
290
|
+
}
|
291
|
+
if($.isArray(invokedResponse)) {
|
292
|
+
invokedResponse.push(response);
|
293
|
+
}
|
294
|
+
else if(typeof invokedResponse == 'string') {
|
295
|
+
invokedResponse = [invokedResponse, response];
|
296
|
+
}
|
297
|
+
else if(response !== undefined) {
|
298
|
+
invokedResponse = response;
|
299
|
+
}
|
300
|
+
return found;
|
301
|
+
}
|
302
|
+
};
|
303
|
+
|
304
|
+
if(methodInvoked) {
|
305
|
+
if(instance === undefined) {
|
306
|
+
module.initialize();
|
307
|
+
}
|
308
|
+
module.invoke(query);
|
309
|
+
}
|
310
|
+
else {
|
311
|
+
if(instance !== undefined) {
|
312
|
+
module.destroy();
|
313
|
+
}
|
314
|
+
module.initialize();
|
315
|
+
}
|
316
|
+
})
|
317
|
+
;
|
318
|
+
|
319
|
+
return (invokedResponse !== undefined)
|
320
|
+
? invokedResponse
|
321
|
+
: this
|
322
|
+
;
|
323
|
+
};
|
324
|
+
|
325
|
+
$.fn.rating.settings = {
|
326
|
+
|
327
|
+
name : 'Rating',
|
328
|
+
namespace : 'rating',
|
329
|
+
|
330
|
+
verbose : true,
|
331
|
+
debug : true,
|
332
|
+
performance : true,
|
333
|
+
|
334
|
+
initialRating : 0,
|
335
|
+
interactive : true,
|
336
|
+
onRate : function(){},
|
337
|
+
|
338
|
+
error : {
|
339
|
+
method : 'The method you called is not defined'
|
340
|
+
},
|
341
|
+
|
342
|
+
metadata: {
|
343
|
+
rating: 'rating'
|
344
|
+
},
|
345
|
+
|
346
|
+
className : {
|
347
|
+
active : 'active',
|
348
|
+
hover : 'hover',
|
349
|
+
loading : 'loading'
|
350
|
+
},
|
351
|
+
|
352
|
+
selector : {
|
353
|
+
icon : '.icon'
|
354
|
+
}
|
355
|
+
|
356
|
+
};
|
357
|
+
|
358
|
+
})( jQuery, window , document );
|