adminlte2-rails 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/README.md +19 -0
  4. data/lib/adminlte2/rails/version.rb +1 -1
  5. data/lib/generators/admin_lte_plugins/USAGE +28 -0
  6. data/lib/generators/admin_lte_plugins/admin_lte_plugins_generator.rb +100 -0
  7. data/lib/generators/admin_lte_plugins/templates/ChartJS/Chart.js +3457 -0
  8. data/lib/generators/admin_lte_plugins/templates/Sparkline/jquery.sparkline.js +3054 -0
  9. data/lib/generators/admin_lte_plugins/templates/bootstrap-slider/bootstrap-slider.js +1167 -0
  10. data/lib/generators/admin_lte_plugins/templates/bootstrap-slider/slider.css +169 -0
  11. data/lib/generators/admin_lte_plugins/templates/bootstrap-wysihtml5/bootstrap3-wysihtml5.css +102 -0
  12. data/lib/generators/admin_lte_plugins/templates/bootstrap-wysihtml5/bootstrap3-wysihtml5.js +350 -0
  13. data/lib/generators/admin_lte_plugins/templates/colorpicker/bootstrap-colorpicker.css +214 -0
  14. data/lib/generators/admin_lte_plugins/templates/colorpicker/bootstrap-colorpicker.js +949 -0
  15. data/lib/generators/admin_lte_plugins/templates/colorpicker/img/alpha-horizontal.png +0 -0
  16. data/lib/generators/admin_lte_plugins/templates/colorpicker/img/alpha.png +0 -0
  17. data/lib/generators/admin_lte_plugins/templates/colorpicker/img/hue-horizontal.png +0 -0
  18. data/lib/generators/admin_lte_plugins/templates/colorpicker/img/hue.png +0 -0
  19. data/lib/generators/admin_lte_plugins/templates/colorpicker/img/saturation.png +0 -0
  20. data/lib/generators/admin_lte_plugins/templates/datepicker/bootstrap-datepicker.js +1671 -0
  21. data/lib/generators/admin_lte_plugins/templates/datepicker/datepicker3.css +790 -0
  22. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.ar.js +15 -0
  23. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.az.js +12 -0
  24. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.bg.js +14 -0
  25. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.ca.js +14 -0
  26. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.cs.js +15 -0
  27. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.cy.js +14 -0
  28. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.da.js +15 -0
  29. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.de.js +17 -0
  30. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.el.js +13 -0
  31. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.es.js +14 -0
  32. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.et.js +18 -0
  33. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.fa.js +17 -0
  34. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.fi.js +16 -0
  35. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.fr.js +17 -0
  36. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.gl.js +11 -0
  37. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.he.js +15 -0
  38. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.hr.js +13 -0
  39. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.hu.js +16 -0
  40. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.id.js +15 -0
  41. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.is.js +14 -0
  42. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.it.js +17 -0
  43. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.ja.js +15 -0
  44. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.ka.js +17 -0
  45. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.kk.js +15 -0
  46. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.kr.js +13 -0
  47. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.lt.js +16 -0
  48. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.lv.js +16 -0
  49. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.mk.js +15 -0
  50. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.ms.js +14 -0
  51. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.nb.js +14 -0
  52. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.nl-BE.js +17 -0
  53. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.nl.js +14 -0
  54. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.no.js +16 -0
  55. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.pl.js +15 -0
  56. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.pt-BR.js +15 -0
  57. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.pt.js +16 -0
  58. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.ro.js +16 -0
  59. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.rs-latin.js +14 -0
  60. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.rs.js +14 -0
  61. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.ru.js +15 -0
  62. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.sk.js +15 -0
  63. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.sl.js +14 -0
  64. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.sq.js +15 -0
  65. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.sv.js +16 -0
  66. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.sw.js +15 -0
  67. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.th.js +14 -0
  68. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.tr.js +16 -0
  69. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.ua.js +15 -0
  70. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.vi.js +16 -0
  71. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.zh-CN.js +16 -0
  72. data/lib/generators/admin_lte_plugins/templates/datepicker/locales/bootstrap-datepicker.zh-TW.js +17 -0
  73. data/lib/generators/admin_lte_plugins/templates/daterangepicker/daterangepicker-bs3.css +245 -0
  74. data/lib/generators/admin_lte_plugins/templates/daterangepicker/daterangepicker.js +883 -0
  75. data/lib/generators/admin_lte_plugins/templates/fullcalendar/fullcalendar.css +977 -0
  76. data/lib/generators/admin_lte_plugins/templates/fullcalendar/fullcalendar.js +9732 -0
  77. data/lib/generators/admin_lte_plugins/templates/fullcalendar/fullcalendar.print.css +202 -0
  78. data/lib/generators/admin_lte_plugins/templates/jVectorMap/jquery-jvectormap-1.2.2.css +40 -0
  79. data/lib/generators/admin_lte_plugins/templates/jVectorMap/jquery-jvectormap-1.2.2.min.js +8 -0
  80. data/lib/generators/admin_lte_plugins/templates/jVectorMap/jquery-jvectormap-world-mill-en.js +1 -0
  81. data/lib/generators/admin_lte_plugins/templates/knob/jquery.knob.js +805 -0
  82. data/lib/generators/admin_lte_plugins/templates/morris/morris.css +2 -0
  83. data/lib/generators/admin_lte_plugins/templates/morris/morris.js +1892 -0
  84. data/lib/generators/admin_lte_plugins/templates/pace/pace.js +2 -0
  85. data/lib/generators/admin_lte_plugins/templates/timepicker/bootstrap-timepicker.css +121 -0
  86. data/lib/generators/admin_lte_plugins/templates/timepicker/bootstrap-timepicker.js +903 -0
  87. metadata +83 -1
@@ -0,0 +1,214 @@
1
+ /*!
2
+ * Bootstrap Colorpicker
3
+ * http://mjolnic.github.io/bootstrap-colorpicker/
4
+ *
5
+ * Originally written by (c) 2012 Stefan Petre
6
+ * Licensed under the Apache License v2.0
7
+ * http://www.apache.org/licenses/LICENSE-2.0.txt
8
+ *
9
+ */
10
+
11
+ .colorpicker-saturation {
12
+ float: left;
13
+ width: 100px;
14
+ height: 100px;
15
+ cursor: crosshair;
16
+ background-image: url("img/saturation.png");
17
+ }
18
+
19
+ .colorpicker-saturation i {
20
+ position: absolute;
21
+ top: 0;
22
+ left: 0;
23
+ display: block;
24
+ width: 5px;
25
+ height: 5px;
26
+ margin: -4px 0 0 -4px;
27
+ border: 1px solid #000;
28
+ -webkit-border-radius: 5px;
29
+ -moz-border-radius: 5px;
30
+ border-radius: 5px;
31
+ }
32
+
33
+ .colorpicker-saturation i b {
34
+ display: block;
35
+ width: 5px;
36
+ height: 5px;
37
+ border: 1px solid #fff;
38
+ -webkit-border-radius: 5px;
39
+ -moz-border-radius: 5px;
40
+ border-radius: 5px;
41
+ }
42
+
43
+ .colorpicker-hue,
44
+ .colorpicker-alpha {
45
+ float: left;
46
+ width: 15px;
47
+ height: 100px;
48
+ margin-bottom: 4px;
49
+ margin-left: 4px;
50
+ cursor: row-resize;
51
+ }
52
+
53
+ .colorpicker-hue i,
54
+ .colorpicker-alpha i {
55
+ position: absolute;
56
+ top: 0;
57
+ left: 0;
58
+ display: block;
59
+ width: 100%;
60
+ height: 1px;
61
+ margin-top: -1px;
62
+ background: #000;
63
+ border-top: 1px solid #fff;
64
+ }
65
+
66
+ .colorpicker-hue {
67
+ background-image: url("img/hue.png");
68
+ }
69
+
70
+ .colorpicker-alpha {
71
+ display: none;
72
+ background-image: url("img/alpha.png");
73
+ }
74
+
75
+ .colorpicker {
76
+ top: 0;
77
+ left: 0;
78
+ z-index: 2500;
79
+ min-width: 130px;
80
+ padding: 4px;
81
+ margin-top: 1px;
82
+ -webkit-border-radius: 4px;
83
+ -moz-border-radius: 4px;
84
+ border-radius: 4px;
85
+ *zoom: 1;
86
+ }
87
+
88
+ .colorpicker:before,
89
+ .colorpicker:after {
90
+ display: table;
91
+ line-height: 0;
92
+ content: "";
93
+ }
94
+
95
+ .colorpicker:after {
96
+ clear: both;
97
+ }
98
+
99
+ .colorpicker:before {
100
+ position: absolute;
101
+ top: -7px;
102
+ left: 6px;
103
+ display: inline-block;
104
+ border-right: 7px solid transparent;
105
+ border-bottom: 7px solid #ccc;
106
+ border-left: 7px solid transparent;
107
+ border-bottom-color: rgba(0, 0, 0, 0.2);
108
+ content: '';
109
+ }
110
+
111
+ .colorpicker:after {
112
+ position: absolute;
113
+ top: -6px;
114
+ left: 7px;
115
+ display: inline-block;
116
+ border-right: 6px solid transparent;
117
+ border-bottom: 6px solid #ffffff;
118
+ border-left: 6px solid transparent;
119
+ content: '';
120
+ }
121
+
122
+ .colorpicker div {
123
+ position: relative;
124
+ }
125
+
126
+ .colorpicker.colorpicker-with-alpha {
127
+ min-width: 140px;
128
+ }
129
+
130
+ .colorpicker.colorpicker-with-alpha .colorpicker-alpha {
131
+ display: block;
132
+ }
133
+
134
+ .colorpicker-color {
135
+ height: 10px;
136
+ margin-top: 5px;
137
+ clear: both;
138
+ background-image: url("img/alpha.png");
139
+ background-position: 0 100%;
140
+ }
141
+
142
+ .colorpicker-color div {
143
+ height: 10px;
144
+ }
145
+
146
+ .colorpicker-element .input-group-addon i {
147
+ display: block;
148
+ width: 16px;
149
+ height: 16px;
150
+ cursor: pointer;
151
+ }
152
+
153
+ .colorpicker.colorpicker-inline {
154
+ position: relative;
155
+ display: inline-block;
156
+ float: none;
157
+ }
158
+
159
+ .colorpicker.colorpicker-horizontal {
160
+ width: 110px;
161
+ height: auto;
162
+ min-width: 110px;
163
+ }
164
+
165
+ .colorpicker.colorpicker-horizontal .colorpicker-saturation {
166
+ margin-bottom: 4px;
167
+ }
168
+
169
+ .colorpicker.colorpicker-horizontal .colorpicker-color {
170
+ width: 100px;
171
+ }
172
+
173
+ .colorpicker.colorpicker-horizontal .colorpicker-hue,
174
+ .colorpicker.colorpicker-horizontal .colorpicker-alpha {
175
+ float: left;
176
+ width: 100px;
177
+ height: 15px;
178
+ margin-bottom: 4px;
179
+ margin-left: 0;
180
+ cursor: col-resize;
181
+ }
182
+
183
+ .colorpicker.colorpicker-horizontal .colorpicker-hue i,
184
+ .colorpicker.colorpicker-horizontal .colorpicker-alpha i {
185
+ position: absolute;
186
+ top: 0;
187
+ left: 0;
188
+ display: block;
189
+ width: 1px;
190
+ height: 15px;
191
+ margin-top: 0;
192
+ background: #ffffff;
193
+ border: none;
194
+ }
195
+
196
+ .colorpicker.colorpicker-horizontal .colorpicker-hue {
197
+ background-image: url("img/hue-horizontal.png");
198
+ }
199
+
200
+ .colorpicker.colorpicker-horizontal .colorpicker-alpha {
201
+ background-image: url("img/alpha-horizontal.png");
202
+ }
203
+
204
+ .colorpicker.colorpicker-hidden {
205
+ display: none;
206
+ }
207
+
208
+ .colorpicker.colorpicker-visible {
209
+ display: block;
210
+ }
211
+
212
+ .colorpicker-inline.colorpicker-visible {
213
+ display: inline-block;
214
+ }
@@ -0,0 +1,949 @@
1
+ /*!
2
+ * Bootstrap Colorpicker
3
+ * http://mjolnic.github.io/bootstrap-colorpicker/
4
+ *
5
+ * Originally written by (c) 2012 Stefan Petre
6
+ * Licensed under the Apache License v2.0
7
+ * http://www.apache.org/licenses/LICENSE-2.0.txt
8
+ *
9
+ * @todo Update DOCS
10
+ */
11
+ (function($) {
12
+ 'use strict';
13
+
14
+ // Color object
15
+ var Color = function(val) {
16
+ this.value = {
17
+ h: 0,
18
+ s: 0,
19
+ b: 0,
20
+ a: 1
21
+ };
22
+ this.origFormat = null; // original string format
23
+ if (val) {
24
+ if (val.toLowerCase !== undefined) {
25
+ this.setColor(val);
26
+ } else if (val.h !== undefined) {
27
+ this.value = val;
28
+ }
29
+ }
30
+ };
31
+
32
+ Color.prototype = {
33
+ constructor: Color,
34
+ _sanitizeNumber: function(val) {
35
+ if (typeof val === 'number') {
36
+ return val;
37
+ }
38
+ if (isNaN(val) || (val === null) || (val === '') || (val === undefined)) {
39
+ return 1;
40
+ }
41
+ if (val.toLowerCase !== undefined) {
42
+ return parseFloat(val);
43
+ }
44
+ return 1;
45
+ },
46
+ //parse a string to HSB
47
+ setColor: function(strVal) {
48
+ strVal = strVal.toLowerCase();
49
+ this.value = this.stringToHSB(strVal) ||  {
50
+ h: 0,
51
+ s: 0,
52
+ b: 0,
53
+ a: 1
54
+ };
55
+ },
56
+ stringToHSB: function(strVal) {
57
+ strVal = strVal.toLowerCase();
58
+ var that = this,
59
+ result = false;
60
+ $.each(this.stringParsers, function(i, parser) {
61
+ var match = parser.re.exec(strVal),
62
+ values = match && parser.parse.apply(that, [match]),
63
+ format = parser.format || 'rgba';
64
+ if (values) {
65
+ if (format.match(/hsla?/)) {
66
+ result = that.RGBtoHSB.apply(that, that.HSLtoRGB.apply(that, values));
67
+ } else {
68
+ result = that.RGBtoHSB.apply(that, values);
69
+ }
70
+ that.origFormat = format;
71
+ return false;
72
+ }
73
+ return true;
74
+ });
75
+ return result;
76
+ },
77
+ setHue: function(h) {
78
+ this.value.h = 1 - h;
79
+ },
80
+ setSaturation: function(s) {
81
+ this.value.s = s;
82
+ },
83
+ setBrightness: function(b) {
84
+ this.value.b = 1 - b;
85
+ },
86
+ setAlpha: function(a) {
87
+ this.value.a = parseInt((1 - a) * 100, 10) / 100;
88
+ },
89
+ toRGB: function(h, s, v, a) {
90
+ h = h || this.value.h;
91
+ s = s || this.value.s;
92
+ v = v || this.value.b;
93
+ a = a || this.value.a;
94
+
95
+ var r, g, b, i, f, p, q, t;
96
+ if (h && s === undefined && v === undefined) {
97
+ s = h.s, v = h.v, h = h.h;
98
+ }
99
+ i = Math.floor(h * 6);
100
+ f = h * 6 - i;
101
+ p = v * (1 - s);
102
+ q = v * (1 - f * s);
103
+ t = v * (1 - (1 - f) * s);
104
+ switch (i % 6) {
105
+ case 0:
106
+ r = v, g = t, b = p;
107
+ break;
108
+ case 1:
109
+ r = q, g = v, b = p;
110
+ break;
111
+ case 2:
112
+ r = p, g = v, b = t;
113
+ break;
114
+ case 3:
115
+ r = p, g = q, b = v;
116
+ break;
117
+ case 4:
118
+ r = t, g = p, b = v;
119
+ break;
120
+ case 5:
121
+ r = v, g = p, b = q;
122
+ break;
123
+ }
124
+ return {
125
+ r: Math.floor(r * 255),
126
+ g: Math.floor(g * 255),
127
+ b: Math.floor(b * 255),
128
+ a: a
129
+ };
130
+ },
131
+ toHex: function(h, s, b, a) {
132
+ var rgb = this.toRGB(h, s, b, a);
133
+ return '#' + ((1 << 24) | (parseInt(rgb.r) << 16) | (parseInt(rgb.g) << 8) | parseInt(rgb.b)).toString(16).substr(1);
134
+ },
135
+ toHSL: function(h, s, b, a) {
136
+ h = h || this.value.h;
137
+ s = s || this.value.s;
138
+ b = b || this.value.b;
139
+ a = a || this.value.a;
140
+
141
+ var H = h,
142
+ L = (2 - s) * b,
143
+ S = s * b;
144
+ if (L > 0 && L <= 1) {
145
+ S /= L;
146
+ } else {
147
+ S /= 2 - L;
148
+ }
149
+ L /= 2;
150
+ if (S > 1) {
151
+ S = 1;
152
+ }
153
+ return {
154
+ h: H,
155
+ s: S,
156
+ l: L,
157
+ a: a
158
+ };
159
+ },
160
+ RGBtoHSB: function(r, g, b, a) {
161
+ r /= 255;
162
+ g /= 255;
163
+ b /= 255;
164
+
165
+ var H, S, V, C;
166
+ V = Math.max(r, g, b);
167
+ C = V - Math.min(r, g, b);
168
+ H = (C === 0 ? null :
169
+ V === r ? (g - b) / C :
170
+ V === g ? (b - r) / C + 2 :
171
+ (r - g) / C + 4
172
+ );
173
+ H = ((H + 360) % 6) * 60 / 360;
174
+ S = C === 0 ? 0 : C / V;
175
+ return {
176
+ h: this._sanitizeNumber(H),
177
+ s: S,
178
+ b: V,
179
+ a: this._sanitizeNumber(a)
180
+ };
181
+ },
182
+ HueToRGB: function(p, q, h) {
183
+ if (h < 0) {
184
+ h += 1;
185
+ } else if (h > 1) {
186
+ h -= 1;
187
+ }
188
+ if ((h * 6) < 1) {
189
+ return p + (q - p) * h * 6;
190
+ } else if ((h * 2) < 1) {
191
+ return q;
192
+ } else if ((h * 3) < 2) {
193
+ return p + (q - p) * ((2 / 3) - h) * 6;
194
+ } else {
195
+ return p;
196
+ }
197
+ },
198
+ HSLtoRGB: function(h, s, l, a) {
199
+ if (s < 0) {
200
+ s = 0;
201
+ }
202
+ var q;
203
+ if (l <= 0.5) {
204
+ q = l * (1 + s);
205
+ } else {
206
+ q = l + s - (l * s);
207
+ }
208
+
209
+ var p = 2 * l - q;
210
+
211
+ var tr = h + (1 / 3);
212
+ var tg = h;
213
+ var tb = h - (1 / 3);
214
+
215
+ var r = Math.round(this.HueToRGB(p, q, tr) * 255);
216
+ var g = Math.round(this.HueToRGB(p, q, tg) * 255);
217
+ var b = Math.round(this.HueToRGB(p, q, tb) * 255);
218
+ return [r, g, b, this._sanitizeNumber(a)];
219
+ },
220
+ toString: function(format) {
221
+ format = format ||  'rgba';
222
+ switch (format) {
223
+ case 'rgb':
224
+ {
225
+ var rgb = this.toRGB();
226
+ return 'rgb(' + rgb.r + ',' + rgb.g + ',' + rgb.b + ')';
227
+ }
228
+ break;
229
+ case 'rgba':
230
+ {
231
+ var rgb = this.toRGB();
232
+ return 'rgba(' + rgb.r + ',' + rgb.g + ',' + rgb.b + ',' + rgb.a + ')';
233
+ }
234
+ break;
235
+ case 'hsl':
236
+ {
237
+ var hsl = this.toHSL();
238
+ return 'hsl(' + Math.round(hsl.h * 360) + ',' + Math.round(hsl.s * 100) + '%,' + Math.round(hsl.l * 100) + '%)';
239
+ }
240
+ break;
241
+ case 'hsla':
242
+ {
243
+ var hsl = this.toHSL();
244
+ return 'hsla(' + Math.round(hsl.h * 360) + ',' + Math.round(hsl.s * 100) + '%,' + Math.round(hsl.l * 100) + '%,' + hsl.a + ')';
245
+ }
246
+ break;
247
+ case 'hex':
248
+ {
249
+ return this.toHex();
250
+ }
251
+ break;
252
+ default:
253
+ {
254
+ return false;
255
+ }
256
+ break;
257
+ }
258
+ },
259
+ // a set of RE's that can match strings and generate color tuples.
260
+ // from John Resig color plugin
261
+ // https://github.com/jquery/jquery-color/
262
+ stringParsers: [{
263
+ re: /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/,
264
+ format: 'hex',
265
+ parse: function(execResult) {
266
+ return [
267
+ parseInt(execResult[1], 16),
268
+ parseInt(execResult[2], 16),
269
+ parseInt(execResult[3], 16),
270
+ 1
271
+ ];
272
+ }
273
+ }, {
274
+ re: /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/,
275
+ format: 'hex',
276
+ parse: function(execResult) {
277
+ return [
278
+ parseInt(execResult[1] + execResult[1], 16),
279
+ parseInt(execResult[2] + execResult[2], 16),
280
+ parseInt(execResult[3] + execResult[3], 16),
281
+ 1
282
+ ];
283
+ }
284
+ }, {
285
+ re: /rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*?\)/,
286
+ format: 'rgb',
287
+ parse: function(execResult) {
288
+ return [
289
+ execResult[1],
290
+ execResult[2],
291
+ execResult[3],
292
+ 1
293
+ ];
294
+ }
295
+ }, {
296
+ re: /rgb\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*?\)/,
297
+ format: 'rgb',
298
+ parse: function(execResult) {
299
+ return [
300
+ 2.55 * execResult[1],
301
+ 2.55 * execResult[2],
302
+ 2.55 * execResult[3],
303
+ 1
304
+ ];
305
+ }
306
+ }, {
307
+ re: /rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
308
+ format: 'rgba',
309
+ parse: function(execResult) {
310
+ return [
311
+ execResult[1],
312
+ execResult[2],
313
+ execResult[3],
314
+ execResult[4]
315
+ ];
316
+ }
317
+ }, {
318
+ re: /rgba\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
319
+ format: 'rgba',
320
+ parse: function(execResult) {
321
+ return [
322
+ 2.55 * execResult[1],
323
+ 2.55 * execResult[2],
324
+ 2.55 * execResult[3],
325
+ execResult[4]
326
+ ];
327
+ }
328
+ }, {
329
+ re: /hsl\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*?\)/,
330
+ format: 'hsl',
331
+ parse: function(execResult) {
332
+ return [
333
+ execResult[1] / 360,
334
+ execResult[2] / 100,
335
+ execResult[3] / 100,
336
+ execResult[4]
337
+ ];
338
+ }
339
+ }, {
340
+ re: /hsla\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
341
+ format: 'hsla',
342
+ parse: function(execResult) {
343
+ return [
344
+ execResult[1] / 360,
345
+ execResult[2] / 100,
346
+ execResult[3] / 100,
347
+ execResult[4]
348
+ ];
349
+ }
350
+ }, {
351
+ //predefined color name
352
+ re: /^([a-z]{3,})$/,
353
+ format: 'alias',
354
+ parse: function(execResult) {
355
+ var hexval = this.colorNameToHex(execResult[0]) ||  '#000000';
356
+ var match = this.stringParsers[0].re.exec(hexval),
357
+ values = match && this.stringParsers[0].parse.apply(this, [match]);
358
+ return values;
359
+ }
360
+ }],
361
+ colorNameToHex: function(name) {
362
+ // 140 predefined colors from the HTML Colors spec
363
+ var colors = {
364
+ "aliceblue": "#f0f8ff",
365
+ "antiquewhite": "#faebd7",
366
+ "aqua": "#00ffff",
367
+ "aquamarine": "#7fffd4",
368
+ "azure": "#f0ffff",
369
+ "beige": "#f5f5dc",
370
+ "bisque": "#ffe4c4",
371
+ "black": "#000000",
372
+ "blanchedalmond": "#ffebcd",
373
+ "blue": "#0000ff",
374
+ "blueviolet": "#8a2be2",
375
+ "brown": "#a52a2a",
376
+ "burlywood": "#deb887",
377
+ "cadetblue": "#5f9ea0",
378
+ "chartreuse": "#7fff00",
379
+ "chocolate": "#d2691e",
380
+ "coral": "#ff7f50",
381
+ "cornflowerblue": "#6495ed",
382
+ "cornsilk": "#fff8dc",
383
+ "crimson": "#dc143c",
384
+ "cyan": "#00ffff",
385
+ "darkblue": "#00008b",
386
+ "darkcyan": "#008b8b",
387
+ "darkgoldenrod": "#b8860b",
388
+ "darkgray": "#a9a9a9",
389
+ "darkgreen": "#006400",
390
+ "darkkhaki": "#bdb76b",
391
+ "darkmagenta": "#8b008b",
392
+ "darkolivegreen": "#556b2f",
393
+ "darkorange": "#ff8c00",
394
+ "darkorchid": "#9932cc",
395
+ "darkred": "#8b0000",
396
+ "darksalmon": "#e9967a",
397
+ "darkseagreen": "#8fbc8f",
398
+ "darkslateblue": "#483d8b",
399
+ "darkslategray": "#2f4f4f",
400
+ "darkturquoise": "#00ced1",
401
+ "darkviolet": "#9400d3",
402
+ "deeppink": "#ff1493",
403
+ "deepskyblue": "#00bfff",
404
+ "dimgray": "#696969",
405
+ "dodgerblue": "#1e90ff",
406
+ "firebrick": "#b22222",
407
+ "floralwhite": "#fffaf0",
408
+ "forestgreen": "#228b22",
409
+ "fuchsia": "#ff00ff",
410
+ "gainsboro": "#dcdcdc",
411
+ "ghostwhite": "#f8f8ff",
412
+ "gold": "#ffd700",
413
+ "goldenrod": "#daa520",
414
+ "gray": "#808080",
415
+ "green": "#008000",
416
+ "greenyellow": "#adff2f",
417
+ "honeydew": "#f0fff0",
418
+ "hotpink": "#ff69b4",
419
+ "indianred ": "#cd5c5c",
420
+ "indigo ": "#4b0082",
421
+ "ivory": "#fffff0",
422
+ "khaki": "#f0e68c",
423
+ "lavender": "#e6e6fa",
424
+ "lavenderblush": "#fff0f5",
425
+ "lawngreen": "#7cfc00",
426
+ "lemonchiffon": "#fffacd",
427
+ "lightblue": "#add8e6",
428
+ "lightcoral": "#f08080",
429
+ "lightcyan": "#e0ffff",
430
+ "lightgoldenrodyellow": "#fafad2",
431
+ "lightgrey": "#d3d3d3",
432
+ "lightgreen": "#90ee90",
433
+ "lightpink": "#ffb6c1",
434
+ "lightsalmon": "#ffa07a",
435
+ "lightseagreen": "#20b2aa",
436
+ "lightskyblue": "#87cefa",
437
+ "lightslategray": "#778899",
438
+ "lightsteelblue": "#b0c4de",
439
+ "lightyellow": "#ffffe0",
440
+ "lime": "#00ff00",
441
+ "limegreen": "#32cd32",
442
+ "linen": "#faf0e6",
443
+ "magenta": "#ff00ff",
444
+ "maroon": "#800000",
445
+ "mediumaquamarine": "#66cdaa",
446
+ "mediumblue": "#0000cd",
447
+ "mediumorchid": "#ba55d3",
448
+ "mediumpurple": "#9370d8",
449
+ "mediumseagreen": "#3cb371",
450
+ "mediumslateblue": "#7b68ee",
451
+ "mediumspringgreen": "#00fa9a",
452
+ "mediumturquoise": "#48d1cc",
453
+ "mediumvioletred": "#c71585",
454
+ "midnightblue": "#191970",
455
+ "mintcream": "#f5fffa",
456
+ "mistyrose": "#ffe4e1",
457
+ "moccasin": "#ffe4b5",
458
+ "navajowhite": "#ffdead",
459
+ "navy": "#000080",
460
+ "oldlace": "#fdf5e6",
461
+ "olive": "#808000",
462
+ "olivedrab": "#6b8e23",
463
+ "orange": "#ffa500",
464
+ "orangered": "#ff4500",
465
+ "orchid": "#da70d6",
466
+ "palegoldenrod": "#eee8aa",
467
+ "palegreen": "#98fb98",
468
+ "paleturquoise": "#afeeee",
469
+ "palevioletred": "#d87093",
470
+ "papayawhip": "#ffefd5",
471
+ "peachpuff": "#ffdab9",
472
+ "peru": "#cd853f",
473
+ "pink": "#ffc0cb",
474
+ "plum": "#dda0dd",
475
+ "powderblue": "#b0e0e6",
476
+ "purple": "#800080",
477
+ "red": "#ff0000",
478
+ "rosybrown": "#bc8f8f",
479
+ "royalblue": "#4169e1",
480
+ "saddlebrown": "#8b4513",
481
+ "salmon": "#fa8072",
482
+ "sandybrown": "#f4a460",
483
+ "seagreen": "#2e8b57",
484
+ "seashell": "#fff5ee",
485
+ "sienna": "#a0522d",
486
+ "silver": "#c0c0c0",
487
+ "skyblue": "#87ceeb",
488
+ "slateblue": "#6a5acd",
489
+ "slategray": "#708090",
490
+ "snow": "#fffafa",
491
+ "springgreen": "#00ff7f",
492
+ "steelblue": "#4682b4",
493
+ "tan": "#d2b48c",
494
+ "teal": "#008080",
495
+ "thistle": "#d8bfd8",
496
+ "tomato": "#ff6347",
497
+ "turquoise": "#40e0d0",
498
+ "violet": "#ee82ee",
499
+ "wheat": "#f5deb3",
500
+ "white": "#ffffff",
501
+ "whitesmoke": "#f5f5f5",
502
+ "yellow": "#ffff00",
503
+ "yellowgreen": "#9acd32"
504
+ };
505
+
506
+ if (typeof colors[name.toLowerCase()] !== 'undefined') {
507
+ return colors[name.toLowerCase()];
508
+ }
509
+ return false;
510
+ }
511
+ };
512
+
513
+
514
+ var defaults = {
515
+ horizontal: false, // horizontal mode layout ?
516
+ inline: false, //forces to show the colorpicker as an inline element
517
+ color: false, //forces a color
518
+ format: false, //forces a format
519
+ input: 'input', // children input selector
520
+ container: false, // container selector
521
+ component: '.add-on, .input-group-addon', // children component selector
522
+ sliders: {
523
+ saturation: {
524
+ maxLeft: 100,
525
+ maxTop: 100,
526
+ callLeft: 'setSaturation',
527
+ callTop: 'setBrightness'
528
+ },
529
+ hue: {
530
+ maxLeft: 0,
531
+ maxTop: 100,
532
+ callLeft: false,
533
+ callTop: 'setHue'
534
+ },
535
+ alpha: {
536
+ maxLeft: 0,
537
+ maxTop: 100,
538
+ callLeft: false,
539
+ callTop: 'setAlpha'
540
+ }
541
+ },
542
+ slidersHorz: {
543
+ saturation: {
544
+ maxLeft: 100,
545
+ maxTop: 100,
546
+ callLeft: 'setSaturation',
547
+ callTop: 'setBrightness'
548
+ },
549
+ hue: {
550
+ maxLeft: 100,
551
+ maxTop: 0,
552
+ callLeft: 'setHue',
553
+ callTop: false
554
+ },
555
+ alpha: {
556
+ maxLeft: 100,
557
+ maxTop: 0,
558
+ callLeft: 'setAlpha',
559
+ callTop: false
560
+ }
561
+ },
562
+ template: '<div class="colorpicker dropdown-menu">' +
563
+ '<div class="colorpicker-saturation"><i><b></b></i></div>' +
564
+ '<div class="colorpicker-hue"><i></i></div>' +
565
+ '<div class="colorpicker-alpha"><i></i></div>' +
566
+ '<div class="colorpicker-color"><div /></div>' +
567
+ '</div>'
568
+ };
569
+
570
+ var Colorpicker = function(element, options) {
571
+ this.element = $(element).addClass('colorpicker-element');
572
+ this.options = $.extend({}, defaults, this.element.data(), options);
573
+ this.component = this.options.component;
574
+ this.component = (this.component !== false) ? this.element.find(this.component) : false;
575
+ if (this.component && (this.component.length === 0)) {
576
+ this.component = false;
577
+ }
578
+ this.container = (this.options.container === true) ? this.element : this.options.container;
579
+ this.container = (this.container !== false) ? $(this.container) : false;
580
+
581
+ // Is the element an input? Should we search inside for any input?
582
+ this.input = this.element.is('input') ? this.element : (this.options.input ?
583
+ this.element.find(this.options.input) : false);
584
+ if (this.input && (this.input.length === 0)) {
585
+ this.input = false;
586
+ }
587
+ // Set HSB color
588
+ this.color = new Color(this.options.color !== false ? this.options.color : this.getValue());
589
+ this.format = this.options.format !== false ? this.options.format : this.color.origFormat;
590
+
591
+ // Setup picker
592
+ this.picker = $(this.options.template);
593
+ if (this.options.inline) {
594
+ this.picker.addClass('colorpicker-inline colorpicker-visible');
595
+ } else {
596
+ this.picker.addClass('colorpicker-hidden');
597
+ }
598
+ if (this.options.horizontal) {
599
+ this.picker.addClass('colorpicker-horizontal');
600
+ }
601
+ if (this.format === 'rgba' || this.format === 'hsla') {
602
+ this.picker.addClass('colorpicker-with-alpha');
603
+ }
604
+ this.picker.on('mousedown.colorpicker', $.proxy(this.mousedown, this));
605
+ this.picker.appendTo(this.container ? this.container : $('body'));
606
+
607
+ // Bind events
608
+ if (this.input !== false) {
609
+ this.input.on({
610
+ 'keyup.colorpicker': $.proxy(this.keyup, this)
611
+ });
612
+ if (this.component === false) {
613
+ this.element.on({
614
+ 'focus.colorpicker': $.proxy(this.show, this)
615
+ });
616
+ }
617
+ if (this.options.inline === false) {
618
+ this.element.on({
619
+ 'focusout.colorpicker': $.proxy(this.hide, this)
620
+ });
621
+ }
622
+ }
623
+
624
+ if (this.component !== false) {
625
+ this.component.on({
626
+ 'click.colorpicker': $.proxy(this.show, this)
627
+ });
628
+ }
629
+
630
+ if ((this.input === false) && (this.component === false)) {
631
+ this.element.on({
632
+ 'click.colorpicker': $.proxy(this.show, this)
633
+ });
634
+ }
635
+ this.update();
636
+
637
+ $($.proxy(function() {
638
+ this.element.trigger('create');
639
+ }, this));
640
+ };
641
+
642
+ Colorpicker.version = '2.0.0-beta';
643
+
644
+ Colorpicker.Color = Color;
645
+
646
+ Colorpicker.prototype = {
647
+ constructor: Colorpicker,
648
+ destroy: function() {
649
+ this.picker.remove();
650
+ this.element.removeData('colorpicker').off('.colorpicker');
651
+ if (this.input !== false) {
652
+ this.input.off('.colorpicker');
653
+ }
654
+ if (this.component !== false) {
655
+ this.component.off('.colorpicker');
656
+ }
657
+ this.element.removeClass('colorpicker-element');
658
+ this.element.trigger({
659
+ type: 'destroy'
660
+ });
661
+ },
662
+ reposition: function() {
663
+ if (this.options.inline !== false) {
664
+ return false;
665
+ }
666
+ var offset = this.component ? this.component.offset() : this.element.offset();
667
+ this.picker.css({
668
+ top: offset.top + (this.component ? this.component.outerHeight() : this.element.outerHeight()),
669
+ left: offset.left
670
+ });
671
+ },
672
+ show: function(e) {
673
+ if (this.isDisabled()) {
674
+ return false;
675
+ }
676
+ this.picker.addClass('colorpicker-visible').removeClass('colorpicker-hidden');
677
+ this.reposition();
678
+ $(window).on('resize.colorpicker', $.proxy(this.reposition, this));
679
+ if (!this.hasInput() && e) {
680
+ if (e.stopPropagation && e.preventDefault) {
681
+ e.stopPropagation();
682
+ e.preventDefault();
683
+ }
684
+ }
685
+ if (this.options.inline === false) {
686
+ $(window.document).on({
687
+ 'mousedown.colorpicker': $.proxy(this.hide, this)
688
+ });
689
+ }
690
+ this.element.trigger({
691
+ type: 'showPicker',
692
+ color: this.color
693
+ });
694
+ },
695
+ hide: function() {
696
+ this.picker.addClass('colorpicker-hidden').removeClass('colorpicker-visible');
697
+ $(window).off('resize.colorpicker', this.reposition);
698
+ $(document).off({
699
+ 'mousedown.colorpicker': this.hide
700
+ });
701
+ this.update();
702
+ this.element.trigger({
703
+ type: 'hidePicker',
704
+ color: this.color
705
+ });
706
+ },
707
+ updateData: function(val) {
708
+ val = val ||  this.color.toString(this.format);
709
+ this.element.data('color', val);
710
+ return val;
711
+ },
712
+ updateInput: function(val) {
713
+ val = val ||  this.color.toString(this.format);
714
+ if (this.input !== false) {
715
+ this.input.prop('value', val);
716
+ }
717
+ return val;
718
+ },
719
+ updatePicker: function(val) {
720
+ if (val !== undefined) {
721
+ this.color = new Color(val);
722
+ }
723
+ var sl = (this.options.horizontal === false) ? this.options.sliders : this.options.slidersHorz;
724
+ var icns = this.picker.find('i');
725
+ if (icns.length === 0) {
726
+ return;
727
+ }
728
+ if (this.options.horizontal === false) {
729
+ sl = this.options.sliders;
730
+ icns.eq(1).css('top', sl.hue.maxTop * (1 - this.color.value.h)).end()
731
+ .eq(2).css('top', sl.alpha.maxTop * (1 - this.color.value.a));
732
+ } else {
733
+ sl = this.options.slidersHorz;
734
+ icns.eq(1).css('left', sl.hue.maxLeft * (1 - this.color.value.h)).end()
735
+ .eq(2).css('left', sl.alpha.maxLeft * (1 - this.color.value.a));
736
+ }
737
+ icns.eq(0).css({
738
+ 'top': sl.saturation.maxTop - this.color.value.b * sl.saturation.maxTop,
739
+ 'left': this.color.value.s * sl.saturation.maxLeft
740
+ });
741
+ this.picker.find('.colorpicker-saturation').css('backgroundColor', this.color.toHex(this.color.value.h, 1, 1, 1));
742
+ this.picker.find('.colorpicker-alpha').css('backgroundColor', this.color.toHex());
743
+ this.picker.find('.colorpicker-color, .colorpicker-color div').css('backgroundColor', this.color.toString(this.format));
744
+ return val;
745
+ },
746
+ updateComponent: function(val) {
747
+ val = val ||  this.color.toString(this.format);
748
+ if (this.component !== false) {
749
+ var icn = this.component.find('i').eq(0);
750
+ if (icn.length > 0) {
751
+ icn.css({
752
+ 'backgroundColor': val
753
+ });
754
+ } else {
755
+ this.component.css({
756
+ 'backgroundColor': val
757
+ });
758
+ }
759
+ }
760
+ return val;
761
+ },
762
+ update: function(force) {
763
+ var val = this.updateComponent();
764
+ if ((this.getValue(false) !== false) || (force === true)) {
765
+ // Update input/data only if the current value is not blank
766
+ this.updateInput(val);
767
+ this.updateData(val);
768
+ }
769
+ this.updatePicker();
770
+ return val;
771
+
772
+ },
773
+ setValue: function(val) { // set color manually
774
+ this.color = new Color(val);
775
+ this.update();
776
+ this.element.trigger({
777
+ type: 'changeColor',
778
+ color: this.color,
779
+ value: val
780
+ });
781
+ },
782
+ getValue: function(defaultValue) {
783
+ defaultValue = (defaultValue === undefined) ? '#000000' : defaultValue;
784
+ var val;
785
+ if (this.hasInput()) {
786
+ val = this.input.val();
787
+ } else {
788
+ val = this.element.data('color');
789
+ }
790
+ if ((val === undefined) || (val === '') || (val === null)) {
791
+ // if not defined or empty, return default
792
+ val = defaultValue;
793
+ }
794
+ return val;
795
+ },
796
+ hasInput: function() {
797
+ return (this.input !== false);
798
+ },
799
+ isDisabled: function() {
800
+ if (this.hasInput()) {
801
+ return (this.input.prop('disabled') === true);
802
+ }
803
+ return false;
804
+ },
805
+ disable: function() {
806
+ if (this.hasInput()) {
807
+ this.input.prop('disabled', true);
808
+ return true;
809
+ }
810
+ return false;
811
+ },
812
+ enable: function() {
813
+ if (this.hasInput()) {
814
+ this.input.prop('disabled', false);
815
+ return true;
816
+ }
817
+ return false;
818
+ },
819
+ currentSlider: null,
820
+ mousePointer: {
821
+ left: 0,
822
+ top: 0
823
+ },
824
+ mousedown: function(e) {
825
+ e.stopPropagation();
826
+ e.preventDefault();
827
+
828
+ var target = $(e.target);
829
+
830
+ //detect the slider and set the limits and callbacks
831
+ var zone = target.closest('div');
832
+ var sl = this.options.horizontal ? this.options.slidersHorz : this.options.sliders;
833
+ if (!zone.is('.colorpicker')) {
834
+ if (zone.is('.colorpicker-saturation')) {
835
+ this.currentSlider = $.extend({}, sl.saturation);
836
+ } else if (zone.is('.colorpicker-hue')) {
837
+ this.currentSlider = $.extend({}, sl.hue);
838
+ } else if (zone.is('.colorpicker-alpha')) {
839
+ this.currentSlider = $.extend({}, sl.alpha);
840
+ } else {
841
+ return false;
842
+ }
843
+ var offset = zone.offset();
844
+ //reference to guide's style
845
+ this.currentSlider.guide = zone.find('i')[0].style;
846
+ this.currentSlider.left = e.pageX - offset.left;
847
+ this.currentSlider.top = e.pageY - offset.top;
848
+ this.mousePointer = {
849
+ left: e.pageX,
850
+ top: e.pageY
851
+ };
852
+ //trigger mousemove to move the guide to the current position
853
+ $(document).on({
854
+ 'mousemove.colorpicker': $.proxy(this.mousemove, this),
855
+ 'mouseup.colorpicker': $.proxy(this.mouseup, this)
856
+ }).trigger('mousemove');
857
+ }
858
+ return false;
859
+ },
860
+ mousemove: function(e) {
861
+ e.stopPropagation();
862
+ e.preventDefault();
863
+ var left = Math.max(
864
+ 0,
865
+ Math.min(
866
+ this.currentSlider.maxLeft,
867
+ this.currentSlider.left + ((e.pageX || this.mousePointer.left) - this.mousePointer.left)
868
+ )
869
+ );
870
+ var top = Math.max(
871
+ 0,
872
+ Math.min(
873
+ this.currentSlider.maxTop,
874
+ this.currentSlider.top + ((e.pageY || this.mousePointer.top) - this.mousePointer.top)
875
+ )
876
+ );
877
+ this.currentSlider.guide.left = left + 'px';
878
+ this.currentSlider.guide.top = top + 'px';
879
+ if (this.currentSlider.callLeft) {
880
+ this.color[this.currentSlider.callLeft].call(this.color, left / 100);
881
+ }
882
+ if (this.currentSlider.callTop) {
883
+ this.color[this.currentSlider.callTop].call(this.color, top / 100);
884
+ }
885
+ this.update(true);
886
+
887
+ this.element.trigger({
888
+ type: 'changeColor',
889
+ color: this.color
890
+ });
891
+ return false;
892
+ },
893
+ mouseup: function(e) {
894
+ e.stopPropagation();
895
+ e.preventDefault();
896
+ $(document).off({
897
+ 'mousemove.colorpicker': this.mousemove,
898
+ 'mouseup.colorpicker': this.mouseup
899
+ });
900
+ return false;
901
+ },
902
+ keyup: function(e) {
903
+ if ((e.keyCode === 38)) {
904
+ if (this.color.value.a < 1) {
905
+ this.color.value.a = Math.round((this.color.value.a + 0.01) * 100) / 100;
906
+ }
907
+ this.update(true);
908
+ } else if ((e.keyCode === 40)) {
909
+ if (this.color.value.a > 0) {
910
+ this.color.value.a = Math.round((this.color.value.a - 0.01) * 100) / 100;
911
+ }
912
+ this.update(true);
913
+ } else {
914
+ var val = this.input.val();
915
+ this.color = new Color(val);
916
+ if (this.getValue(false) !== false) {
917
+ this.updateData();
918
+ this.updateComponent();
919
+ this.updatePicker();
920
+ }
921
+ }
922
+ this.element.trigger({
923
+ type: 'changeColor',
924
+ color: this.color,
925
+ value: val
926
+ });
927
+ }
928
+ };
929
+
930
+ $.colorpicker = Colorpicker;
931
+
932
+ $.fn.colorpicker = function(option) {
933
+ return this.each(function() {
934
+ var $this = $(this),
935
+ inst = $this.data('colorpicker'),
936
+ options = ((typeof option === 'object') ? option : {});
937
+ if ((!inst) && (typeof option !== 'string')) {
938
+ $this.data('colorpicker', new Colorpicker(this, options));
939
+ } else {
940
+ if (typeof option === 'string') {
941
+ inst[option].apply(inst, Array.prototype.slice.call(arguments, 1));
942
+ }
943
+ }
944
+ });
945
+ };
946
+
947
+ $.fn.colorpicker.constructor = Colorpicker;
948
+
949
+ })(window.jQuery);