Commit d8b44418fccb76fec26a2d0865230032683918a0
Committed by
Paulo Meireles
1 parent
aeef9a08
Exists in
master
and in
29 other branches
[Mezuro] Adding background-color for reading color in show reading group.
Showing
4 changed files
with
1 additions
and
377 deletions
Show diff stats
plugins/mezuro/public/javascripts/colorPicker/LICENSE
... | ... | @@ -1,22 +0,0 @@ |
1 | -Copyright (c) 2012 Lakshan Perera | |
2 | - | |
3 | -Permission is hereby granted, free of charge, to any person | |
4 | -obtaining a copy of this software and associated documentation | |
5 | -files (the "Software"), to deal in the Software without | |
6 | -restriction, including without limitation the rights to use, | |
7 | -copy, modify, merge, publish, distribute, sublicense, and/or sell | |
8 | -copies of the Software, and to permit persons to whom the | |
9 | -Software is furnished to do so, subject to the following | |
10 | -conditions: | |
11 | - | |
12 | -The above copyright notice and this permission notice shall be | |
13 | -included in all copies or substantial portions of the Software. | |
14 | - | |
15 | -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
16 | -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | |
17 | -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
18 | -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | |
19 | -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | |
20 | -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
21 | -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | |
22 | -OTHER DEALINGS IN THE SOFTWARE. |
plugins/mezuro/public/javascripts/colorPicker/jquery.colorPicker.js
... | ... | @@ -1,328 +0,0 @@ |
1 | -/** | |
2 | - * Really Simple Color Picker in jQuery | |
3 | - * | |
4 | - * Licensed under the MIT (MIT-LICENSE.txt) licenses. | |
5 | - * | |
6 | - * Copyright (c) 2008-2012 | |
7 | - * Lakshan Perera (www.laktek.com) & Daniel Lacy (daniellacy.com) | |
8 | - * | |
9 | - * Permission is hereby granted, free of charge, to any person obtaining a copy | |
10 | - * of this software and associated documentation files (the "Software"), to | |
11 | - * deal in the Software without restriction, including without limitation the | |
12 | - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | |
13 | - * sell copies of the Software, and to permit persons to whom the Software is | |
14 | - * furnished to do so, subject to the following conditions: | |
15 | - * | |
16 | - * The above copyright notice and this permission notice shall be included in | |
17 | - * all copies or substantial portions of the Software. | |
18 | - * | |
19 | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
20 | - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
21 | - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
22 | - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
23 | - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
24 | - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | |
25 | - * IN THE SOFTWARE. | |
26 | - */ | |
27 | - | |
28 | -(function ($) { | |
29 | - /** | |
30 | - * Create a couple private variables. | |
31 | - **/ | |
32 | - var selectorOwner, | |
33 | - activePalette, | |
34 | - cItterate = 0, | |
35 | - templates = { | |
36 | - control : $('<div class="colorPicker-picker"> </div>'), | |
37 | - palette : $('<div id="colorPicker_palette" class="colorPicker-palette" />'), | |
38 | - swatch : $('<div class="colorPicker-swatch"> </div>'), | |
39 | - hexLabel: $('<label for="colorPicker_hex">Hex</label>'), | |
40 | - hexField: $('<input type="text" id="colorPicker_hex" />') | |
41 | - }, | |
42 | - transparent = "transparent", | |
43 | - lastColor; | |
44 | - | |
45 | - /** | |
46 | - * Create our colorPicker function | |
47 | - **/ | |
48 | - $.fn.colorPicker = function (options) { | |
49 | - | |
50 | - return this.each(function () { | |
51 | - // Setup time. Clone new elements from our templates, set some IDs, make shortcuts, jazzercise. | |
52 | - var element = $(this), | |
53 | - opts = $.extend({}, $.fn.colorPicker.defaults, options), | |
54 | - defaultColor = $.fn.colorPicker.toHex( | |
55 | - (element.val().length > 0) ? element.val() : opts.pickerDefault | |
56 | - ), | |
57 | - newControl = templates.control.clone(), | |
58 | - newPalette = templates.palette.clone().attr('id', 'colorPicker_palette-' + cItterate), | |
59 | - newHexLabel = templates.hexLabel.clone(), | |
60 | - newHexField = templates.hexField.clone(), | |
61 | - paletteId = newPalette[0].id, | |
62 | - swatch; | |
63 | - | |
64 | - | |
65 | - /** | |
66 | - * Build a color palette. | |
67 | - **/ | |
68 | - $.each(opts.colors, function (i) { | |
69 | - swatch = templates.swatch.clone(); | |
70 | - | |
71 | - if (opts.colors[i] === transparent) { | |
72 | - swatch.addClass(transparent).text('X'); | |
73 | - $.fn.colorPicker.bindPalette(newHexField, swatch, transparent); | |
74 | - } else { | |
75 | - swatch.css("background-color", "#" + this); | |
76 | - $.fn.colorPicker.bindPalette(newHexField, swatch); | |
77 | - } | |
78 | - swatch.appendTo(newPalette); | |
79 | - }); | |
80 | - | |
81 | - newHexLabel.attr('for', 'colorPicker_hex-' + cItterate); | |
82 | - | |
83 | - newHexField.attr({ | |
84 | - 'id' : 'colorPicker_hex-' + cItterate, | |
85 | - 'value' : defaultColor | |
86 | - }); | |
87 | - | |
88 | - newHexField.bind("keydown", function (event) { | |
89 | - if (event.keyCode === 13) { | |
90 | - var hexColor = $.fn.colorPicker.toHex($(this).val()); | |
91 | - $.fn.colorPicker.changeColor(hexColor ? hexColor : element.val()); | |
92 | - } | |
93 | - if (event.keyCode === 27) { | |
94 | - $.fn.colorPicker.hidePalette(); | |
95 | - } | |
96 | - }); | |
97 | - | |
98 | - newHexField.bind("keyup", function (event) { | |
99 | - var hexColor = $.fn.colorPicker.toHex($(event.target).val()); | |
100 | - $.fn.colorPicker.previewColor(hexColor ? hexColor : element.val()); | |
101 | - }); | |
102 | - | |
103 | - $('<div class="colorPicker_hexWrap" />').append(newHexLabel).appendTo(newPalette); | |
104 | - | |
105 | - newPalette.find('.colorPicker_hexWrap').append(newHexField); | |
106 | - | |
107 | - $("body").append(newPalette); | |
108 | - | |
109 | - newPalette.hide(); | |
110 | - | |
111 | - | |
112 | - /** | |
113 | - * Build replacement interface for original color input. | |
114 | - **/ | |
115 | - newControl.css("background-color", defaultColor); | |
116 | - | |
117 | - newControl.bind("click", function () { | |
118 | - $.fn.colorPicker.togglePalette($('#' + paletteId), $(this)); | |
119 | - }); | |
120 | - | |
121 | - if( options && options.onColorChange ) { | |
122 | - newControl.data('onColorChange', options.onColorChange); | |
123 | - } else { | |
124 | - newControl.data('onColorChange', function() {} ); | |
125 | - } | |
126 | - element.after(newControl); | |
127 | - | |
128 | - element.bind("change", function () { | |
129 | - element.next(".colorPicker-picker").css( | |
130 | - "background-color", $.fn.colorPicker.toHex($(this).val()) | |
131 | - ); | |
132 | - }); | |
133 | - | |
134 | - // Hide the original input. | |
135 | - element.val(defaultColor).hide(); | |
136 | - | |
137 | - cItterate++; | |
138 | - }); | |
139 | - }; | |
140 | - | |
141 | - /** | |
142 | - * Extend colorPicker with... all our functionality. | |
143 | - **/ | |
144 | - $.extend(true, $.fn.colorPicker, { | |
145 | - /** | |
146 | - * Return a Hex color, convert an RGB value and return Hex, or return false. | |
147 | - * | |
148 | - * Inspired by http://code.google.com/p/jquery-color-utils | |
149 | - **/ | |
150 | - toHex : function (color) { | |
151 | - // If we have a standard or shorthand Hex color, return that value. | |
152 | - if (color.match(/[0-9A-F]{6}|[0-9A-F]{3}$/i)) { | |
153 | - return (color.charAt(0) === "#") ? color : ("#" + color); | |
154 | - | |
155 | - // Alternatively, check for RGB color, then convert and return it as Hex. | |
156 | - } else if (color.match(/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/)) { | |
157 | - var c = ([parseInt(RegExp.$1, 10), parseInt(RegExp.$2, 10), parseInt(RegExp.$3, 10)]), | |
158 | - pad = function (str) { | |
159 | - if (str.length < 2) { | |
160 | - for (var i = 0, len = 2 - str.length; i < len; i++) { | |
161 | - str = '0' + str; | |
162 | - } | |
163 | - } | |
164 | - | |
165 | - return str; | |
166 | - }; | |
167 | - | |
168 | - if (c.length === 3) { | |
169 | - var r = pad(c[0].toString(16)), | |
170 | - g = pad(c[1].toString(16)), | |
171 | - b = pad(c[2].toString(16)); | |
172 | - | |
173 | - return '#' + r + g + b; | |
174 | - } | |
175 | - | |
176 | - // Otherwise we wont do anything. | |
177 | - } else { | |
178 | - return false; | |
179 | - | |
180 | - } | |
181 | - }, | |
182 | - | |
183 | - /** | |
184 | - * Check whether user clicked on the selector or owner. | |
185 | - **/ | |
186 | - checkMouse : function (event, paletteId) { | |
187 | - var selector = activePalette, | |
188 | - selectorParent = $(event.target).parents("#" + selector.attr('id')).length; | |
189 | - | |
190 | - if (event.target === $(selector)[0] || event.target === selectorOwner[0] || selectorParent > 0) { | |
191 | - return; | |
192 | - } | |
193 | - | |
194 | - $.fn.colorPicker.hidePalette(); | |
195 | - }, | |
196 | - | |
197 | - /** | |
198 | - * Hide the color palette modal. | |
199 | - **/ | |
200 | - hidePalette : function () { | |
201 | - $(document).unbind("mousedown", $.fn.colorPicker.checkMouse); | |
202 | - | |
203 | - $('.colorPicker-palette').hide(); | |
204 | - }, | |
205 | - | |
206 | - /** | |
207 | - * Show the color palette modal. | |
208 | - **/ | |
209 | - showPalette : function (palette) { | |
210 | - var hexColor = selectorOwner.prev("input").val(); | |
211 | - | |
212 | - palette.css({ | |
213 | - top: selectorOwner.offset().top + (selectorOwner.outerHeight()), | |
214 | - left: selectorOwner.offset().left | |
215 | - }); | |
216 | - | |
217 | - $("#color_value").val(hexColor); | |
218 | - | |
219 | - palette.show(); | |
220 | - | |
221 | - $(document).bind("mousedown", $.fn.colorPicker.checkMouse); | |
222 | - }, | |
223 | - | |
224 | - /** | |
225 | - * Toggle visibility of the colorPicker palette. | |
226 | - **/ | |
227 | - togglePalette : function (palette, origin) { | |
228 | - // selectorOwner is the clicked .colorPicker-picker. | |
229 | - if (origin) { | |
230 | - selectorOwner = origin; | |
231 | - } | |
232 | - | |
233 | - activePalette = palette; | |
234 | - | |
235 | - if (activePalette.is(':visible')) { | |
236 | - $.fn.colorPicker.hidePalette(); | |
237 | - | |
238 | - } else { | |
239 | - $.fn.colorPicker.showPalette(palette); | |
240 | - | |
241 | - } | |
242 | - }, | |
243 | - | |
244 | - /** | |
245 | - * Update the input with a newly selected color. | |
246 | - **/ | |
247 | - changeColor : function (value) { | |
248 | - selectorOwner.css("background-color", value); | |
249 | - selectorOwner.prev("input").val(value).change(); | |
250 | - | |
251 | - $.fn.colorPicker.hidePalette(); | |
252 | - | |
253 | - selectorOwner.data('onColorChange').call(selectorOwner, $(selectorOwner).prev("input").attr("id"), value); | |
254 | - }, | |
255 | - | |
256 | - | |
257 | - /** | |
258 | - * Preview the input with a newly selected color. | |
259 | - **/ | |
260 | - previewColor : function (value) { | |
261 | - selectorOwner.css("background-color", value); | |
262 | - }, | |
263 | - | |
264 | - /** | |
265 | - * Bind events to the color palette swatches. | |
266 | - */ | |
267 | - bindPalette : function (paletteInput, element, color) { | |
268 | - color = color ? color : $.fn.colorPicker.toHex(element.css("background-color")); | |
269 | - | |
270 | - element.bind({ | |
271 | - click : function (ev) { | |
272 | - lastColor = color; | |
273 | - | |
274 | - $.fn.colorPicker.changeColor(color); | |
275 | - }, | |
276 | - mouseover : function (ev) { | |
277 | - lastColor = paletteInput.val(); | |
278 | - | |
279 | - $(this).css("border-color", "#598FEF"); | |
280 | - | |
281 | - paletteInput.val(color); | |
282 | - | |
283 | - $.fn.colorPicker.previewColor(color); | |
284 | - }, | |
285 | - mouseout : function (ev) { | |
286 | - $(this).css("border-color", "#000"); | |
287 | - | |
288 | - paletteInput.val(selectorOwner.css("background-color")); | |
289 | - | |
290 | - paletteInput.val(lastColor); | |
291 | - | |
292 | - $.fn.colorPicker.previewColor(lastColor); | |
293 | - } | |
294 | - }); | |
295 | - } | |
296 | - }); | |
297 | - | |
298 | - /** | |
299 | - * Default colorPicker options. | |
300 | - * | |
301 | - * These are publibly available for global modification using a setting such as: | |
302 | - * | |
303 | - * $.fn.colorPicker.defaults.colors = ['151337', '111111'] | |
304 | - * | |
305 | - * They can also be applied on a per-bound element basis like so: | |
306 | - * | |
307 | - * $('#element1').colorPicker({pickerDefault: 'efefef', transparency: true}); | |
308 | - * $('#element2').colorPicker({pickerDefault: '333333', colors: ['333333', '111111']}); | |
309 | - * | |
310 | - **/ | |
311 | - $.fn.colorPicker.defaults = { | |
312 | - // colorPicker default selected color. | |
313 | - pickerDefault : "FFFFFF", | |
314 | - | |
315 | - // Default color set. | |
316 | - colors : [ | |
317 | - '000000', '993300', '333300', '000080', '333399', '333333', '800000', 'FF6600', | |
318 | - '808000', '008000', '008080', '0000FF', '666699', '808080', 'FF0000', 'FF9900', | |
319 | - '99CC00', '339966', '33CCCC', '3366FF', '800080', '999999', 'FF00FF', 'FFCC00', | |
320 | - 'FFFF00', '00FF00', '00FFFF', '00CCFF', '993366', 'C0C0C0', 'FF99CC', 'FFCC99', | |
321 | - 'FFFF99', 'CCFFFF', '99CCFF', 'FFFFFF' | |
322 | - ], | |
323 | - | |
324 | - // If we want to simply add more colors to the default set, use addColors. | |
325 | - addColors : [] | |
326 | - }; | |
327 | - | |
328 | -})(jQuery); |
plugins/mezuro/public/javascripts/colorPicker/jquery.colorPicker.min.js
... | ... | @@ -1,26 +0,0 @@ |
1 | -/** | |
2 | - * Really Simple Color Picker in jQuery | |
3 | - * | |
4 | - * Licensed under the MIT (MIT-LICENSE.txt) licenses. | |
5 | - * | |
6 | - * Copyright (c) 2008-2012 | |
7 | - * Lakshan Perera (www.laktek.com) & Daniel Lacy (daniellacy.com) | |
8 | - * | |
9 | - * Permission is hereby granted, free of charge, to any person obtaining a copy | |
10 | - * of this software and associated documentation files (the "Software"), to | |
11 | - * deal in the Software without restriction, including without limitation the | |
12 | - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | |
13 | - * sell copies of the Software, and to permit persons to whom the Software is | |
14 | - * furnished to do so, subject to the following conditions: | |
15 | - * | |
16 | - * The above copyright notice and this permission notice shall be included in | |
17 | - * all copies or substantial portions of the Software. | |
18 | - * | |
19 | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
20 | - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
21 | - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
22 | - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
23 | - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
24 | - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | |
25 | - * IN THE SOFTWARE. | |
26 | - */(function(a){var b,c,d=0,e={control:a('<div class="colorPicker-picker"> </div>'),palette:a('<div id="colorPicker_palette" class="colorPicker-palette" />'),swatch:a('<div class="colorPicker-swatch"> </div>'),hexLabel:a('<label for="colorPicker_hex">Hex</label>'),hexField:a('<input type="text" id="colorPicker_hex" />')},f="transparent",g;a.fn.colorPicker=function(b){return this.each(function(){var c=a(this),g=a.extend({},a.fn.colorPicker.defaults,b),h=a.fn.colorPicker.toHex(c.val().length>0?c.val():g.pickerDefault),i=e.control.clone(),j=e.palette.clone().attr("id","colorPicker_palette-"+d),k=e.hexLabel.clone(),l=e.hexField.clone(),m=j[0].id,n;a.each(g.colors,function(b){n=e.swatch.clone(),g.colors[b]===f?(n.addClass(f).text("X"),a.fn.colorPicker.bindPalette(l,n,f)):(n.css("background-color","#"+this),a.fn.colorPicker.bindPalette(l,n)),n.appendTo(j)}),k.attr("for","colorPicker_hex-"+d),l.attr({id:"colorPicker_hex-"+d,value:h}),l.bind("keydown",function(b){if(b.keyCode===13){var d=a.fn.colorPicker.toHex(a(this).val());a.fn.colorPicker.changeColor(d?d:c.val())}b.keyCode===27&&a.fn.colorPicker.hidePalette()}),l.bind("keyup",function(b){var d=a.fn.colorPicker.toHex(a(b.target).val());a.fn.colorPicker.previewColor(d?d:c.val())}),a('<div class="colorPicker_hexWrap" />').append(k).appendTo(j),j.find(".colorPicker_hexWrap").append(l),a("body").append(j),j.hide(),i.css("background-color",h),i.bind("click",function(){a.fn.colorPicker.togglePalette(a("#"+m),a(this))}),b&&b.onColorChange?i.data("onColorChange",b.onColorChange):i.data("onColorChange",function(){}),c.after(i),c.bind("change",function(){c.next(".colorPicker-picker").css("background-color",a.fn.colorPicker.toHex(a(this).val()))}),c.val(h).hide(),d++})},a.extend(!0,a.fn.colorPicker,{toHex:function(a){if(a.match(/[0-9A-F]{6}|[0-9A-F]{3}$/i))return a.charAt(0)==="#"?a:"#"+a;if(!a.match(/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/))return!1;var b=[parseInt(RegExp.$1,10),parseInt(RegExp.$2,10),parseInt(RegExp.$3,10)],c=function(a){if(a.length<2)for(var b=0,c=2-a.length;b<c;b++)a="0"+a;return a};if(b.length===3){var d=c(b[0].toString(16)),e=c(b[1].toString(16)),f=c(b[2].toString(16));return"#"+d+e+f}},checkMouse:function(d,e){var f=c,g=a(d.target).parents("#"+f.attr("id")).length;if(d.target===a(f)[0]||d.target===b[0]||g>0)return;a.fn.colorPicker.hidePalette()},hidePalette:function(){a(document).unbind("mousedown",a.fn.colorPicker.checkMouse),a(".colorPicker-palette").hide()},showPalette:function(c){var d=b.prev("input").val();c.css({top:b.offset().top+b.outerHeight(),left:b.offset().left}),a("#color_value").val(d),c.show(),a(document).bind("mousedown",a.fn.colorPicker.checkMouse)},togglePalette:function(d,e){e&&(b=e),c=d,c.is(":visible")?a.fn.colorPicker.hidePalette():a.fn.colorPicker.showPalette(d)},changeColor:function(c){b.css("background-color",c),b.prev("input").val(c).change(),a.fn.colorPicker.hidePalette(),b.data("onColorChange").call(b,a(b).prev("input").attr("id"),c)},previewColor:function(a){b.css("background-color",a)},bindPalette:function(c,d,e){e=e?e:a.fn.colorPicker.toHex(d.css("background-color")),d.bind({click:function(b){g=e,a.fn.colorPicker.changeColor(e)},mouseover:function(b){g=c.val(),a(this).css("border-color","#598FEF"),c.val(e),a.fn.colorPicker.previewColor(e)},mouseout:function(d){a(this).css("border-color","#000"),c.val(b.css("background-color")),c.val(g),a.fn.colorPicker.previewColor(g)}})}}),a.fn.colorPicker.defaults={pickerDefault:"FFFFFF",colors:["000000","993300","333300","000080","333399","333333","800000","FF6600","808000","008000","008080","0000FF","666699","808080","FF0000","FF9900","99CC00","339966","33CCCC","3366FF","800080","999999","FF00FF","FFCC00","FFFF00","00FF00","00FFFF","00CCFF","993366","C0C0C0","FF99CC","FFCC99","FFFF99","CCFFFF","99CCFF","FFFFFF"],addColors:[]}})(jQuery) | |
27 | 0 | \ No newline at end of file |
plugins/mezuro/views/content_viewer/show_reading_group.rhtml
... | ... | @@ -29,7 +29,7 @@ |
29 | 29 | :id => @page.id, |
30 | 30 | :reading_id => reading.id %></td> |
31 | 31 | <td><%= reading.grade %></td> |
32 | - <td><%= reading.color %></td> | |
32 | + <td bgcolor="#<%= reading.color %>"></td> | |
33 | 33 | <td ><%= link_to _('Remove'), {:controller => "mezuro_plugin_reading", |
34 | 34 | :profile => @page.profile.identifier, |
35 | 35 | :action => "destroy", | ... | ... |