Skip to content

Commit

Permalink
spectrum 1.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bdukes committed May 4, 2015
1 parent 6602e89 commit ef29f30
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 24 deletions.
Binary file removed _InstallPackages/spectrum_1.6.0.zip
Binary file not shown.
Binary file added _InstallPackages/spectrum_1.7.0.zip
Binary file not shown.
1 change: 0 additions & 1 deletion spectrum_1.6.0/CHANGES.htm

This file was deleted.

1 change: 0 additions & 1 deletion spectrum_1.6.0/LICENSE.htm

This file was deleted.

1 change: 1 addition & 0 deletions spectrum_1.7.0/CHANGES.htm
Original file line number Diff line number Diff line change
@@ -0,0 +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>
1 change: 1 addition & 0 deletions spectrum_1.7.0/LICENSE.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>spectrum is licened under the <a href="https://raw.githubusercontent.com/bgrins/spectrum/1.7.0/LICENSE">MIT License</a>.</p>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/***
Spectrum Colorpicker v1.6.0
Spectrum Colorpicker v1.7.0
https://github.com/bgrins/spectrum
Author: Brian Grinstead
License: MIT
Expand Down
4 changes: 2 additions & 2 deletions spectrum_1.6.0/spectrum.dnn → spectrum_1.7.0/spectrum.dnn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<dotnetnuke type="Package" version="5.0">
<packages>
<package name="spectrum" type="JavaScript_Library" version="1.6.0">
<package name="spectrum" type="JavaScript_Library" version="1.7.0">
<friendlyName>spectrum</friendlyName>
<description>The No Hassle JavaScript Colorpicker</description>
<owner>
Expand All @@ -21,7 +21,7 @@
<libraryName>spectrum</libraryName>
<fileName>spectrum.js</fileName>
<preferredScriptLocation>BodyBottom</preferredScriptLocation>
<CDNPath>https://cdnjs.cloudflare.com/ajax/libs/spectrum/1.6.0/spectrum.min.js</CDNPath>
<CDNPath>https://cdnjs.cloudflare.com/ajax/libs/spectrum/1.7.0/spectrum.min.js</CDNPath>
<objectName>jQuery.fn.spectrum</objectName>
</javaScriptLibrary>
</component>
Expand Down
68 changes: 49 additions & 19 deletions spectrum_1.6.0/spectrum.js → spectrum_1.7.0/spectrum.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Spectrum Colorpicker v1.6.0
// Spectrum Colorpicker v1.7.0
// https://github.com/bgrins/spectrum
// Author: Brian Grinstead
// License: MIT
Expand Down Expand Up @@ -33,7 +33,7 @@
showInput: false,
allowEmpty: false,
showButtons: true,
clickoutFiresChange: false,
clickoutFiresChange: true,
showInitial: false,
showPalette: false,
showPaletteOnly: false,
Expand Down Expand Up @@ -72,10 +72,6 @@
style.cssText = 'background-color:rgba(0,0,0,.5)';
return contains(style.backgroundColor, 'rgba') || contains(style.backgroundColor, 'hsla');
})(),
inputTypeColorSupport = (function() {
var colorInput = $("<input type='color' value='!' />")[0];
return colorInput.type === "color" && colorInput.value !== "!";
})(),
replaceInput = [
"<div class='sp-replacer'>",
"<div class='sp-preview'><div class='sp-preview-inner'></div></div>",
Expand Down Expand Up @@ -189,6 +185,7 @@
callbacks = opts.callbacks,
resize = throttle(reflow, 10),
visible = false,
isDragging = false,
dragWidth = 0,
dragHeight = 0,
dragHelperHeight = 0,
Expand Down Expand Up @@ -230,7 +227,7 @@
chooseButton = container.find(".sp-choose"),
toggleButton = container.find(".sp-palette-toggle"),
isInput = boundElement.is("input"),
isInputTypeColor = isInput && inputTypeColorSupport && boundElement.attr("type") === "color",
isInputTypeColor = isInput && boundElement.attr("type") === "color" && inputTypeColorSupport(),
shouldReplace = isInput && !flat,
replacer = (shouldReplace) ? $(replaceInput).addClass(theme).addClass(opts.className).addClass(opts.replacerClassName) : $([]),
offsetElement = (shouldReplace) ? replacer : boundElement,
Expand Down Expand Up @@ -360,6 +357,10 @@
e.stopPropagation();
e.preventDefault();

if (IE && textInput.is(":focus")) {
textInput.trigger('change');
}

if (isValid()) {
updateOriginalInput(true);
hide();
Expand Down Expand Up @@ -562,12 +563,14 @@
if (dragHeight <= 0 || dragWidth <= 0 || slideHeight <= 0) {
reflow();
}
isDragging = true;
container.addClass(draggingClass);
shiftMovementDirection = null;
boundElement.trigger('dragstart.spectrum', [ get() ]);
}

function dragStop() {
isDragging = false;
container.removeClass(draggingClass);
boundElement.trigger('dragstop.spectrum', [ get() ]);
}
Expand Down Expand Up @@ -618,6 +621,7 @@
hideAll();
visible = true;

$(doc).bind("keydown.spectrum", onkeydown);
$(doc).bind("click.spectrum", clickout);
$(window).bind("resize.spectrum", resize);
replacer.addClass("sp-active");
Expand All @@ -633,10 +637,21 @@
boundElement.trigger('show.spectrum', [ colorOnShow ]);
}

function onkeydown(e) {
// Close on ESC
if (e.keyCode === 27) {
hide();
}
}

function clickout(e) {
// Return on right click.
if (e.button == 2) { return; }

// If a drag event was happening during the mouseup, don't hide
// on click.
if (isDragging) { return; }

if (clickoutFiresChange) {
updateOriginalInput(true);
}
Expand All @@ -651,6 +666,7 @@
if (!visible || flat) { return; }
visible = false;

$(doc).unbind("keydown.spectrum", onkeydown);
$(doc).unbind("click.spectrum", clickout);
$(window).unbind("resize.spectrum", resize);

Expand Down Expand Up @@ -1043,9 +1059,9 @@
return stop();
}

var touches = e.originalEvent && e.originalEvent.touches;
var pageX = touches ? touches[0].pageX : e.pageX;
var pageY = touches ? touches[0].pageY : e.pageY;
var t0 = e.originalEvent && e.originalEvent.touches && e.originalEvent.touches[0];
var pageX = t0 && t0.pageX || e.pageX;
var pageY = t0 && t0.pageY || e.pageY;

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

if (!hasTouch) {
move(e);
}
move(e);

prevent(e);
}
Expand All @@ -1085,7 +1099,12 @@
if (dragging) {
$(doc).unbind(duringDragEvents);
$(doc.body).removeClass("sp-dragging");
onstop.apply(element, arguments);

// Wait a tick before notifying observers to allow the click event
// to fire in Chrome.
setTimeout(function() {
onstop.apply(element, arguments);
}, 0);
}
dragging = false;
}
Expand All @@ -1106,6 +1125,10 @@
};
}

function inputTypeColorSupport() {
return $.fn.spectrum.inputTypeColorSupport();
}

/**
* Define a jQuery plugin
*/
Expand Down Expand Up @@ -1159,20 +1182,28 @@
$.fn.spectrum.loadOpts = {};
$.fn.spectrum.draggable = draggable;
$.fn.spectrum.defaults = defaultOpts;
$.fn.spectrum.inputTypeColorSupport = function inputTypeColorSupport() {
if (typeof inputTypeColorSupport._cachedResult === "undefined") {
var colorInput = $("<input type='color' value='!' />")[0];
inputTypeColorSupport._cachedResult = colorInput.type === "color" && colorInput.value !== "!";
}
return inputTypeColorSupport._cachedResult;
};

$.spectrum = { };
$.spectrum.localization = { };
$.spectrum.palettes = { };

$.fn.spectrum.processNativeColorInputs = function () {
if (!inputTypeColorSupport) {
$("input[type=color]").spectrum({
var colorInputs = $("input[type=color]");
if (colorInputs.length && !inputTypeColorSupport()) {
colorInputs.spectrum({
preferredFormat: "hex6"
});
}
};

// TinyColor v1.1.1
// TinyColor v1.1.2
// https://github.com/bgrins/TinyColor
// Brian Grinstead, MIT License

Expand All @@ -1187,7 +1218,7 @@
mathMax = math.max,
mathRandom = math.random;

var tinycolor = function tinycolor (color, opts) {
var tinycolor = function(color, opts) {

color = (color) ? color : '';
opts = opts || { };
Expand Down Expand Up @@ -2277,7 +2308,6 @@
window.tinycolor = tinycolor;
})();


$(function () {
if ($.fn.spectrum.load) {
$.fn.spectrum.processNativeColorInputs();
Expand Down

0 comments on commit ef29f30

Please sign in to comment.