Skip to content

Commit ef29f30

Browse files
committed
spectrum 1.7.0
1 parent 6602e89 commit ef29f30

File tree

9 files changed

+54
-24
lines changed

9 files changed

+54
-24
lines changed

_InstallPackages/spectrum_1.6.0.zip

-22.6 KB
Binary file not shown.

_InstallPackages/spectrum_1.7.0.zip

22.8 KB
Binary file not shown.

spectrum_1.6.0/CHANGES.htm

Lines changed: 0 additions & 1 deletion
This file was deleted.

spectrum_1.6.0/LICENSE.htm

Lines changed: 0 additions & 1 deletion
This file was deleted.

spectrum_1.7.0/CHANGES.htm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<p>You can review <a href="https://github.com/bgrins/spectrum/compare/1.6.2...1.7.0">all changes between 1.6.2 and 1.7.0</a></p>

spectrum_1.7.0/LICENSE.htm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<p>spectrum is licened under the <a href="https://github.com/bgrins/spectrum/1.7.0/LICENSE">MIT License</a>.</p>

spectrum_1.6.0/spectrum.css renamed to spectrum_1.7.0/spectrum.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/***
2-
Spectrum Colorpicker v1.6.0
2+
Spectrum Colorpicker v1.7.0
33
https://github.com/bgrins/spectrum
44
Author: Brian Grinstead
55
License: MIT

spectrum_1.6.0/spectrum.dnn renamed to spectrum_1.7.0/spectrum.dnn

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<dotnetnuke type="Package" version="5.0">
22
<packages>
3-
<package name="spectrum" type="JavaScript_Library" version="1.6.0">
3+
<package name="spectrum" type="JavaScript_Library" version="1.7.0">
44
<friendlyName>spectrum</friendlyName>
55
<description>The No Hassle JavaScript Colorpicker</description>
66
<owner>
@@ -21,7 +21,7 @@
2121
<libraryName>spectrum</libraryName>
2222
<fileName>spectrum.js</fileName>
2323
<preferredScriptLocation>BodyBottom</preferredScriptLocation>
24-
<CDNPath>https://cdnjs.cloudflare.com/ajax/libs/spectrum/1.6.0/spectrum.min.js</CDNPath>
24+
<CDNPath>https://cdnjs.cloudflare.com/ajax/libs/spectrum/1.7.0/spectrum.min.js</CDNPath>
2525
<objectName>jQuery.fn.spectrum</objectName>
2626
</javaScriptLibrary>
2727
</component>

spectrum_1.6.0/spectrum.js renamed to spectrum_1.7.0/spectrum.js

Lines changed: 49 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Spectrum Colorpicker v1.6.0
1+
// Spectrum Colorpicker v1.7.0
22
// https://github.com/bgrins/spectrum
33
// Author: Brian Grinstead
44
// License: MIT
@@ -33,7 +33,7 @@
3333
showInput: false,
3434
allowEmpty: false,
3535
showButtons: true,
36-
clickoutFiresChange: false,
36+
clickoutFiresChange: true,
3737
showInitial: false,
3838
showPalette: false,
3939
showPaletteOnly: false,
@@ -72,10 +72,6 @@
7272
style.cssText = 'background-color:rgba(0,0,0,.5)';
7373
return contains(style.backgroundColor, 'rgba') || contains(style.backgroundColor, 'hsla');
7474
})(),
75-
inputTypeColorSupport = (function() {
76-
var colorInput = $("<input type='color' value='!' />")[0];
77-
return colorInput.type === "color" && colorInput.value !== "!";
78-
})(),
7975
replaceInput = [
8076
"<div class='sp-replacer'>",
8177
"<div class='sp-preview'><div class='sp-preview-inner'></div></div>",
@@ -189,6 +185,7 @@
189185
callbacks = opts.callbacks,
190186
resize = throttle(reflow, 10),
191187
visible = false,
188+
isDragging = false,
192189
dragWidth = 0,
193190
dragHeight = 0,
194191
dragHelperHeight = 0,
@@ -230,7 +227,7 @@
230227
chooseButton = container.find(".sp-choose"),
231228
toggleButton = container.find(".sp-palette-toggle"),
232229
isInput = boundElement.is("input"),
233-
isInputTypeColor = isInput && inputTypeColorSupport && boundElement.attr("type") === "color",
230+
isInputTypeColor = isInput && boundElement.attr("type") === "color" && inputTypeColorSupport(),
234231
shouldReplace = isInput && !flat,
235232
replacer = (shouldReplace) ? $(replaceInput).addClass(theme).addClass(opts.className).addClass(opts.replacerClassName) : $([]),
236233
offsetElement = (shouldReplace) ? replacer : boundElement,
@@ -360,6 +357,10 @@
360357
e.stopPropagation();
361358
e.preventDefault();
362359

360+
if (IE && textInput.is(":focus")) {
361+
textInput.trigger('change');
362+
}
363+
363364
if (isValid()) {
364365
updateOriginalInput(true);
365366
hide();
@@ -562,12 +563,14 @@
562563
if (dragHeight <= 0 || dragWidth <= 0 || slideHeight <= 0) {
563564
reflow();
564565
}
566+
isDragging = true;
565567
container.addClass(draggingClass);
566568
shiftMovementDirection = null;
567569
boundElement.trigger('dragstart.spectrum', [ get() ]);
568570
}
569571

570572
function dragStop() {
573+
isDragging = false;
571574
container.removeClass(draggingClass);
572575
boundElement.trigger('dragstop.spectrum', [ get() ]);
573576
}
@@ -618,6 +621,7 @@
618621
hideAll();
619622
visible = true;
620623

624+
$(doc).bind("keydown.spectrum", onkeydown);
621625
$(doc).bind("click.spectrum", clickout);
622626
$(window).bind("resize.spectrum", resize);
623627
replacer.addClass("sp-active");
@@ -633,10 +637,21 @@
633637
boundElement.trigger('show.spectrum', [ colorOnShow ]);
634638
}
635639

640+
function onkeydown(e) {
641+
// Close on ESC
642+
if (e.keyCode === 27) {
643+
hide();
644+
}
645+
}
646+
636647
function clickout(e) {
637648
// Return on right click.
638649
if (e.button == 2) { return; }
639650

651+
// If a drag event was happening during the mouseup, don't hide
652+
// on click.
653+
if (isDragging) { return; }
654+
640655
if (clickoutFiresChange) {
641656
updateOriginalInput(true);
642657
}
@@ -651,6 +666,7 @@
651666
if (!visible || flat) { return; }
652667
visible = false;
653668

669+
$(doc).unbind("keydown.spectrum", onkeydown);
654670
$(doc).unbind("click.spectrum", clickout);
655671
$(window).unbind("resize.spectrum", resize);
656672

@@ -1043,9 +1059,9 @@
10431059
return stop();
10441060
}
10451061

1046-
var touches = e.originalEvent && e.originalEvent.touches;
1047-
var pageX = touches ? touches[0].pageX : e.pageX;
1048-
var pageY = touches ? touches[0].pageY : e.pageY;
1062+
var t0 = e.originalEvent && e.originalEvent.touches && e.originalEvent.touches[0];
1063+
var pageX = t0 && t0.pageX || e.pageX;
1064+
var pageY = t0 && t0.pageY || e.pageY;
10491065

10501066
var dragX = Math.max(0, Math.min(pageX - offset.left, maxWidth));
10511067
var dragY = Math.max(0, Math.min(pageY - offset.top, maxHeight));
@@ -1072,9 +1088,7 @@
10721088
$(doc).bind(duringDragEvents);
10731089
$(doc.body).addClass("sp-dragging");
10741090

1075-
if (!hasTouch) {
1076-
move(e);
1077-
}
1091+
move(e);
10781092

10791093
prevent(e);
10801094
}
@@ -1085,7 +1099,12 @@
10851099
if (dragging) {
10861100
$(doc).unbind(duringDragEvents);
10871101
$(doc.body).removeClass("sp-dragging");
1088-
onstop.apply(element, arguments);
1102+
1103+
// Wait a tick before notifying observers to allow the click event
1104+
// to fire in Chrome.
1105+
setTimeout(function() {
1106+
onstop.apply(element, arguments);
1107+
}, 0);
10891108
}
10901109
dragging = false;
10911110
}
@@ -1106,6 +1125,10 @@
11061125
};
11071126
}
11081127

1128+
function inputTypeColorSupport() {
1129+
return $.fn.spectrum.inputTypeColorSupport();
1130+
}
1131+
11091132
/**
11101133
* Define a jQuery plugin
11111134
*/
@@ -1159,20 +1182,28 @@
11591182
$.fn.spectrum.loadOpts = {};
11601183
$.fn.spectrum.draggable = draggable;
11611184
$.fn.spectrum.defaults = defaultOpts;
1185+
$.fn.spectrum.inputTypeColorSupport = function inputTypeColorSupport() {
1186+
if (typeof inputTypeColorSupport._cachedResult === "undefined") {
1187+
var colorInput = $("<input type='color' value='!' />")[0];
1188+
inputTypeColorSupport._cachedResult = colorInput.type === "color" && colorInput.value !== "!";
1189+
}
1190+
return inputTypeColorSupport._cachedResult;
1191+
};
11621192

11631193
$.spectrum = { };
11641194
$.spectrum.localization = { };
11651195
$.spectrum.palettes = { };
11661196

11671197
$.fn.spectrum.processNativeColorInputs = function () {
1168-
if (!inputTypeColorSupport) {
1169-
$("input[type=color]").spectrum({
1198+
var colorInputs = $("input[type=color]");
1199+
if (colorInputs.length && !inputTypeColorSupport()) {
1200+
colorInputs.spectrum({
11701201
preferredFormat: "hex6"
11711202
});
11721203
}
11731204
};
11741205

1175-
// TinyColor v1.1.1
1206+
// TinyColor v1.1.2
11761207
// https://github.com/bgrins/TinyColor
11771208
// Brian Grinstead, MIT License
11781209

@@ -1187,7 +1218,7 @@
11871218
mathMax = math.max,
11881219
mathRandom = math.random;
11891220

1190-
var tinycolor = function tinycolor (color, opts) {
1221+
var tinycolor = function(color, opts) {
11911222

11921223
color = (color) ? color : '';
11931224
opts = opts || { };
@@ -2277,7 +2308,6 @@
22772308
window.tinycolor = tinycolor;
22782309
})();
22792310

2280-
22812311
$(function () {
22822312
if ($.fn.spectrum.load) {
22832313
$.fn.spectrum.processNativeColorInputs();

0 commit comments

Comments
 (0)