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,271 @@
|
|
1
|
+
/* ******************************
|
2
|
+
Colorizer
|
3
|
+
Author: Jack Lukic
|
4
|
+
Notes: First Commit June 06, 2012
|
5
|
+
|
6
|
+
Tooltip Wrapper for loading
|
7
|
+
colorizes of ideations, concepts and users
|
8
|
+
|
9
|
+
Will eventually rewrite to use own tooltip lib
|
10
|
+
|
11
|
+
****************************** */
|
12
|
+
|
13
|
+
;(function ( $, window, document, undefined ) {
|
14
|
+
|
15
|
+
$.fn.colorize = function(parameters) {
|
16
|
+
var
|
17
|
+
settings = $.extend(true, {}, $.fn.colorize.settings, parameters),
|
18
|
+
// hoist arguments
|
19
|
+
moduleArguments = arguments || false
|
20
|
+
;
|
21
|
+
$(this)
|
22
|
+
.each(function(instanceIndex) {
|
23
|
+
|
24
|
+
var
|
25
|
+
$module = $(this),
|
26
|
+
|
27
|
+
mainCanvas = $('<canvas />')[0],
|
28
|
+
imageCanvas = $('<canvas />')[0],
|
29
|
+
overlayCanvas = $('<canvas />')[0],
|
30
|
+
|
31
|
+
backgroundImage = new Image(),
|
32
|
+
|
33
|
+
// defs
|
34
|
+
mainContext,
|
35
|
+
imageContext,
|
36
|
+
overlayContext,
|
37
|
+
|
38
|
+
image,
|
39
|
+
imageName,
|
40
|
+
|
41
|
+
width,
|
42
|
+
height,
|
43
|
+
|
44
|
+
// shortucts
|
45
|
+
colors = settings.colors,
|
46
|
+
paths = settings.paths,
|
47
|
+
namespace = settings.namespace,
|
48
|
+
error = settings.error,
|
49
|
+
|
50
|
+
// boilerplate
|
51
|
+
instance = $module.data('module-' + namespace),
|
52
|
+
module
|
53
|
+
;
|
54
|
+
|
55
|
+
module = {
|
56
|
+
|
57
|
+
checkPreconditions: function() {
|
58
|
+
module.debug('Checking pre-conditions');
|
59
|
+
|
60
|
+
if( !$.isPlainObject(colors) || $.isEmptyObject(colors) ) {
|
61
|
+
module.error(error.undefinedColors);
|
62
|
+
return false;
|
63
|
+
}
|
64
|
+
return true;
|
65
|
+
},
|
66
|
+
|
67
|
+
async: function(callback) {
|
68
|
+
if(settings.async) {
|
69
|
+
setTimeout(callback, 0);
|
70
|
+
}
|
71
|
+
else {
|
72
|
+
callback();
|
73
|
+
}
|
74
|
+
},
|
75
|
+
|
76
|
+
getMetadata: function() {
|
77
|
+
module.debug('Grabbing metadata');
|
78
|
+
image = $module.data('image') || settings.image || undefined;
|
79
|
+
imageName = $module.data('name') || settings.name || instanceIndex;
|
80
|
+
width = settings.width || $module.width();
|
81
|
+
height = settings.height || $module.height();
|
82
|
+
if(width === 0 || height === 0) {
|
83
|
+
module.error(error.undefinedSize);
|
84
|
+
}
|
85
|
+
},
|
86
|
+
|
87
|
+
initialize: function() {
|
88
|
+
module.debug('Initializing with colors', colors);
|
89
|
+
if( module.checkPreconditions() ) {
|
90
|
+
|
91
|
+
module.async(function() {
|
92
|
+
module.getMetadata();
|
93
|
+
module.canvas.create();
|
94
|
+
|
95
|
+
module.draw.image(function() {
|
96
|
+
module.draw.colors();
|
97
|
+
module.canvas.merge();
|
98
|
+
});
|
99
|
+
$module
|
100
|
+
.data('module-' + namespace, module)
|
101
|
+
;
|
102
|
+
});
|
103
|
+
}
|
104
|
+
},
|
105
|
+
|
106
|
+
redraw: function() {
|
107
|
+
module.debug('Redrawing image');
|
108
|
+
module.async(function() {
|
109
|
+
module.canvas.clear();
|
110
|
+
module.draw.colors();
|
111
|
+
module.canvas.merge();
|
112
|
+
});
|
113
|
+
},
|
114
|
+
|
115
|
+
change: {
|
116
|
+
color: function(colorName, color) {
|
117
|
+
module.debug('Changing color', colorName);
|
118
|
+
if(colors[colorName] === undefined) {
|
119
|
+
module.error(error.missingColor);
|
120
|
+
return false;
|
121
|
+
}
|
122
|
+
colors[colorName] = color;
|
123
|
+
module.redraw();
|
124
|
+
}
|
125
|
+
},
|
126
|
+
|
127
|
+
canvas: {
|
128
|
+
create: function() {
|
129
|
+
module.debug('Creating canvases');
|
130
|
+
|
131
|
+
mainCanvas.width = width;
|
132
|
+
mainCanvas.height = height;
|
133
|
+
imageCanvas.width = width;
|
134
|
+
imageCanvas.height = height;
|
135
|
+
overlayCanvas.width = width;
|
136
|
+
overlayCanvas.height = height;
|
137
|
+
|
138
|
+
mainContext = mainCanvas.getContext('2d');
|
139
|
+
imageContext = imageCanvas.getContext('2d');
|
140
|
+
overlayContext = overlayCanvas.getContext('2d');
|
141
|
+
|
142
|
+
$module
|
143
|
+
.append( mainCanvas )
|
144
|
+
;
|
145
|
+
mainContext = $module.children('canvas')[0].getContext('2d');
|
146
|
+
},
|
147
|
+
clear: function(context) {
|
148
|
+
module.debug('Clearing canvas');
|
149
|
+
overlayContext.fillStyle = '#FFFFFF';
|
150
|
+
overlayContext.fillRect(0, 0, width, height);
|
151
|
+
},
|
152
|
+
merge: function() {
|
153
|
+
if( !$.isFunction(mainContext.blendOnto) ) {
|
154
|
+
module.error(error.missingPlugin);
|
155
|
+
return;
|
156
|
+
}
|
157
|
+
mainContext.putImageData( imageContext.getImageData(0, 0, width, height), 0, 0);
|
158
|
+
overlayContext.blendOnto(mainContext, 'multiply');
|
159
|
+
}
|
160
|
+
},
|
161
|
+
|
162
|
+
draw: {
|
163
|
+
|
164
|
+
image: function(callback) {
|
165
|
+
module.debug('Drawing image');
|
166
|
+
callback = callback || function(){};
|
167
|
+
if(image) {
|
168
|
+
backgroundImage.src = image;
|
169
|
+
backgroundImage.onload = function() {
|
170
|
+
imageContext.drawImage(backgroundImage, 0, 0);
|
171
|
+
callback();
|
172
|
+
};
|
173
|
+
}
|
174
|
+
else {
|
175
|
+
module.error(error.noImage);
|
176
|
+
callback();
|
177
|
+
}
|
178
|
+
},
|
179
|
+
|
180
|
+
colors: function() {
|
181
|
+
module.debug('Drawing color overlays', colors);
|
182
|
+
$.each(colors, function(colorName, color) {
|
183
|
+
settings.onDraw(overlayContext, imageName, colorName, color);
|
184
|
+
});
|
185
|
+
}
|
186
|
+
|
187
|
+
},
|
188
|
+
|
189
|
+
debug: function(message, variableName) {
|
190
|
+
if(settings.debug) {
|
191
|
+
if(variableName !== undefined) {
|
192
|
+
console.info(settings.moduleName + ': ' + message, variableName);
|
193
|
+
}
|
194
|
+
else {
|
195
|
+
console.info(settings.moduleName + ': ' + message);
|
196
|
+
}
|
197
|
+
}
|
198
|
+
},
|
199
|
+
error: function(errorMessage) {
|
200
|
+
console.warn(settings.moduleName + ': ' + errorMessage);
|
201
|
+
},
|
202
|
+
invoke: function(methodName, context, methodArguments) {
|
203
|
+
var
|
204
|
+
method
|
205
|
+
;
|
206
|
+
methodArguments = methodArguments || Array.prototype.slice.call( arguments, 2 );
|
207
|
+
|
208
|
+
if(typeof methodName == 'string' && instance !== undefined) {
|
209
|
+
methodName = methodName.split('.');
|
210
|
+
$.each(methodName, function(index, name) {
|
211
|
+
if( $.isPlainObject( instance[name] ) ) {
|
212
|
+
instance = instance[name];
|
213
|
+
return true;
|
214
|
+
}
|
215
|
+
else if( $.isFunction( instance[name] ) ) {
|
216
|
+
method = instance[name];
|
217
|
+
return true;
|
218
|
+
}
|
219
|
+
module.error(settings.error.method);
|
220
|
+
return false;
|
221
|
+
});
|
222
|
+
}
|
223
|
+
return ( $.isFunction( method ) )
|
224
|
+
? method.apply(context, methodArguments)
|
225
|
+
: false
|
226
|
+
;
|
227
|
+
}
|
228
|
+
|
229
|
+
};
|
230
|
+
if(instance !== undefined && moduleArguments) {
|
231
|
+
// simpler than invoke realizing to invoke itself (and losing scope due prototype.call()
|
232
|
+
if(moduleArguments[0] == 'invoke') {
|
233
|
+
moduleArguments = Array.prototype.slice.call( moduleArguments, 1 );
|
234
|
+
}
|
235
|
+
return module.invoke(moduleArguments[0], this, Array.prototype.slice.call( moduleArguments, 1 ) );
|
236
|
+
}
|
237
|
+
// initializing
|
238
|
+
module.initialize();
|
239
|
+
})
|
240
|
+
;
|
241
|
+
return this;
|
242
|
+
};
|
243
|
+
|
244
|
+
$.fn.colorize.settings = {
|
245
|
+
name : 'Image Colorizer',
|
246
|
+
debug : true,
|
247
|
+
namespace : 'colorize',
|
248
|
+
|
249
|
+
onDraw: function(overlayContext, imageName, colorName, color) {},
|
250
|
+
|
251
|
+
// whether to block execution while updating canvas
|
252
|
+
async: true,
|
253
|
+
// object containing names and default values of color regions
|
254
|
+
colors: {},
|
255
|
+
|
256
|
+
metadata: {
|
257
|
+
image : 'image',
|
258
|
+
name : 'name'
|
259
|
+
},
|
260
|
+
|
261
|
+
error: {
|
262
|
+
noImage : 'No tracing image specified',
|
263
|
+
undefinedColors : 'No default colors specified.',
|
264
|
+
missingColor : 'Attempted to change color that does not exist',
|
265
|
+
missingPlugin : 'Blend onto plug-in must be included',
|
266
|
+
undefinedHeight : 'The width or height of image canvas could not be automatically determined. Please specify a height.'
|
267
|
+
}
|
268
|
+
|
269
|
+
};
|
270
|
+
|
271
|
+
})( jQuery, window , document );
|