|
157 | 157 |
|
158 | 158 | // The wrapper
|
159 | 159 | minicolors
|
160 |
| - .addClass('minicolors-theme-' + settings.theme) |
161 |
| - .toggleClass('minicolors-with-opacity', settings.opacity); |
| 160 | + .addClass('minicolors-theme-' + settings.theme) |
| 161 | + .toggleClass('minicolors-with-opacity', settings.opacity); |
162 | 162 |
|
163 | 163 | // Custom positioning
|
164 | 164 | if(settings.position !== undefined) {
|
|
176 | 176 |
|
177 | 177 | // The input
|
178 | 178 | input
|
179 |
| - .addClass('minicolors-input') |
180 |
| - .data('minicolors-initialized', false) |
181 |
| - .data('minicolors-settings', settings) |
182 |
| - .prop('size', size) |
183 |
| - .wrap(minicolors) |
184 |
| - .after( |
185 |
| - '<div class="minicolors-panel minicolors-slider-' + settings.control + '">' + |
| 179 | + .addClass('minicolors-input') |
| 180 | + .data('minicolors-initialized', false) |
| 181 | + .data('minicolors-settings', settings) |
| 182 | + .prop('size', size) |
| 183 | + .wrap(minicolors) |
| 184 | + .after( |
| 185 | + '<div class="minicolors-panel minicolors-slider-' + settings.control + '">' + |
186 | 186 | '<div class="minicolors-slider minicolors-sprite">' +
|
187 | 187 | '<div class="minicolors-picker"></div>' +
|
188 | 188 | '</div>' +
|
|
194 | 194 | '<div class="minicolors-picker"><div></div></div>' +
|
195 | 195 | '</div>' +
|
196 | 196 | '</div>'
|
197 |
| - ); |
| 197 | + ); |
198 | 198 |
|
199 | 199 | // The swatch
|
200 | 200 | if(!settings.inline) {
|
|
213 | 213 | if(settings.swatches && settings.swatches.length !== 0) {
|
214 | 214 | panel.addClass('minicolors-with-swatches');
|
215 | 215 | swatches = $('<ul class="minicolors-swatches"></ul>')
|
216 |
| - .appendTo(panel); |
| 216 | + .appendTo(panel); |
217 | 217 | for(i = 0; i < settings.swatches.length; ++i) {
|
218 | 218 | // allow for custom objects as swatches
|
219 |
| - if($.type(settings.swatches[i]) === "object") { |
| 219 | + if($.type(settings.swatches[i]) === 'object') { |
220 | 220 | name = settings.swatches[i].name;
|
221 | 221 | swatch = settings.swatches[i].color;
|
222 | 222 | } else {
|
|
225 | 225 | }
|
226 | 226 | swatch = isRgb(swatch) ? parseRgb(swatch, true) : hex2rgb(parseHex(swatch, true));
|
227 | 227 | $('<li class="minicolors-swatch minicolors-sprite"><span class="minicolors-swatch-color" title="' + name + '"></span></li>')
|
228 |
| - .appendTo(swatches) |
229 |
| - .data('swatch-color', settings.swatches[i]) |
230 |
| - .find('.minicolors-swatch-color') |
231 |
| - .css({ |
232 |
| - backgroundColor: rgb2hex(swatch), |
233 |
| - opacity: swatch.a |
234 |
| - }); |
| 228 | + .appendTo(swatches) |
| 229 | + .data('swatch-color', settings.swatches[i]) |
| 230 | + .find('.minicolors-swatch-color') |
| 231 | + .css({ |
| 232 | + backgroundColor: rgb2hex(swatch), |
| 233 | + opacity: swatch.a |
| 234 | + }); |
235 | 235 | settings.swatches[i] = swatch;
|
236 | 236 | }
|
237 | 237 | }
|
|
354 | 354 | top: y + 'px'
|
355 | 355 | };
|
356 | 356 | if(target.is('.minicolors-grid')) {
|
357 |
| - styles.left = x + 'px' |
| 357 | + styles.left = x + 'px'; |
358 | 358 | }
|
359 | 359 | if (picker.animate) {
|
360 | 360 | picker
|
361 |
| - .stop(true) |
362 |
| - .animate(styles, duration, settings.animationEasing, function() { |
363 |
| - updateFromControl(input, target); |
364 |
| - }); |
| 361 | + .stop(true) |
| 362 | + .animate(styles, duration, settings.animationEasing, function() { |
| 363 | + updateFromControl(input, target); |
| 364 | + }); |
365 | 365 | } else {
|
366 | 366 | picker
|
367 |
| - .css(styles); |
| 367 | + .css(styles); |
368 | 368 | updateFromControl(input, target);
|
369 | 369 | }
|
370 | 370 | }
|
|
831 | 831 | rgba[0] = keepWithin(parseInt(rgba[0], 10), 0, 255);
|
832 | 832 | rgba[1] = keepWithin(parseInt(rgba[1], 10), 0, 255);
|
833 | 833 | rgba[2] = keepWithin(parseInt(rgba[2], 10), 0, 255);
|
834 |
| - if(rgba[3]) { |
| 834 | + if(rgba[3] !== undefined) { |
835 | 835 | rgba[3] = keepWithin(parseFloat(rgba[3], 10), 0, 1);
|
836 | 836 | }
|
837 | 837 |
|
838 | 838 | // Return RGBA object
|
839 | 839 | if( obj ) {
|
840 |
| - if (rgba[3]) { |
| 840 | + if (rgba[3] !== undefined) { |
841 | 841 | return {
|
842 | 842 | r: rgba[0],
|
843 | 843 | g: rgba[1],
|
|
1068 | 1068 | value = settings.defaultValue;
|
1069 | 1069 | } else if(settings.format === 'rgb') {
|
1070 | 1070 | value = settings.opacity ?
|
1071 |
| - parseRgb('rgba(' + rgba.r + ',' + rgba.g + ',' + rgba.b + ',' + input.attr('data-opacity') + ')') : |
1072 |
| - parseRgb('rgb(' + rgba.r + ',' + rgba.g + ',' + rgba.b + ')'); |
| 1071 | + parseRgb('rgba(' + rgba.r + ',' + rgba.g + ',' + rgba.b + ',' + input.attr('data-opacity') + ')') : |
| 1072 | + parseRgb('rgb(' + rgba.r + ',' + rgba.g + ',' + rgba.b + ')'); |
1073 | 1073 | } else {
|
1074 | 1074 | value = rgb2hex(rgba);
|
1075 | 1075 | }
|
|
1079 | 1079 | swatchOpacity = settings.opacity ? input.attr('data-opacity') : 1;
|
1080 | 1080 | if(value.toLowerCase() === 'transparent') swatchOpacity = 0;
|
1081 | 1081 | input
|
1082 |
| - .closest('.minicolors') |
1083 |
| - .find('.minicolors-input-swatch > span') |
1084 |
| - .css('opacity', swatchOpacity); |
| 1082 | + .closest('.minicolors') |
| 1083 | + .find('.minicolors-input-swatch > span') |
| 1084 | + .css('opacity', swatchOpacity); |
1085 | 1085 |
|
1086 | 1086 | // Set input value
|
1087 | 1087 | input.val(value);
|
|
0 commit comments