Remove unnecessary files from spectrum library to dismiss github security alert

This commit is contained in:
Kijin Sung 2022-04-28 20:20:15 +09:00
parent 2998bad5c5
commit 00dfd003f8
21 changed files with 0 additions and 32631 deletions

View file

@ -1,64 +0,0 @@
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
qunit: {
all: ['test/index.html', 'test/loaders.html']
},
jshint: {
options: {
sub: true,
strict: true,
newcap: false,
globals: {
jQuery: true
}
},
with_overrides: {
options: {
strict: false
},
files: {
src: ['i18n/*.js', 'test/tests.js']
}
},
all: ['spectrum.js']
},
uglify: {
options: {
},
dist: {
files: {
'build/spectrum-min.js': ['spectrum.js']
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-uglify');
// Testing tasks
grunt.registerTask('test', ['jshint', 'qunit']);
// Travis CI task.
grunt.registerTask('travis', 'test');
// Default task.
grunt.registerTask('default', ['test']);
//Build Task.
grunt.registerTask('build', ['test', 'uglify']);
};

View file

@ -1,22 +0,0 @@
{
"name": "spectrum",
"version": "1.8.0",
"main": ["./spectrum.css", "./spectrum.js"],
"docs": "http://bgrins.github.com/spectrum",
"homepage": "http://bgrins.github.com/spectrum",
"demo": "http://jsfiddle.net/bgrins/ctkY3/",
"dependencies": {
"jquery": ">=1.7.2"
},
"ignore": [
".gitignore",
".travis.yml",
"build/",
"docs/",
"example/",
"Gruntfile.js",
"LICENSE",
"README.md",
"test/"
]
}

File diff suppressed because it is too large Load diff

View file

@ -1,273 +0,0 @@
/* Styles for the demo page only. See spectrum.css for the actual colorpicker styles */
html { font-size: 100%; overflow-y: scroll; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; }
body { margin: 0; font-size: 14px; line-height: 1.5; background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAYAAADEUlfTAAAAG0lEQVQIW2OMqXogyYADMIIkl7QpPMcmP+gkAYLGGdeobP2EAAAAAElFTkSuQmCC); }
body, button, input, select, textarea { font-family: Droid Sans, Tahoma, sans-serif; color: #222; }
body p { font-family: Verdana; font-size: 12px; color: #333; line-height: 1.8; }
h1 { font-family: Lucida Sans, Droid Sans, Verdana; font-size: 30px; line-height: inherit; margin: 0; padding:0; font-weight: lighter; position:fixed; top: 3px; left: 10px; }
h1 a { text-decoration: none; color: #334 !important; }
h1 a:hover { text-decoration: underline; color: #336 !important; }
#header { background: #eee; background: #eee; height: 60px; line-height: 60px; padding: 3px 10px;}
#goals { margin:0 auto; padding:0; width: 98%; }
.goal { float: left; width: 29%; margin:1%; padding:1%; color: #335; min-height: 300px; background: #eee; border-radius: 10px; font-family: Verdana; }
#docs .goal h4 { text-align: center; margin: .5em 0; font-weight: lighter; text-decoration: underline; font-family: Verdana; }
a { color: #00e; }
a:visited { color: #009; }
a:hover { color: #06e; }
a:focus { outline: thin dotted; }
#header h2 { float:left; margin:0; padding:0; margin-left: 180px; font-size: 14px; line-height: inherit; font-weight: normal; font-family: Georgia;}
#header h2 em {background: #444; color: #fff; font-style: normal; padding: 5px; border-radius: 5px; border: solid 1px #999; box-shadow: 0 0 4px #333;}
#links { float:right; text-align: right; }
#pick2-details { font: monospace; }
#switch-current { float: left; position:relative; display:none;}
/*#switch-current .spectrum-container { position: fixed; top:60px; left: 10px; }*/
#docs-content { margin-left: 190px; padding: 10px 30px; border:solid 10px #ecc; border-right:none;border-bottom:none; padding-bottom: 20px; background: #fff; background: rgba(255, 255, 255, .6); }
.footer { padding-top: 50px; }
.switch-current-output { display:none; margin:3px auto; width: 200px; text-align: center; }
.type { padding-left: 4px; font-size: .8em; font-weight: bold;}
.description, .example {
padding: 10px;
border: 1px solid #888;
background: white;
position:relative;
padding-top: 15px;
}
#docs { }
#docs ul { margin-left: 25px; padding-left:10px; }
#docs li { list-style: square; margin-left: 6px; }
#docs p { margin: 0; padding:0; padding-top:4px; }
#docs pre { position:relative; }
#docs h2 { margin: 30px -25px; border-bottom: solid 1px; }
#docs h3 { padding: 10px 15px; margin: 10px auto; margin-top: 40px; border: solid 3px #aaa;
box-shadow: 0 3px 5px #333; }
#docs h3.point { box-shadow: none; margin-left: -30px; margin-right: -30px; border: solid 1px #999; border-left: none; border-right:none;}
#code-heading { font-size: 24px; text-align: center; margin: 6px 0; }
#docs-content { color: #222; }
#docs-content.dark { color: #ddd; }
code { font-weight: bold; color: #933; }
.note { float:right; background: #eee; padding: 4px; font-size: 11px; border: solid 1px #bbb; border-radius: 4px;}
.option-content .note { float:none; position:absolute; right: 0; top: -40px;}
.option-content { position:relative; background: #ededed;
border: solid 2px #aaa; border-top: none;
padding: 12px; width: 95%; margin: 0 auto;
margin-top: -10px; padding-top: 20px;
box-shadow: 0 0 10px #ccc; border-radius: 0 0 5px 5px;
}
.em-label { padding:4px; margin-left: 10px; display:inline-block; vertical-align: top; margin-top: 3px; }
.hide { display:none; }
.clearfix:before, .clearfix:after { content: ""; display: table; }
.clearfix:after { clear: both; }
.clearfix { *zoom: 1; }
input[type="text"] { height: auto; }
.label {
padding: 1px 4px 2px;
font-size: 10.998px;
font-weight: bold;
line-height: 13px;
color: #ffffff;
vertical-align: middle;
white-space: nowrap;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
background-color: #999999;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
.label:hover {
color: #ffffff;
text-decoration: none;
}
.label-important {
background-color: #b94a48;
}
.label-important:hover {
background-color: #953b39;
}
.label-result {
background-color: #3a87ad;
margin-right: 5px;
}
.example .label-result {
position:absolute;
top: -10px;
left: 5px;
}
.label-warning {
background-color: #f89406;
}
.label-warning:hover {
background-color: #c67605;
}
.label-success {
background-color: #468847;
}
.label-success:hover {
background-color: #356635;
}
.label-info {
background-color: #3a87ad;
}
.label-info:hover {
background-color: #2d6987;
}
.label-inverse {
background-color: #333333;
}
.label-inverse:hover {
background-color: #1a1a1a;
}
.alert {
padding: 8px 35px 8px 14px;
margin: 10px 0;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
background-color: #fcf8e3;
border: 1px solid #fbeed5;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
color: #c09853;
}
.alert-heading {
color: inherit;
}
.alert .close {
position: relative;
top: -2px;
right: -21px;
line-height: 18px;
}
.alert-success {
background-color: #dff0d8;
border-color: #d6e9c6;
color: #468847;
}
.alert-danger,
.alert-error {
background-color: #f2dede;
border-color: #eed3d7;
color: #b94a48;
}
.alert-info {
background-color: #d9edf7;
border-color: #bce8f1;
color: #3a87ad;
}
.alert-block {
padding-top: 14px;
padding-bottom: 14px;
}
.alert-block > p,
.alert-block > ul {
margin-bottom: 0;
}
.alert-block p + p {
margin-top: 5px;
}
.btn-primary:visited {
color: #ffffff;
}
/* prettify */
.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888; background: white;}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee}
/* desert scheme ported from vim to google prettify */
.dark pre { display: block; background-color: #333; border:1px solid #888; padding:2px; }
.dark pre .nocode { background-color: none; color: #000 }
.dark pre .str { color: #ffa0a0 } /* string - pink */
.dark pre .kwd { color: #f0e68c; font-weight: bold }
.dark pre .com { color: #87ceeb } /* comment - skyblue */
.dark pre .typ { color: #98fb98 } /* type - lightgreen */
.dark pre .lit { color: #cd5c5c } /* literal - darkred */
.dark pre .pun { color: #fff } /* punctuation */
.dark pre .pln { color: #fff } /* plaintext */
.dark pre .tag { color: #f0e68c; font-weight: bold } /* html/xml tag - lightyellow */
.dark pre .atn { color: #bdb76b; font-weight: bold } /* attribute name - khaki */
.dark pre .atv { color: #ffa0a0 } /* attribute value - pink */
.dark pre .dec { color: #98fb98 } /* decimal - lightgreen */
@media print {
.dark pre { background-color: none }
.dark pre .str, .dark code .str { color: #060 }
.dark pre .kwd, .dark code .kwd { color: #006; font-weight: bold }
.dark pre .com, .dark code .com { color: #600; font-style: italic }
.dark pre .typ, .dark code .typ { color: #404; font-weight: bold }
.dark pre .lit, .dark code .lit { color: #044 }
.dark pre .pun, .dark code .pun { color: #440 }
.dark pre .pln, .dark code .pln { color: #000 }
.dark pre .tag, .dark code .tag { color: #006; font-weight: bold }
.dark pre .atn, .dark code .atn { color: #404 }
.dark pre .atv, .dark code .atv { color: #060 }
}
/* http://projects.jga.me/toc/ */
#toc {
top: 76px;
bottom: 0;
left: 0px;
position: fixed;
font-size: 11px;
width: 180px;
color: #222;
overflow-y: auto;
font-family: Georgia;
}
#toc-slider {
position:fixed;
top:0;
bottom:0;
left: 0;
width: 170px;
background: #eee;
line-height: 60px;
padding-top: 3px;
padding-left: 10px;
border-right: solid 10px #cce;
z-index: -1;
}
@media (max-device-width: 480px) {
#toc, #toc-slider, h1 {
position:absolute;
}
}
#toc ul {
margin: 0;
padding: 0;
list-style: none;
}
#toc li {
padding: 5px 10px;
}
#toc a {
color: #225;
text-decoration: none;
display: block;
}
#toc .toc-h2 {
padding-left: 10px;
}
#toc .toc-h3 {
padding-left: 25px;
}
#toc .toc-active {
background: #CCE;
}
.full-spectrum {
margin: 0 auto;
}
.full-spectrum .sp-palette {
max-width: 200px;
}

View file

@ -1,466 +0,0 @@
function updateBorders(color) {
var hexColor = "transparent";
if(color) {
hexColor = color.toHexString();
}
$("#docs-content").css("border-color", hexColor);
}
$(function() {
$("#full").spectrum({
allowEmpty:true,
color: "#ECC",
showInput: true,
containerClassName: "full-spectrum",
showInitial: true,
showPalette: true,
showSelectionPalette: true,
showAlpha: true,
maxPaletteSize: 10,
preferredFormat: "hex",
localStorageKey: "spectrum.demo",
move: function (color) {
updateBorders(color);
},
show: function () {
},
beforeShow: function () {
},
hide: function (color) {
updateBorders(color);
},
palette: [
["rgb(0, 0, 0)", "rgb(67, 67, 67)", "rgb(102, 102, 102)", /*"rgb(153, 153, 153)","rgb(183, 183, 183)",*/
"rgb(204, 204, 204)", "rgb(217, 217, 217)", /*"rgb(239, 239, 239)", "rgb(243, 243, 243)",*/ "rgb(255, 255, 255)"],
["rgb(152, 0, 0)", "rgb(255, 0, 0)", "rgb(255, 153, 0)", "rgb(255, 255, 0)", "rgb(0, 255, 0)",
"rgb(0, 255, 255)", "rgb(74, 134, 232)", "rgb(0, 0, 255)", "rgb(153, 0, 255)", "rgb(255, 0, 255)"],
["rgb(230, 184, 175)", "rgb(244, 204, 204)", "rgb(252, 229, 205)", "rgb(255, 242, 204)", "rgb(217, 234, 211)",
"rgb(208, 224, 227)", "rgb(201, 218, 248)", "rgb(207, 226, 243)", "rgb(217, 210, 233)", "rgb(234, 209, 220)",
"rgb(221, 126, 107)", "rgb(234, 153, 153)", "rgb(249, 203, 156)", "rgb(255, 229, 153)", "rgb(182, 215, 168)",
"rgb(162, 196, 201)", "rgb(164, 194, 244)", "rgb(159, 197, 232)", "rgb(180, 167, 214)", "rgb(213, 166, 189)",
"rgb(204, 65, 37)", "rgb(224, 102, 102)", "rgb(246, 178, 107)", "rgb(255, 217, 102)", "rgb(147, 196, 125)",
"rgb(118, 165, 175)", "rgb(109, 158, 235)", "rgb(111, 168, 220)", "rgb(142, 124, 195)", "rgb(194, 123, 160)",
"rgb(166, 28, 0)", "rgb(204, 0, 0)", "rgb(230, 145, 56)", "rgb(241, 194, 50)", "rgb(106, 168, 79)",
"rgb(69, 129, 142)", "rgb(60, 120, 216)", "rgb(61, 133, 198)", "rgb(103, 78, 167)", "rgb(166, 77, 121)",
/*"rgb(133, 32, 12)", "rgb(153, 0, 0)", "rgb(180, 95, 6)", "rgb(191, 144, 0)", "rgb(56, 118, 29)",
"rgb(19, 79, 92)", "rgb(17, 85, 204)", "rgb(11, 83, 148)", "rgb(53, 28, 117)", "rgb(116, 27, 71)",*/
"rgb(91, 15, 0)", "rgb(102, 0, 0)", "rgb(120, 63, 4)", "rgb(127, 96, 0)", "rgb(39, 78, 19)",
"rgb(12, 52, 61)", "rgb(28, 69, 135)", "rgb(7, 55, 99)", "rgb(32, 18, 77)", "rgb(76, 17, 48)"]
]
});
$("#hideButtons").spectrum({
showButtons: false,
change: updateBorders
});
var isDisabled = true;
$("#toggle-disabled").click(function() {
if (isDisabled) {
$("#disabled").spectrum("enable");
}
else {
$("#disabled").spectrum("disable");
}
isDisabled = !isDisabled;
return false;
});
$("input:disabled").spectrum({
});
$("#disabled").spectrum({
disabled: true
});
$("#pick1").spectrum({
flat: true,
change: function(color) {
var hsv = color.toHsv();
var rgb = color.toRgbString();
var hex = color.toHexString();
//console.log("callback",color.toHslString(), color.toHsl().h, color.toHsl().s, color.toHsl().l)
$("#docs-content").css({
'background-color': color.toRgbString()
}).toggleClass("dark", hsv.v < .5);
$("#switch-current-rgb").text(rgb);
$("#switch-current-hex").text(hex);
},
show: function() {
},
hide: function() {
},
showInput: true,
showPalette: true,
palette: ['white', '#306', '#c5c88d', '#ac5c5c', '#344660']
});
$("#collapsed").spectrum({
color: "#dd3333",
change: updateBorders,
show: function() {
},
hide: function() {
}
});
$("#flat").spectrum({
flat: true,
showInput: true,
move: updateBorders
});
$("#flatClearable").spectrum({
flat: true,
move: updateBorders,
change: updateBorders,
allowEmpty:true,
showInput: true
});
$("#showInput").spectrum({
color: "#dd33dd",
showInput: true,
change: updateBorders,
show: function() {
},
hide: function() {
}
});
$("#showAlpha").spectrum({
color: "rgba(255, 128, 0, .5)",
showAlpha: true,
change: updateBorders
});
$("#showAlphaWithInput").spectrum({
color: "rgba(255, 128, 0, .5)",
showAlpha: true,
showInput: true,
showPalette: true,
palette: [
["rgba(255, 128, 0, .9)", "rgba(255, 128, 0, .5)"],
["red", "green", "blue"],
["hsla(25, 50, 75, .5)", "rgba(100, .5, .5, .8)"]
],
change: updateBorders
});
$("#showAlphaWithInputAndEmpty").spectrum({
color: "rgba(255, 128, 0, .5)",
allowEmpty:true,
showAlpha: true,
showInput: true,
showPalette: true,
palette: [
["rgba(255, 128, 0, .9)", "rgba(255, 128, 0, .5)"],
["red", "green", "blue"],
["hsla(25, 50, 75, .5)", "rgba(100, .5, .5, .8)"]
],
change: updateBorders
});
$("#showInputWithClear").spectrum({
allowEmpty:true,
color: "",
showInput: true,
change: updateBorders,
show: function() {
},
hide: function() {
}
});
$("#openWithLink").spectrum({
color: "#dd3333",
change: updateBorders,
show: function() {
},
hide: function() {
}
});
$("#className").spectrum({
className: 'awesome'
});
$("#replacerClassName").spectrum({
replacerClassName: 'awesome'
});
$("#containerClassName").spectrum({
containerClassName: 'awesome'
});
$("#showPalette").spectrum({
showPalette: true,
palette: [
['black', 'white', 'blanchedalmond'],
['rgb(255, 128, 0);', 'hsv 100 70 50', 'lightyellow']
],
change: updateBorders
});
var textPalette = ["rgb(255, 255, 255)", "rgb(204, 204, 204)", "rgb(192, 192, 192)", "rgb(153, 153, 153)", "rgb(102, 102, 102)", "rgb(51, 51, 51)", "rgb(0, 0, 0)", "rgb(255, 204, 204)", "rgb(255, 102, 102)", "rgb(255, 0, 0)", "rgb(204, 0, 0)", "rgb(153, 0, 0)", "rgb(102, 0, 0)", "rgb(51, 0, 0)", "rgb(255, 204, 153)", "rgb(255, 153, 102)", "rgb(255, 153, 0)", "rgb(255, 102, 0)", "rgb(204, 102, 0)", "rgb(153, 51, 0)", "rgb(102, 51, 0)", "rgb(255, 255, 153)", "rgb(255, 255, 102)", "rgb(255, 204, 102)", "rgb(255, 204, 51)", "rgb(204, 153, 51)", "rgb(153, 102, 51)", "rgb(102, 51, 51)", "rgb(255, 255, 204)", "rgb(255, 255, 51)", "rgb(255, 255, 0)", "rgb(255, 204, 0)", "rgb(153, 153, 0)", "rgb(102, 102, 0)", "rgb(51, 51, 0)", "rgb(153, 255, 153)", "rgb(102, 255, 153)", "rgb(51, 255, 51)", "rgb(51, 204, 0)", "rgb(0, 153, 0)", "rgb(0, 102, 0)", "rgb(0, 51, 0)", "rgb(153, 255, 255)", "rgb(51, 255, 255)", "rgb(102, 204, 204)", "rgb(0, 204, 204)", "rgb(51, 153, 153)", "rgb(51, 102, 102)", "rgb(0, 51, 51)", "rgb(204, 255, 255)", "rgb(102, 255, 255)", "rgb(51, 204, 255)", "rgb(51, 102, 255)", "rgb(51, 51, 255)", "rgb(0, 0, 153)", "rgb(0, 0, 102)", "rgb(204, 204, 255)", "rgb(153, 153, 255)", "rgb(102, 102, 204)", "rgb(102, 51, 255)", "rgb(102, 0, 204)", "rgb(51, 51, 153)", "rgb(51, 0, 153)", "rgb(255, 204, 255)", "rgb(255, 153, 255)", "rgb(204, 102, 204)", "rgb(204, 51, 204)", "rgb(153, 51, 153)", "rgb(102, 51, 102)", "rgb(51, 0, 51)"];
$("#showPaletteOnly").spectrum({
color: 'blanchedalmond',
showPaletteOnly: true,
showPalette:true,
palette: [
['black', 'white', 'blanchedalmond',
'rgb(255, 128, 0);', 'hsv 100 70 50'],
['red', 'yellow', 'green', 'blue', 'violet']
]
});
$("#hideAfterPaletteSelect").spectrum({
showPaletteOnly: true,
showPalette:true,
hideAfterPaletteSelect:true,
color: 'blanchedalmond',
palette: [
['black', 'white', 'blanchedalmond',
'rgb(255, 128, 0);', 'hsv 100 70 50'],
['red', 'yellow', 'green', 'blue', 'violet']
]
});
$("#togglePaletteOnly").spectrum({
color: 'blanchedalmond',
showPaletteOnly: true,
togglePaletteOnly: true,
showPalette:true,
palette: [
["#000","#444","#666","#999","#ccc","#eee","#f3f3f3","#fff"],
["#f00","#f90","#ff0","#0f0","#0ff","#00f","#90f","#f0f"],
["#f4cccc","#fce5cd","#fff2cc","#d9ead3","#d0e0e3","#cfe2f3","#d9d2e9","#ead1dc"],
["#ea9999","#f9cb9c","#ffe599","#b6d7a8","#a2c4c9","#9fc5e8","#b4a7d6","#d5a6bd"],
["#e06666","#f6b26b","#ffd966","#93c47d","#76a5af","#6fa8dc","#8e7cc3","#c27ba0"],
["#c00","#e69138","#f1c232","#6aa84f","#45818e","#3d85c6","#674ea7","#a64d79"],
["#900","#b45f06","#bf9000","#38761d","#134f5c","#0b5394","#351c75","#741b47"],
["#600","#783f04","#7f6000","#274e13","#0c343d","#073763","#20124d","#4c1130"]
]
});
$("#clickoutFiresChange").spectrum({
change: updateBorders
});
$("#clickoutDoesntFireChange").spectrum({
change: updateBorders,
clickoutFiresChange: false
});
$("#showInitial").spectrum({
showInitial: true
});
$("#showInputAndInitial").spectrum({
showInitial: true,
showInput: true
});
$("#showInputInitialClear").spectrum({
allowEmpty:true,
showInitial: true,
showInput: true
});
$("#changeOnMove").spectrum({
move: function(c) {
var label = $("#changeOnMoveLabel");
label.text("Move called: " + c.toHexString());
}
});
$("#changeOnMoveNo").spectrum({
showInput: true,
change: function(c) {
var label = $("#changeOnMoveNoLabel");
label.text("Change called: " + c.toHexString());
}
});
function prettyTime() {
var date = new Date();
return date.toLocaleTimeString();
}
$("#eventshow").spectrum({
show: function(c) {
var label = $("#eventshowLabel");
label.text("show called at " + prettyTime() + " (color is " + c.toHexString() + ")");
}
});
$("#eventhide").spectrum({
hide: function(c) {
var label = $("#eventhideLabel");
label.text("hide called at " + prettyTime() + " (color is " + c.toHexString() + ")");
}
});
$("#eventdragstart").spectrum({
showAlpha: true
}).on("dragstart.spectrum", function(e, c) {
var label = $("#eventdragstartLabel");
label.text("dragstart called at " + prettyTime() + " (color is " + c.toHexString() + ")");
});
$("#eventdragstop").spectrum({
showAlpha: true
}).on("dragstop.spectrum", function(e, c) {
var label = $("#eventdragstopLabel");
label.text("dragstop called at " + prettyTime() + " (color is " + c.toHexString() + ")");
});
$(".basic").spectrum({ change: updateBorders });
$(".override").spectrum({
color: "yellow",
change: updateBorders
});
$(".startEmpty").spectrum({
allowEmpty:true,
change: updateBorders});
$("#beforeShow").spectrum({
beforeShow: function() {
return false;
}
});
$("#custom").spectrum({
color: "#f00"
});
$("#buttonText").spectrum({
allowEmpty:true,
chooseText: "Alright",
cancelText: "No way"
});
$("#showSelectionPalette").spectrum({
showPalette: true,
showSelectionPalette: true, // true by default
palette: [ ]
});
$("#showSelectionPaletteStorage").spectrum({
showPalette: true,
localStorageKey: "spectrum.homepage", // Any picker with the same string will share selection
showSelectionPalette: true,
palette: [ ]
});
$("#showSelectionPaletteStorage2").spectrum({
showPalette: true,
localStorageKey: "spectrum.homepage", // Any picker with the same string will share selection
showSelectionPalette: true,
palette: [ ]
});
$("#selectionPalette").spectrum({
showPalette: true,
palette: [ ],
showSelectionPalette: true, // true by default
selectionPalette: ["red", "green", "blue"]
});
$("#maxSelectionSize").spectrum({
showPalette: true,
palette: [ ],
showSelectionPalette: true, // true by default
selectionPalette: ["red", "green", "blue"],
maxSelectionSize: 2
});
$("#preferredHex").spectrum({
preferredFormat: "hex",
showInput: true,
showPalette: true,
palette: [["red", "rgba(0, 255, 0, .5)", "rgb(0, 0, 255)"]]
});
$("#preferredHex3").spectrum({
preferredFormat: "hex3",
showInput: true,
showPalette: true,
palette: [["red", "rgba(0, 255, 0, .5)", "rgb(0, 0, 255)"]]
});
$("#preferredHsl").spectrum({
preferredFormat: "hsl",
showInput: true,
showPalette: true,
palette: [["red", "rgba(0, 255, 0, .5)", "rgb(0, 0, 255)"]]
});
$("#preferredRgb").spectrum({
preferredFormat: "rgb",
showInput: true,
showPalette: true,
palette: [["red", "rgba(0, 255, 0, .5)", "rgb(0, 0, 255)"]]
});
$("#preferredName").spectrum({
preferredFormat: "name",
showInput: true,
showPalette: true,
palette: [["red", "rgba(0, 255, 0, .5)", "rgb(0, 0, 255)"]]
});
$("#preferredNone").spectrum({
showInput: true,
showPalette: true,
palette: [["red", "rgba(0, 255, 0, .5)", "rgb(0, 0, 255)"]]
});
$("#triggerSet").spectrum({
change: updateBorders
});
// Show the original input to demonstrate the value changing when calling `set`
$("#triggerSet").show();
$("#btnEnterAColor").click(function() {
$("#triggerSet").spectrum("set", $("#enterAColor").val());
});
$("#toggle").spectrum();
$("#btn-toggle").click(function() {
$("#toggle").spectrum("toggle");
return false;
});
$('#toc').toc({
'selectors': 'h2,h3', //elements to use as headings
'container': '#docs', //element to find all selectors in
'smoothScrolling': true, //enable or disable smooth scrolling on click
'prefix': 'toc', //prefix for anchor tags and class names
'highlightOnScroll': true, //add class to heading that is currently in focus
'highlightOffset': 100, //offset to trigger the next headline
'anchorName': function(i, heading, prefix) { //custom function for anchor name
return heading.id || prefix+i;
}
});
prettyPrint();
});

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,28 +0,0 @@
var q=null;window.PR_SHOULD_USE_CONTINUATION=!0;
(function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a=
[],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c<i;++c){var j=f[c];if(/\\[bdsw]/i.test(j))a.push(j);else{var j=m(j),d;c+2<i&&"-"===f[c+1]?(d=m(f[c+2]),c+=2):d=j;b.push([j,d]);d<65||j>122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;c<b.length;++c)i=b[c],i[0]<=j[1]+1?j[1]=Math.max(j[1],i[1]):f.push(j=i);b=["["];o&&b.push("^");b.push.apply(b,a);for(c=0;c<
f.length;++c)i=f[c],b.push(e(i[0])),i[1]>i[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c<b;++c){var j=f[c];j==="("?++i:"\\"===j.charAt(0)&&(j=+j.substring(1))&&j<=i&&(d[j]=-1)}for(c=1;c<d.length;++c)-1===d[c]&&(d[c]=++t);for(i=c=0;c<b;++c)j=f[c],j==="("?(++i,d[i]===void 0&&(f[c]="(?:")):"\\"===j.charAt(0)&&
(j=+j.substring(1))&&j<=i&&(f[c]="\\"+d[i]);for(i=c=0;c<b;++c)"^"===f[c]&&"^"!==f[c+1]&&(f[c]="");if(a.ignoreCase&&s)for(c=0;c<b;++c)j=f[c],a=j.charAt(0),j.length>=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p<d;++p){var g=a[p];if(g.ignoreCase)l=!0;else if(/[a-z]/i.test(g.source.replace(/\\u[\da-f]{4}|\\x[\da-f]{2}|\\[^UXux]/gi,""))){s=!0;l=!1;break}}for(var r=
{b:8,t:9,n:10,v:11,f:12,r:13},n=[],p=0,d=a.length;p<d;++p){g=a[p];if(g.global||g.multiline)throw Error(""+g);n.push("(?:"+y(g)+")")}return RegExp(n.join("|"),l?"gi":"g")}function M(a){function m(a){switch(a.nodeType){case 1:if(e.test(a.className))break;for(var g=a.firstChild;g;g=g.nextSibling)m(g);g=a.nodeName;if("BR"===g||"LI"===g)h[s]="\n",t[s<<1]=y++,t[s++<<1|1]=a;break;case 3:case 4:g=a.nodeValue,g.length&&(g=p?g.replace(/\r\n?/g,"\n"):g.replace(/[\t\n\r ]+/g," "),h[s]=g,t[s<<1]=y,y+=g.length,
t[s++<<1|1]=a)}}var e=/(?:^|\s)nocode(?:\s|$)/,h=[],y=0,t=[],s=0,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=document.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);m(a);return{a:h.join("").replace(/\n$/,""),c:t}}function B(a,m,e,h){m&&(a={a:m,d:a},e(a),h.push.apply(h,a.e))}function x(a,m){function e(a){for(var l=a.d,p=[l,"pln"],d=0,g=a.a.match(y)||[],r={},n=0,z=g.length;n<z;++n){var f=g[n],b=r[f],o=void 0,c;if(typeof b===
"string")c=!1;else{var i=h[f.charAt(0)];if(i)o=f.match(i[1]),b=i[0];else{for(c=0;c<t;++c)if(i=m[c],o=f.match(i[1])){b=i[0];break}o||(b="pln")}if((c=b.length>=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m),
l=[],p={},d=0,g=e.length;d<g;++d){var r=e[d],n=r[3];if(n)for(var k=n.length;--k>=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/,
q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/,
q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g,
"");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a),
a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e}
for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g<d.length;++g)e(d[g]);m===(m|0)&&d[0].setAttribute("value",
m);var r=s.createElement("OL");r.className="linenums";for(var n=Math.max(0,m-1|0)||0,g=0,z=d.length;g<z;++g)l=d[g],l.className="L"+(g+n)%10,l.firstChild||l.appendChild(s.createTextNode("\xa0")),r.appendChild(l);a.appendChild(r)}function k(a,m){for(var e=m.length;--e>=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*</.test(m)?"default-markup":"default-code";return A[a]}function E(a){var m=
a.g;try{var e=M(a.h),h=e.a;a.a=h;a.c=e.c;a.d=0;C(m,h)(a);var k=/\bMSIE\b/.test(navigator.userAgent),m=/\n/g,t=a.a,s=t.length,e=0,l=a.c,p=l.length,h=0,d=a.e,g=d.length,a=0;d[g]=s;var r,n;for(n=r=0;n<g;)d[n]!==d[n+2]?(d[r++]=d[n++],d[r++]=d[n++]):n+=2;g=r;for(n=r=0;n<g;){for(var z=d[n],f=d[n+1],b=n+2;b+2<=g&&d[b+1]===f;)b+=2;d[r++]=z;d[r++]=f;n=b}for(d.length=r;h<p;){var o=l[h+2]||s,c=d[a+2]||s,b=Math.min(o,c),i=l[h+1],j;if(i.nodeType!==1&&(j=t.substring(e,b))){k&&(j=j.replace(m,"\r"));i.nodeValue=
j;var u=i.ownerDocument,v=u.createElement("SPAN");v.className=d[a+1];var x=i.parentNode;x.replaceChild(v,i);v.appendChild(i);e<o&&(l[h+1]=i=u.createTextNode(t.substring(b,o)),x.insertBefore(i,v.nextSibling))}e=b;e>=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],
"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"],
H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],
J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+
I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^<?]+/],["dec",/^<!\w[^>]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),
["default-markup","htm","html","mxml","xhtml","xml","xsl"]);k(x([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css",
/^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);k(x([],[["atv",/^[\S\s]+/]]),["uq.val"]);k(u({keywords:F,hashComments:!0,cStyleComments:!0,types:K}),["c","cc","cpp","cxx","cyc","m"]);k(u({keywords:"null,true,false"}),["json"]);k(u({keywords:H,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:K}),["cs"]);k(u({keywords:G,cStyleComments:!0}),["java"]);k(u({keywords:v,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]);k(u({keywords:I,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),
["cv","py"]);k(u({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]);k(u({keywords:J,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]);k(u({keywords:w,cStyleComments:!0,regexLiterals:!0}),["js"]);k(u({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes",
hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);k(x([],[["str",/^[\S\s]+/]]),["regex"]);window.prettyPrintOne=function(a,m,e){var h=document.createElement("PRE");h.innerHTML=a;e&&D(h,e);E({g:m,i:e,h:h});return h.innerHTML};window.prettyPrint=function(a){function m(){for(var e=window.PR_SHOULD_USE_CONTINUATION?l.now()+250:Infinity;p<h.length&&l.now()<e;p++){var n=h[p],k=n.className;if(k.indexOf("prettyprint")>=0){var k=k.match(g),f,b;if(b=
!k){b=n;for(var o=void 0,c=b.firstChild;c;c=c.nextSibling)var i=c.nodeType,o=i===1?o?b:c:i===3?N.test(c.nodeValue)?b:o:o;b=(f=o===b?void 0:o)&&"CODE"===f.tagName}b&&(k=f.className.match(g));k&&(k=k[1]);b=!1;for(o=n.parentNode;o;o=o.parentNode)if((o.tagName==="pre"||o.tagName==="code"||o.tagName==="xmp")&&o.className&&o.className.indexOf("prettyprint")>=0){b=!0;break}b||((b=(b=n.className.match(/\blinenums\b(?::(\d+))?/))?b[1]&&b[1].length?+b[1]:!0:!1)&&D(n,b),d={g:k,h:n,i:b},E(d))}}p<h.length?setTimeout(m,
250):a&&a()}for(var e=[document.getElementsByTagName("pre"),document.getElementsByTagName("code"),document.getElementsByTagName("xmp")],h=[],k=0;k<e.length;++k)for(var t=0,s=e[k].length;t<s;++t)h.push(e[k][t]);var e=q,l=Date;l.now||(l={now:function(){return+new Date}});var p=0,d,g=/\blang(?:uage)?-([\w.]+)(?!\S)/;m()};window.PR={createSimpleLexer:x,registerLangHandler:k,sourceDecorator:u,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit",
PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ"}})();

View file

@ -1,109 +0,0 @@
!function($) {
$.fn.toc = function(options) {
var self = this;
var opts = $.extend({}, jQuery.fn.toc.defaults, options);
var container = $(opts.container);
var headings = $(opts.selectors, container);
var headingOffsets = [];
var activeClassName = opts.prefix+'-active';
var findScrollableElement = function(els) {
for (var i = 0, argLength = arguments.length; i < argLength; i++) {
var el = arguments[i],
$scrollElement = $(el);
if ($scrollElement.scrollTop() > 0) {
return $scrollElement;
} else {
$scrollElement.scrollTop(1);
var isScrollable = $scrollElement.scrollTop() > 0;
$scrollElement.scrollTop(0);
if (isScrollable) {
return $scrollElement;
}
}
}
return [];
};
var scrollable = findScrollableElement(opts.container, 'body', 'html');
var scrollTo = function(e) {
if (opts.smoothScrolling) {
e.preventDefault();
var elScrollTo = $(e.target).attr('href');
var $el = $(elScrollTo);
scrollable.animate({ scrollTop: $el.offset().top }, 400, 'swing', function() {
location.hash = elScrollTo;
});
}
$('li', self).removeClass(activeClassName);
$(e.target).parent().addClass(activeClassName);
};
//highlight on scroll
var timeout;
var highlightOnScroll = function(e) {
if (timeout) {
clearTimeout(timeout);
}
timeout = setTimeout(function() {
var top = $(window).scrollTop();
for (var i = 0, c = headingOffsets.length; i < c; i++) {
if (headingOffsets[i] >= top) {
$('li', self).removeClass(activeClassName);
$('li:eq('+(i-1)+')', self).addClass(activeClassName);
break;
}
}
}, 50);
};
if (opts.highlightOnScroll) {
$(window).bind('scroll', highlightOnScroll);
highlightOnScroll();
}
return this.each(function() {
//build TOC
var ul = $('<ul/>');
headings.each(function(i, heading) {
var $h = $(heading);
headingOffsets.push($h.offset().top - opts.highlightOffset);
//add anchor
var anchorName = opts.anchorName(i, heading, opts.prefix);
var anchor = $([]);
if (!document.getElementById(anchorName)) {
anchor = $('<span/>').attr('id', opts.anchorName(i, heading, opts.prefix)).insertBefore($h);
}
//build TOC item
var a = $('<a/>')
.text($h.text())
.attr('href', '#' + anchorName)
.bind('click', scrollTo);
var li = $('<li/>')
.addClass(opts.prefix+'-'+$h[0].tagName.toLowerCase())
.append(a);
ul.append(li);
});
var el = $(this);
el.html(ul);
});
};
jQuery.fn.toc.defaults = {
container: 'body',
selectors: 'h1,h2,h3',
smoothScrolling: true,
prefix: '',
highlightOnScroll: true,
highlightOffset: 100,
anchorName: function(i, heading, prefix) {
return prefix+i;
}
};
}(jQuery);

View file

@ -1,254 +0,0 @@
$(function() {
var colorpickerInput = $("#full");
function toggleButtonState() {
var options = colorpickerInput.spectrum("option");
$(".toggleBtn").each(function() {
$(this).toggleClass("active", !!options[$(this).data("rule")]);
});
}
$(document).on("click", ".toggleBtn", function() {
var option = $(this).data("rule");
var existing = colorpickerInput.spectrum("option", option);
colorpickerInput.spectrum("option", option, !existing);
toggleButtonState();
});
colorpickerInput.spectrum({
color: "#ECC",
flat: true,
showInput: true,
className: "full-spectrum",
showInitial: true,
showPalette: true,
showSelectionPalette: true,
maxPaletteSize: 10,
preferredFormat: "hex",
localStorageKey: "spectrum.example",
move: function (color) {
},
show: function () {
},
beforeShow: function () {
},
hide: function (color) {
},
palette: [
["rgb(0, 0, 0)", "rgb(67, 67, 67)", "rgb(102, 102, 102)", /*"rgb(153, 153, 153)","rgb(183, 183, 183)",*/
"rgb(204, 204, 204)", "rgb(217, 217, 217)", /*"rgb(239, 239, 239)", "rgb(243, 243, 243)",*/ "rgb(255, 255, 255)"],
["rgb(152, 0, 0)", "rgb(255, 0, 0)", "rgb(255, 153, 0)", "rgb(255, 255, 0)", "rgb(0, 255, 0)",
"rgb(0, 255, 255)", "rgb(74, 134, 232)", "rgb(0, 0, 255)", "rgb(153, 0, 255)", "rgb(255, 0, 255)"],
["rgb(230, 184, 175)", "rgb(244, 204, 204)", "rgb(252, 229, 205)", "rgb(255, 242, 204)", "rgb(217, 234, 211)",
"rgb(208, 224, 227)", "rgb(201, 218, 248)", "rgb(207, 226, 243)", "rgb(217, 210, 233)", "rgb(234, 209, 220)",
"rgb(221, 126, 107)", "rgb(234, 153, 153)", "rgb(249, 203, 156)", "rgb(255, 229, 153)", "rgb(182, 215, 168)",
"rgb(162, 196, 201)", "rgb(164, 194, 244)", "rgb(159, 197, 232)", "rgb(180, 167, 214)", "rgb(213, 166, 189)",
"rgb(204, 65, 37)", "rgb(224, 102, 102)", "rgb(246, 178, 107)", "rgb(255, 217, 102)", "rgb(147, 196, 125)",
"rgb(118, 165, 175)", "rgb(109, 158, 235)", "rgb(111, 168, 220)", "rgb(142, 124, 195)", "rgb(194, 123, 160)",
"rgb(166, 28, 0)", "rgb(204, 0, 0)", "rgb(230, 145, 56)", "rgb(241, 194, 50)", "rgb(106, 168, 79)",
"rgb(69, 129, 142)", "rgb(60, 120, 216)", "rgb(61, 133, 198)", "rgb(103, 78, 167)", "rgb(166, 77, 121)",
/*"rgb(133, 32, 12)", "rgb(153, 0, 0)", "rgb(180, 95, 6)", "rgb(191, 144, 0)", "rgb(56, 118, 29)",
"rgb(19, 79, 92)", "rgb(17, 85, 204)", "rgb(11, 83, 148)", "rgb(53, 28, 117)", "rgb(116, 27, 71)",*/
"rgb(91, 15, 0)", "rgb(102, 0, 0)", "rgb(120, 63, 4)", "rgb(127, 96, 0)", "rgb(39, 78, 19)",
"rgb(12, 52, 61)", "rgb(28, 69, 135)", "rgb(7, 55, 99)", "rgb(32, 18, 77)", "rgb(76, 17, 48)"]
]
});
$("#size").change(function() {
var size = Math.min(500, Math.max(50, $(this).val()));
$(".sp-picker-container").width(size);
colorpickerInput.spectrum("reflow");
});
$("#huesize").change(function() {
var size = Math.min(80, Math.max(5, $(this).val()));
$(".sp-hue").css("left", (103 - size) + "%");
$(".sp-color").css("right", size + "%");
$(".sp-fill").css("padding-top", (100 - size) + "%");
colorpickerInput.spectrum("reflow");
});
toggleButtonState();
});
var palettes = { };
palettes.newGmail = [["#000","#444","#666","#999","#ccc","#eee","#f3f3f3","#fff"],["#f00","#f90","#ff0","#0f0","#0ff","#00f","#90f","#f0f"],["#f4cccc","#fce5cd","#fff2cc","#d9ead3","#d0e0e3","#cfe2f3","#d9d2e9","#ead1dc"],["#ea9999","#f9cb9c","#ffe599","#b6d7a8","#a2c4c9","#9fc5e8","#b4a7d6","#d5a6bd"],["#e06666","#f6b26b","#ffd966","#93c47d","#76a5af","#6fa8dc","#8e7cc3","#c27ba0"],["#c00","#e69138","#f1c232","#6aa84f","#45818e","#3d85c6","#674ea7","#a64d79"],["#900","#b45f06","#bf9000","#38761d","#134f5c","#0b5394","#351c75","#741b47"],["#600","#783f04","#7f6000","#274e13","#0c343d","#073763","#20124d","#4c1130"]];
palettes.default = [
["#000000", "#434343", "#666666", "#999999", "#b7b7b7", "#cccccc", "#d9d9d9", "#efefef", "#f3f3f3", "#ffffff"],
["#980000", "#ff0000", "#ff9900", "#ffff00", "#00ff00", "#00ffff", "#4a86e8", "#0000ff", "#9900ff", "#ff00ff"],
["#e6b8af", "#f4cccc", "#fce5cd", "#fff2cc", "#d9ead3", "#d9ead3", "#c9daf8", "#cfe2f3", "#d9d2e9", "#ead1dc"],
["#dd7e6b", "#ea9999", "#f9cb9c", "#ffe599", "#b6d7a8", "#a2c4c9", "#a4c2f4", "#9fc5e8", "#b4a7d6", "#d5a6bd"],
["#cc4125", "#e06666", "#f6b26b", "#ffd966", "#93c47d", "#76a5af", "#6d9eeb", "#6fa8dc", "#8e7cc3", "#c27ba0"],
["#a61c00", "#cc0000", "#e69138", "#f1c232", "#6aa84f", "#45818e", "#3c78d8", "#3d85c6", "#674ea7", "#a64d79"],
["#85200c", "#990000", "#b45f06", "#bf9000", "#38761d", "#134f5c", "#1155cc", "#0b5394", "#351c75", "#741b47"],
["#5b0f00", "#660000", "#783f04", "#7f6000", "#274e13", "#0c343d", "#1c4587", "#073763", "#20124d", "#4c1130"]
];
palettes.snagit = [
["#ffffff", "#000000", "#c00000", "#f79646", "#f5f445", "#7fd13b", "#4bacc6", "#1f497d", "#8064a2", "#ff0000"],
["#f2f2f2", "#7f7f7f", "#f8d1d3", "#fdeada", "#fafdd7", "#e5f5d7", "#dbeef3", "#c6d9f0", "#e5e0ec", "#ffcc00"],
["#d7d7d7", "#595959", "#f2a3a7", "#fbd5b5", "#fbfaae", "#cbecb0", "#b7dde8", "#8db3e2", "#ccc1d9", "#ffff00"],
["#bebebe", "#414141", "#eb757b", "#fac08f", "#eef98e", "#b2e389", "#92cddc", "#548dd4", "#b2a2c7", "#00ff00"],
["#a3a3a3", "#2a2a2a", "#a3171e", "#e36c09", "#dede07", "#5ea226", "#31859b", "#17365d", "#5f497a", "#0000ff"],
["#7e7e7e", "#141414", "#6d0f14", "#974806", "#c0c00d", "#3f6c19", "#205867", "#0f243e", "#3f3151", "#9900ff"]
];
palettes.newton = [
"#ffffff", "#000000", "#ff0000", "#ff8000", "#ffff00", "#008000", "#0000ff", "#4b0082", "#9400d3"
];
palettes.aol = [
["#ffffff", "#fff7de", "#ffffce", "#ffffbd", "#ffffd6", "#b5ff84", "#c6efde", "#efffff", "#efe7f7", "#dea5d6"],
["#ded6c6", "#ffc6bd", "#ffe7b5", "#ffe7a5", "#efef7b", "#adf77b", "#5abd9c", "#a5d6f7", "#8494e7", "#ef7be7"],
["#cec6b5", "#e78473", "#efad52", "#f7b500", "#efef9c", "#a5ff00", "#7bd6bd", "#a5d6de", "#8c5ae7", "#de6bce"],
["#8c8473", "#ef0018", "#ef4210", "#f79400", "#ffff00", "#63d600", "#a5c684", "#5a63d6", "#7b52c6", "#c642ce"],
["#736b63", "#d60039", "#d67310", "#f7844a", "#f7de00", "#429400", "#4a944a", "#4200ff", "#9c00de", "#a500c6"],
["#39524a", "#b51821", "#944a08", "#a55229", "#8c8c00", "#318c00", "#429484", "#3100c6", "#523984", "#940084"],
["#000000", "#940008", "#840008", "#ad2929", "#637321", "#296b00", "#29006b", "#21007b", "#52007b", "#84007b"]
];
palettes.oldGmail = [
["#ffffff", "#cecece", "#c6c6c6", "#9c9c9c", "#636363", "#313131", "#000000"],
["#ffcece", "#ff6363", "#ff0000", "#ce0000", "#9c0000", "#630000", "#310000"],
["#ffce9c", "#ff9c63", "#ff9c00", "#ff6300", "#ce6300", "#9c3100", "#633100"],
["#ffff9c", "#ffff63", "#ffce63", "#ffce31", "#ce9c31", "#9c6331", "#633131"],
["#ffffce", "#ffff31", "#ffff00", "#ffce00", "#9c9c00", "#636300", "#313100"],
["#9cff9c", "#63ff9c", "#31ff31", "#31ce00", "#009c00", "#006300", "#003100"],
["#9cffff", "#31ffff", "#63cece", "#00cece", "#319c9c", "#316363", "#003131"],
["#ceffff", "#63ffff", "#31ceff", "#3163ff", "#3131ff", "#00009c", "#000063"],
["#ceceff", "#9c9cff", "#6363ce", "#6331ff", "#6300ce", "#31319c", "#31009c"],
["#ffceff", "#ff9cff", "#ce63ce", "#ce31ce", "#9c319c", "#633163", "#310031"]
];
palettes.hotmail = [
["#ffffff", "#000000", "#efefe7", "#184a7b", "#4a84bd", "#c6524a", "#9cbd5a", "#8463a5", "#4aadc6", "#f79442"],
["#f7f7f7", "#7b7b7b", "#dedec6", "#c6def7", "#dee7f7", "#f7dede", "#eff7de", "#e7e7ef", "#deeff7", "#ffefde"],
["#dedede", "#5a5a5a", "#c6bd94", "#8cb5e7", "#bdcee7", "#e7bdb5", "#d6e7bd", "#cec6de", "#b5deef", "#ffd6b5"],
["#bdbdbd", "#393939", "#948c52", "#528cd6", "#94b5d6", "#de9494", "#c6d69c", "#b5a5c6", "#94cede", "#ffc68c"],
["#a5a5a5", "#212121", "#4a4229", "#10315a", "#316394", "#943131", "#739439", "#5a4a7b", "#31849c", "#e76b08"],
["#848484", "#080808", "#181810", "#082139", "#214263", "#632121", "#4a6329", "#393152", "#215a63", "#944a00"],
["#c60000", "#ff0000", "#ffc600", "#ffff00", "#94d652", "#00b552", "#00b5f7", "#0073c6", "#002163", "#7331a5"],
];
palettes.yahoo = [
["#000000", "#111111", "#2d2d2d", "#434343", "#5b5b5b", "#737373", "#8b8b8b", "#a2a2a2", "#b9b9b9", "#d0d0d0", "#e6e6e6", "#ffffff"],
["#7f7f00", "#bfbf00", "#ffff00", "#ffff40", "#ffff80", "#ffffbf", "#525330", "#898a49", "#aea945", "#c3be71", "#e0dcaa", "#fcfae1"],
["#407f00", "#60bf00", "#80ff00", "#a0ff40", "#c0ff80", "#dfffbf", "#3b5738", "#668f5a", "#7f9757", "#8a9b55", "#b7c296", "#e6ebd5"],
["#007f40", "#00bf60", "#00ff80", "#40ffa0", "#80ffc0", "#bfffdf", "#033d21", "#438059", "#7fa37c", "#8dae94", "#acc6b5", "#ddebe2"],
["#007f7f", "#00bfbf", "#00ffff", "#40ffff", "#80ffff", "#bfffff", "#033d3d", "#347d7e", "#609a9f", "#96bdc4", "#b5d1d7", "#e2f1f4"],
["#00407f", "#0060bf", "#0080ff", "#40a0ff", "#80c0ff", "#bfdfff", "#1b2c48", "#385376", "#57708f", "#7792ac", "#a8bed1", "#deebf6"],
["#00007f", "#0000bf", "#0000ff", "#4040ff", "#8080ff", "#bfbfff", "#212143", "#373e68", "#444f75", "#585e82", "#8687a4", "#d2d1e1"],
["#40007f", "#6000bf", "#8000ff", "#a040ff", "#c080ff", "#dfbfff", "#302449", "#54466f", "#655a7f", "#726284", "#9e8fa9", "#dcd1df"],
["#7f007f", "#bf00bf", "#ff00ff", "#ff40ff", "#ff80ff", "#ffbfff", "#4a234a", "#794a72", "#936386", "#9d7292", "#c0a0b6", "#ecdae5"],
["#7f003f", "#bf005f", "#ff007f", "#ff409f", "#ff80bf", "#ffbfdf", "#451528", "#823857", "#a94a76", "#bc6f95", "#d8a5bb", "#f7dde9"],
["#800000", "#c00000", "#ff0000", "#ff4040", "#ff8080", "#ffc0c0", "#441415", "#82393c", "#aa4d4e", "#bc6e6e", "#d8a3a4", "#f8dddd"],
["#7f3f00", "#bf5f00", "#ff7f00", "#ff9f40", "#ffbf80", "#ffdfbf", "#482c1b", "#855a40", "#b27c51", "#c49b71", "#e1c4a8", "#fdeee0"]
];
palettes.sixteen = [
["#000000", "#000084", "#0000ff", "#840000"],
["#840084", "#008200", "#ff0000", "#008284"],
["#ff00ff", "#848200", "#848284", "#00ff00"],
["#ffa600", "#00ffff", "#c6c3c6", "#ffff00"],
["#ffffff"]
];
palettes.websafe = [
["#000", "#300", "#600", "#900", "#c00", "#f00"],
["#003", "#303", "#603", "#903", "#c03", "#f03"],
["#006", "#306", "#606", "#906", "#c06", "#f06"],
["#009", "#309", "#609", "#909", "#c09", "#f09"],
["#00c", "#30c", "#60c", "#90c", "#c0c", "#f0c"],
["#00f", "#30f", "#60f", "#90f", "#c0f", "#f0f"],
["#030", "#330", "#630", "#930", "#c30", "#f30"],
["#033", "#333", "#633", "#933", "#c33", "#f33"],
["#036", "#336", "#636", "#936", "#c36", "#f36"],
["#039", "#339", "#639", "#939", "#c39", "#f39"],
["#03c", "#33c", "#63c", "#93c", "#c3c", "#f3c"],
["#03f", "#33f", "#63f", "#93f", "#c3f", "#f3f"],
["#060", "#360", "#660", "#960", "#c60", "#f60"],
["#063", "#363", "#663", "#963", "#c63", "#f63"],
["#066", "#366", "#666", "#966", "#c66", "#f66"],
["#069", "#369", "#669", "#969", "#c69", "#f69"],
["#06c", "#36c", "#66c", "#96c", "#c6c", "#f6c"],
["#06f", "#36f", "#66f", "#96f", "#c6f", "#f6f"],
["#090", "#390", "#690", "#990", "#c90", "#f90"],
["#093", "#393", "#693", "#993", "#c93", "#f93"],
["#096", "#396", "#696", "#996", "#c96", "#f96"],
["#099", "#399", "#699", "#999", "#c99", "#f99"],
["#09c", "#39c", "#69c", "#99c", "#c9c", "#f9c"],
["#09f", "#39f", "#69f", "#99f", "#c9f", "#f9f"],
["#0c0", "#3c0", "#6c0", "#9c0", "#cc0", "#fc0"],
["#0c3", "#3c3", "#6c3", "#9c3", "#cc3", "#fc3"],
["#0c6", "#3c6", "#6c6", "#9c6", "#cc6", "#fc6"],
["#0c9", "#3c9", "#6c9", "#9c9", "#cc9", "#fc9"],
["#0cc", "#3cc", "#6cc", "#9cc", "#ccc", "#fcc"],
["#0cf", "#3cf", "#6cf", "#9cf", "#ccf", "#fcf"],
["#0f0", "#3f0", "#6f0", "#9f0", "#cf0", "#ff0"],
["#0f3", "#3f3", "#6f3", "#9f3", "#cf3", "#ff3"],
["#0f6", "#3f6", "#6f6", "#9f6", "#cf6", "#ff6"],
["#0f9", "#3f9", "#6f9", "#9f9", "#cf9", "#ff9"],
["#0fc", "#3fc", "#6fc", "#9fc", "#cfc", "#ffc"],
["#0ff", "#3ff", "#6ff", "#9ff", "#cff", "#fff"]
];
palettes.named = [
["White", "Ivory", "Snow", "LightYellow", "MintCream", "Azure", "FloralWhite", "Honeydew", "GhostWhite", "Seashell", "Cornsilk", "AliceBlue", "LemonChiffon", "LightCyan"],
["OldLace", "LightGoldenrodYellow", "LavenderBlush", "WhiteSmoke", "Beige", "Linen", "PapayaWhip", "BlanchedAlmond", "AntiqueWhite", "MistyRose", "Bisque", "Lavender", "Moccasin", "PaleGoldenrod"],
["NavajoWhite", "Yellow", "PeachPuff", "Wheat", "Khaki", "Gainsboro", "PaleTurquoise", "Pink", "Aquamarine", "LightGray", "PowderBlue", "PaleGreen", "GreenYellow", "LightPink"],
["LightBlue", "Gold", "Thistle", "LightGreen", "LightSteelBlue", "Silver", "LightSkyBlue", "BurlyWood", "SkyBlue", "Chartreuse", "Plum", "LawnGreen", "Tan", "LightSalmon"],
["SandyBrown", "Cyan", "Aqua", "DarkKhaki", "Violet", "Turquoise", "Orange", "YellowGreen", "DarkSalmon", "MediumAquamarine", "DarkSeaGreen", "DarkGray", "MediumTurquoise", "Goldenrod"],
["MediumSpringGreen", "SpringGreen", "Salmon", "LightCoral", "Coral", "DarkOrange", "HotPink", "RosyBrown", "Orchid", "Lime", "PaleVioletRed", "Peru", "DarkTurquoise", "CornflowerBlue"],
["Tomato", "DeepSkyBlue", "LimeGreen", "CadetBlue", "MediumSeaGreen", "DarkGoldenrod", "MediumPurple", "LightSeaGreen", "LightSlateGray", "MediumOrchid", "Gray", "Chocolate", "IndianRed", "SlateGray"],
["MediumSlateBlue", "DodgerBlue", "OliveDrab", "SteelBlue", "OrangeRed", "Olive", "SlateBlue", "RoyalBlue", "Magenta", "Fuchsia", "SeaGreen", "DimGray", "DeepPink", "Sienna"],
["DarkOrchid", "DarkCyan", "ForestGreen", "DarkOliveGreen", "BlueViolet", "Teal", "MediumVioletRed", "Crimson", "SaddleBrown", "Brown", "FireBrick", "Red", "Green", "DarkSlateBlue"],
["DarkSlateGray", "DarkViolet", "DarkGreen", "DarkMagenta", "Purple", "DarkRed", "Maroon", "Indigo", "MidnightBlue", "Blue", "MediumBlue", "DarkBlue", "Navy", "Black"]
];
$(function() {
for (var i in palettes) {
$("<h3 />").text(i).appendTo("#palettes");
$("<input />").appendTo("#palettes").spectrum({
flat: true,
showInput: true,
className: i,
preferredFormat: "rgb",
showPalette: true,
showPaletteOnly: true,
palette: palettes[i]
});
}
});
$(function() {
$("#langdemo").spectrum({
flat: false,
showInput: true,
});
});

View file

@ -1,149 +0,0 @@
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Spectrum - The No Hassle jQuery Colorpicker</title>
<meta name="description" content="Spectrum is a JavaScript colorpicker plugin using the jQuery framework. It is highly customizable, but can also be used as a simple input type=color polyfill">
<meta name="author" content="Brian Grinstead and Spectrum contributors">
<link rel="stylesheet" type="text/css" href="../spectrum.css">
<link rel="stylesheet" type="text/css" href="../docs/bootstrap.css">
<link rel="stylesheet" type="text/css" href="../docs/docs.css">
<script type="text/javascript" src="../docs/jquery-1.9.1.js"></script>
<script type="text/javascript" src="../spectrum.js"></script>
<script type="text/javascript" src="../i18n/jquery.spectrum-fi.js"></script>
<script type='text/javascript' src='example.js'></script>
<style>
.example-container {
margin-top: 10px;
text-align: center;
background: #333;
background: linear-gradient(to bottom, #eee, #ccc);
padding: 3px;
padding-top: 0;
border-radius: 5px;
}
.example-controls {
background: #999;
margin: 0 -3px;
padding: 10px 0;
margin-bottom: 15px;
}
label {
display: inline-block;
font-weight: bold;
}
#palettes .sp-palette {
max-width: 500px;
}
.newGmail .sp-palette-row-0, .newGmail .sp-palette-row-1 {
margin-bottom: 5px;
}
.newGmail .sp-palette .sp-thumb-el {
width: 20px;
height: 20px;
margin: 1px 1px;
}
.newGmail .sp-palette .sp-thumb-el:hover, .newGmail .sp-palette .sp-thumb-el.sp-thumb-active {
border-color: #000;
}
</style>
</head>
<body>
<div id='header'>
<h1><a href='http://bgrins.github.com/spectrum'>Spectrum</a></h1> <h2><em>The No Hassle jQuery Colorpicker</em></h2>
<div id='links'>
View the <a href='http://github.com/bgrins/spectrum'>Source code</a>.
Spectrum is a project by <a href='http://twitter.com/bgrins'>@bgrins</a>.
</div>
<br style='clear:both;' />
</div>
<div class="container">
<h2>Spectrum Colorpicker Crazy Configurator</h2>
<div class='alert'>NOTE: this page is currently in development. Please refer to the <a href='http://github.com/bgrins/spectrum'>Home Page</a> for demos and documentation instead.
</div>
<p>
Spectrum can be customized to show and hide different portions of the colorpicker. Try clicking some of the buttons below to see how it can change.
</p>
<div class="example-container">
<div class="example-controls">
<div class='btn-group'>
<button class='btn toggleBtn' data-rule='showPalette'>Show Palette</button>
<button class='btn toggleBtn' data-rule='showInput'>Show Input</button>
<button class='btn toggleBtn' data-rule='showInitial'>Show Initial</button>
<button class='btn toggleBtn' data-rule='showAlpha'>Show Alpha</button>
<button class='btn toggleBtn' data-rule='showPaletteOnly'>Show Palette Only</button>
<button class='btn toggleBtn' data-rule='togglePaletteOnly'>Show Picker Toggle Button</button>
<button class='btn toggleBtn' data-rule='showButtons'>Show Buttons</button>
</div>
<br />
<br />
<p>
<label>Draggable Size <input type='range' value='172' id='size' max='500' min='50' /></label>
<label>Hue Size <input type='range' value='16' id='huesize' max='90' min='5' /></label>
</p>
</div>
<input id="full">
</div>
<hr />
<h2>Spectrum Colorpicker Localization</h2>
<div class='alert'>
<p>
This page has loaded the German localization. Here is a list of all <a href='https://github.com/bgrins/spectrum/tree/master/i18n'>spectrum localizations</a>. <strong>Please help expand our localizations</strong> if you know a language that isn't represented! You can copy and paste one of the files, and update the text for 'cancel' and 'choose', then submit a pull request at: <a href'https://github.com/bgrins/spectrum'>https://github.com/bgrins/spectrum</a>.
</p>
</div>
<input id="langdemo" />
<hr />
<h2>Spectrum Colorpicker Sample Palettes</h2>
<div class='alert'>
<p>
NOTE: these palettes are also a work in progress. Ideally the site will eventually allow you to choose between a few options and download them.
</p>
<p>
The <code>newGmail</code> palette below is an example of customizing the palette size and layout with CSS.
</p>
</div>
<div id="palettes" class="example-container">
</div>
</div>
<script type="text/javascript" src="../docs/prettify.js"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-8259845-4']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</body>
</html>

View file

@ -1,93 +0,0 @@
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Spectrum - The No Hassle jQuery Colorpicker</title>
<meta name="description" content="Spectrum is a JavaScript colorpicker plugin using the jQuery framework. It is highly customizable, but can also be used as a simple input type=color polyfill">
<meta name="author" content="Brian Grinstead and Spectrum contributors">
<link rel="stylesheet" type="text/css" href="../spectrum.css">
<link rel="stylesheet" type="text/css" href="../docs/bootstrap.css">
<link rel="stylesheet" type="text/css" href="../docs/docs.css">
<script type="text/javascript" src="../docs/jquery-1.9.1.js"></script>
<script type="text/javascript" src="../spectrum.js"></script>
</head>
<body>
<div id='header'>
<h1><a href='http://bgrins.github.com/spectrum'>Spectrum</a></h1> <h2><em>The No Hassle jQuery Colorpicker</em></h2>
<div id='links'>
View the <a href='http://github.com/bgrins/spectrum'>Source code</a>.
Spectrum is a project by <a href='http://twitter.com/bgrins'>@bgrins</a>.
</div>
<br style='clear:both;' />
</div>
<div class="container">
<h2>Basic Test Case</h2>
<p>Also available as a <a href="http://jsfiddle.net/bgrins/ctkY3/">jsfiddle</a></p>
<button id="update">Update palette</button>
<h2>Full Example</h2>
<input type='text' id="full"/>
</div>
<script type="text/javascript">
$("#update").click (function() {
console.log($("#full").spectrum("option", "palette"));
$("#full").spectrum("option", "palette", [
["red", "green", "blue"]
]);
});
$("#full").spectrum({
color: "#ECC",
flat: true,
showInput: true,
className: "full-spectrum",
showInitial: true,
showPalette: true,
showSelectionPalette: true,
maxPaletteSize: 10,
preferredFormat: "hex",
localStorageKey: "spectrum.demo",
move: function (color) {
},
show: function () {
},
beforeShow: function () {
},
hide: function () {
},
change: function() {
},
palette: [
["rgb(0, 0, 0)", "rgb(67, 67, 67)", "rgb(102, 102, 102)",
"rgb(204, 204, 204)", "rgb(217, 217, 217)","rgb(255, 255, 255)"],
["rgb(152, 0, 0)", "rgb(255, 0, 0)", "rgb(255, 153, 0)", "rgb(255, 255, 0)", "rgb(0, 255, 0)",
"rgb(0, 255, 255)", "rgb(74, 134, 232)", "rgb(0, 0, 255)", "rgb(153, 0, 255)", "rgb(255, 0, 255)"],
["rgb(230, 184, 175)", "rgb(244, 204, 204)", "rgb(252, 229, 205)", "rgb(255, 242, 204)", "rgb(217, 234, 211)",
"rgb(208, 224, 227)", "rgb(201, 218, 248)", "rgb(207, 226, 243)", "rgb(217, 210, 233)", "rgb(234, 209, 220)",
"rgb(221, 126, 107)", "rgb(234, 153, 153)", "rgb(249, 203, 156)", "rgb(255, 229, 153)", "rgb(182, 215, 168)",
"rgb(162, 196, 201)", "rgb(164, 194, 244)", "rgb(159, 197, 232)", "rgb(180, 167, 214)", "rgb(213, 166, 189)",
"rgb(204, 65, 37)", "rgb(224, 102, 102)", "rgb(246, 178, 107)", "rgb(255, 217, 102)", "rgb(147, 196, 125)",
"rgb(118, 165, 175)", "rgb(109, 158, 235)", "rgb(111, 168, 220)", "rgb(142, 124, 195)", "rgb(194, 123, 160)",
"rgb(166, 28, 0)", "rgb(204, 0, 0)", "rgb(230, 145, 56)", "rgb(241, 194, 50)", "rgb(106, 168, 79)",
"rgb(69, 129, 142)", "rgb(60, 120, 216)", "rgb(61, 133, 198)", "rgb(103, 78, 167)", "rgb(166, 77, 121)",
"rgb(91, 15, 0)", "rgb(102, 0, 0)", "rgb(120, 63, 4)", "rgb(127, 96, 0)", "rgb(39, 78, 19)",
"rgb(12, 52, 61)", "rgb(28, 69, 135)", "rgb(7, 55, 99)", "rgb(32, 18, 77)", "rgb(76, 17, 48)"]
]
});
</script>
</body>
</html>

File diff suppressed because it is too large Load diff

View file

@ -1,24 +0,0 @@
{
"name": "spectrum-colorpicker",
"description": "Spectrum: the no hassle jQuery colorpicker",
"version": "1.8.0",
"main": "spectrum.js",
"license": "MIT",
"keywords": ["jquery-plugin", "ecosystem:jquery", "color", "colorpicker", "ui"],
"homepage": "http://bgrins.github.com/spectrum",
"repository": {
"type": "git",
"url": "https://bgrins.github.com/spectrum"
},
"author": {
"name" : "Brian Grinstead",
"email" : "briangrinstead@gmail.com",
"url" : "http://briangrinstead.com/"
},
"devDependencies": {
"grunt": "~0.4.0",
"grunt-contrib-jshint": "~0.4.3",
"grunt-contrib-qunit": "~0.2.0",
"grunt-contrib-uglify": "~0.2.0"
}
}

View file

@ -1,18 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Spectrum Tests</title>
<link rel="stylesheet" href="qunit.css">
<link rel="stylesheet" href="../spectrum.css">
</head>
<body>
<div id="qunit"></div>
<script src="../docs/jquery-1.9.1.js"></script>
<script src="../spectrum.js"></script>
<script src="qunit.js"></script>
<script src="tests.js"></script>
<input type="color" id="type-color-on-page" />
</body>
</html>

View file

@ -1,15 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Spectrum Tests</title>
<link rel="stylesheet" href="qunit.css">
<link rel="stylesheet" href="../spectrum.css">
</head>
<body>
<div id="qunit"></div>
<script src="qunit.js"></script>
<script src="require.js"></script>
<script src="loaders.js"></script>
</body>
</html>

View file

@ -1,22 +0,0 @@
require.config({
paths: {
jquery: '../docs/jquery-2.1.0'
}
});
asyncTest ("requirejs", function() {
require([
"../spectrum"
], function(spectrum) {
ok ($.fn.spectrum, "Plugin has been loaded");
// Just do some basic stuff with the API as a sanity check.
var el = $("<input id='spec' />").spectrum();
el.spectrum("set", "red");
equal(el.spectrum("get").toName(), "red", "Basic color setting");
el.spectrum("destroy");
QUnit.start();
});
});

View file

@ -1,235 +0,0 @@
/**
* QUnit v1.10.0 - A JavaScript Unit Testing Framework
*
* http://qunitjs.com
*
* Copyright 2012 jQuery Foundation and other contributors
* Released under the MIT license.
* http://jquery.org/license
*/
/** Font Family and Sizes */
#qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult {
font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif;
}
#qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }
#qunit-tests { font-size: smaller; }
/** Resets */
#qunit-tests, #qunit-tests ol, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult, #qunit-modulefilter {
margin: 0;
padding: 0;
}
/** Header */
#qunit-header {
padding: 0.5em 0 0.5em 1em;
color: #8699a4;
background-color: #0d3349;
font-size: 1.5em;
line-height: 1em;
font-weight: normal;
border-radius: 5px 5px 0 0;
-moz-border-radius: 5px 5px 0 0;
-webkit-border-top-right-radius: 5px;
-webkit-border-top-left-radius: 5px;
}
#qunit-header a {
text-decoration: none;
color: #c2ccd1;
}
#qunit-header a:hover,
#qunit-header a:focus {
color: #fff;
}
#qunit-testrunner-toolbar label {
display: inline-block;
padding: 0 .5em 0 .1em;
}
#qunit-banner {
height: 5px;
}
#qunit-testrunner-toolbar {
padding: 0.5em 0 0.5em 2em;
color: #5E740B;
background-color: #eee;
overflow: hidden;
}
#qunit-userAgent {
padding: 0.5em 0 0.5em 2.5em;
background-color: #2b81af;
color: #fff;
text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
}
#qunit-modulefilter-container {
float: right;
}
/** Tests: Pass/Fail */
#qunit-tests {
list-style-position: inside;
}
#qunit-tests li {
padding: 0.4em 0.5em 0.4em 2.5em;
border-bottom: 1px solid #fff;
list-style-position: inside;
}
#qunit-tests.hidepass li.pass, #qunit-tests.hidepass li.running {
display: none;
}
#qunit-tests li strong {
cursor: pointer;
}
#qunit-tests li a {
padding: 0.5em;
color: #c2ccd1;
text-decoration: none;
}
#qunit-tests li a:hover,
#qunit-tests li a:focus {
color: #000;
}
#qunit-tests ol {
margin-top: 0.5em;
padding: 0.5em;
background-color: #fff;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
}
#qunit-tests table {
border-collapse: collapse;
margin-top: .2em;
}
#qunit-tests th {
text-align: right;
vertical-align: top;
padding: 0 .5em 0 0;
}
#qunit-tests td {
vertical-align: top;
}
#qunit-tests pre {
margin: 0;
white-space: pre-wrap;
word-wrap: break-word;
}
#qunit-tests del {
background-color: #e0f2be;
color: #374e0c;
text-decoration: none;
}
#qunit-tests ins {
background-color: #ffcaca;
color: #500;
text-decoration: none;
}
/*** Test Counts */
#qunit-tests b.counts { color: black; }
#qunit-tests b.passed { color: #5E740B; }
#qunit-tests b.failed { color: #710909; }
#qunit-tests li li {
padding: 5px;
background-color: #fff;
border-bottom: none;
list-style-position: inside;
}
/*** Passing Styles */
#qunit-tests li li.pass {
color: #3c510c;
background-color: #fff;
border-left: 10px solid #C6E746;
}
#qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; }
#qunit-tests .pass .test-name { color: #366097; }
#qunit-tests .pass .test-actual,
#qunit-tests .pass .test-expected { color: #999999; }
#qunit-banner.qunit-pass { background-color: #C6E746; }
/*** Failing Styles */
#qunit-tests li li.fail {
color: #710909;
background-color: #fff;
border-left: 10px solid #EE5757;
white-space: pre;
}
#qunit-tests > li:last-child {
border-radius: 0 0 5px 5px;
-moz-border-radius: 0 0 5px 5px;
-webkit-border-bottom-right-radius: 5px;
-webkit-border-bottom-left-radius: 5px;
}
#qunit-tests .fail { color: #000000; background-color: #EE5757; }
#qunit-tests .fail .test-name,
#qunit-tests .fail .module-name { color: #000000; }
#qunit-tests .fail .test-actual { color: #EE5757; }
#qunit-tests .fail .test-expected { color: green; }
#qunit-banner.qunit-fail { background-color: #EE5757; }
/** Result */
#qunit-testresult {
padding: 0.5em 0.5em 0.5em 2.5em;
color: #2b81af;
background-color: #D2E0E6;
border-bottom: 1px solid white;
}
#qunit-testresult .module-name {
font-weight: bold;
}
/** Fixture */
#qunit-fixture {
position: absolute;
top: -10000px;
left: -10000px;
width: 1000px;
height: 1000px;
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,730 +0,0 @@
// Spectrum Colorpicker Tests
// https://github.com/bgrins/spectrum
// Author: Brian Grinstead
// License: MIT
// Pretend like the color inputs aren't supported for initial load.
$.fn.spectrum.inputTypeColorSupport = function() { return false; };
module("Initialization");
test( "jQuery Plugin Can Be Created", function() {
var el = $("<input id='spec' />").spectrum();
ok(el.attr("id") === "spec", "Element returned from plugin" );
el.spectrum("set", "red");
equal(el.spectrum("get").toName(), "red", "Basic color setting");
equal(el.spectrum("option", "showInput"), false, "Undefined option is false.");
el.spectrum({showInput: true});
equal(el.spectrum("option", "showInput"), true, "Double initialized spectrum is destroyed before recreating.");
el.spectrum("destroy");
equal(el.spectrum("container"), el, "After destroying spectrum, string function returns input.");
});
test ("Polyfill", function() {
var el = $("#type-color-on-page");
ok (el.spectrum("get").toHex, "The input[type=color] has been initialized on load");
el.spectrum("destroy");
// Pretend like the color inputs are supported.
$.fn.spectrum.inputTypeColorSupport = function() { return true; };
el = $("<input type='color' value='red' />").spectrum({
allowEmpty: true
});
el.spectrum("set", null);
ok(el.spectrum("get"), "input[type] color does not allow null values");
el.spectrum("destroy");
});
test( "Per-element Options Are Read From Data Attributes", function() {
var el = $("<input id='spec' data-show-alpha='true' />").spectrum();
equal ( el.spectrum("option", "showAlpha"), true, "Took showAlpha value from data attribute");
el.spectrum("destroy");
var changeDefault = $("<input id='spec' data-show-alpha='false' />").spectrum({
showAlpha: true
});
equal ( changeDefault.spectrum("option", "showAlpha"), false, "Took showAlpha value from data attribute");
changeDefault.spectrum("destroy");
var noData = $("<input id='spec' />").spectrum({
showAlpha: true
});
equal ( noData.spectrum("option", "showAlpha"), true, "Kept showAlpha without data attribute");
noData.spectrum("destroy");
});
test( "Events Fire", function() {
var el = $("<input id='spec' />").spectrum();
var count = 0;
expect(5);
el.on("beforeShow.spectrum", function(e) {
// Cancel the event the first time
if (count === 0) {
ok(true, "Cancel beforeShow");
count++;
return false;
}
ok (count === 1, "Allow beforeShow");
count++;
});
el.on("show.spectrum", function(e) {
ok(count === 2, "Show");
count++;
});
el.on("hide.spectrum", function(e) {
ok(count === 3, "Hide");
count++;
});
el.on("move.spectrum", function(e) {
});
el.on("change", function(e, color) {
ok(false, "Change should not fire from `set` call");
});
el.spectrum("show");
el.spectrum("show");
el.spectrum("hide");
el.spectrum("set", "red");
el.spectrum("destroy");
var el2 = $("<input />").spectrum({
showInput: true
});
el2.on("change.spectrum", function(e, color) {
ok(true, "Change should fire input changing");
});
el2.spectrum("container").find(".sp-input").val("blue").trigger("change");
el2.spectrum("destroy");
});
test( "Escape hides the colorpicker", function() {
expect(1);
var el = $("<input id='spec' />").spectrum();
el.on("hide.spectrum", function(e) {
ok(true, "Hide event should fire");
});
// Simulate an escape before showing -- should do nothing
var e = jQuery.Event("keydown");
e.keyCode = 27;
$(document).trigger(e);
el.spectrum("show");
// Simulate an escape after showing -- should call the hide handler
$(document).trigger(e);
el.spectrum("destroy");
});
test( "Dragging", function() {
var el = $("<input id='spec' />").spectrum();
var hueSlider = el.spectrum("container").find(".sp-hue");
ok (hueSlider.length, "There is a hue slider");
hueSlider.trigger("mousedown");
ok ($("body").hasClass("sp-dragging"), "The body has dragging class");
hueSlider.trigger("mouseup");
ok (!$("body").hasClass("sp-dragging"), "The body does not have a dragging class");
el.spectrum("destroy");
});
module("Defaults");
test( "Default Color Is Set By Input Value", function() {
var red = $("<input id='spec' value='red' />").spectrum();
equal ( red.spectrum("get").toName(), "red", "Basic color setting");
var noColor = $("<input id='spec' value='not a color' />").spectrum();
equal ( noColor.spectrum("get").toHex(), "000000", "Defaults to black with an invalid color");
var noValue = $("<input id='spec' />").spectrum();
equal ( noValue.spectrum("get").toHex(), "000000", "Defaults to black with no value set");
var noValueHex3 = $("<input id='spec' />").spectrum({
preferredFormat: "hex3"
});
equal ( noValueHex3.spectrum("get").toHex(true), "000", "Defaults to 3 char hex with no value set");
equal ( noValueHex3.spectrum("get").toString(), "#000", "Defaults to 3 char hex with no value set");
red.spectrum("destroy");
noColor.spectrum("destroy");
noValue.spectrum("destroy");
noValueHex3.spectrum("destroy");
});
module("Palettes");
test( "Palette Events Fire In Correct Order ", function() {
expect(2);
var el = $("<input id='spec' value='red' />").spectrum({
showPalette: true,
palette: [
["red", "green", "blue"]
],
move: function() {
}
});
var count = 0;
el.on("move.spectrum", function(e) {
ok(count === 0, "move fires before change");
count++;
});
el.on("change.spectrum", function(e) {
ok(count === 1, "change fires after move");
});
el.spectrum("container").find(".sp-thumb-el:last-child").click();
el.spectrum("destroy");
});
test( "Palette click events work ", function() {
var el = $("<input id='spec' value='red' />").spectrum({
showPalette: true,
palette: [
["red", "green", "blue"]
],
move: function() {
}
});
el.spectrum("container").find(".sp-thumb-el:nth-child(3)").click();
equal (el.spectrum("get").toName(), "blue", "First click worked");
el.spectrum("container").find(".sp-thumb-el:nth-child(2) .sp-thumb-inner").click();
equal (el.spectrum("get").toName(), "green", "Second click worked (on child element)");
el.spectrum("container").find(".sp-thumb-el:nth-child(1) .sp-thumb-inner").click();
equal (el.spectrum("get").toName(), "red", "Third click worked (on child element)");
el.spectrum("destroy");
});
test( "hideAfterPaletteSelect: Palette stays open after color select", function() {
var el = $("<input id='spec' value='red' />").spectrum({
showPalette: true,
hideAfterPaletteSelect: false,
palette: [
["red", "green", "blue"]
]
});
el.spectrum("show");
el.spectrum("container").find(".sp-thumb-el:nth-child(1)").click();
ok(!el.spectrum("container").hasClass('sp-hidden'), "palette is still visible after color selection");
el.spectrum("destroy");
});
test( "hideAfterPaletteSelect: Palette closes after color select", function() {
var el = $("<input id='spec' value='red' />").spectrum({
showPalette: true,
hideAfterPaletteSelect: true,
palette: [
["red", "green", "blue"]
]
});
el.spectrum("show");
el.spectrum("container").find(".sp-thumb-el:nth-child(1)").click();
ok(el.spectrum("container").hasClass('sp-hidden'), "palette is still hidden after color selection");
el.spectrum("destroy");
});
test( "Local Storage Is Limited ", function() {
var el = $("<input id='spec' value='red' />").spectrum({
localStorageKey: "spectrum.tests",
palette: [["#ff0", "#0ff"]],
maxSelectionSize: 3
});
el.spectrum("set", "#f00");
el.spectrum("set", "#e00");
el.spectrum("set", "#d00");
el.spectrum("set", "#c00");
el.spectrum("set", "#b00");
el.spectrum("set", "#a00");
equal (
localStorage["spectrum.tests"],
"rgb(204, 0, 0);rgb(187, 0, 0);rgb(170, 0, 0)",
"Local storage array has been limited"
);
el.spectrum("set", "#ff0");
el.spectrum("set", "#0ff");
equal (
localStorage["spectrum.tests"],
"rgb(204, 0, 0);rgb(187, 0, 0);rgb(170, 0, 0)",
"Local storage array did not get changed by selecting palette items"
);
el.spectrum("destroy");
});
module("Options");
test ("allowEmpty", function() {
var el = $("<input value='red' />").spectrum({
allowEmpty: true
});
el.spectrum("set", null);
ok(!el.spectrum("get"), "input[type] color does not allow null values");
el.spectrum("destroy");
el = $("<input value='red' />").spectrum();
el.spectrum("set", null);
ok(el.spectrum("get"), "input[type] color does not allow null values");
el.spectrum("destroy");
});
test ("clickoutFiresChange", function() {
var el = $("<input value='red' />").spectrum({
clickoutFiresChange: false
});
el.spectrum("show");
equal ( el.spectrum("get").toName(), "red", "Color is initialized");
el.spectrum("set", "orange");
equal ( el.spectrum("get").toName(), "orange", "Color is set");
$(document).click();
equal ( el.spectrum("get").toName(), "red", "Color is reverted after clicking 'cancel'");
el.spectrum("destroy");
// Try again with default behavior (clickoutFiresChange = true)
el = $("<input value='red' />").spectrum();
el.spectrum("show");
equal ( el.spectrum("get").toName(), "red", "Color is initialized");
el.spectrum("set", "orange");
equal ( el.spectrum("get").toName(), "orange", "Color is set");
$(document).click();
equal ( el.spectrum("get").toName(), "orange", "Color is changed after clicking out");
el.spectrum("destroy");
});
test ("replacerClassName", function() {
var el = $("<input />").appendTo("body").spectrum({
replacerClassName: "test"
});
ok (el.next(".sp-replacer").hasClass("test"), "Replacer class has been applied");
el.spectrum("destroy").remove();
});
test ("containerClassName", function() {
var el = $("<input />").appendTo("body").spectrum({
containerClassName: "test"
});
ok (el.spectrum("container").hasClass("test"), "Container class has been applied");
el.spectrum("destroy").remove();
});
test( "Options Can Be Set and Gotten Programmatically", function() {
var spec = $("<input id='spec' />").spectrum({
color: "#ECC",
flat: true,
showInput: true,
className: "full-spectrum",
showInitial: true,
showPalette: true,
showSelectionPalette: true,
maxPaletteSize: 10,
preferredFormat: "hex",
localStorageKey: "spectrum.example",
palette: [['red'], ['green']]
});
var allOptions = spec.spectrum("option");
equal ( allOptions.flat, true, "Fetching all options provides accurate value");
var singleOption = spec.spectrum("option", "className");
equal ( singleOption, "full-spectrum", "Fetching a single option returns that value");
spec.spectrum("option", "className", "changed");
singleOption = spec.spectrum("option", "className");
equal ( singleOption, "changed", "Changing an option then fetching it is updated");
var numPaletteElements = spec.spectrum("container").find(".sp-palette-row:not(.sp-palette-row-selection) .sp-thumb-el").length;
equal (numPaletteElements, 2, "Two palette elements to start");
spec.spectrum("option", "palette", [['red'], ['green'], ['blue']]);
var optPalette = spec.spectrum("option", "palette");
deepEqual (optPalette, [['red'], ['green'], ['blue']], "Changing an option then fetching it is updated");
numPaletteElements = spec.spectrum("container").find(".sp-palette-row:not(.sp-palette-row-selection) .sp-thumb-el").length;
equal (numPaletteElements, 3, "Three palette elements after updating");
var appendToDefault = $("<input />").spectrum({
});
var container = $("<div id='c' />").appendTo("body");
var appendToOther = $("<input />").spectrum({
appendTo: container
});
var appendToParent = $("<input />").appendTo("#c").spectrum({
appendTo: "parent"
});
var appendToOtherFlat = $("<input />").spectrum({
appendTo: container,
flat: true
});
equal ( appendToDefault.spectrum("container").parent()[0], document.body, "Appended to body by default");
equal ( appendToOther.spectrum("container").parent()[0], container[0], "Can be appended to another element");
equal ( appendToOtherFlat.spectrum("container").parent()[0], $(appendToOtherFlat).parent()[0], "Flat CANNOT be appended to another element, will be same as input");
equal ( appendToParent.spectrum("container").parent()[0], container[0], "Passing 'parent' to appendTo works as expected");
// Issue #70 - https://github.com/bgrins/spectrum/issues/70
equal (spec.spectrum("option", "showPalette"), true, "showPalette is true by default");
spec.spectrum("option", "showPalette", false);
equal (spec.spectrum("option", "showPalette"), false, "showPalette is false after setting showPalette");
spec.spectrum("option", "showPaletteOnly", true);
equal (spec.spectrum("option", "showPaletteOnly"), true, "showPaletteOnly is true after setting showPaletteOnly");
equal (spec.spectrum("option", "showPalette"), true, "showPalette is true after setting showPaletteOnly");
spec.spectrum("destroy");
appendToDefault.spectrum("destroy");
appendToOther.spectrum("destroy");
appendToOtherFlat.spectrum("destroy");
appendToParent.spectrum("destroy").remove();
delete window.localStorage["spectrum.example"];
container.remove();
});
test ("Show Input works as expected", function() {
var el = $("<input />").spectrum({
showInput: true,
color: "red"
});
var input = el.spectrum("container").find(".sp-input");
equal(input.val(), "red", "Input is set to color by default");
input.val("").trigger("change");
ok(input.hasClass("sp-validation-error"), "Input has validation error class after being emptied.");
input.val("red").trigger("change");
ok(!input.hasClass("sp-validation-error"), "Input does not have validation error class after being reset to original color.");
equal (el.spectrum("get").toHexString(), "#ff0000", "Color is still red");
el.spectrum("destroy");
});
test ("Toggle Picker Area button works as expected", function() {
var div = $("<div style='position:absolute; right:0; height:20px; width:150px'>").appendTo('body').show(),
el = $("<input />").appendTo(div);
el.spectrum({
showInput: true,
showPaletteOnly: true,
togglePaletteOnly: true,
color: "red"
});
var spectrum = el.spectrum("container").show(),
toggle = spectrum.find(".sp-palette-toggle"),
picker = spectrum.find(".sp-picker-container"),
palette = spectrum.find(".sp-palette-container");
// Open the Colorpicker
el.spectrum("show");
equal(picker.is(":hidden"), true, "The picker area is hidden by default.");
ok(spectrum.hasClass("sp-palette-only"), "The 'palette-only' class is enabled.");
// Click the Picker area Toggle button to show the Picker
toggle.click();
equal(picker.is(":hidden"), false, "After toggling, the picker area is visible.");
ok(!spectrum.hasClass("sp-palette-only"), "The 'palette-only' class is disabled.");
equal(Math.round(picker.offset().top), Math.round(palette.offset().top), "The picker area is next to the palette.");
// Click the toggle again to hide the picker
toggle.trigger("click");
equal(picker.is(":hidden"), true, "After toggling again, the picker area is hidden.");
ok(spectrum.hasClass("sp-palette-only"), "And the 'palette-only' class is enabled.");
// Cleanup
el.spectrum("hide");
el.spectrum("destroy");
el.remove();
div.remove();
});
test ("Tooltip is formatted based on preferred format", function() {
var el = $("<input />").spectrum({
showInput: true,
color: "red",
showPalette: true,
palette: [["red", "rgba(255, 255, 255, .5)", "rgb(0, 0, 255)"]]
});
el.spectrum("show");
function getTitlesString() {
return el.spectrum("container").find(".sp-thumb-el").map(function() {
return this.getAttribute("title");
}).toArray().join(" ");
}
equal (getTitlesString(), "rgb(255, 0, 0) rgba(255, 255, 255, 0.5) rgb(0, 0, 255)", "Titles use rgb format by default");
el.spectrum("option", "preferredFormat", "hex");
equal (getTitlesString(), "#ff0000 #ffffff #0000ff", "Titles are updated to hex");
equal (el.spectrum("get").toString(), "#ff0000", "Value's format is updated");
el.spectrum("option", "preferredFormat", "hex6");
equal (getTitlesString(), "#ff0000 #ffffff #0000ff", "Titles are updated to hex6");
equal (el.spectrum("get").toString(), "#ff0000", "Value's format is updated");
el.spectrum("option", "preferredFormat", "hex3");
equal (getTitlesString(), "#f00 #fff #00f", "Titles are updated to hex3");
equal (el.spectrum("get").toString(), "#f00", "Value's format is updated");
el.spectrum("option", "preferredFormat", "name");
equal (getTitlesString(), "red #ffffff blue", "Titles are updated to name");
equal (el.spectrum("get").toString(), "red", "Value's format is updated");
el.spectrum("option", "preferredFormat", "hsv");
equal (getTitlesString(), "hsv(0, 100%, 100%) hsva(0, 0%, 100%, 0.5) hsv(240, 100%, 100%)", "Titles are updated to hsv");
equal (el.spectrum("get").toString(), "hsv(0, 100%, 100%)", "Value's format is updated");
el.spectrum("option", "preferredFormat", "hsl");
equal (getTitlesString(), "hsl(0, 100%, 50%) hsla(0, 0%, 100%, 0.5) hsl(240, 100%, 50%)", "Titles are updated to hsl");
equal (el.spectrum("get").toString(), "hsl(0, 100%, 50%)", "Value's format is updated");
el.spectrum("option", "preferredFormat", "rgb");
equal (getTitlesString(), "rgb(255, 0, 0) rgba(255, 255, 255, 0.5) rgb(0, 0, 255)", "Titles are updated to rgb");
equal (el.spectrum("get").toString(), "rgb(255, 0, 0)", "Value's format is updated");
el.spectrum("destroy");
});
module("Methods");
test( "Methods work as described", function() {
var el = $("<input id='spec' />").spectrum();
// Method - show
el.spectrum("show");
ok (el.spectrum("container").is(":visible"), "Spectrum is visible");
// Method - hide
el.spectrum("hide");
ok (el.spectrum("container").not(":visible"), "Spectrum is no longer visible");
// Method - toggle
el.spectrum("toggle");
ok (el.spectrum("container").is(":visible"), "Spectrum is visible after toggle");
el.spectrum("toggle");
ok (el.spectrum("container").not(":visible"), "Spectrum is no longer visible after toggle");
// Method - set / get
el.spectrum("set", "orange");
var color = el.spectrum("get", "color");
ok (color.toHexString() == "#ffa500", "Color has been set and gotten as hex");
ok (color.toName() == "orange", "Color has been set and gotten as name");
ok (color.toHsvString() == "hsv(39, 100%, 100%)", "Color has been set and gotten as hsv");
ok (color.toRgbString() == "rgb(255, 165, 0)", "Color has been set and gotten as rgb");
ok (color.toHslString() == "hsl(39, 100%, 50%)", "Color has been set and gotten as hsl");
// Method - container
ok (el.spectrum("container").hasClass("sp-container"), "Container can be retrieved");
// Method - disable
el.spectrum("disable");
ok (el.is(":disabled") , "Can be disabled");
el.spectrum("show");
ok (el.not(":visible") , "Cannot show when disabled");
// Method - enable
el.spectrum("enable");
ok (!el.is(":disabled") , "Can be enabled");
// Method - reflow
el.spectrum("reflow");
// Method - throw exception when not existing
raises(function() {
el.spectrum("no method");
}, "Expecting exception to be thrown when calling with no method");
// Method - destroy
el.spectrum("destroy");
equal (el.spectrum("container"), el , "No usage after being destroyed");
equal (el.spectrum("get"), el , "No usage after being destroyed");
el.spectrum("destroy");
});
// https://github.com/bgrins/spectrum/issues/97
test( "Change events fire as described" , function() {
expect(0);
var input = $("<input />");
input.on("change", function() {
ok(false, "Change should not be fired inside of input change");
});
input.spectrum({
color: "red",
change: function() {
ok (false, "Change should not be fired inside of spectrum callback");
}
});
input.spectrum("set", "orange");
});
test("The selectedPalette should be updated in each spectrum instance, when storageKeys are identical.", function () {
delete window.localStorage["spectrum.tests"];
var colorToChoose = "rgb(0, 244, 0)";
var firstEl = $("<input id='firstEl' value='red' />").spectrum({
showPalette: true,
localStorageKey: "spectrum.tests"
});
var secondEl = $("<input id='secondEl' value='blue' />").spectrum({
showPalette: true,
localStorageKey: "spectrum.tests"
});
firstEl.spectrum("set", colorToChoose);
secondEl.spectrum("toggle");
var selectedColor = secondEl.spectrum("container").find('span[data-color="' + colorToChoose + '"]');
ok(selectedColor.length > 0, "Selected color is also shown in the others instance's palette.");
delete window.localStorage["spectrum.tests"];
firstEl.spectrum("destroy");
secondEl.spectrum("destroy");
});
test("The selectedPalette should not be updated in spectrum instances that have different storageKeys.", function () {
delete window.localStorage["spectrum.test_1"];
delete window.localStorage["spectrum.test_2"];
var colorToChoose = "rgb(0, 244, 0)";
var firstEl = $("<input id='firstEl' value='red' />").spectrum({
showPalette: true,
localStorageKey: "spectrum.test_1"
});
var secondEl = $("<input id='secondEl' value='blue' />").spectrum({
showPalette: true,
localStorageKey: "spectrum.test_2"
});
firstEl.spectrum("set", colorToChoose);
secondEl.spectrum("toggle");
var selectedColor = secondEl.spectrum("container").find('span[data-color="' + colorToChoose + '"]');
ok(selectedColor.length === 0, "Selected color should not be available in instances with other storageKey.");
firstEl.spectrum("destroy");
secondEl.spectrum("destroy");
delete window.localStorage["spectrum.test_1"];
delete window.localStorage["spectrum.test_2"];
});
test( "Cancelling reverts color", function() {
var el = $("<input value='red' />").spectrum();
el.spectrum("show");
equal ( el.spectrum("get").toName(), "red", "Color is initialized");
el.spectrum("set", "orange");
equal ( el.spectrum("get").toName(), "orange", "Color is set");
el.spectrum("container").find(".sp-cancel").click();
equal ( el.spectrum("get").toName(), "red", "Color is reverted after clicking 'cancel'");
el.spectrum("destroy");
});
test( "Choosing updates the color", function() {
var el = $("<input value='red' />").spectrum();
el.spectrum("show");
equal ( el.spectrum("get").toName(), "red", "Color is initialized");
el.spectrum("set", "orange");
equal ( el.spectrum("get").toName(), "orange", "Color is set");
el.spectrum("container").find(".sp-choose").click();
equal ( el.spectrum("get").toName(), "orange", "Color is kept after clicking 'choose'");
el.spectrum("destroy");
});
test( "Custom offset", function() {
var el = $("<input value='red' />").spectrum();
el.spectrum("show");
deepEqual (el.spectrum("container").offset(), {top: 0, left: 0});
el.spectrum("hide");
el.spectrum("offset", {top: 10, left: 10});
el.spectrum("show");
deepEqual (el.spectrum("container").offset(), {top: 10, left: 10});
el.spectrum("hide");
el.spectrum("offset", null);
el.spectrum("show");
deepEqual (el.spectrum("container").offset(), {top: 0, left: 0});
el.spectrum("hide");
el.spectrum("destroy");
var el2 = $("<input value='red' />").spectrum({
offset: { top: 100, left: 100 }
});
el2.spectrum("show");
deepEqual (el2.spectrum("container").offset(), {top: 100, left: 100});
el2.spectrum("hide");
});