forked from bgrins/TinyColor
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.html
More file actions
Latest commit
124 lines (106 loc) · 3.87 KB
/
Copy pathplugin.html
File metadata and controls
124 lines (106 loc) · 3.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<!DOCTYPE html>
<html>
<head>
<metacharset='utf-8'>
<title>TinyColor - Fast, small color manipulation in JavaScript</title>
<linkrel="stylesheet" href="demo/demo.css" type="text/css" media="screen" />
<scripttype='text/javascript' src='demo/jquery-1.9.1.js'></script>
<scripttype='text/javascript' src='tinycolor.js'></script>
<scripttype='text/javascript' src='tinycolor.plugin.js'></script>
<scripttype='text/javascript'>
functioncolorChange(color){
vartiny=tinycolor.plugins.getLibraryColor(color);
if(!tiny.isValid())returnfalse;
vartheme=color.match(/([a-z0-9]+)[-.\s]/i)[1];
if(theme=="bootstrap")theme+=4;
varoutput=[
"hex:\t"+tiny.toHexString(),
"hex8:\t"+tiny.toHex8String(),
"rgb:\t"+tiny.toRgbString(),
"hsl:\t"+tiny.toHslString(),
"hsv:\t"+tiny.toHsvString(),
"hwb:\t"+tiny.toHwbString(),
"cmyk:\t"+tiny.toCmykString(),
"lab:\t"+tiny.toLabString(),
"name:\t"+(tiny.toName()||"none"),
"format:\t"+(tiny.getFormat()),
"format string:\t"+tiny.toString(),
].join("\n");
$("#code-output").text(output).css("border-color",tiny.toHexString());
}
functioncolorListToHTML(list){
varhtml='<table>',name;
for(varthemeinlist){
html+='<tr><th>'+theme+'</th><td>';
$.map(list[theme],function(i,e){
name=theme.toLowerCase().replace(//g,"")+" "+i;
html+='<span data-name="'+name+'" title="'+i+'" style="background:'+tinycolor.plugins.getLibraryColor(name).toHexString()+'"></span>';
});
html+='</td>';
}
html+="</table>";
$("#list-output").append(html);
}
$(function(){
$("#color").bind("keyup change",function(){
colorChange($(this).val());
});
colorChange("bootstrap4-danger");
$("#inputter a").click(function(){
vartext=$(this).text();
$("#color").val(text).trigger("change");
returnfalse;
});
$(document).on("click","#list-output span",function(e){
vartext=$(e.target).data("name")
$("#color").val(text).trigger("change");
returnfalse;
})
varallColors={
"Bootstrap 4": ["primary","success","info","warning","danger"],
"Flat UI": ["sunflower","amethyst","nephritis","alizarin","peterriver"],
"Material": ["red","blue","yellow","green","lime"],
"Metro UI": ["green","lightpurple","darkpurple","blue","red"],
}
colorListToHTML(allColors);
});
</script>
</head>
<body>
<divid="container">
<h1>TinyColor - Plugin</h1>
<h2>Fast, small color manipulation and conversion for JavaScript</h2>
<p>
<ahref="https://github.com/chingcm/TinyColor">TinyColor</a> is a micro framework for inputting colors and outputting colors as different formats.
Input is meant to be as permissive as possible.
</p>
<p>This plugin contains lists of colors, including colors used in Flat UI, Material, Metro UI.</p>
<h3>Usage Documentation</h3>
<p>Read the documentation on the <ahref='https://github.com/chingcm/TinyColor#plugin'>TinyColor project page</a> on github.</p>
<h3>Code</h3>
<p><ahref='docs/tinycolor.plugin.html'>View the annotated source code</a> or <ahref='https://github.com/chingcm/TinyColor/blob/master/tinycolor.plugin.js'>see the full source on github</a>.</p>
<h3>Demo</h3>
<divid='demo'>
<divid='inputter'>
<p>
Enter a color: <inputtype="text" placeholder="any color." id='color' />
</p>
<p>
Or try these:
<ahref="#">material blue</a>
<ahref="#">flatui emerald</a>
<ahref="#">bootstrap4 danger</a>
<ahref="#">metroui purple</a>
<ahref="#">flatui greensea 200</a>
</p>
<p>And I'll tell you what I know about it:</p>
</div>
<preid='code-output'></pre>
<h3>Sample of Colors</h3>
<divid='list-output'></div>
</div>
<h3>Credit</h3>
<p>Developed by Dem Ching.</p>
</div>
</body>
</html>