jquery-minicolors-rails 2.1.1.2 → 2.1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NDcyOTk0YzJlZGE3ZTJjNTIxYTY0NDAxMWU3ZjQ0MTNkZDkzMjU0Yg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YjA2NDU1ZjkxODA2MmI1YjQ0NjZlYTgxYjM4MzY3NDczMGQ3Y2E3MQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OGMwNDI5NGZjZjk4MzQ3NmU3MTMwYzZiY2YzOWEyMzFiZGY4ZjM2ZjQ5NGUy
|
10
|
+
YjNiYTljNTM1ZGZlMWU2YjAzNTdkNjY2ZDg0NmI5OThhYjczZTIzMmM5MjFk
|
11
|
+
ZWQ5YjdiMDJmNTZmMWQyMjgzYzBkMzRmOTg1YTZhYWJjNTg3MDQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YzQyNGFjNjNmYzgwOTdjYjdmOTFhODkxMTA2OTgxN2MyNTExNzBiODAxOGI5
|
14
|
+
ZDkxNjkwODBjNTg0MTQ3NzRmZDVmZGI4ZDI2OGFiZmZmYmE1ZDQzOTJiMzBj
|
15
|
+
ZGYyNGExNzAxY2NlYzNmYWQ1MjlkMTI3NTUwYTRjNTA1ZjMzOGU=
|
@@ -7,7 +7,7 @@
|
|
7
7
|
*
|
8
8
|
*/
|
9
9
|
if(jQuery) (function($) {
|
10
|
-
|
10
|
+
|
11
11
|
// Defaults
|
12
12
|
$.minicolors = {
|
13
13
|
defaults: {
|
@@ -28,25 +28,25 @@ if(jQuery) (function($) {
|
|
28
28
|
theme: 'default'
|
29
29
|
}
|
30
30
|
};
|
31
|
-
|
31
|
+
|
32
32
|
// Public methods
|
33
33
|
$.extend($.fn, {
|
34
34
|
minicolors: function(method, data) {
|
35
|
-
|
35
|
+
|
36
36
|
switch(method) {
|
37
|
-
|
37
|
+
|
38
38
|
// Destroy the control
|
39
39
|
case 'destroy':
|
40
40
|
$(this).each( function() {
|
41
41
|
destroy($(this));
|
42
42
|
});
|
43
43
|
return $(this);
|
44
|
-
|
44
|
+
|
45
45
|
// Hide the color picker
|
46
46
|
case 'hide':
|
47
47
|
hide();
|
48
48
|
return $(this);
|
49
|
-
|
49
|
+
|
50
50
|
// Get/set opacity
|
51
51
|
case 'opacity':
|
52
52
|
// Getter
|
@@ -60,16 +60,16 @@ if(jQuery) (function($) {
|
|
60
60
|
});
|
61
61
|
}
|
62
62
|
return $(this);
|
63
|
-
|
63
|
+
|
64
64
|
// Get an RGB(A) object based on the current color/opacity
|
65
65
|
case 'rgbObject':
|
66
66
|
return rgbObject($(this), method === 'rgbaObject');
|
67
|
-
|
67
|
+
|
68
68
|
// Get an RGB(A) string based on the current color/opacity
|
69
69
|
case 'rgbString':
|
70
70
|
case 'rgbaString':
|
71
71
|
return rgbString($(this), method === 'rgbaString');
|
72
|
-
|
72
|
+
|
73
73
|
// Get/set settings on the fly
|
74
74
|
case 'settings':
|
75
75
|
if( data === undefined ) {
|
@@ -83,12 +83,12 @@ if(jQuery) (function($) {
|
|
83
83
|
});
|
84
84
|
}
|
85
85
|
return $(this);
|
86
|
-
|
86
|
+
|
87
87
|
// Show the color picker
|
88
88
|
case 'show':
|
89
89
|
show( $(this).eq(0) );
|
90
90
|
return $(this);
|
91
|
-
|
91
|
+
|
92
92
|
// Get/set the hex color value
|
93
93
|
case 'value':
|
94
94
|
if( data === undefined ) {
|
@@ -101,7 +101,7 @@ if(jQuery) (function($) {
|
|
101
101
|
});
|
102
102
|
}
|
103
103
|
return $(this);
|
104
|
-
|
104
|
+
|
105
105
|
// Initializes the control
|
106
106
|
default:
|
107
107
|
if( method !== 'create' ) data = method;
|
@@ -109,36 +109,36 @@ if(jQuery) (function($) {
|
|
109
109
|
init($(this), data);
|
110
110
|
});
|
111
111
|
return $(this);
|
112
|
-
|
112
|
+
|
113
113
|
}
|
114
|
-
|
114
|
+
|
115
115
|
}
|
116
116
|
});
|
117
|
-
|
117
|
+
|
118
118
|
// Initialize input elements
|
119
119
|
function init(input, settings) {
|
120
|
-
|
120
|
+
|
121
121
|
var minicolors = $('<div class="minicolors" />'),
|
122
122
|
defaults = $.minicolors.defaults;
|
123
|
-
|
123
|
+
|
124
124
|
// Do nothing if already initialized
|
125
125
|
if( input.data('minicolors-initialized') ) return;
|
126
|
-
|
126
|
+
|
127
127
|
// Handle settings
|
128
128
|
settings = $.extend(true, {}, defaults, settings);
|
129
|
-
|
129
|
+
|
130
130
|
// The wrapper
|
131
131
|
minicolors
|
132
132
|
.addClass('minicolors-theme-' + settings.theme)
|
133
133
|
.toggleClass('minicolors-with-opacity', settings.opacity);
|
134
|
-
|
134
|
+
|
135
135
|
// Custom positioning
|
136
136
|
if( settings.position !== undefined ) {
|
137
137
|
$.each(settings.position.split(' '), function() {
|
138
138
|
minicolors.addClass('minicolors-position-' + this);
|
139
139
|
});
|
140
140
|
}
|
141
|
-
|
141
|
+
|
142
142
|
// The input
|
143
143
|
input
|
144
144
|
.addClass('minicolors-input')
|
@@ -147,11 +147,11 @@ if(jQuery) (function($) {
|
|
147
147
|
.prop('size', 7)
|
148
148
|
.wrap(minicolors)
|
149
149
|
.after(
|
150
|
-
'<div class="minicolors-panel minicolors-slider-' + settings.control + '">' +
|
151
|
-
'<div class="minicolors-slider">' +
|
150
|
+
'<div class="minicolors-panel minicolors-slider-' + settings.control + '">' +
|
151
|
+
'<div class="minicolors-slider">' +
|
152
152
|
'<div class="minicolors-picker"></div>' +
|
153
|
-
'</div>' +
|
154
|
-
'<div class="minicolors-opacity-slider">' +
|
153
|
+
'</div>' +
|
154
|
+
'<div class="minicolors-opacity-slider">' +
|
155
155
|
'<div class="minicolors-picker"></div>' +
|
156
156
|
'</div>' +
|
157
157
|
'<div class="minicolors-grid">' +
|
@@ -160,7 +160,7 @@ if(jQuery) (function($) {
|
|
160
160
|
'</div>' +
|
161
161
|
'</div>'
|
162
162
|
);
|
163
|
-
|
163
|
+
|
164
164
|
// The swatch
|
165
165
|
if( !settings.inline ) {
|
166
166
|
input.after('<span class="minicolors-swatch"><span class="minicolors-swatch-color"></span></span>');
|
@@ -169,86 +169,82 @@ if(jQuery) (function($) {
|
|
169
169
|
input.focus();
|
170
170
|
});
|
171
171
|
}
|
172
|
-
|
172
|
+
|
173
173
|
// Prevent text selection in IE
|
174
174
|
input.parent().find('.minicolors-panel').on('selectstart', function() { return false; }).end();
|
175
|
-
|
175
|
+
|
176
176
|
// Inline controls
|
177
177
|
if( settings.inline ) input.parent().addClass('minicolors-inline');
|
178
|
-
|
178
|
+
|
179
179
|
updateFromInput(input, false);
|
180
|
-
|
180
|
+
|
181
181
|
input.data('minicolors-initialized', true);
|
182
|
-
|
182
|
+
|
183
183
|
}
|
184
|
-
|
184
|
+
|
185
185
|
// Returns the input back to its original state
|
186
186
|
function destroy(input) {
|
187
|
-
|
187
|
+
|
188
188
|
var minicolors = input.parent();
|
189
|
-
|
189
|
+
|
190
190
|
// Revert the input element
|
191
191
|
input
|
192
192
|
.removeData('minicolors-initialized')
|
193
193
|
.removeData('minicolors-settings')
|
194
194
|
.removeProp('size')
|
195
195
|
.removeClass('minicolors-input');
|
196
|
-
|
196
|
+
|
197
197
|
// Remove the wrap and destroy whatever remains
|
198
198
|
minicolors.before(input).remove();
|
199
|
-
|
199
|
+
|
200
200
|
}
|
201
|
-
|
201
|
+
|
202
202
|
// Shows the specified dropdown panel
|
203
203
|
function show(input) {
|
204
|
-
|
204
|
+
|
205
205
|
var minicolors = input.parent(),
|
206
206
|
panel = minicolors.find('.minicolors-panel'),
|
207
207
|
settings = input.data('minicolors-settings');
|
208
|
-
|
208
|
+
|
209
209
|
// Do nothing if uninitialized, disabled, inline, or already open
|
210
|
-
if( !input.data('minicolors-initialized') ||
|
211
|
-
input.prop('disabled') ||
|
212
|
-
minicolors.hasClass('minicolors-inline') ||
|
210
|
+
if( !input.data('minicolors-initialized') ||
|
211
|
+
input.prop('disabled') ||
|
212
|
+
minicolors.hasClass('minicolors-inline') ||
|
213
213
|
minicolors.hasClass('minicolors-focus')
|
214
214
|
) return;
|
215
|
-
|
215
|
+
|
216
216
|
hide();
|
217
|
-
|
217
|
+
|
218
218
|
minicolors.addClass('minicolors-focus');
|
219
219
|
panel
|
220
220
|
.stop(true, true)
|
221
221
|
.fadeIn(settings.showSpeed, function() {
|
222
222
|
if( settings.show ) settings.show.call(input.get(0));
|
223
223
|
});
|
224
|
-
|
224
|
+
|
225
225
|
}
|
226
|
-
|
226
|
+
|
227
227
|
// Hides all dropdown panels
|
228
228
|
function hide() {
|
229
|
-
|
230
|
-
$('.minicolors-
|
231
|
-
|
232
|
-
var
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
minicolors.find('.minicolors-panel').fadeOut(settings.hideSpeed, function() {
|
240
|
-
if(minicolors.hasClass('minicolors-focus')) {
|
241
|
-
if( settings.hide ) settings.hide.call(input.get(0));
|
242
|
-
}
|
229
|
+
|
230
|
+
$('.minicolors-focus').each( function() {
|
231
|
+
|
232
|
+
var minicolors = $(this),
|
233
|
+
input = minicolors.find('.minicolors-input'),
|
234
|
+
panel = minicolors.find('.minicolors-panel'),
|
235
|
+
settings = input.data('minicolors-settings');
|
236
|
+
|
237
|
+
panel.fadeOut(settings.hideSpeed, function() {
|
238
|
+
if( settings.hide ) settings.hide.call(input.get(0));
|
243
239
|
minicolors.removeClass('minicolors-focus');
|
244
|
-
});
|
245
|
-
|
240
|
+
});
|
241
|
+
|
246
242
|
});
|
247
243
|
}
|
248
|
-
|
244
|
+
|
249
245
|
// Moves the selected picker
|
250
246
|
function move(target, event, animate) {
|
251
|
-
|
247
|
+
|
252
248
|
var input = target.parents('.minicolors').find('.minicolors-input'),
|
253
249
|
settings = input.data('minicolors-settings'),
|
254
250
|
picker = target.find('[class$=-picker]'),
|
@@ -258,20 +254,19 @@ if(jQuery) (function($) {
|
|
258
254
|
y = Math.round(event.pageY - offsetY),
|
259
255
|
duration = animate ? settings.animationSpeed : 0,
|
260
256
|
wx, wy, r, phi;
|
261
|
-
|
262
|
-
|
257
|
+
|
263
258
|
// Touch support
|
264
259
|
if( event.originalEvent.changedTouches ) {
|
265
260
|
x = event.originalEvent.changedTouches[0].pageX - offsetX;
|
266
261
|
y = event.originalEvent.changedTouches[0].pageY - offsetY;
|
267
262
|
}
|
268
|
-
|
263
|
+
|
269
264
|
// Constrain picker to its container
|
270
265
|
if( x < 0 ) x = 0;
|
271
266
|
if( y < 0 ) y = 0;
|
272
267
|
if( x > target.width() ) x = target.width();
|
273
268
|
if( y > target.height() ) y = target.height();
|
274
|
-
|
269
|
+
|
275
270
|
// Constrain color wheel values to the wheel
|
276
271
|
if( target.parent().is('.minicolors-slider-wheel') && picker.parent().is('.minicolors-grid') ) {
|
277
272
|
wx = 75 - x;
|
@@ -287,7 +282,7 @@ if(jQuery) (function($) {
|
|
287
282
|
x = Math.round(x);
|
288
283
|
y = Math.round(y);
|
289
284
|
}
|
290
|
-
|
285
|
+
|
291
286
|
// Move the picker
|
292
287
|
if( target.is('.minicolors-grid') ) {
|
293
288
|
picker
|
@@ -307,57 +302,57 @@ if(jQuery) (function($) {
|
|
307
302
|
updateFromControl(input, target);
|
308
303
|
});
|
309
304
|
}
|
310
|
-
|
305
|
+
|
311
306
|
}
|
312
|
-
|
307
|
+
|
313
308
|
// Sets the input based on the color picker values
|
314
309
|
function updateFromControl(input, target) {
|
315
|
-
|
310
|
+
|
316
311
|
function getCoords(picker, container) {
|
317
|
-
|
312
|
+
|
318
313
|
var left, top;
|
319
314
|
if( !picker.length || !container ) return null;
|
320
315
|
left = picker.offset().left;
|
321
316
|
top = picker.offset().top;
|
322
|
-
|
317
|
+
|
323
318
|
return {
|
324
319
|
x: left - container.offset().left + (picker.outerWidth() / 2),
|
325
320
|
y: top - container.offset().top + (picker.outerHeight() / 2)
|
326
321
|
};
|
327
|
-
|
322
|
+
|
328
323
|
}
|
329
|
-
|
324
|
+
|
330
325
|
var hue, saturation, brightness, x, y, r, phi,
|
331
|
-
|
326
|
+
|
332
327
|
hex = input.val(),
|
333
328
|
opacity = input.attr('data-opacity'),
|
334
|
-
|
329
|
+
|
335
330
|
// Helpful references
|
336
331
|
minicolors = input.parent(),
|
337
332
|
settings = input.data('minicolors-settings'),
|
338
333
|
swatch = minicolors.find('.minicolors-swatch'),
|
339
|
-
|
334
|
+
|
340
335
|
// Panel objects
|
341
336
|
grid = minicolors.find('.minicolors-grid'),
|
342
337
|
slider = minicolors.find('.minicolors-slider'),
|
343
338
|
opacitySlider = minicolors.find('.minicolors-opacity-slider'),
|
344
|
-
|
339
|
+
|
345
340
|
// Picker objects
|
346
341
|
gridPicker = grid.find('[class$=-picker]'),
|
347
342
|
sliderPicker = slider.find('[class$=-picker]'),
|
348
343
|
opacityPicker = opacitySlider.find('[class$=-picker]'),
|
349
|
-
|
344
|
+
|
350
345
|
// Picker positions
|
351
346
|
gridPos = getCoords(gridPicker, grid),
|
352
347
|
sliderPos = getCoords(sliderPicker, slider),
|
353
348
|
opacityPos = getCoords(opacityPicker, opacitySlider);
|
354
|
-
|
349
|
+
|
355
350
|
// Handle colors
|
356
351
|
if( target.is('.minicolors-grid, .minicolors-slider') ) {
|
357
|
-
|
352
|
+
|
358
353
|
// Determine HSB values
|
359
354
|
switch(settings.control) {
|
360
|
-
|
355
|
+
|
361
356
|
case 'wheel':
|
362
357
|
// Calculate hue, saturation, and brightness
|
363
358
|
x = (grid.width() / 2) - gridPos.x;
|
@@ -378,11 +373,11 @@ if(jQuery) (function($) {
|
|
378
373
|
s: saturation,
|
379
374
|
b: brightness
|
380
375
|
});
|
381
|
-
|
376
|
+
|
382
377
|
// Update UI
|
383
378
|
slider.css('backgroundColor', hsb2hex({ h: hue, s: saturation, b: 100 }));
|
384
379
|
break;
|
385
|
-
|
380
|
+
|
386
381
|
case 'saturation':
|
387
382
|
// Calculate hue, saturation, and brightness
|
388
383
|
hue = keepWithin(parseInt(gridPos.x * (360 / grid.width()), 10), 0, 360);
|
@@ -393,12 +388,12 @@ if(jQuery) (function($) {
|
|
393
388
|
s: saturation,
|
394
389
|
b: brightness
|
395
390
|
});
|
396
|
-
|
391
|
+
|
397
392
|
// Update UI
|
398
393
|
slider.css('backgroundColor', hsb2hex({ h: hue, s: 100, b: brightness }));
|
399
394
|
minicolors.find('.minicolors-grid-inner').css('opacity', saturation / 100);
|
400
395
|
break;
|
401
|
-
|
396
|
+
|
402
397
|
case 'brightness':
|
403
398
|
// Calculate hue, saturation, and brightness
|
404
399
|
hue = keepWithin(parseInt(gridPos.x * (360 / grid.width()), 10), 0, 360);
|
@@ -409,12 +404,12 @@ if(jQuery) (function($) {
|
|
409
404
|
s: saturation,
|
410
405
|
b: brightness
|
411
406
|
});
|
412
|
-
|
407
|
+
|
413
408
|
// Update UI
|
414
409
|
slider.css('backgroundColor', hsb2hex({ h: hue, s: saturation, b: 100 }));
|
415
410
|
minicolors.find('.minicolors-grid-inner').css('opacity', 1 - (brightness / 100));
|
416
411
|
break;
|
417
|
-
|
412
|
+
|
418
413
|
default:
|
419
414
|
// Calculate hue, saturation, and brightness
|
420
415
|
hue = keepWithin(360 - parseInt(sliderPos.y * (360 / slider.height()), 10), 0, 360);
|
@@ -425,18 +420,18 @@ if(jQuery) (function($) {
|
|
425
420
|
s: saturation,
|
426
421
|
b: brightness
|
427
422
|
});
|
428
|
-
|
423
|
+
|
429
424
|
// Update UI
|
430
425
|
grid.css('backgroundColor', hsb2hex({ h: hue, s: 100, b: 100 }));
|
431
426
|
break;
|
432
|
-
|
427
|
+
|
433
428
|
}
|
434
|
-
|
429
|
+
|
435
430
|
// Adjust case
|
436
431
|
input.val( convertCase(hex, settings.letterCase) );
|
437
|
-
|
432
|
+
|
438
433
|
}
|
439
|
-
|
434
|
+
|
440
435
|
// Handle opacity
|
441
436
|
if( target.is('.minicolors-opacity-slider') ) {
|
442
437
|
if( settings.opacity ) {
|
@@ -446,51 +441,51 @@ if(jQuery) (function($) {
|
|
446
441
|
}
|
447
442
|
if( settings.opacity ) input.attr('data-opacity', opacity);
|
448
443
|
}
|
449
|
-
|
444
|
+
|
450
445
|
// Set swatch color
|
451
446
|
swatch.find('SPAN').css({
|
452
447
|
backgroundColor: hex,
|
453
448
|
opacity: opacity
|
454
449
|
});
|
455
|
-
|
450
|
+
|
456
451
|
// Handle change event
|
457
452
|
doChange(input, hex, opacity);
|
458
|
-
|
453
|
+
|
459
454
|
}
|
460
|
-
|
455
|
+
|
461
456
|
// Sets the color picker values from the input
|
462
457
|
function updateFromInput(input, preserveInputValue) {
|
463
|
-
|
458
|
+
|
464
459
|
var hex,
|
465
460
|
hsb,
|
466
461
|
opacity,
|
467
462
|
x, y, r, phi,
|
468
|
-
|
463
|
+
|
469
464
|
// Helpful references
|
470
465
|
minicolors = input.parent(),
|
471
466
|
settings = input.data('minicolors-settings'),
|
472
467
|
swatch = minicolors.find('.minicolors-swatch'),
|
473
|
-
|
468
|
+
|
474
469
|
// Panel objects
|
475
470
|
grid = minicolors.find('.minicolors-grid'),
|
476
471
|
slider = minicolors.find('.minicolors-slider'),
|
477
472
|
opacitySlider = minicolors.find('.minicolors-opacity-slider'),
|
478
|
-
|
473
|
+
|
479
474
|
// Picker objects
|
480
475
|
gridPicker = grid.find('[class$=-picker]'),
|
481
476
|
sliderPicker = slider.find('[class$=-picker]'),
|
482
477
|
opacityPicker = opacitySlider.find('[class$=-picker]');
|
483
|
-
|
478
|
+
|
484
479
|
// Determine hex/HSB values
|
485
480
|
hex = convertCase(parseHex(input.val(), true), settings.letterCase);
|
486
481
|
if( !hex ){
|
487
482
|
hex = convertCase(parseHex(settings.defaultValue, true), settings.letterCase);
|
488
483
|
}
|
489
484
|
hsb = hex2hsb(hex);
|
490
|
-
|
485
|
+
|
491
486
|
// Update input value
|
492
487
|
if( !preserveInputValue ) input.val(hex);
|
493
|
-
|
488
|
+
|
494
489
|
// Determine opacity value
|
495
490
|
if( settings.opacity ) {
|
496
491
|
// Get from data-opacity attribute and keep within 0-1 range
|
@@ -498,18 +493,18 @@ if(jQuery) (function($) {
|
|
498
493
|
if( isNaN(opacity) ) opacity = 1;
|
499
494
|
input.attr('data-opacity', opacity);
|
500
495
|
swatch.find('SPAN').css('opacity', opacity);
|
501
|
-
|
496
|
+
|
502
497
|
// Set opacity picker position
|
503
498
|
y = keepWithin(opacitySlider.height() - (opacitySlider.height() * opacity), 0, opacitySlider.height());
|
504
499
|
opacityPicker.css('top', y + 'px');
|
505
500
|
}
|
506
|
-
|
501
|
+
|
507
502
|
// Update swatch
|
508
503
|
swatch.find('SPAN').css('backgroundColor', hex);
|
509
|
-
|
504
|
+
|
510
505
|
// Determine picker locations
|
511
506
|
switch(settings.control) {
|
512
|
-
|
507
|
+
|
513
508
|
case 'wheel':
|
514
509
|
// Set grid position
|
515
510
|
r = keepWithin(Math.ceil(hsb.s * 0.75), 0, grid.height() / 2);
|
@@ -520,16 +515,16 @@ if(jQuery) (function($) {
|
|
520
515
|
top: y + 'px',
|
521
516
|
left: x + 'px'
|
522
517
|
});
|
523
|
-
|
518
|
+
|
524
519
|
// Set slider position
|
525
520
|
y = 150 - (hsb.b / (100 / grid.height()));
|
526
521
|
if( hex === '' ) y = 0;
|
527
522
|
sliderPicker.css('top', y + 'px');
|
528
|
-
|
523
|
+
|
529
524
|
// Update panel color
|
530
525
|
slider.css('backgroundColor', hsb2hex({ h: hsb.h, s: hsb.s, b: 100 }));
|
531
526
|
break;
|
532
|
-
|
527
|
+
|
533
528
|
case 'saturation':
|
534
529
|
// Set grid position
|
535
530
|
x = keepWithin((5 * hsb.h) / 12, 0, 150);
|
@@ -537,17 +532,17 @@ if(jQuery) (function($) {
|
|
537
532
|
gridPicker.css({
|
538
533
|
top: y + 'px',
|
539
534
|
left: x + 'px'
|
540
|
-
});
|
541
|
-
|
535
|
+
});
|
536
|
+
|
542
537
|
// Set slider position
|
543
538
|
y = keepWithin(slider.height() - (hsb.s * (slider.height() / 100)), 0, slider.height());
|
544
539
|
sliderPicker.css('top', y + 'px');
|
545
|
-
|
540
|
+
|
546
541
|
// Update UI
|
547
542
|
slider.css('backgroundColor', hsb2hex({ h: hsb.h, s: 100, b: hsb.b }));
|
548
543
|
minicolors.find('.minicolors-grid-inner').css('opacity', hsb.s / 100);
|
549
544
|
break;
|
550
|
-
|
545
|
+
|
551
546
|
case 'brightness':
|
552
547
|
// Set grid position
|
553
548
|
x = keepWithin((5 * hsb.h) / 12, 0, 150);
|
@@ -555,17 +550,17 @@ if(jQuery) (function($) {
|
|
555
550
|
gridPicker.css({
|
556
551
|
top: y + 'px',
|
557
552
|
left: x + 'px'
|
558
|
-
});
|
559
|
-
|
553
|
+
});
|
554
|
+
|
560
555
|
// Set slider position
|
561
556
|
y = keepWithin(slider.height() - (hsb.b * (slider.height() / 100)), 0, slider.height());
|
562
557
|
sliderPicker.css('top', y + 'px');
|
563
|
-
|
558
|
+
|
564
559
|
// Update UI
|
565
560
|
slider.css('backgroundColor', hsb2hex({ h: hsb.h, s: hsb.s, b: 100 }));
|
566
561
|
minicolors.find('.minicolors-grid-inner').css('opacity', 1 - (hsb.b / 100));
|
567
562
|
break;
|
568
|
-
|
563
|
+
|
569
564
|
default:
|
570
565
|
// Set grid position
|
571
566
|
x = keepWithin(Math.ceil(hsb.s / (100 / grid.width())), 0, grid.width());
|
@@ -574,39 +569,39 @@ if(jQuery) (function($) {
|
|
574
569
|
top: y + 'px',
|
575
570
|
left: x + 'px'
|
576
571
|
});
|
577
|
-
|
572
|
+
|
578
573
|
// Set slider position
|
579
574
|
y = keepWithin(slider.height() - (hsb.h / (360 / slider.height())), 0, slider.height());
|
580
575
|
sliderPicker.css('top', y + 'px');
|
581
|
-
|
576
|
+
|
582
577
|
// Update panel color
|
583
578
|
grid.css('backgroundColor', hsb2hex({ h: hsb.h, s: 100, b: 100 }));
|
584
579
|
break;
|
585
|
-
|
580
|
+
|
586
581
|
}
|
587
|
-
|
582
|
+
|
588
583
|
// Fire change event, but only if minicolors is fully initialized
|
589
584
|
if( input.data('minicolors-initialized') ) {
|
590
585
|
doChange(input, hex, opacity);
|
591
586
|
}
|
592
|
-
|
587
|
+
|
593
588
|
}
|
594
|
-
|
589
|
+
|
595
590
|
// Runs the change and changeDelay callbacks
|
596
591
|
function doChange(input, hex, opacity) {
|
597
|
-
|
592
|
+
|
598
593
|
var settings = input.data('minicolors-settings'),
|
599
594
|
lastChange = input.data('minicolors-lastChange');
|
600
|
-
|
595
|
+
|
601
596
|
// Only run if it actually changed
|
602
597
|
if( !lastChange || lastChange.hex !== hex || lastChange.opacity !== opacity ) {
|
603
|
-
|
598
|
+
|
604
599
|
// Remember last-changed value
|
605
600
|
input.data('minicolors-lastChange', {
|
606
601
|
hex: hex,
|
607
602
|
opacity: opacity
|
608
603
|
});
|
609
|
-
|
604
|
+
|
610
605
|
// Fire change event
|
611
606
|
if( settings.change ) {
|
612
607
|
if( settings.changeDelay ) {
|
@@ -622,9 +617,9 @@ if(jQuery) (function($) {
|
|
622
617
|
}
|
623
618
|
input.trigger('change').trigger('input');
|
624
619
|
}
|
625
|
-
|
620
|
+
|
626
621
|
}
|
627
|
-
|
622
|
+
|
628
623
|
// Generates an RGB(A) object based on the input's value
|
629
624
|
function rgbObject(input) {
|
630
625
|
var hex = parseHex($(input).val(), true),
|
@@ -634,7 +629,7 @@ if(jQuery) (function($) {
|
|
634
629
|
if( opacity !== undefined ) $.extend(rgb, { a: parseFloat(opacity) });
|
635
630
|
return rgb;
|
636
631
|
}
|
637
|
-
|
632
|
+
|
638
633
|
// Genearates an RGB(A) string based on the input's value
|
639
634
|
function rgbString(input, alpha) {
|
640
635
|
var hex = parseHex($(input).val(), true),
|
@@ -648,12 +643,12 @@ if(jQuery) (function($) {
|
|
648
643
|
return 'rgb(' + rgb.r + ', ' + rgb.g + ', ' + rgb.b + ')';
|
649
644
|
}
|
650
645
|
}
|
651
|
-
|
646
|
+
|
652
647
|
// Converts to the letter case specified in settings
|
653
648
|
function convertCase(string, letterCase) {
|
654
649
|
return letterCase === 'uppercase' ? string.toUpperCase() : string.toLowerCase();
|
655
650
|
}
|
656
|
-
|
651
|
+
|
657
652
|
// Parses a string and returns a valid hex string when possible
|
658
653
|
function parseHex(string, expand) {
|
659
654
|
string = string.replace(/[^A-F0-9]/ig, '');
|
@@ -663,14 +658,14 @@ if(jQuery) (function($) {
|
|
663
658
|
}
|
664
659
|
return '#' + string;
|
665
660
|
}
|
666
|
-
|
661
|
+
|
667
662
|
// Keeps value within min and max
|
668
663
|
function keepWithin(value, min, max) {
|
669
664
|
if( value < min ) value = min;
|
670
665
|
if( value > max ) value = max;
|
671
666
|
return value;
|
672
667
|
}
|
673
|
-
|
668
|
+
|
674
669
|
// Converts an HSB object to an RGB object
|
675
670
|
function hsb2rgb(hsb) {
|
676
671
|
var rgb = {};
|
@@ -698,7 +693,7 @@ if(jQuery) (function($) {
|
|
698
693
|
b: Math.round(rgb.b)
|
699
694
|
};
|
700
695
|
}
|
701
|
-
|
696
|
+
|
702
697
|
// Converts an RGB object to a hex string
|
703
698
|
function rgb2hex(rgb) {
|
704
699
|
var hex = [
|
@@ -711,19 +706,19 @@ if(jQuery) (function($) {
|
|
711
706
|
});
|
712
707
|
return '#' + hex.join('');
|
713
708
|
}
|
714
|
-
|
709
|
+
|
715
710
|
// Converts an HSB object to a hex string
|
716
711
|
function hsb2hex(hsb) {
|
717
712
|
return rgb2hex(hsb2rgb(hsb));
|
718
713
|
}
|
719
|
-
|
714
|
+
|
720
715
|
// Converts a hex string to an HSB object
|
721
716
|
function hex2hsb(hex) {
|
722
717
|
var hsb = rgb2hsb(hex2rgb(hex));
|
723
718
|
if( hsb.s === 0 ) hsb.h = 360;
|
724
719
|
return hsb;
|
725
720
|
}
|
726
|
-
|
721
|
+
|
727
722
|
// Converts an RGB object to an HSB object
|
728
723
|
function rgb2hsb(rgb) {
|
729
724
|
var hsb = { h: 0, s: 0, b: 0 };
|
@@ -751,7 +746,7 @@ if(jQuery) (function($) {
|
|
751
746
|
hsb.b *= 100/255;
|
752
747
|
return hsb;
|
753
748
|
}
|
754
|
-
|
749
|
+
|
755
750
|
// Converts a hex string to an RGB object
|
756
751
|
function hex2rgb(hex) {
|
757
752
|
hex = parseInt(((hex.indexOf('#') > -1) ? hex.substring(1) : hex), 16);
|
@@ -761,7 +756,7 @@ if(jQuery) (function($) {
|
|
761
756
|
b: (hex & 0x0000FF)
|
762
757
|
};
|
763
758
|
}
|
764
|
-
|
759
|
+
|
765
760
|
// Handle events
|
766
761
|
$(document)
|
767
762
|
// Hide on clicks outside of the control
|
@@ -803,16 +798,16 @@ if(jQuery) (function($) {
|
|
803
798
|
var input = $(this),
|
804
799
|
settings = input.data('minicolors-settings');
|
805
800
|
if( !input.data('minicolors-initialized') ) return;
|
806
|
-
|
801
|
+
|
807
802
|
// Parse Hex
|
808
803
|
input.val(parseHex(input.val(), true));
|
809
|
-
|
804
|
+
|
810
805
|
// Is it blank?
|
811
806
|
if( input.val() === '' ) input.val(parseHex(settings.defaultValue, true));
|
812
|
-
|
807
|
+
|
813
808
|
// Adjust case
|
814
809
|
input.val( convertCase(input.val(), settings.letterCase) );
|
815
|
-
|
810
|
+
|
816
811
|
})
|
817
812
|
// Handle keypresses
|
818
813
|
.on('keydown.minicolors', '.minicolors-input', function(event) {
|
@@ -843,5 +838,5 @@ if(jQuery) (function($) {
|
|
843
838
|
updateFromInput(input, true);
|
844
839
|
}, 1);
|
845
840
|
});
|
846
|
-
|
841
|
+
|
847
842
|
})(jQuery);
|
@@ -266,6 +266,9 @@
|
|
266
266
|
height: 28px;
|
267
267
|
border-radius: 3px;
|
268
268
|
}
|
269
|
+
.minicolors-theme-bootstrap .minicolors-swatch-color {
|
270
|
+
border-radius: inherit;
|
271
|
+
}
|
269
272
|
.minicolors-theme-bootstrap.minicolors-position-right .minicolors-swatch {
|
270
273
|
left: auto;
|
271
274
|
right: 3px;
|
@@ -277,3 +280,14 @@
|
|
277
280
|
padding-right: 44px;
|
278
281
|
padding-left: 12px;
|
279
282
|
}
|
283
|
+
.minicolors-theme-bootstrap .minicolors-input.input-lg + .minicolors-swatch {
|
284
|
+
top: 4px;
|
285
|
+
left: 4px;
|
286
|
+
width: 37px;
|
287
|
+
height: 37px;
|
288
|
+
border-radius: 5px;
|
289
|
+
}
|
290
|
+
.minicolors-theme-bootstrap .minicolors-input.input-sm + .minicolors-swatch {
|
291
|
+
width: 24px;
|
292
|
+
height: 24px;
|
293
|
+
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jquery-minicolors-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kostiantyn Kahanskyi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|