webshims-rails 1.10.3 → 1.10.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/webshims-rails/version.rb +2 -2
- data/vendor/assets/javascripts/webshims/polyfiller.js +96 -73
- data/vendor/assets/javascripts/webshims/shims/color-picker.js +2415 -0
- data/vendor/assets/javascripts/webshims/shims/combos/1.js +248 -745
- data/vendor/assets/javascripts/webshims/shims/combos/10.js +771 -1206
- data/vendor/assets/javascripts/webshims/shims/combos/11.js +679 -1201
- data/vendor/assets/javascripts/webshims/shims/combos/12.js +46 -65
- data/vendor/assets/javascripts/webshims/shims/combos/13.js +45 -64
- data/vendor/assets/javascripts/webshims/shims/combos/14.js +94 -7
- data/vendor/assets/javascripts/webshims/shims/combos/15.js +557 -1189
- data/vendor/assets/javascripts/webshims/shims/combos/16.js +598 -1249
- data/vendor/assets/javascripts/webshims/shims/combos/17.js +697 -1208
- data/vendor/assets/javascripts/webshims/shims/combos/18.js +697 -1208
- data/vendor/assets/javascripts/webshims/shims/combos/19.js +145 -78
- data/vendor/assets/javascripts/webshims/shims/combos/2.js +472 -1280
- data/vendor/assets/javascripts/webshims/shims/combos/20.js +144 -77
- data/vendor/assets/javascripts/webshims/shims/combos/21.js +14 -15
- data/vendor/assets/javascripts/webshims/shims/combos/22.js +2 -2
- data/vendor/assets/javascripts/webshims/shims/combos/23.js +45 -64
- data/vendor/assets/javascripts/webshims/shims/combos/24.js +848 -0
- data/vendor/assets/javascripts/webshims/shims/combos/25.js +4373 -0
- data/vendor/assets/javascripts/webshims/shims/combos/26.js +1516 -0
- data/vendor/assets/javascripts/webshims/shims/combos/27.js +884 -0
- data/vendor/assets/javascripts/webshims/shims/combos/28.js +2067 -0
- data/vendor/assets/javascripts/webshims/shims/combos/29.js +1156 -0
- data/vendor/assets/javascripts/webshims/shims/combos/3.js +313 -700
- data/vendor/assets/javascripts/webshims/shims/combos/30.js +1868 -0
- data/vendor/assets/javascripts/webshims/shims/combos/31.js +1663 -0
- data/vendor/assets/javascripts/webshims/shims/combos/4.js +111 -20
- data/vendor/assets/javascripts/webshims/shims/combos/5.js +747 -1321
- data/vendor/assets/javascripts/webshims/shims/combos/6.js +837 -1809
- data/vendor/assets/javascripts/webshims/shims/combos/7.js +435 -1239
- data/vendor/assets/javascripts/webshims/shims/combos/8.js +360 -766
- data/vendor/assets/javascripts/webshims/shims/combos/9.js +843 -1676
- data/vendor/assets/javascripts/webshims/shims/details.js +1 -1
- data/vendor/assets/javascripts/webshims/shims/dom-extend.js +90 -3
- data/vendor/assets/javascripts/webshims/shims/filereader.js +386 -0
- data/vendor/assets/javascripts/webshims/shims/form-core.js +201 -680
- data/vendor/assets/javascripts/webshims/shims/form-datalist-lazy.js +418 -0
- data/vendor/assets/javascripts/webshims/shims/form-datalist.js +69 -467
- data/vendor/assets/javascripts/webshims/shims/form-message.js +21 -17
- data/vendor/assets/javascripts/webshims/shims/form-native-extend.js +19 -82
- data/vendor/assets/javascripts/webshims/shims/form-number-date-api.js +17 -6
- data/vendor/assets/javascripts/webshims/shims/form-number-date-ui.js +570 -1185
- data/vendor/assets/javascripts/webshims/shims/form-shim-extend.js +181 -28
- data/vendor/assets/javascripts/webshims/shims/form-validation.js +599 -0
- data/vendor/assets/javascripts/webshims/{extras/custom-validity.js → shims/form-validators.js} +33 -38
- data/vendor/assets/javascripts/webshims/shims/forms-picker.js +865 -0
- data/vendor/assets/javascripts/webshims/shims/geolocation.js +2 -2
- data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-de.txt +37 -34
- data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-en.txt +88 -48
- data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-lt.js +74 -0
- data/vendor/assets/javascripts/webshims/shims/jpicker/ChangeLog.txt +121 -0
- data/vendor/assets/javascripts/webshims/shims/jpicker/ReadMe.txt +47 -0
- data/vendor/assets/javascripts/webshims/shims/jpicker/images/AlphaBar.png +0 -0
- data/vendor/assets/javascripts/webshims/shims/jpicker/images/Bars.png +0 -0
- data/vendor/assets/javascripts/webshims/shims/jpicker/images/Maps.png +0 -0
- data/vendor/assets/javascripts/webshims/shims/jpicker/images/NoColor.png +0 -0
- data/vendor/assets/javascripts/webshims/shims/jpicker/images/Thumbs.db +0 -0
- data/vendor/assets/javascripts/webshims/shims/jpicker/images/bar-opacity.png +0 -0
- data/vendor/assets/javascripts/webshims/shims/jpicker/images/map-opacity.png +0 -0
- data/vendor/assets/javascripts/webshims/shims/jpicker/images/mappoint.gif +0 -0
- data/vendor/assets/javascripts/webshims/shims/jpicker/images/picker.gif +0 -0
- data/vendor/assets/javascripts/webshims/shims/jpicker/images/preview-opacity.png +0 -0
- data/vendor/assets/javascripts/webshims/shims/jpicker/images/rangearrows.gif +0 -0
- data/vendor/assets/javascripts/webshims/shims/jpicker/jpicker.css +257 -0
- data/vendor/assets/javascripts/webshims/shims/json-storage.js +4 -4
- data/vendor/assets/javascripts/webshims/shims/mediaelement-core.js +44 -63
- data/vendor/assets/javascripts/webshims/shims/mediaelement-jaris.js +10 -11
- data/vendor/assets/javascripts/webshims/shims/mediaelement-native-fix.js +2 -1
- data/vendor/assets/javascripts/webshims/shims/mediaelement-yt.js +5 -3
- data/vendor/assets/javascripts/webshims/shims/range-ui.js +110 -17
- data/vendor/assets/javascripts/webshims/shims/styles/forms.png +0 -0
- data/vendor/assets/javascripts/webshims/shims/styles/range-track.png +0 -0
- data/vendor/assets/javascripts/webshims/shims/styles/scss/shim.scss +104 -21
- data/vendor/assets/javascripts/webshims/shims/styles/shim.css +90 -16
- data/vendor/assets/javascripts/webshims/shims/styles/vertical-range.png +0 -0
- data/vendor/assets/javascripts/webshims/shims/swf/filereader.swf +0 -0
- data/vendor/assets/javascripts/webshims/shims/swfmini.js +1 -1
- data/vendor/assets/javascripts/webshims/shims/track-ui.js +35 -3
- data/vendor/assets/javascripts/webshims/shims/track.js +1 -1
- metadata +33 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZjdlMzZkNjM4YTFjNWVmNWZiNmQ1ZWQ4M2YyOGIyYTljMzMwZjU2Mg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OWIxZDJmNjQ0ZTcyYzY5Mjg0NWQxZjg1NGVkOTY1Yzg0ODM4ZmQwMQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MGQ4ZjgyMjJhNjNkNzg2ZDk4ZmRhYTg1YmQ4ZmUzYWYxZTI4YmNmYmVlNzQz
|
10
|
+
MTgxZjI3MDRiNWJmNjk1NjhjYWRiOWI2YzNjMTg2ZjQ3ODdiNWNlMjNlMmRh
|
11
|
+
M2IyYzNlZTQ2MWZmZDlmNzc5N2M1NWYwZWJkYzVmMWY4YWFlM2I=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NGRmZGY2ZGI2YTk3ZTY5ZjlhYWExMDU2MzVhMGVkOTlkZTExNTY4MmVhM2Yy
|
14
|
+
YzVkYmMwMTI4ZjY2MTc1MDBmMDE2ZTg4NzRiNTM4ZDVlYTAzZDMxYzczYzM2
|
15
|
+
NTFhOTllMjQ4Yjc2MDk4ZDAwMDg4ZjM5ZmFiNmI4Y2NjYjJhMDI=
|
@@ -21,12 +21,16 @@
|
|
21
21
|
|
22
22
|
Modernizr.advancedObjectProperties = Modernizr.objectAccessor = Modernizr.ES5 = !!('create' in Object && 'seal' in Object);
|
23
23
|
|
24
|
+
if(Modernizr.ES5 && !('toJSON' in Date.prototype)){
|
25
|
+
Modernizr.ES5 = false;
|
26
|
+
}
|
27
|
+
|
24
28
|
if(!$.event.customEvent){
|
25
29
|
$.event.customEvent = {};
|
26
30
|
}
|
27
31
|
|
28
32
|
var webshims = {
|
29
|
-
version: '1.10.
|
33
|
+
version: '1.10.6',
|
30
34
|
cfg: {
|
31
35
|
useImportantStyles: true,
|
32
36
|
//addCacheBuster: false,
|
@@ -63,7 +67,6 @@
|
|
63
67
|
var feature = cfg.f || name;
|
64
68
|
if (!webshimsFeatures[feature]) {
|
65
69
|
webshimsFeatures[feature] = [];
|
66
|
-
webshimsFeatures[feature].delayReady = 0;
|
67
70
|
webshims.featureList.push(feature);
|
68
71
|
webCFG[feature] = {};
|
69
72
|
}
|
@@ -95,22 +98,19 @@
|
|
95
98
|
},
|
96
99
|
polyfill: (function(){
|
97
100
|
var loaded = {};
|
98
|
-
var called;
|
99
101
|
return function(features){
|
100
102
|
if(!features){
|
101
103
|
features = webshims.featureList;
|
104
|
+
webshims.info('loading all features without specifing might be bad for performance');
|
102
105
|
}
|
103
106
|
|
104
107
|
if (typeof features == 'string') {
|
105
108
|
features = features.split(' ');
|
106
109
|
}
|
107
|
-
|
108
|
-
webshims.warn('polyfill already called, you might want to use updatePolyfill instead? see: bit.ly/12BtXX3. polyfill should be called only once.');
|
109
|
-
}
|
110
|
-
called = true;
|
110
|
+
|
111
111
|
for(var i = 0; i < features.length; i++){
|
112
|
-
if(features[i]
|
113
|
-
webshims.
|
112
|
+
if(loaded[features[i]]){
|
113
|
+
webshims.error(features[i] +' already loaded, you might want to use updatePolyfill instead? see: bit.ly/12BtXX3');
|
114
114
|
}
|
115
115
|
loaded[features[i]] = true;
|
116
116
|
}
|
@@ -203,7 +203,6 @@
|
|
203
203
|
*/
|
204
204
|
reTest: (function(){
|
205
205
|
var resList;
|
206
|
-
var noDelayReady;
|
207
206
|
var reTest = function(i, name){
|
208
207
|
var module = modules[name];
|
209
208
|
var readyName = name+'Ready';
|
@@ -213,18 +212,11 @@
|
|
213
212
|
delete special[readyName];
|
214
213
|
}
|
215
214
|
feature = webshimsFeatures[module.f];
|
216
|
-
|
217
|
-
feature.delayReady++;
|
218
|
-
onReady(name, function(){
|
219
|
-
feature.delayReady--;
|
220
|
-
isReady(module.f, feature.callReady);
|
221
|
-
});
|
222
|
-
}
|
215
|
+
|
223
216
|
resList.push(name);
|
224
217
|
}
|
225
218
|
};
|
226
|
-
return function(moduleNames
|
227
|
-
noDelayReady = _noDelay;
|
219
|
+
return function(moduleNames){
|
228
220
|
if(typeof moduleNames == 'string'){
|
229
221
|
moduleNames = moduleNames.split(' ');
|
230
222
|
}
|
@@ -234,12 +226,7 @@
|
|
234
226
|
};
|
235
227
|
})(),
|
236
228
|
isReady: function(name, _set){
|
237
|
-
|
238
|
-
if(_set){
|
239
|
-
webshimsFeatures[name].callReady = true;
|
240
|
-
}
|
241
|
-
return false;
|
242
|
-
}
|
229
|
+
|
243
230
|
name = name + 'Ready';
|
244
231
|
if (_set) {
|
245
232
|
if (special[name] && special[name].add) {
|
@@ -630,10 +617,14 @@
|
|
630
617
|
};
|
631
618
|
})();
|
632
619
|
|
620
|
+
webshims.errorLog = [];
|
633
621
|
$.each(['log', 'error', 'warn', 'info'], function(i, fn){
|
634
622
|
webshims[fn] = function(message){
|
635
|
-
if(
|
636
|
-
|
623
|
+
if( (importantLogs[fn] && webshims.debug !== false) || webshims.debug){
|
624
|
+
webshims.errorLog.push(message);
|
625
|
+
if(window.console && console.log){
|
626
|
+
console[(console[fn]) ? fn : 'log'](message);
|
627
|
+
}
|
637
628
|
}
|
638
629
|
};
|
639
630
|
});
|
@@ -666,7 +657,9 @@
|
|
666
657
|
|
667
658
|
$(window).load(function(){
|
668
659
|
onReady();
|
669
|
-
|
660
|
+
setTimeout(function(){
|
661
|
+
isReady('WINDOWLOAD', true);
|
662
|
+
}, 9);
|
670
663
|
});
|
671
664
|
})();
|
672
665
|
|
@@ -686,6 +679,11 @@
|
|
686
679
|
|
687
680
|
(function(){
|
688
681
|
var readyFns = [];
|
682
|
+
var eachTrigger = function(){
|
683
|
+
if(this.nodeType == 1){
|
684
|
+
webshims.triggerDomUpdate(this);
|
685
|
+
}
|
686
|
+
};
|
689
687
|
$.extend(webshims, {
|
690
688
|
addReady: function(fn){
|
691
689
|
var readyFn = function(context, elem){
|
@@ -715,11 +713,7 @@
|
|
715
713
|
$.fn.htmlPolyfill = function(a){
|
716
714
|
var ret = $.fn.html.call(this, a);
|
717
715
|
if(ret === this && $.isDOMReady){
|
718
|
-
this.each(
|
719
|
-
if(this.nodeType == 1){
|
720
|
-
webshims.triggerDomUpdate(this);
|
721
|
-
}
|
722
|
-
});
|
716
|
+
this.each(eachTrigger);
|
723
717
|
}
|
724
718
|
return ret;
|
725
719
|
};
|
@@ -733,11 +727,7 @@
|
|
733
727
|
a = $(a);
|
734
728
|
$.fn[name].call(this, a);
|
735
729
|
if($.isDOMReady){
|
736
|
-
a.each(
|
737
|
-
if (this.nodeType == 1) {
|
738
|
-
webshims.triggerDomUpdate(this);
|
739
|
-
}
|
740
|
-
});
|
730
|
+
a.each(eachTrigger);
|
741
731
|
}
|
742
732
|
return this;
|
743
733
|
};
|
@@ -839,7 +829,7 @@
|
|
839
829
|
}
|
840
830
|
return ('swfmini' in window);
|
841
831
|
},
|
842
|
-
c: [16, 7, 2, 8, 1, 12, 19, 23]
|
832
|
+
c: [16, 7, 2, 8, 1, 12, 19, 25, 23, 27]
|
843
833
|
});
|
844
834
|
modules.swfmini.test();
|
845
835
|
|
@@ -850,14 +840,14 @@
|
|
850
840
|
// webshims lib uses a of http://github.com/kriskowal/es5-shim/ to implement
|
851
841
|
addPolyfill('es5', {
|
852
842
|
test: !!(Modernizr.ES5 && Function.prototype.bind),
|
853
|
-
c: [14, 18, 19, 20]
|
843
|
+
c: [14, 18, 19, 25, 20]
|
854
844
|
});
|
855
845
|
|
856
846
|
addPolyfill('dom-extend', {
|
857
847
|
f: DOMSUPPORT,
|
858
848
|
noAutoCallback: true,
|
859
849
|
d: ['es5'],
|
860
|
-
c: [16, 7, 2, 15, 3, 8, 4, 9, 10, 14, 19, 20]
|
850
|
+
c: [16, 7, 2, 15, 30, 3, 8, 4, 9, 10, 14, 25, 19, 20, 26, 28, 31]
|
861
851
|
});
|
862
852
|
|
863
853
|
|
@@ -948,38 +938,47 @@
|
|
948
938
|
|
949
939
|
//<forms
|
950
940
|
(function(){
|
941
|
+
var formExtend, formOptions, formExtras;
|
951
942
|
var modernizrInputAttrs = Modernizr.input;
|
952
943
|
var modernizrInputTypes = Modernizr.inputtypes;
|
953
944
|
var formvalidation = 'formvalidation';
|
945
|
+
var fNuAPI = 'form-number-date-api';
|
954
946
|
var select = $('<select required="" name="a"><option disabled="" /></select>')[0];
|
955
947
|
var bustedValidity = false;
|
956
|
-
var formExtend, formOptions;
|
957
948
|
|
958
949
|
var initialFormTest = function(){
|
959
950
|
if(!initialFormTest.run){
|
960
951
|
addTest(formvalidation, function(){
|
961
952
|
return !!(modernizrInputAttrs.required && modernizrInputAttrs.pattern);
|
962
953
|
});
|
954
|
+
|
963
955
|
addTest('fieldsetdisabled', function(){
|
964
956
|
var fieldset = $('<fieldset />')[0];
|
965
957
|
return 'elements' in fieldset && 'disabled' in fieldset;
|
966
958
|
});
|
967
959
|
|
960
|
+
if(modernizrInputTypes){
|
961
|
+
addTest('styleableinputrange', function(){
|
962
|
+
return modernizrInputTypes.range && !window.opera;
|
963
|
+
});
|
964
|
+
}
|
965
|
+
|
968
966
|
if(Modernizr[formvalidation]){
|
969
|
-
bugs.bustedValidity = bustedValidity = Modernizr.formattribute === false || !Modernizr.fieldsetdisabled || !('value' in document.createElement('progress')) || !('value' in document.createElement('output')) || !($('<input type="date" value="1488-12-11" />')[0].validity || {valid: true}).valid || !('required' in select) || (select.validity || {}).valid;
|
967
|
+
bugs.bustedValidity = bustedValidity = !modernizrInputAttrs.list || window.opera || Modernizr.formattribute === false || !Modernizr.fieldsetdisabled || !('value' in document.createElement('progress')) || !('value' in document.createElement('output')) || !($('<input type="date" value="1488-12-11" />')[0].validity || {valid: true}).valid || !('required' in select) || (select.validity || {}).valid;
|
970
968
|
}
|
971
969
|
|
972
970
|
formExtend = Modernizr[formvalidation] && !bustedValidity ? 'form-native-extend' : 'form-shim-extend';
|
973
971
|
|
974
|
-
addTest('styleableinputrange', function(){
|
975
|
-
return modernizrInputTypes.range && !window.opera;
|
976
|
-
});
|
977
972
|
}
|
978
973
|
initialFormTest.run = true;
|
979
974
|
return false;
|
980
975
|
};
|
981
976
|
|
982
|
-
|
977
|
+
if(modernizrInputAttrs && modernizrInputTypes){
|
978
|
+
initialFormTest();
|
979
|
+
}
|
980
|
+
document.createElement('datalist');
|
981
|
+
|
983
982
|
webshims.formcfg = [];
|
984
983
|
webshims.validationMessages = webshims.validityMessages = [];
|
985
984
|
webshims.inputTypes = {};
|
@@ -995,13 +994,21 @@
|
|
995
994
|
datalistPopover: {
|
996
995
|
constrainWidth: true
|
997
996
|
},
|
998
|
-
|
997
|
+
iVal: {
|
998
|
+
handleBubble: true,
|
999
|
+
sel: '.ws-instantvalidation',
|
1000
|
+
recheckDelay: 400
|
1001
|
+
// ,hideBubble: undefined,
|
1002
|
+
// ,fieldWrapper: undefined
|
1003
|
+
// ,fx: 'slide'
|
1004
|
+
},
|
1005
|
+
availabeLangs: ['ar', 'ch-ZN', 'el', 'es', 'fr', 'he', 'hi', 'hu', 'it', 'ja', 'lt', 'nl', 'pt-PT', 'ru', 'sv'] //en and de are directly implemented in core
|
999
1006
|
// ,customMessages: false,
|
1000
|
-
//
|
1007
|
+
// overridePlaceholder: false, // might be good for IE10
|
1001
1008
|
// replaceValidationUI: false
|
1002
1009
|
},
|
1003
1010
|
methodNames: ['setCustomValidity','checkValidity'],
|
1004
|
-
c: [16, 7, 2, 8, 1, 15, 3],
|
1011
|
+
c: [16, 7, 2, 8, 1, 15, 30, 3, 31],
|
1005
1012
|
nM: 'input'
|
1006
1013
|
});
|
1007
1014
|
|
@@ -1010,8 +1017,7 @@
|
|
1010
1017
|
addPolyfill('form-native-extend', {
|
1011
1018
|
f: 'forms',
|
1012
1019
|
test: function(toLoad){
|
1013
|
-
|
1014
|
-
return (!Modernizr[formvalidation] || bustedValidity) || ((modules['form-number-date-api'].test() || $.inArray('form-number-date-api', toLoad || []) == -1) && !formOptions.overrideMessages );
|
1020
|
+
return !Modernizr[formvalidation] || bustedValidity || $.inArray(fNuAPI, toLoad || []) == -1 || modules[fNuAPI].test();
|
1015
1021
|
},
|
1016
1022
|
d: ['form-core', DOMSUPPORT, 'form-message'],
|
1017
1023
|
c: [6, 5]
|
@@ -1020,7 +1026,6 @@
|
|
1020
1026
|
addPolyfill('form-shim-extend', {
|
1021
1027
|
f: 'forms',
|
1022
1028
|
test: function(){
|
1023
|
-
initialFormTest();
|
1024
1029
|
return Modernizr[formvalidation] && !bustedValidity;
|
1025
1030
|
},
|
1026
1031
|
d: ['form-core', DOMSUPPORT],
|
@@ -1030,29 +1035,36 @@
|
|
1030
1035
|
addPolyfill('form-message', {
|
1031
1036
|
f: 'forms',
|
1032
1037
|
test: function(toLoad){
|
1033
|
-
|
1034
|
-
return !( formOptions.customMessages || !Modernizr[formvalidation] || bugs.validationMessage || bustedValidity || !modules[formExtend].test(toLoad) );
|
1038
|
+
return !( formOptions.customMessages || !Modernizr[formvalidation] || bustedValidity || !modules[formExtend].test(toLoad) );
|
1035
1039
|
},
|
1036
1040
|
d: [DOMSUPPORT],
|
1037
|
-
c: [16, 7, 15, 3, 8, 4]
|
1041
|
+
c: [16, 7, 15, 30, 3, 8, 4]
|
1038
1042
|
});
|
1039
1043
|
|
1040
|
-
|
1044
|
+
formExtras = {
|
1045
|
+
noAutoCallback: true,
|
1046
|
+
options: formOptions,
|
1047
|
+
c: [24]
|
1048
|
+
};
|
1049
|
+
addModule('form-validation', $.extend({d: ['form-message']}, formExtras));
|
1050
|
+
|
1051
|
+
addModule('form-validators', $.extend({}, formExtras));
|
1052
|
+
|
1053
|
+
addPolyfill(fNuAPI, {
|
1041
1054
|
f: 'forms-ext',
|
1042
1055
|
options: {
|
1043
1056
|
types: 'range date time number month'
|
1044
1057
|
},
|
1045
|
-
test: function(
|
1058
|
+
test: function(){
|
1046
1059
|
var ret = true;
|
1047
|
-
var
|
1048
|
-
if(
|
1049
|
-
|
1050
|
-
} else {
|
1051
|
-
types = types.split(' ');
|
1060
|
+
var o = this.options;
|
1061
|
+
if(!o._types){
|
1062
|
+
o._types = o.types.split(' ');
|
1052
1063
|
}
|
1064
|
+
|
1053
1065
|
initialFormTest();
|
1054
|
-
$.each(
|
1055
|
-
if(!modernizrInputTypes[name]){
|
1066
|
+
$.each(o._types, function(i, name){
|
1067
|
+
if((name in modernizrInputTypes) && !modernizrInputTypes[name]){
|
1056
1068
|
ret = false;
|
1057
1069
|
return false;
|
1058
1070
|
}
|
@@ -1065,7 +1077,7 @@
|
|
1065
1077
|
nM: 'input inputtypes'
|
1066
1078
|
});
|
1067
1079
|
|
1068
|
-
|
1080
|
+
addModule('range-ui', {
|
1069
1081
|
options: {},
|
1070
1082
|
noAutoCallback: true,
|
1071
1083
|
test: function(){
|
@@ -1079,9 +1091,9 @@
|
|
1079
1091
|
f: 'forms-ext',
|
1080
1092
|
test: function(){
|
1081
1093
|
initialFormTest();
|
1082
|
-
return !this.options.replaceUI && modules[
|
1094
|
+
return !this.options.replaceUI && modules[fNuAPI].test();
|
1083
1095
|
},
|
1084
|
-
d: ['forms', DOMSUPPORT,
|
1096
|
+
d: ['forms', DOMSUPPORT, fNuAPI, 'range-ui'],
|
1085
1097
|
options: {
|
1086
1098
|
|
1087
1099
|
widgets: {
|
@@ -1101,11 +1113,18 @@
|
|
1101
1113
|
return modernizrInputAttrs.list && !formOptions.customDatalist;
|
1102
1114
|
},
|
1103
1115
|
d: ['form-core', DOMSUPPORT],
|
1104
|
-
c: [16, 7, 6, 2, 9, 15]
|
1116
|
+
c: [16, 7, 6, 2, 9, 15, 30, 31]
|
1105
1117
|
});
|
1106
1118
|
})();
|
1107
1119
|
//>
|
1108
1120
|
|
1121
|
+
addPolyfill('filereader', {
|
1122
|
+
test: 'FileReader' in window,
|
1123
|
+
d: ['swfmini', DOMSUPPORT],
|
1124
|
+
c: [25, 26, 27]
|
1125
|
+
// ,nM: 'filereader'
|
1126
|
+
});
|
1127
|
+
|
1109
1128
|
//<details
|
1110
1129
|
if(!('details' in Modernizr)){
|
1111
1130
|
addTest('details', function(){
|
@@ -1140,7 +1159,7 @@
|
|
1140
1159
|
},
|
1141
1160
|
methodNames: ['play', 'pause', 'canPlayType', 'mediaLoad:load'],
|
1142
1161
|
d: ['swfmini'],
|
1143
|
-
c: [16, 7, 2, 8, 1, 12, 13, 19, 20, 23],
|
1162
|
+
c: [16, 7, 2, 8, 1, 12, 13, 19, 25, 20, 23],
|
1144
1163
|
nM: 'audio video texttrackapi'
|
1145
1164
|
});
|
1146
1165
|
|
@@ -1159,7 +1178,7 @@
|
|
1159
1178
|
}
|
1160
1179
|
return !( options.preferFlash && window.swfmini.hasFlashPlayerVersion('9.0.115') );
|
1161
1180
|
},
|
1162
|
-
c: [21, 19, 20]
|
1181
|
+
c: [21, 19, 25, 20, 28]
|
1163
1182
|
});
|
1164
1183
|
|
1165
1184
|
bugs.track = (Modernizr.track && (!Modernizr.texttrackapi || typeof (document.createElement('track').track || {}).mode != 'string'));
|
@@ -1174,12 +1193,13 @@
|
|
1174
1193
|
},
|
1175
1194
|
d: ['mediaelement', DOMSUPPORT],
|
1176
1195
|
methodNames: ['addTextTrack'],
|
1177
|
-
c: [21, 12, 13, 22],
|
1196
|
+
c: [21, 12, 13, 22, 29],
|
1178
1197
|
nM: 'texttrackapi'
|
1179
1198
|
});
|
1180
1199
|
|
1181
1200
|
addModule('track-ui', {
|
1182
|
-
d: ['track']
|
1201
|
+
d: ['track', DOMSUPPORT],
|
1202
|
+
c: [29]
|
1183
1203
|
});
|
1184
1204
|
})();
|
1185
1205
|
//>
|
@@ -1192,6 +1212,9 @@
|
|
1192
1212
|
c: removeCombos
|
1193
1213
|
});
|
1194
1214
|
|
1215
|
+
webshims.$ = $;
|
1216
|
+
webshims.M = Modernizr;
|
1217
|
+
window.webshims = webshims;
|
1195
1218
|
|
1196
1219
|
jScripts
|
1197
1220
|
.filter('[data-polyfill-cfg]')
|
@@ -0,0 +1,2415 @@
|
|
1
|
+
/**
|
2
|
+
* jPicker 1.1.6 modified for webshims
|
3
|
+
*
|
4
|
+
* jQuery Plugin for Photoshop style color picker
|
5
|
+
*
|
6
|
+
* Copyright (c) 2010 Christopher T. Tillman
|
7
|
+
* Digital Magic Productions, Inc. (http://www.digitalmagicpro.com/)
|
8
|
+
* MIT style license, FREE to use, alter, copy, sell, and especially ENHANCE
|
9
|
+
*
|
10
|
+
* Painstakingly ported from John Dyers' excellent work on his own color picker based on the Prototype framework.
|
11
|
+
*
|
12
|
+
* John Dyers' website: (http://johndyer.name)
|
13
|
+
* Color Picker page: (http://johndyer.name/post/2007/09/PhotoShop-like-JavaScript-Color-Picker.aspx)
|
14
|
+
*
|
15
|
+
*/
|
16
|
+
(function ($, version) {
|
17
|
+
"use strict";
|
18
|
+
if(!window.Modernizr || !('opacity' in Modernizr) || !('csstransitions' in Modernizr)){
|
19
|
+
$('html').addClass(('opacity' in document.documentElement.style) ? 'opacity' : 'no-opacity');
|
20
|
+
}
|
21
|
+
var mPrecision = function (value, precision) {
|
22
|
+
if (precision === undefined) precision = 0;
|
23
|
+
return Math.round(value * Math.pow(10, precision)) / Math.pow(10, precision);
|
24
|
+
};
|
25
|
+
var elemExtend = function (deep, elem, data) {
|
26
|
+
var ex = elem;
|
27
|
+
if (elem.nodeType) {
|
28
|
+
ex = $.data(elem, 'wsjPicker') || $.data(elem, 'wsjPicker', {});
|
29
|
+
}
|
30
|
+
if(deep){
|
31
|
+
$.extend(true, ex, data);
|
32
|
+
} else {
|
33
|
+
$.extend(ex, data);
|
34
|
+
}
|
35
|
+
};
|
36
|
+
var Slider = // encapsulate slider functionality for the ColorMap and ColorBar - could be useful to use a jQuery UI draggable for this with certain extensions
|
37
|
+
|
38
|
+
function (bar, options) {
|
39
|
+
var $this = this, // private properties, methods, and events - keep these variables and classes invisible to outside code
|
40
|
+
arrow = bar.find('img').eq(0), // the arrow image to drag
|
41
|
+
minX = 0,
|
42
|
+
maxX = 100,
|
43
|
+
rangeX = 100,
|
44
|
+
minY = 0,
|
45
|
+
maxY = 100,
|
46
|
+
rangeY = 100,
|
47
|
+
x = 0,
|
48
|
+
y = 0,
|
49
|
+
offset,
|
50
|
+
timeout,
|
51
|
+
changeEvents = new Array(),
|
52
|
+
fireChangeEvents = function (context) {
|
53
|
+
for (var i = 0; i < changeEvents.length; i++) changeEvents[i].call($this, $this, context);
|
54
|
+
},
|
55
|
+
mouseDown = // bind the mousedown to the bar not the arrow for quick snapping to the clicked location
|
56
|
+
|
57
|
+
function (e) {
|
58
|
+
var off = bar.offset();
|
59
|
+
offset = {
|
60
|
+
l: off.left | 0,
|
61
|
+
t: off.top | 0
|
62
|
+
};
|
63
|
+
clearTimeout(timeout);
|
64
|
+
timeout = setTimeout( // using setTimeout for visual updates - once the style is updated the browser will re-render internally allowing the next Javascript to run
|
65
|
+
|
66
|
+
function () {
|
67
|
+
setValuesFromMousePosition.call($this, e);
|
68
|
+
}, 0);
|
69
|
+
// Bind mousemove and mouseup event to the document so it responds when dragged of of the bar - we will unbind these when on mouseup to save processing
|
70
|
+
$(document).bind('mousemove', mouseMove).bind('mouseup', mouseUp);
|
71
|
+
e.preventDefault(); // don't try to select anything or drag the image to the desktop
|
72
|
+
},
|
73
|
+
mouseMove = // set the values as the mouse moves
|
74
|
+
|
75
|
+
function (e) {
|
76
|
+
clearTimeout(timeout);
|
77
|
+
timeout = setTimeout(function () {
|
78
|
+
setValuesFromMousePosition.call($this, e);
|
79
|
+
}, 0);
|
80
|
+
e.stopPropagation();
|
81
|
+
e.preventDefault();
|
82
|
+
return false;
|
83
|
+
},
|
84
|
+
mouseUp = // unbind the document events - they aren't needed when not dragging
|
85
|
+
|
86
|
+
function (e) {
|
87
|
+
$(document).unbind('mouseup', mouseUp).unbind('mousemove', mouseMove);
|
88
|
+
e.stopPropagation();
|
89
|
+
e.preventDefault();
|
90
|
+
return false;
|
91
|
+
},
|
92
|
+
setValuesFromMousePosition = // calculate mouse position and set value within the current range
|
93
|
+
|
94
|
+
function (e) {
|
95
|
+
var locX = e.pageX - offset.l,
|
96
|
+
locY = e.pageY - offset.t,
|
97
|
+
barW = bar.w, // local copies for YUI compressor
|
98
|
+
barH = bar.h;
|
99
|
+
// keep the arrow within the bounds of the bar
|
100
|
+
if (locX < 0) locX = 0;
|
101
|
+
else if (locX > barW) locX = barW;
|
102
|
+
if (locY < 0) locY = 0;
|
103
|
+
else if (locY > barH) locY = barH;
|
104
|
+
val.call($this, 'xy', {
|
105
|
+
x: ((locX / barW) * rangeX) + minX,
|
106
|
+
y: ((locY / barH) * rangeY) + minY
|
107
|
+
});
|
108
|
+
},
|
109
|
+
drawTimeout,
|
110
|
+
draw = function () {
|
111
|
+
var arrowOffsetX = 0,
|
112
|
+
arrowOffsetY = 0,
|
113
|
+
barW = bar.w,
|
114
|
+
barH = bar.h,
|
115
|
+
arrowW = arrow.w,
|
116
|
+
arrowH = arrow.h;
|
117
|
+
clearTimeout(drawTimeout);
|
118
|
+
drawTimeout = setTimeout(function () {
|
119
|
+
if (rangeX > 0) // range is greater than zero
|
120
|
+
{
|
121
|
+
// constrain to bounds
|
122
|
+
if (x == maxX) arrowOffsetX = barW;
|
123
|
+
else arrowOffsetX = ((x / rangeX) * barW) | 0;
|
124
|
+
}
|
125
|
+
if (rangeY > 0) // range is greater than zero
|
126
|
+
{
|
127
|
+
// constrain to bounds
|
128
|
+
if (y == maxY) arrowOffsetY = barH;
|
129
|
+
else arrowOffsetY = ((y / rangeY) * barH) | 0;
|
130
|
+
}
|
131
|
+
// if arrow width is greater than bar width, center arrow and prevent horizontal dragging
|
132
|
+
if (arrowW >= barW) arrowOffsetX = (barW >> 1) - (arrowW >> 1); // number >> 1 - superfast bitwise divide by two and truncate (move bits over one bit discarding lowest)
|
133
|
+
else arrowOffsetX -= arrowW >> 1;
|
134
|
+
// if arrow height is greater than bar height, center arrow and prevent vertical dragging
|
135
|
+
if (arrowH >= barH) arrowOffsetY = (barH >> 1) - (arrowH >> 1);
|
136
|
+
else arrowOffsetY -= arrowH >> 1;
|
137
|
+
// set the arrow position based on these offsets
|
138
|
+
arrow.css({
|
139
|
+
left: arrowOffsetX + 'px',
|
140
|
+
top: arrowOffsetY + 'px'
|
141
|
+
});
|
142
|
+
}, 0);
|
143
|
+
},
|
144
|
+
val = function (name, value, context) {
|
145
|
+
var set = value !== undefined;
|
146
|
+
if (!set) {
|
147
|
+
if (name === undefined || name == null) name = 'xy';
|
148
|
+
switch (name.toLowerCase()) {
|
149
|
+
case 'x':
|
150
|
+
return x;
|
151
|
+
case 'y':
|
152
|
+
return y;
|
153
|
+
case 'xy':
|
154
|
+
default:
|
155
|
+
return {
|
156
|
+
x: x,
|
157
|
+
y: y
|
158
|
+
};
|
159
|
+
}
|
160
|
+
}
|
161
|
+
if (context != null && context == $this) return;
|
162
|
+
var changed = false,
|
163
|
+
newX,
|
164
|
+
newY;
|
165
|
+
if (name == null) name = 'xy';
|
166
|
+
switch (name.toLowerCase()) {
|
167
|
+
case 'x':
|
168
|
+
newX = value && (value.x && value.x | 0 || value | 0) || 0;
|
169
|
+
break;
|
170
|
+
case 'y':
|
171
|
+
newY = value && (value.y && value.y | 0 || value | 0) || 0;
|
172
|
+
break;
|
173
|
+
case 'xy':
|
174
|
+
default:
|
175
|
+
newX = value && value.x && value.x | 0 || 0;
|
176
|
+
newY = value && value.y && value.y | 0 || 0;
|
177
|
+
break;
|
178
|
+
}
|
179
|
+
if (newX != null) {
|
180
|
+
if (newX < minX) newX = minX;
|
181
|
+
else if (newX > maxX) newX = maxX;
|
182
|
+
if (x != newX) {
|
183
|
+
x = newX;
|
184
|
+
changed = true;
|
185
|
+
}
|
186
|
+
}
|
187
|
+
if (newY != null) {
|
188
|
+
if (newY < minY) newY = minY;
|
189
|
+
else if (newY > maxY) newY = maxY;
|
190
|
+
if (y != newY) {
|
191
|
+
y = newY;
|
192
|
+
changed = true;
|
193
|
+
}
|
194
|
+
}
|
195
|
+
changed && fireChangeEvents.call($this, context || $this);
|
196
|
+
},
|
197
|
+
range = function (name, value) {
|
198
|
+
var set = value !== undefined;
|
199
|
+
if (!set) {
|
200
|
+
if (name === undefined || name == null) name = 'all';
|
201
|
+
switch (name.toLowerCase()) {
|
202
|
+
case 'minx':
|
203
|
+
return minX;
|
204
|
+
case 'maxx':
|
205
|
+
return maxX;
|
206
|
+
case 'rangex':
|
207
|
+
return {
|
208
|
+
minX: minX,
|
209
|
+
maxX: maxX,
|
210
|
+
rangeX: rangeX
|
211
|
+
};
|
212
|
+
case 'miny':
|
213
|
+
return minY;
|
214
|
+
case 'maxy':
|
215
|
+
return maxY;
|
216
|
+
case 'rangey':
|
217
|
+
return {
|
218
|
+
minY: minY,
|
219
|
+
maxY: maxY,
|
220
|
+
rangeY: rangeY
|
221
|
+
};
|
222
|
+
case 'all':
|
223
|
+
default:
|
224
|
+
return {
|
225
|
+
minX: minX,
|
226
|
+
maxX: maxX,
|
227
|
+
rangeX: rangeX,
|
228
|
+
minY: minY,
|
229
|
+
maxY: maxY,
|
230
|
+
rangeY: rangeY
|
231
|
+
};
|
232
|
+
}
|
233
|
+
}
|
234
|
+
var changed = false,
|
235
|
+
newMinX,
|
236
|
+
newMaxX,
|
237
|
+
newMinY,
|
238
|
+
newMaxY;
|
239
|
+
if (name == null) name = 'all';
|
240
|
+
switch (name.toLowerCase()) {
|
241
|
+
case 'minx':
|
242
|
+
newMinX = value && (value.minX && value.minX | 0 || value | 0) || 0;
|
243
|
+
break;
|
244
|
+
case 'maxx':
|
245
|
+
newMaxX = value && (value.maxX && value.maxX | 0 || value | 0) || 0;
|
246
|
+
break;
|
247
|
+
case 'rangex':
|
248
|
+
newMinX = value && value.minX && value.minX | 0 || 0;
|
249
|
+
newMaxX = value && value.maxX && value.maxX | 0 || 0;
|
250
|
+
break;
|
251
|
+
case 'miny':
|
252
|
+
newMinY = value && (value.minY && value.minY | 0 || value | 0) || 0;
|
253
|
+
break;
|
254
|
+
case 'maxy':
|
255
|
+
newMaxY = value && (value.maxY && value.maxY | 0 || value | 0) || 0;
|
256
|
+
break;
|
257
|
+
case 'rangey':
|
258
|
+
newMinY = value && value.minY && value.minY | 0 || 0;
|
259
|
+
newMaxY = value && value.maxY && value.maxY | 0 || 0;
|
260
|
+
break;
|
261
|
+
case 'all':
|
262
|
+
default:
|
263
|
+
newMinX = value && value.minX && value.minX | 0 || 0;
|
264
|
+
newMaxX = value && value.maxX && value.maxX | 0 || 0;
|
265
|
+
newMinY = value && value.minY && value.minY | 0 || 0;
|
266
|
+
newMaxY = value && value.maxY && value.maxY | 0 || 0;
|
267
|
+
break;
|
268
|
+
}
|
269
|
+
if (newMinX != null && minX != newMinX) {
|
270
|
+
minX = newMinX;
|
271
|
+
rangeX = maxX - minX;
|
272
|
+
}
|
273
|
+
if (newMaxX != null && maxX != newMaxX) {
|
274
|
+
maxX = newMaxX;
|
275
|
+
rangeX = maxX - minX;
|
276
|
+
}
|
277
|
+
if (newMinY != null && minY != newMinY) {
|
278
|
+
minY = newMinY;
|
279
|
+
rangeY = maxY - minY;
|
280
|
+
}
|
281
|
+
if (newMaxY != null && maxY != newMaxY) {
|
282
|
+
maxY = newMaxY;
|
283
|
+
rangeY = maxY - minY;
|
284
|
+
}
|
285
|
+
},
|
286
|
+
bind = function (callback) {
|
287
|
+
if ($.isFunction(callback)) changeEvents.push(callback);
|
288
|
+
},
|
289
|
+
unbind = function (callback) {
|
290
|
+
if (!$.isFunction(callback)) return;
|
291
|
+
var i;
|
292
|
+
while ((i = $.inArray(callback, changeEvents)) != -1) changeEvents.splice(i, 1);
|
293
|
+
},
|
294
|
+
destroy = function () {
|
295
|
+
// unbind all possible events and null objects
|
296
|
+
$(document).unbind('mouseup', mouseUp).unbind('mousemove', mouseMove);
|
297
|
+
bar.unbind('mousedown', mouseDown);
|
298
|
+
bar = null;
|
299
|
+
arrow = null;
|
300
|
+
changeEvents = null;
|
301
|
+
};
|
302
|
+
|
303
|
+
$.extend(true, $this, // public properties, methods, and event bindings - these we need to access from other controls
|
304
|
+
{
|
305
|
+
val: val,
|
306
|
+
range: range,
|
307
|
+
bind: bind,
|
308
|
+
unbind: unbind,
|
309
|
+
destroy: destroy
|
310
|
+
});
|
311
|
+
// initialize this control
|
312
|
+
arrow.src = options.arrow && options.arrow.image;
|
313
|
+
arrow.w = options.arrow && options.arrow.width || arrow.width();
|
314
|
+
arrow.h = options.arrow && options.arrow.height || arrow.height();
|
315
|
+
bar.w = options.map && options.map.width || bar.width();
|
316
|
+
bar.h = options.map && options.map.height || bar.height();
|
317
|
+
// bind mousedown event
|
318
|
+
bar.bind('mousedown', mouseDown);
|
319
|
+
bind.call($this, draw);
|
320
|
+
},
|
321
|
+
ColorValuePicker = // controls for all the input elements for the typing in color values
|
322
|
+
|
323
|
+
function (picker, color, bindedHex, alphaPrecision) {
|
324
|
+
var $this = this, // private properties and methods
|
325
|
+
inputs = picker.find('td.Text input'),
|
326
|
+
red = inputs.eq(3),
|
327
|
+
green = inputs.eq(4),
|
328
|
+
blue = inputs.eq(5),
|
329
|
+
alpha = inputs.length > 7 ? inputs.eq(6) : null,
|
330
|
+
hue = inputs.eq(0),
|
331
|
+
saturation = inputs.eq(1),
|
332
|
+
value = inputs.eq(2),
|
333
|
+
hex = inputs.eq(inputs.length > 7 ? 7 : 6),
|
334
|
+
ahex = inputs.length > 7 ? inputs.eq(8) : null,
|
335
|
+
keyDown = // input box key down - use arrows to alter color
|
336
|
+
|
337
|
+
function (e) {
|
338
|
+
if (e.target.value == '' && e.target != hex.get(0) && (bindedHex != null && e.target != bindedHex.get(0) || bindedHex == null)) return;
|
339
|
+
if (!validateKey(e)) return e;
|
340
|
+
switch (e.target) {
|
341
|
+
case red.get(0):
|
342
|
+
switch (e.keyCode) {
|
343
|
+
case 38:
|
344
|
+
red.val(setValueInRange.call($this, (red.val() << 0) + 1, 0, 255));
|
345
|
+
color.val('r', red.val(), e.target);
|
346
|
+
return false;
|
347
|
+
case 40:
|
348
|
+
red.val(setValueInRange.call($this, (red.val() << 0) - 1, 0, 255));
|
349
|
+
color.val('r', red.val(), e.target);
|
350
|
+
return false;
|
351
|
+
}
|
352
|
+
break;
|
353
|
+
case green.get(0):
|
354
|
+
switch (e.keyCode) {
|
355
|
+
case 38:
|
356
|
+
green.val(setValueInRange.call($this, (green.val() << 0) + 1, 0, 255));
|
357
|
+
color.val('g', green.val(), e.target);
|
358
|
+
return false;
|
359
|
+
case 40:
|
360
|
+
green.val(setValueInRange.call($this, (green.val() << 0) - 1, 0, 255));
|
361
|
+
color.val('g', green.val(), e.target);
|
362
|
+
return false;
|
363
|
+
}
|
364
|
+
break;
|
365
|
+
case blue.get(0):
|
366
|
+
switch (e.keyCode) {
|
367
|
+
case 38:
|
368
|
+
blue.val(setValueInRange.call($this, (blue.val() << 0) + 1, 0, 255));
|
369
|
+
color.val('b', blue.val(), e.target);
|
370
|
+
return false;
|
371
|
+
case 40:
|
372
|
+
blue.val(setValueInRange.call($this, (blue.val() << 0) - 1, 0, 255));
|
373
|
+
color.val('b', blue.val(), e.target);
|
374
|
+
return false;
|
375
|
+
}
|
376
|
+
break;
|
377
|
+
case alpha && alpha.get(0):
|
378
|
+
switch (e.keyCode) {
|
379
|
+
case 38:
|
380
|
+
alpha.val(setValueInRange.call($this, parseFloat(alpha.val()) + 1, 0, 100));
|
381
|
+
color.val('a', mPrecision((alpha.val() * 255) / 100, alphaPrecision), e.target);
|
382
|
+
return false;
|
383
|
+
case 40:
|
384
|
+
alpha.val(setValueInRange.call($this, parseFloat(alpha.val()) - 1, 0, 100));
|
385
|
+
color.val('a', mPrecision((alpha.val() * 255) / 100, alphaPrecision), e.target);
|
386
|
+
return false;
|
387
|
+
}
|
388
|
+
break;
|
389
|
+
case hue.get(0):
|
390
|
+
switch (e.keyCode) {
|
391
|
+
case 38:
|
392
|
+
hue.val(setValueInRange.call($this, (hue.val() << 0) + 1, 0, 360));
|
393
|
+
color.val('h', hue.val(), e.target);
|
394
|
+
return false;
|
395
|
+
case 40:
|
396
|
+
hue.val(setValueInRange.call($this, (hue.val() << 0) - 1, 0, 360));
|
397
|
+
color.val('h', hue.val(), e.target);
|
398
|
+
return false;
|
399
|
+
}
|
400
|
+
break;
|
401
|
+
case saturation.get(0):
|
402
|
+
switch (e.keyCode) {
|
403
|
+
case 38:
|
404
|
+
saturation.val(setValueInRange.call($this, (saturation.val() << 0) + 1, 0, 100));
|
405
|
+
color.val('s', saturation.val(), e.target);
|
406
|
+
return false;
|
407
|
+
case 40:
|
408
|
+
saturation.val(setValueInRange.call($this, (saturation.val() << 0) - 1, 0, 100));
|
409
|
+
color.val('s', saturation.val(), e.target);
|
410
|
+
return false;
|
411
|
+
}
|
412
|
+
break;
|
413
|
+
case value.get(0):
|
414
|
+
switch (e.keyCode) {
|
415
|
+
case 38:
|
416
|
+
value.val(setValueInRange.call($this, (value.val() << 0) + 1, 0, 100));
|
417
|
+
color.val('v', value.val(), e.target);
|
418
|
+
return false;
|
419
|
+
case 40:
|
420
|
+
value.val(setValueInRange.call($this, (value.val() << 0) - 1, 0, 100));
|
421
|
+
color.val('v', value.val(), e.target);
|
422
|
+
return false;
|
423
|
+
}
|
424
|
+
break;
|
425
|
+
}
|
426
|
+
},
|
427
|
+
keyUp = // input box key up - validate value and set color
|
428
|
+
|
429
|
+
function (e) {
|
430
|
+
if (e.target.value == '' && e.target != hex.get(0) && (bindedHex != null && e.target != bindedHex.get(0) || bindedHex == null)) return;
|
431
|
+
if (!validateKey(e)) return e;
|
432
|
+
switch (e.target) {
|
433
|
+
case red.get(0):
|
434
|
+
red.val(setValueInRange.call($this, red.val(), 0, 255));
|
435
|
+
color.val('r', red.val(), e.target);
|
436
|
+
break;
|
437
|
+
case green.get(0):
|
438
|
+
green.val(setValueInRange.call($this, green.val(), 0, 255));
|
439
|
+
color.val('g', green.val(), e.target);
|
440
|
+
break;
|
441
|
+
case blue.get(0):
|
442
|
+
blue.val(setValueInRange.call($this, blue.val(), 0, 255));
|
443
|
+
color.val('b', blue.val(), e.target);
|
444
|
+
break;
|
445
|
+
case alpha && alpha.get(0):
|
446
|
+
alpha.val(setValueInRange.call($this, alpha.val(), 0, 100));
|
447
|
+
color.val('a', mPrecision((alpha.val() * 255) / 100, alphaPrecision), e.target);
|
448
|
+
break;
|
449
|
+
case hue.get(0):
|
450
|
+
hue.val(setValueInRange.call($this, hue.val(), 0, 360));
|
451
|
+
color.val('h', hue.val(), e.target);
|
452
|
+
break;
|
453
|
+
case saturation.get(0):
|
454
|
+
saturation.val(setValueInRange.call($this, saturation.val(), 0, 100));
|
455
|
+
color.val('s', saturation.val(), e.target);
|
456
|
+
break;
|
457
|
+
case value.get(0):
|
458
|
+
value.val(setValueInRange.call($this, value.val(), 0, 100));
|
459
|
+
color.val('v', value.val(), e.target);
|
460
|
+
break;
|
461
|
+
case hex.get(0):
|
462
|
+
hex.val(hex.val().replace(/[^a-fA-F0-9]/g, '').toLowerCase().substring(0, 6));
|
463
|
+
bindedHex && bindedHex.val(hex.val());
|
464
|
+
color.val('hex', hex.val() != '' ? hex.val() : null, e.target);
|
465
|
+
break;
|
466
|
+
case bindedHex && bindedHex.get(0):
|
467
|
+
bindedHex.val(bindedHex.val().replace(/[^a-fA-F0-9]/g, '').toLowerCase().substring(0, 6));
|
468
|
+
hex.val(bindedHex.val());
|
469
|
+
color.val('hex', bindedHex.val() != '' ? bindedHex.val() : null, e.target);
|
470
|
+
break;
|
471
|
+
case ahex && ahex.get(0):
|
472
|
+
ahex.val(ahex.val().replace(/[^a-fA-F0-9]/g, '').toLowerCase().substring(0, 2));
|
473
|
+
color.val('a', ahex.val() != null ? parseInt(ahex.val(), 16) : null, e.target);
|
474
|
+
break;
|
475
|
+
}
|
476
|
+
},
|
477
|
+
blur = // input box blur - reset to original if value empty
|
478
|
+
|
479
|
+
function (e) {
|
480
|
+
if (color.val() != null) {
|
481
|
+
switch (e.target) {
|
482
|
+
case red.get(0):
|
483
|
+
red.val(color.val('r'));
|
484
|
+
break;
|
485
|
+
case green.get(0):
|
486
|
+
green.val(color.val('g'));
|
487
|
+
break;
|
488
|
+
case blue.get(0):
|
489
|
+
blue.val(color.val('b'));
|
490
|
+
break;
|
491
|
+
case alpha && alpha.get(0):
|
492
|
+
alpha.val(mPrecision((color.val('a') * 100) / 255, alphaPrecision));
|
493
|
+
break;
|
494
|
+
case hue.get(0):
|
495
|
+
hue.val(color.val('h'));
|
496
|
+
break;
|
497
|
+
case saturation.get(0):
|
498
|
+
saturation.val(color.val('s'));
|
499
|
+
break;
|
500
|
+
case value.get(0):
|
501
|
+
value.val(color.val('v'));
|
502
|
+
break;
|
503
|
+
case hex.get(0):
|
504
|
+
case bindedHex && bindedHex.get(0):
|
505
|
+
hex.val(color.val('hex'));
|
506
|
+
bindedHex && bindedHex.val(color.val('hex'));
|
507
|
+
break;
|
508
|
+
case ahex && ahex.get(0):
|
509
|
+
ahex.val(color.val('ahex').substring(6));
|
510
|
+
break;
|
511
|
+
}
|
512
|
+
}
|
513
|
+
},
|
514
|
+
validateKey = // validate key
|
515
|
+
|
516
|
+
function (e) {
|
517
|
+
switch (e.keyCode) {
|
518
|
+
case 9:
|
519
|
+
case 16:
|
520
|
+
case 29:
|
521
|
+
case 37:
|
522
|
+
case 39:
|
523
|
+
return false;
|
524
|
+
case 'c'.charCodeAt():
|
525
|
+
case 'v'.charCodeAt():
|
526
|
+
if (e.ctrlKey) return false;
|
527
|
+
}
|
528
|
+
return true;
|
529
|
+
},
|
530
|
+
setValueInRange = // constrain value within range
|
531
|
+
|
532
|
+
function (value, min, max) {
|
533
|
+
if (value == '' || isNaN(value)) return min;
|
534
|
+
if (value > max) return max;
|
535
|
+
if (value < min) return min;
|
536
|
+
return value;
|
537
|
+
},
|
538
|
+
colorChanged = function (ui, context) {
|
539
|
+
var all = ui.val('all');
|
540
|
+
if (context != red.get(0)) red.val(all != null ? all.r : '');
|
541
|
+
if (context != green.get(0)) green.val(all != null ? all.g : '');
|
542
|
+
if (context != blue.get(0)) blue.val(all != null ? all.b : '');
|
543
|
+
if (alpha && context != alpha.get(0)) alpha.val(all != null ? mPrecision((all.a * 100) / 255, alphaPrecision) : '');
|
544
|
+
if (context != hue.get(0)) hue.val(all != null ? all.h : '');
|
545
|
+
if (context != saturation.get(0)) saturation.val(all != null ? all.s : '');
|
546
|
+
if (context != value.get(0)) value.val(all != null ? all.v : '');
|
547
|
+
if (context != hex.get(0) && (bindedHex && context != bindedHex.get(0) || !bindedHex)) hex.val(all != null ? all.hex : '');
|
548
|
+
if (bindedHex && context != bindedHex.get(0) && context != hex.get(0)) bindedHex.val(all != null ? all.hex : '');
|
549
|
+
if (ahex && context != ahex.get(0)) ahex.val(all != null ? all.ahex.substring(6) : '');
|
550
|
+
},
|
551
|
+
destroy = function () {
|
552
|
+
// unbind all events and null objects
|
553
|
+
red.add(green).add(blue).add(alpha).add(hue).add(saturation).add(value).add(hex).add(bindedHex).add(ahex).unbind('keyup', keyUp).unbind('blur', blur);
|
554
|
+
red.add(green).add(blue).add(alpha).add(hue).add(saturation).add(value).unbind('keydown', keyDown);
|
555
|
+
color.unbind(colorChanged);
|
556
|
+
red = null;
|
557
|
+
green = null;
|
558
|
+
blue = null;
|
559
|
+
alpha = null;
|
560
|
+
hue = null;
|
561
|
+
saturation = null;
|
562
|
+
value = null;
|
563
|
+
hex = null;
|
564
|
+
ahex = null;
|
565
|
+
};
|
566
|
+
elemExtend(true, $this, // public properties and methods
|
567
|
+
{
|
568
|
+
destroy: destroy
|
569
|
+
});
|
570
|
+
red.add(green).add(blue).add(alpha).add(hue).add(saturation).add(value).add(hex).add(bindedHex).add(ahex).bind('keyup', keyUp).bind('blur', blur);
|
571
|
+
red.add(green).add(blue).add(alpha).add(hue).add(saturation).add(value).bind('keydown', keyDown);
|
572
|
+
color.bind(colorChanged);
|
573
|
+
};
|
574
|
+
$.wsjPicker = {
|
575
|
+
List: [], // array holding references to each active instance of the control
|
576
|
+
Color: // color object - we will be able to assign by any color space type or retrieve any color space info
|
577
|
+
// we want this public so we can optionally assign new color objects to initial values using inputs other than a string hex value (also supported)
|
578
|
+
|
579
|
+
function (init) {
|
580
|
+
var $this = this,
|
581
|
+
r,
|
582
|
+
g,
|
583
|
+
b,
|
584
|
+
a,
|
585
|
+
h,
|
586
|
+
s,
|
587
|
+
v,
|
588
|
+
changeEvents = new Array(),
|
589
|
+
fireChangeEvents = function (context) {
|
590
|
+
for (var i = 0; i < changeEvents.length; i++) changeEvents[i].call($this, $this, context);
|
591
|
+
},
|
592
|
+
val = function (name, value, context) {
|
593
|
+
var set = value !== undefined;
|
594
|
+
if (!set) {
|
595
|
+
if (name === undefined || name == null || name == '') name = 'all';
|
596
|
+
if (r == null) return null;
|
597
|
+
switch (name.toLowerCase()) {
|
598
|
+
case 'ahex':
|
599
|
+
return ColorMethods.rgbaToHex({
|
600
|
+
r: r,
|
601
|
+
g: g,
|
602
|
+
b: b,
|
603
|
+
a: a
|
604
|
+
});
|
605
|
+
case 'hex':
|
606
|
+
return val('ahex').substring(0, 6);
|
607
|
+
case 'all':
|
608
|
+
return {
|
609
|
+
r: r,
|
610
|
+
g: g,
|
611
|
+
b: b,
|
612
|
+
a: a,
|
613
|
+
h: h,
|
614
|
+
s: s,
|
615
|
+
v: v,
|
616
|
+
hex: val.call($this, 'hex'),
|
617
|
+
ahex: val.call($this, 'ahex')
|
618
|
+
};
|
619
|
+
default:
|
620
|
+
var ret = {};
|
621
|
+
for (var i = 0; i < name.length; i++) {
|
622
|
+
switch (name.charAt(i)) {
|
623
|
+
case 'r':
|
624
|
+
if (name.length == 1) ret = r;
|
625
|
+
else ret.r = r;
|
626
|
+
break;
|
627
|
+
case 'g':
|
628
|
+
if (name.length == 1) ret = g;
|
629
|
+
else ret.g = g;
|
630
|
+
break;
|
631
|
+
case 'b':
|
632
|
+
if (name.length == 1) ret = b;
|
633
|
+
else ret.b = b;
|
634
|
+
break;
|
635
|
+
case 'a':
|
636
|
+
if (name.length == 1) ret = a;
|
637
|
+
else ret.a = a;
|
638
|
+
break;
|
639
|
+
case 'h':
|
640
|
+
if (name.length == 1) ret = h;
|
641
|
+
else ret.h = h;
|
642
|
+
break;
|
643
|
+
case 's':
|
644
|
+
if (name.length == 1) ret = s;
|
645
|
+
else ret.s = s;
|
646
|
+
break;
|
647
|
+
case 'v':
|
648
|
+
if (name.length == 1) ret = v;
|
649
|
+
else ret.v = v;
|
650
|
+
break;
|
651
|
+
}
|
652
|
+
}
|
653
|
+
return ret == {} ? val.call($this, 'all') : ret;
|
654
|
+
break;
|
655
|
+
}
|
656
|
+
}
|
657
|
+
if (context != null && context == $this) return;
|
658
|
+
var changed = false;
|
659
|
+
if (name == null) name = '';
|
660
|
+
if (value == null) {
|
661
|
+
if (r != null) {
|
662
|
+
r = null;
|
663
|
+
changed = true;
|
664
|
+
}
|
665
|
+
if (g != null) {
|
666
|
+
g = null;
|
667
|
+
changed = true;
|
668
|
+
}
|
669
|
+
if (b != null) {
|
670
|
+
b = null;
|
671
|
+
changed = true;
|
672
|
+
}
|
673
|
+
if (a != null) {
|
674
|
+
a = null;
|
675
|
+
changed = true;
|
676
|
+
}
|
677
|
+
if (h != null) {
|
678
|
+
h = null;
|
679
|
+
changed = true;
|
680
|
+
}
|
681
|
+
if (s != null) {
|
682
|
+
s = null;
|
683
|
+
changed = true;
|
684
|
+
}
|
685
|
+
if (v != null) {
|
686
|
+
v = null;
|
687
|
+
changed = true;
|
688
|
+
}
|
689
|
+
changed && fireChangeEvents.call($this, context || $this);
|
690
|
+
return;
|
691
|
+
}
|
692
|
+
switch (name.toLowerCase()) {
|
693
|
+
case 'ahex':
|
694
|
+
case 'hex':
|
695
|
+
var ret = ColorMethods.hexToRgba(value && (value.ahex || value.hex) || value || '00000000');
|
696
|
+
val.call($this, 'rgba', {
|
697
|
+
r: ret.r,
|
698
|
+
g: ret.g,
|
699
|
+
b: ret.b,
|
700
|
+
a: name == 'ahex' ? ret.a : a != null ? a : 255
|
701
|
+
}, context);
|
702
|
+
break;
|
703
|
+
default:
|
704
|
+
if (value && (value.ahex != null || value.hex != null)) {
|
705
|
+
val.call($this, 'ahex', value.ahex || value.hex || '00000000', context);
|
706
|
+
return;
|
707
|
+
}
|
708
|
+
var newV = {}, rgb = false,
|
709
|
+
hsv = false;
|
710
|
+
if (value.r !== undefined && !name.indexOf('r') == -1) name += 'r';
|
711
|
+
if (value.g !== undefined && !name.indexOf('g') == -1) name += 'g';
|
712
|
+
if (value.b !== undefined && !name.indexOf('b') == -1) name += 'b';
|
713
|
+
if (value.a !== undefined && !name.indexOf('a') == -1) name += 'a';
|
714
|
+
if (value.h !== undefined && !name.indexOf('h') == -1) name += 'h';
|
715
|
+
if (value.s !== undefined && !name.indexOf('s') == -1) name += 's';
|
716
|
+
if (value.v !== undefined && !name.indexOf('v') == -1) name += 'v';
|
717
|
+
for (var i = 0; i < name.length; i++) {
|
718
|
+
switch (name.charAt(i)) {
|
719
|
+
case 'r':
|
720
|
+
if (hsv) continue;
|
721
|
+
rgb = true;
|
722
|
+
newV.r = value && value.r && value.r | 0 || value && value | 0 || 0;
|
723
|
+
if (newV.r < 0) newV.r = 0;
|
724
|
+
else if (newV.r > 255) newV.r = 255;
|
725
|
+
if (r != newV.r) {
|
726
|
+
r = newV.r;
|
727
|
+
changed = true;
|
728
|
+
}
|
729
|
+
break;
|
730
|
+
case 'g':
|
731
|
+
if (hsv) continue;
|
732
|
+
rgb = true;
|
733
|
+
newV.g = value && value.g && value.g | 0 || value && value | 0 || 0;
|
734
|
+
if (newV.g < 0) newV.g = 0;
|
735
|
+
else if (newV.g > 255) newV.g = 255;
|
736
|
+
if (g != newV.g) {
|
737
|
+
g = newV.g;
|
738
|
+
changed = true;
|
739
|
+
}
|
740
|
+
break;
|
741
|
+
case 'b':
|
742
|
+
if (hsv) continue;
|
743
|
+
rgb = true;
|
744
|
+
newV.b = value && value.b && value.b | 0 || value && value | 0 || 0;
|
745
|
+
if (newV.b < 0) newV.b = 0;
|
746
|
+
else if (newV.b > 255) newV.b = 255;
|
747
|
+
if (b != newV.b) {
|
748
|
+
b = newV.b;
|
749
|
+
changed = true;
|
750
|
+
}
|
751
|
+
break;
|
752
|
+
case 'a':
|
753
|
+
newV.a = value && value.a != null ? value.a | 0 : value != null ? value | 0 : 255;
|
754
|
+
if (newV.a < 0) newV.a = 0;
|
755
|
+
else if (newV.a > 255) newV.a = 255;
|
756
|
+
if (a != newV.a) {
|
757
|
+
a = newV.a;
|
758
|
+
changed = true;
|
759
|
+
}
|
760
|
+
break;
|
761
|
+
case 'h':
|
762
|
+
if (rgb) continue;
|
763
|
+
hsv = true;
|
764
|
+
newV.h = value && value.h && value.h | 0 || value && value | 0 || 0;
|
765
|
+
if (newV.h < 0) newV.h = 0;
|
766
|
+
else if (newV.h > 360) newV.h = 360;
|
767
|
+
if (h != newV.h) {
|
768
|
+
h = newV.h;
|
769
|
+
changed = true;
|
770
|
+
}
|
771
|
+
break;
|
772
|
+
case 's':
|
773
|
+
if (rgb) continue;
|
774
|
+
hsv = true;
|
775
|
+
newV.s = value && value.s != null ? value.s | 0 : value != null ? value | 0 : 100;
|
776
|
+
if (newV.s < 0) newV.s = 0;
|
777
|
+
else if (newV.s > 100) newV.s = 100;
|
778
|
+
if (s != newV.s) {
|
779
|
+
s = newV.s;
|
780
|
+
changed = true;
|
781
|
+
}
|
782
|
+
break;
|
783
|
+
case 'v':
|
784
|
+
if (rgb) continue;
|
785
|
+
hsv = true;
|
786
|
+
newV.v = value && value.v != null ? value.v | 0 : value != null ? value | 0 : 100;
|
787
|
+
if (newV.v < 0) newV.v = 0;
|
788
|
+
else if (newV.v > 100) newV.v = 100;
|
789
|
+
if (v != newV.v) {
|
790
|
+
v = newV.v;
|
791
|
+
changed = true;
|
792
|
+
}
|
793
|
+
break;
|
794
|
+
}
|
795
|
+
}
|
796
|
+
if (changed) {
|
797
|
+
if (rgb) {
|
798
|
+
r = r || 0;
|
799
|
+
g = g || 0;
|
800
|
+
b = b || 0;
|
801
|
+
var ret = ColorMethods.rgbToHsv({
|
802
|
+
r: r,
|
803
|
+
g: g,
|
804
|
+
b: b
|
805
|
+
});
|
806
|
+
h = ret.h;
|
807
|
+
s = ret.s;
|
808
|
+
v = ret.v;
|
809
|
+
} else if (hsv) {
|
810
|
+
h = h || 0;
|
811
|
+
s = s != null ? s : 100;
|
812
|
+
v = v != null ? v : 100;
|
813
|
+
var ret = ColorMethods.hsvToRgb({
|
814
|
+
h: h,
|
815
|
+
s: s,
|
816
|
+
v: v
|
817
|
+
});
|
818
|
+
r = ret.r;
|
819
|
+
g = ret.g;
|
820
|
+
b = ret.b;
|
821
|
+
}
|
822
|
+
a = a != null ? a : 255;
|
823
|
+
fireChangeEvents.call($this, context || $this);
|
824
|
+
}
|
825
|
+
break;
|
826
|
+
}
|
827
|
+
},
|
828
|
+
bind = function (callback) {
|
829
|
+
if ($.isFunction(callback)) changeEvents.push(callback);
|
830
|
+
},
|
831
|
+
unbind = function (callback) {
|
832
|
+
if (!$.isFunction(callback)) return;
|
833
|
+
var i;
|
834
|
+
while ((i = $.inArray(callback, changeEvents)) != -1) changeEvents.splice(i, 1);
|
835
|
+
},
|
836
|
+
destroy = function () {
|
837
|
+
changeEvents = null;
|
838
|
+
}
|
839
|
+
elemExtend(true, $this, // public properties and methods
|
840
|
+
{
|
841
|
+
val: val,
|
842
|
+
bind: bind,
|
843
|
+
unbind: unbind,
|
844
|
+
destroy: destroy
|
845
|
+
});
|
846
|
+
if (init) {
|
847
|
+
if (init.ahex != null) val('ahex', init);
|
848
|
+
else if (init.hex != null) val((init.a != null ? 'a' : '') + 'hex', init.a != null ? {
|
849
|
+
ahex: init.hex + ColorMethods.intToHex(init.a)
|
850
|
+
} : init);
|
851
|
+
else if (init.r != null && init.g != null && init.b != null) val('rgb' + (init.a != null ? 'a' : ''), init);
|
852
|
+
else if (init.h != null && init.s != null && init.v != null) val('hsv' + (init.a != null ? 'a' : ''), init);
|
853
|
+
}
|
854
|
+
},
|
855
|
+
ColorMethods: // color conversion methods - make public to give use to external scripts
|
856
|
+
{
|
857
|
+
hexToRgba: function (hex) {
|
858
|
+
hex = this.validateHex(hex);
|
859
|
+
if (hex == '') return {
|
860
|
+
r: null,
|
861
|
+
g: null,
|
862
|
+
b: null,
|
863
|
+
a: null
|
864
|
+
};
|
865
|
+
var r = '00',
|
866
|
+
g = '00',
|
867
|
+
b = '00',
|
868
|
+
a = '255';
|
869
|
+
if (hex.length == 6) hex += 'ff';
|
870
|
+
if (hex.length > 6) {
|
871
|
+
r = hex.substring(0, 2);
|
872
|
+
g = hex.substring(2, 4);
|
873
|
+
b = hex.substring(4, 6);
|
874
|
+
a = hex.substring(6, hex.length);
|
875
|
+
} else {
|
876
|
+
if (hex.length > 4) {
|
877
|
+
r = hex.substring(4, hex.length);
|
878
|
+
hex = hex.substring(0, 4);
|
879
|
+
}
|
880
|
+
if (hex.length > 2) {
|
881
|
+
g = hex.substring(2, hex.length);
|
882
|
+
hex = hex.substring(0, 2);
|
883
|
+
}
|
884
|
+
if (hex.length > 0) b = hex.substring(0, hex.length);
|
885
|
+
}
|
886
|
+
return {
|
887
|
+
r: this.hexToInt(r),
|
888
|
+
g: this.hexToInt(g),
|
889
|
+
b: this.hexToInt(b),
|
890
|
+
a: this.hexToInt(a)
|
891
|
+
};
|
892
|
+
},
|
893
|
+
validateHex: function (hex) {
|
894
|
+
hex = hex.toLowerCase().replace(/[^a-f0-9]/g, '');
|
895
|
+
if (hex.length > 8) hex = hex.substring(0, 8);
|
896
|
+
return hex;
|
897
|
+
},
|
898
|
+
rgbaToHex: function (rgba) {
|
899
|
+
return this.intToHex(rgba.r) + this.intToHex(rgba.g) + this.intToHex(rgba.b) + this.intToHex(rgba.a);
|
900
|
+
},
|
901
|
+
intToHex: function (dec) {
|
902
|
+
var result = (dec | 0).toString(16);
|
903
|
+
if (result.length == 1) result = ('0' + result);
|
904
|
+
return result.toLowerCase();
|
905
|
+
},
|
906
|
+
hexToInt: function (hex) {
|
907
|
+
return parseInt(hex, 16);
|
908
|
+
},
|
909
|
+
rgbToHsv: function (rgb) {
|
910
|
+
var r = rgb.r / 255,
|
911
|
+
g = rgb.g / 255,
|
912
|
+
b = rgb.b / 255,
|
913
|
+
hsv = {
|
914
|
+
h: 0,
|
915
|
+
s: 0,
|
916
|
+
v: 0
|
917
|
+
}, min = 0,
|
918
|
+
max = 0,
|
919
|
+
delta;
|
920
|
+
if (r >= g && r >= b) {
|
921
|
+
max = r;
|
922
|
+
min = g > b ? b : g;
|
923
|
+
} else if (g >= b && g >= r) {
|
924
|
+
max = g;
|
925
|
+
min = r > b ? b : r;
|
926
|
+
} else {
|
927
|
+
max = b;
|
928
|
+
min = g > r ? r : g;
|
929
|
+
}
|
930
|
+
hsv.v = max;
|
931
|
+
hsv.s = max ? (max - min) / max : 0;
|
932
|
+
if (!hsv.s) hsv.h = 0;
|
933
|
+
else {
|
934
|
+
delta = max - min;
|
935
|
+
if (r == max) hsv.h = (g - b) / delta;
|
936
|
+
else if (g == max) hsv.h = 2 + (b - r) / delta;
|
937
|
+
else hsv.h = 4 + (r - g) / delta;
|
938
|
+
hsv.h = parseInt(hsv.h * 60);
|
939
|
+
if (hsv.h < 0) hsv.h += 360;
|
940
|
+
}
|
941
|
+
hsv.s = (hsv.s * 100) | 0;
|
942
|
+
hsv.v = (hsv.v * 100) | 0;
|
943
|
+
return hsv;
|
944
|
+
},
|
945
|
+
hsvToRgb: function (hsv) {
|
946
|
+
var rgb = {
|
947
|
+
r: 0,
|
948
|
+
g: 0,
|
949
|
+
b: 0,
|
950
|
+
a: 100
|
951
|
+
}, h = hsv.h,
|
952
|
+
s = hsv.s,
|
953
|
+
v = hsv.v;
|
954
|
+
if (s == 0) {
|
955
|
+
if (v == 0) rgb.r = rgb.g = rgb.b = 0;
|
956
|
+
else rgb.r = rgb.g = rgb.b = (v * 255 / 100) | 0;
|
957
|
+
} else {
|
958
|
+
if (h == 360) h = 0;
|
959
|
+
h /= 60;
|
960
|
+
s = s / 100;
|
961
|
+
v = v / 100;
|
962
|
+
var i = h | 0,
|
963
|
+
f = h - i,
|
964
|
+
p = v * (1 - s),
|
965
|
+
q = v * (1 - (s * f)),
|
966
|
+
t = v * (1 - (s * (1 - f)));
|
967
|
+
switch (i) {
|
968
|
+
case 0:
|
969
|
+
rgb.r = v;
|
970
|
+
rgb.g = t;
|
971
|
+
rgb.b = p;
|
972
|
+
break;
|
973
|
+
case 1:
|
974
|
+
rgb.r = q;
|
975
|
+
rgb.g = v;
|
976
|
+
rgb.b = p;
|
977
|
+
break;
|
978
|
+
case 2:
|
979
|
+
rgb.r = p;
|
980
|
+
rgb.g = v;
|
981
|
+
rgb.b = t;
|
982
|
+
break;
|
983
|
+
case 3:
|
984
|
+
rgb.r = p;
|
985
|
+
rgb.g = q;
|
986
|
+
rgb.b = v;
|
987
|
+
break;
|
988
|
+
case 4:
|
989
|
+
rgb.r = t;
|
990
|
+
rgb.g = p;
|
991
|
+
rgb.b = v;
|
992
|
+
break;
|
993
|
+
case 5:
|
994
|
+
rgb.r = v;
|
995
|
+
rgb.g = p;
|
996
|
+
rgb.b = q;
|
997
|
+
break;
|
998
|
+
}
|
999
|
+
rgb.r = (rgb.r * 255) | 0;
|
1000
|
+
rgb.g = (rgb.g * 255) | 0;
|
1001
|
+
rgb.b = (rgb.b * 255) | 0;
|
1002
|
+
}
|
1003
|
+
return rgb;
|
1004
|
+
}
|
1005
|
+
}
|
1006
|
+
};
|
1007
|
+
var Color = $.wsjPicker.Color,
|
1008
|
+
List = $.wsjPicker.List,
|
1009
|
+
ColorMethods = $.wsjPicker.ColorMethods; // local copies for YUI compressor
|
1010
|
+
$.fn.wsjPicker = function (options) {
|
1011
|
+
var $arguments = arguments;
|
1012
|
+
return this.each(function () {
|
1013
|
+
var $this = this,
|
1014
|
+
settings = $.extend(true, {}, $.fn.wsjPicker.defaults, options); // local copies for YUI compressor
|
1015
|
+
|
1016
|
+
settings.window.liveUpdate = false; // Basic control binding for inline use - You will need to override the liveCallback or commitCallback function to retrieve results
|
1017
|
+
var container = null,
|
1018
|
+
colorMapDiv = null,
|
1019
|
+
colorBarDiv = null,
|
1020
|
+
colorMapL1 = null, // different layers of colorMap and colorBar
|
1021
|
+
colorMapL2 = null,
|
1022
|
+
colorMapL3 = null,
|
1023
|
+
colorBarL1 = null,
|
1024
|
+
colorBarL2 = null,
|
1025
|
+
colorBarL3 = null,
|
1026
|
+
colorBarL4 = null,
|
1027
|
+
colorBarL5 = null,
|
1028
|
+
colorBarL6 = null,
|
1029
|
+
colorMap = null, // color maps
|
1030
|
+
colorBar = null,
|
1031
|
+
colorPicker = null,
|
1032
|
+
elementStartX = null, // Used to record the starting css positions for dragging the control
|
1033
|
+
elementStartY = null,
|
1034
|
+
pageStartX = null, // Used to record the mousedown coordinates for dragging the control
|
1035
|
+
pageStartY = null,
|
1036
|
+
activePreview = null, // color boxes above the radio buttons
|
1037
|
+
currentPreview = null,
|
1038
|
+
okButton = null,
|
1039
|
+
cancelButton = null,
|
1040
|
+
grid = null, // preset colors grid
|
1041
|
+
moveBar = null, // drag bar
|
1042
|
+
setColorMode = // set color mode and update visuals for the new color mode
|
1043
|
+
|
1044
|
+
function (colorMode) {
|
1045
|
+
var active = color.active, // local copies for YUI compressor
|
1046
|
+
clientPath = images.clientPath,
|
1047
|
+
hex = active.val('hex'),
|
1048
|
+
rgbMap,
|
1049
|
+
rgbBar;
|
1050
|
+
settings.color.mode = colorMode;
|
1051
|
+
switch (colorMode) {
|
1052
|
+
case 'h':
|
1053
|
+
setTimeout(function () {
|
1054
|
+
setBG.call($this, colorMapDiv, 'transparent');
|
1055
|
+
setImgLoc.call($this, colorMapL1, 0);
|
1056
|
+
setAlpha.call($this, colorMapL1, 100);
|
1057
|
+
setImgLoc.call($this, colorMapL2, 260);
|
1058
|
+
setAlpha.call($this, colorMapL2, 100);
|
1059
|
+
setBG.call($this, colorBarDiv, 'transparent');
|
1060
|
+
setImgLoc.call($this, colorBarL1, 0);
|
1061
|
+
setAlpha.call($this, colorBarL1, 100);
|
1062
|
+
setImgLoc.call($this, colorBarL2, 260);
|
1063
|
+
setAlpha.call($this, colorBarL2, 100);
|
1064
|
+
setImgLoc.call($this, colorBarL3, 260);
|
1065
|
+
setAlpha.call($this, colorBarL3, 100);
|
1066
|
+
setImgLoc.call($this, colorBarL4, 260);
|
1067
|
+
setAlpha.call($this, colorBarL4, 100);
|
1068
|
+
setImgLoc.call($this, colorBarL6, 260);
|
1069
|
+
setAlpha.call($this, colorBarL6, 100);
|
1070
|
+
}, 0);
|
1071
|
+
colorMap.range('all', {
|
1072
|
+
minX: 0,
|
1073
|
+
maxX: 100,
|
1074
|
+
minY: 0,
|
1075
|
+
maxY: 100
|
1076
|
+
});
|
1077
|
+
colorBar.range('rangeY', {
|
1078
|
+
minY: 0,
|
1079
|
+
maxY: 360
|
1080
|
+
});
|
1081
|
+
if (active.val('ahex') == null) break;
|
1082
|
+
colorMap.val('xy', {
|
1083
|
+
x: active.val('s'),
|
1084
|
+
y: 100 - active.val('v')
|
1085
|
+
}, colorMap);
|
1086
|
+
colorBar.val('y', 360 - active.val('h'), colorBar);
|
1087
|
+
break;
|
1088
|
+
case 's':
|
1089
|
+
setTimeout(function () {
|
1090
|
+
setBG.call($this, colorMapDiv, 'transparent');
|
1091
|
+
setImgLoc.call($this, colorMapL1, -260);
|
1092
|
+
setImgLoc.call($this, colorMapL2, -520);
|
1093
|
+
setImgLoc.call($this, colorBarL1, -260);
|
1094
|
+
setImgLoc.call($this, colorBarL2, -520);
|
1095
|
+
setImgLoc.call($this, colorBarL6, 260);
|
1096
|
+
setAlpha.call($this, colorBarL6, 100);
|
1097
|
+
}, 0);
|
1098
|
+
colorMap.range('all', {
|
1099
|
+
minX: 0,
|
1100
|
+
maxX: 360,
|
1101
|
+
minY: 0,
|
1102
|
+
maxY: 100
|
1103
|
+
});
|
1104
|
+
colorBar.range('rangeY', {
|
1105
|
+
minY: 0,
|
1106
|
+
maxY: 100
|
1107
|
+
});
|
1108
|
+
if (active.val('ahex') == null) break;
|
1109
|
+
colorMap.val('xy', {
|
1110
|
+
x: active.val('h'),
|
1111
|
+
y: 100 - active.val('v')
|
1112
|
+
}, colorMap);
|
1113
|
+
colorBar.val('y', 100 - active.val('s'), colorBar);
|
1114
|
+
break;
|
1115
|
+
case 'v':
|
1116
|
+
setTimeout(function () {
|
1117
|
+
setBG.call($this, colorMapDiv, '000000');
|
1118
|
+
setImgLoc.call($this, colorMapL1, -780);
|
1119
|
+
setImgLoc.call($this, colorMapL2, 260);
|
1120
|
+
setBG.call($this, colorBarDiv, hex);
|
1121
|
+
setImgLoc.call($this, colorBarL1, -520);
|
1122
|
+
setImgLoc.call($this, colorBarL2, 260);
|
1123
|
+
setAlpha.call($this, colorBarL2, 100);
|
1124
|
+
setImgLoc.call($this, colorBarL6, 260);
|
1125
|
+
setAlpha.call($this, colorBarL6, 100);
|
1126
|
+
}, 0);
|
1127
|
+
colorMap.range('all', {
|
1128
|
+
minX: 0,
|
1129
|
+
maxX: 360,
|
1130
|
+
minY: 0,
|
1131
|
+
maxY: 100
|
1132
|
+
});
|
1133
|
+
colorBar.range('rangeY', {
|
1134
|
+
minY: 0,
|
1135
|
+
maxY: 100
|
1136
|
+
});
|
1137
|
+
if (active.val('ahex') == null) break;
|
1138
|
+
colorMap.val('xy', {
|
1139
|
+
x: active.val('h'),
|
1140
|
+
y: 100 - active.val('s')
|
1141
|
+
}, colorMap);
|
1142
|
+
colorBar.val('y', 100 - active.val('v'), colorBar);
|
1143
|
+
break;
|
1144
|
+
case 'r':
|
1145
|
+
rgbMap = -1040;
|
1146
|
+
rgbBar = -780;
|
1147
|
+
colorMap.range('all', {
|
1148
|
+
minX: 0,
|
1149
|
+
maxX: 255,
|
1150
|
+
minY: 0,
|
1151
|
+
maxY: 255
|
1152
|
+
});
|
1153
|
+
colorBar.range('rangeY', {
|
1154
|
+
minY: 0,
|
1155
|
+
maxY: 255
|
1156
|
+
});
|
1157
|
+
if (active.val('ahex') == null) break;
|
1158
|
+
colorMap.val('xy', {
|
1159
|
+
x: active.val('b'),
|
1160
|
+
y: 255 - active.val('g')
|
1161
|
+
}, colorMap);
|
1162
|
+
colorBar.val('y', 255 - active.val('r'), colorBar);
|
1163
|
+
break;
|
1164
|
+
case 'g':
|
1165
|
+
rgbMap = -1560;
|
1166
|
+
rgbBar = -1820;
|
1167
|
+
colorMap.range('all', {
|
1168
|
+
minX: 0,
|
1169
|
+
maxX: 255,
|
1170
|
+
minY: 0,
|
1171
|
+
maxY: 255
|
1172
|
+
});
|
1173
|
+
colorBar.range('rangeY', {
|
1174
|
+
minY: 0,
|
1175
|
+
maxY: 255
|
1176
|
+
});
|
1177
|
+
if (active.val('ahex') == null) break;
|
1178
|
+
colorMap.val('xy', {
|
1179
|
+
x: active.val('b'),
|
1180
|
+
y: 255 - active.val('r')
|
1181
|
+
}, colorMap);
|
1182
|
+
colorBar.val('y', 255 - active.val('g'), colorBar);
|
1183
|
+
break;
|
1184
|
+
case 'b':
|
1185
|
+
rgbMap = -2080;
|
1186
|
+
rgbBar = -2860;
|
1187
|
+
colorMap.range('all', {
|
1188
|
+
minX: 0,
|
1189
|
+
maxX: 255,
|
1190
|
+
minY: 0,
|
1191
|
+
maxY: 255
|
1192
|
+
});
|
1193
|
+
colorBar.range('rangeY', {
|
1194
|
+
minY: 0,
|
1195
|
+
maxY: 255
|
1196
|
+
});
|
1197
|
+
if (active.val('ahex') == null) break;
|
1198
|
+
colorMap.val('xy', {
|
1199
|
+
x: active.val('r'),
|
1200
|
+
y: 255 - active.val('g')
|
1201
|
+
}, colorMap);
|
1202
|
+
colorBar.val('y', 255 - active.val('b'), colorBar);
|
1203
|
+
break;
|
1204
|
+
case 'a':
|
1205
|
+
setTimeout(function () {
|
1206
|
+
setBG.call($this, colorMapDiv, 'transparent');
|
1207
|
+
setImgLoc.call($this, colorMapL1, -260);
|
1208
|
+
setImgLoc.call($this, colorMapL2, -520);
|
1209
|
+
setImgLoc.call($this, colorBarL1, 260);
|
1210
|
+
setImgLoc.call($this, colorBarL2, 260);
|
1211
|
+
setAlpha.call($this, colorBarL2, 100);
|
1212
|
+
setImgLoc.call($this, colorBarL6, 0);
|
1213
|
+
setAlpha.call($this, colorBarL6, 100);
|
1214
|
+
}, 0);
|
1215
|
+
colorMap.range('all', {
|
1216
|
+
minX: 0,
|
1217
|
+
maxX: 360,
|
1218
|
+
minY: 0,
|
1219
|
+
maxY: 100
|
1220
|
+
});
|
1221
|
+
colorBar.range('rangeY', {
|
1222
|
+
minY: 0,
|
1223
|
+
maxY: 255
|
1224
|
+
});
|
1225
|
+
if (active.val('ahex') == null) break;
|
1226
|
+
colorMap.val('xy', {
|
1227
|
+
x: active.val('h'),
|
1228
|
+
y: 100 - active.val('v')
|
1229
|
+
}, colorMap);
|
1230
|
+
colorBar.val('y', 255 - active.val('a'), colorBar);
|
1231
|
+
break;
|
1232
|
+
default:
|
1233
|
+
throw ('Invalid Mode');
|
1234
|
+
break;
|
1235
|
+
}
|
1236
|
+
switch (colorMode) {
|
1237
|
+
case 'h':
|
1238
|
+
break;
|
1239
|
+
case 's':
|
1240
|
+
case 'v':
|
1241
|
+
case 'a':
|
1242
|
+
setTimeout(function () {
|
1243
|
+
setAlpha.call($this, colorMapL1, 100);
|
1244
|
+
setAlpha.call($this, colorBarL1, 100);
|
1245
|
+
setImgLoc.call($this, colorBarL3, 260);
|
1246
|
+
setAlpha.call($this, colorBarL3, 100);
|
1247
|
+
setImgLoc.call($this, colorBarL4, 260);
|
1248
|
+
setAlpha.call($this, colorBarL4, 100);
|
1249
|
+
}, 0);
|
1250
|
+
break;
|
1251
|
+
case 'r':
|
1252
|
+
case 'g':
|
1253
|
+
case 'b':
|
1254
|
+
setTimeout(function () {
|
1255
|
+
setBG.call($this, colorMapDiv, 'transparent');
|
1256
|
+
setBG.call($this, colorBarDiv, 'transparent');
|
1257
|
+
setAlpha.call($this, colorBarL1, 100);
|
1258
|
+
setAlpha.call($this, colorMapL1, 100);
|
1259
|
+
setImgLoc.call($this, colorMapL1, rgbMap);
|
1260
|
+
setImgLoc.call($this, colorMapL2, rgbMap - 260);
|
1261
|
+
setImgLoc.call($this, colorBarL1, rgbBar - 780);
|
1262
|
+
setImgLoc.call($this, colorBarL2, rgbBar - 520);
|
1263
|
+
setImgLoc.call($this, colorBarL3, rgbBar);
|
1264
|
+
setImgLoc.call($this, colorBarL4, rgbBar - 260);
|
1265
|
+
setImgLoc.call($this, colorBarL6, 260);
|
1266
|
+
setAlpha.call($this, colorBarL6, 100);
|
1267
|
+
}, 0);
|
1268
|
+
break;
|
1269
|
+
}
|
1270
|
+
if (active.val('ahex') == null) return;
|
1271
|
+
activeColorChanged.call($this, active);
|
1272
|
+
},
|
1273
|
+
activeColorChanged = // Update color when user changes text values
|
1274
|
+
|
1275
|
+
function (ui, context) {
|
1276
|
+
if (context == null || (context != colorBar && context != colorMap)) positionMapAndBarArrows.call($this, ui, context);
|
1277
|
+
setTimeout(function () {
|
1278
|
+
updatePreview.call($this, ui);
|
1279
|
+
updateMapVisuals.call($this, ui);
|
1280
|
+
updateBarVisuals.call($this, ui);
|
1281
|
+
}, 0);
|
1282
|
+
},
|
1283
|
+
mapValueChanged = // user has dragged the ColorMap pointer
|
1284
|
+
|
1285
|
+
function (ui, context) {
|
1286
|
+
var active = color.active;
|
1287
|
+
if (context != colorMap && active.val() == null) return;
|
1288
|
+
var xy = ui.val('all');
|
1289
|
+
switch (settings.color.mode) {
|
1290
|
+
case 'h':
|
1291
|
+
active.val('sv', {
|
1292
|
+
s: xy.x,
|
1293
|
+
v: 100 - xy.y
|
1294
|
+
}, context);
|
1295
|
+
break;
|
1296
|
+
case 's':
|
1297
|
+
case 'a':
|
1298
|
+
active.val('hv', {
|
1299
|
+
h: xy.x,
|
1300
|
+
v: 100 - xy.y
|
1301
|
+
}, context);
|
1302
|
+
break;
|
1303
|
+
case 'v':
|
1304
|
+
active.val('hs', {
|
1305
|
+
h: xy.x,
|
1306
|
+
s: 100 - xy.y
|
1307
|
+
}, context);
|
1308
|
+
break;
|
1309
|
+
case 'r':
|
1310
|
+
active.val('gb', {
|
1311
|
+
g: 255 - xy.y,
|
1312
|
+
b: xy.x
|
1313
|
+
}, context);
|
1314
|
+
break;
|
1315
|
+
case 'g':
|
1316
|
+
active.val('rb', {
|
1317
|
+
r: 255 - xy.y,
|
1318
|
+
b: xy.x
|
1319
|
+
}, context);
|
1320
|
+
break;
|
1321
|
+
case 'b':
|
1322
|
+
active.val('rg', {
|
1323
|
+
r: xy.x,
|
1324
|
+
g: 255 - xy.y
|
1325
|
+
}, context);
|
1326
|
+
break;
|
1327
|
+
}
|
1328
|
+
},
|
1329
|
+
colorBarValueChanged = // user has dragged the ColorBar slider
|
1330
|
+
|
1331
|
+
function (ui, context) {
|
1332
|
+
var active = color.active;
|
1333
|
+
if (context != colorBar && active.val() == null) return;
|
1334
|
+
switch (settings.color.mode) {
|
1335
|
+
case 'h':
|
1336
|
+
active.val('h', {
|
1337
|
+
h: 360 - ui.val('y')
|
1338
|
+
}, context);
|
1339
|
+
break;
|
1340
|
+
case 's':
|
1341
|
+
active.val('s', {
|
1342
|
+
s: 100 - ui.val('y')
|
1343
|
+
}, context);
|
1344
|
+
break;
|
1345
|
+
case 'v':
|
1346
|
+
active.val('v', {
|
1347
|
+
v: 100 - ui.val('y')
|
1348
|
+
}, context);
|
1349
|
+
break;
|
1350
|
+
case 'r':
|
1351
|
+
active.val('r', {
|
1352
|
+
r: 255 - ui.val('y')
|
1353
|
+
}, context);
|
1354
|
+
break;
|
1355
|
+
case 'g':
|
1356
|
+
active.val('g', {
|
1357
|
+
g: 255 - ui.val('y')
|
1358
|
+
}, context);
|
1359
|
+
break;
|
1360
|
+
case 'b':
|
1361
|
+
active.val('b', {
|
1362
|
+
b: 255 - ui.val('y')
|
1363
|
+
}, context);
|
1364
|
+
break;
|
1365
|
+
case 'a':
|
1366
|
+
active.val('a', 255 - ui.val('y'), context);
|
1367
|
+
break;
|
1368
|
+
}
|
1369
|
+
},
|
1370
|
+
positionMapAndBarArrows = // position map and bar arrows to match current color
|
1371
|
+
|
1372
|
+
function (ui, context) {
|
1373
|
+
if (context != colorMap) {
|
1374
|
+
switch (settings.color.mode) {
|
1375
|
+
case 'h':
|
1376
|
+
var sv = ui.val('sv');
|
1377
|
+
colorMap.val('xy', {
|
1378
|
+
x: sv != null ? sv.s : 100,
|
1379
|
+
y: 100 - (sv != null ? sv.v : 100)
|
1380
|
+
}, context);
|
1381
|
+
break;
|
1382
|
+
case 's':
|
1383
|
+
case 'a':
|
1384
|
+
var hv = ui.val('hv');
|
1385
|
+
colorMap.val('xy', {
|
1386
|
+
x: hv && hv.h || 0,
|
1387
|
+
y: 100 - (hv != null ? hv.v : 100)
|
1388
|
+
}, context);
|
1389
|
+
break;
|
1390
|
+
case 'v':
|
1391
|
+
var hs = ui.val('hs');
|
1392
|
+
colorMap.val('xy', {
|
1393
|
+
x: hs && hs.h || 0,
|
1394
|
+
y: 100 - (hs != null ? hs.s : 100)
|
1395
|
+
}, context);
|
1396
|
+
break;
|
1397
|
+
case 'r':
|
1398
|
+
var bg = ui.val('bg');
|
1399
|
+
colorMap.val('xy', {
|
1400
|
+
x: bg && bg.b || 0,
|
1401
|
+
y: 255 - (bg && bg.g || 0)
|
1402
|
+
}, context);
|
1403
|
+
break;
|
1404
|
+
case 'g':
|
1405
|
+
var br = ui.val('br');
|
1406
|
+
colorMap.val('xy', {
|
1407
|
+
x: br && br.b || 0,
|
1408
|
+
y: 255 - (br && br.r || 0)
|
1409
|
+
}, context);
|
1410
|
+
break;
|
1411
|
+
case 'b':
|
1412
|
+
var rg = ui.val('rg');
|
1413
|
+
colorMap.val('xy', {
|
1414
|
+
x: rg && rg.r || 0,
|
1415
|
+
y: 255 - (rg && rg.g || 0)
|
1416
|
+
}, context);
|
1417
|
+
break;
|
1418
|
+
}
|
1419
|
+
}
|
1420
|
+
if (context != colorBar) {
|
1421
|
+
switch (settings.color.mode) {
|
1422
|
+
case 'h':
|
1423
|
+
colorBar.val('y', 360 - (ui.val('h') || 0), context);
|
1424
|
+
break;
|
1425
|
+
case 's':
|
1426
|
+
var s = ui.val('s');
|
1427
|
+
colorBar.val('y', 100 - (s != null ? s : 100), context);
|
1428
|
+
break;
|
1429
|
+
case 'v':
|
1430
|
+
var v = ui.val('v');
|
1431
|
+
colorBar.val('y', 100 - (v != null ? v : 100), context);
|
1432
|
+
break;
|
1433
|
+
case 'r':
|
1434
|
+
colorBar.val('y', 255 - (ui.val('r') || 0), context);
|
1435
|
+
break;
|
1436
|
+
case 'g':
|
1437
|
+
colorBar.val('y', 255 - (ui.val('g') || 0), context);
|
1438
|
+
break;
|
1439
|
+
case 'b':
|
1440
|
+
colorBar.val('y', 255 - (ui.val('b') || 0), context);
|
1441
|
+
break;
|
1442
|
+
case 'a':
|
1443
|
+
var a = ui.val('a');
|
1444
|
+
colorBar.val('y', 255 - (a != null ? a : 255), context);
|
1445
|
+
break;
|
1446
|
+
}
|
1447
|
+
}
|
1448
|
+
},
|
1449
|
+
updatePreview = function (ui) {
|
1450
|
+
try {
|
1451
|
+
var all = ui.val('all');
|
1452
|
+
activePreview.css({
|
1453
|
+
backgroundColor: all && '#' + all.hex || 'transparent'
|
1454
|
+
});
|
1455
|
+
setAlpha.call($this, activePreview, all && mPrecision((all.a * 100) / 255, 4) || 0);
|
1456
|
+
} catch (e) {}
|
1457
|
+
},
|
1458
|
+
updateMapVisuals = function (ui) {
|
1459
|
+
switch (settings.color.mode) {
|
1460
|
+
case 'h':
|
1461
|
+
setBG.call($this, colorMapDiv, new Color({
|
1462
|
+
h: ui.val('h') || 0,
|
1463
|
+
s: 100,
|
1464
|
+
v: 100
|
1465
|
+
}).val('hex'));
|
1466
|
+
break;
|
1467
|
+
case 's':
|
1468
|
+
case 'a':
|
1469
|
+
var s = ui.val('s');
|
1470
|
+
setAlpha.call($this, colorMapL2, 100 - (s != null ? s : 100));
|
1471
|
+
break;
|
1472
|
+
case 'v':
|
1473
|
+
var v = ui.val('v');
|
1474
|
+
setAlpha.call($this, colorMapL1, v != null ? v : 100);
|
1475
|
+
break;
|
1476
|
+
case 'r':
|
1477
|
+
setAlpha.call($this, colorMapL2, mPrecision((ui.val('r') || 0) / 255 * 100, 4));
|
1478
|
+
break;
|
1479
|
+
case 'g':
|
1480
|
+
setAlpha.call($this, colorMapL2, mPrecision((ui.val('g') || 0) / 255 * 100, 4));
|
1481
|
+
break;
|
1482
|
+
case 'b':
|
1483
|
+
setAlpha.call($this, colorMapL2, mPrecision((ui.val('b') || 0) / 255 * 100));
|
1484
|
+
break;
|
1485
|
+
}
|
1486
|
+
var a = ui.val('a');
|
1487
|
+
setAlpha.call($this, colorMapL3, mPrecision(((255 - (a || 0)) * 100) / 255, 4));
|
1488
|
+
},
|
1489
|
+
updateBarVisuals = function (ui) {
|
1490
|
+
switch (settings.color.mode) {
|
1491
|
+
case 'h':
|
1492
|
+
var a = ui.val('a');
|
1493
|
+
setAlpha.call($this, colorBarL5, mPrecision(((255 - (a || 0)) * 100) / 255, 4));
|
1494
|
+
break;
|
1495
|
+
case 's':
|
1496
|
+
var hva = ui.val('hva'),
|
1497
|
+
saturatedColor = new Color({
|
1498
|
+
h: hva && hva.h || 0,
|
1499
|
+
s: 100,
|
1500
|
+
v: hva != null ? hva.v : 100
|
1501
|
+
});
|
1502
|
+
setBG.call($this, colorBarDiv, saturatedColor.val('hex'));
|
1503
|
+
setAlpha.call($this, colorBarL2, 100 - (hva != null ? hva.v : 100));
|
1504
|
+
setAlpha.call($this, colorBarL5, mPrecision(((255 - (hva && hva.a || 0)) * 100) / 255, 4));
|
1505
|
+
break;
|
1506
|
+
case 'v':
|
1507
|
+
var hsa = ui.val('hsa'),
|
1508
|
+
valueColor = new Color({
|
1509
|
+
h: hsa && hsa.h || 0,
|
1510
|
+
s: hsa != null ? hsa.s : 100,
|
1511
|
+
v: 100
|
1512
|
+
});
|
1513
|
+
setBG.call($this, colorBarDiv, valueColor.val('hex'));
|
1514
|
+
setAlpha.call($this, colorBarL5, mPrecision(((255 - (hsa && hsa.a || 0)) * 100) / 255, 4));
|
1515
|
+
break;
|
1516
|
+
case 'r':
|
1517
|
+
case 'g':
|
1518
|
+
case 'b':
|
1519
|
+
var hValue = 0,
|
1520
|
+
vValue = 0,
|
1521
|
+
rgba = ui.val('rgba');
|
1522
|
+
if (settings.color.mode == 'r') {
|
1523
|
+
hValue = rgba && rgba.b || 0;
|
1524
|
+
vValue = rgba && rgba.g || 0;
|
1525
|
+
} else if (settings.color.mode == 'g') {
|
1526
|
+
hValue = rgba && rgba.b || 0;
|
1527
|
+
vValue = rgba && rgba.r || 0;
|
1528
|
+
} else if (settings.color.mode == 'b') {
|
1529
|
+
hValue = rgba && rgba.r || 0;
|
1530
|
+
vValue = rgba && rgba.g || 0;
|
1531
|
+
}
|
1532
|
+
var middle = vValue > hValue ? hValue : vValue;
|
1533
|
+
setAlpha.call($this, colorBarL2, hValue > vValue ? mPrecision(((hValue - vValue) / (255 - vValue)) * 100, 4) : 0);
|
1534
|
+
setAlpha.call($this, colorBarL3, vValue > hValue ? mPrecision(((vValue - hValue) / (255 - hValue)) * 100, 4) : 0);
|
1535
|
+
setAlpha.call($this, colorBarL4, mPrecision((middle / 255) * 100, 4));
|
1536
|
+
setAlpha.call($this, colorBarL5, mPrecision(((255 - (rgba && rgba.a || 0)) * 100) / 255, 4));
|
1537
|
+
break;
|
1538
|
+
case 'a':
|
1539
|
+
var a = ui.val('a');
|
1540
|
+
setBG.call($this, colorBarDiv, ui.val('hex') || '000000');
|
1541
|
+
setAlpha.call($this, colorBarL5, a != null ? 0 : 100);
|
1542
|
+
setAlpha.call($this, colorBarL6, a != null ? 100 : 0);
|
1543
|
+
break;
|
1544
|
+
}
|
1545
|
+
},
|
1546
|
+
setBG = function (el, c) {
|
1547
|
+
el.css({
|
1548
|
+
backgroundColor: c && c.length == 6 && '#' + c || 'transparent'
|
1549
|
+
});
|
1550
|
+
},
|
1551
|
+
setImg = function (img, src) {
|
1552
|
+
img.css({
|
1553
|
+
backgroundImage: 'url(\'' + src + '\')'
|
1554
|
+
});
|
1555
|
+
},
|
1556
|
+
setImgLoc = function (img, y) {
|
1557
|
+
img.css({
|
1558
|
+
top: y + 'px'
|
1559
|
+
});
|
1560
|
+
},
|
1561
|
+
setAlpha = function (obj, alpha) {
|
1562
|
+
obj.css({
|
1563
|
+
visibility: alpha > 0 ? 'visible' : 'hidden'
|
1564
|
+
});
|
1565
|
+
if (alpha > 0 && alpha < 100) {
|
1566
|
+
obj.css({
|
1567
|
+
opacity: mPrecision(alpha / 100, 4)
|
1568
|
+
});
|
1569
|
+
} else if (alpha == 0 || alpha == 100) {
|
1570
|
+
obj.css({
|
1571
|
+
opacity: ''
|
1572
|
+
});
|
1573
|
+
}
|
1574
|
+
},
|
1575
|
+
revertColor = // revert color to original color when opened
|
1576
|
+
|
1577
|
+
function () {
|
1578
|
+
color.active.val('ahex', color.current.val('ahex'));
|
1579
|
+
},
|
1580
|
+
commitColor = // commit the color changes
|
1581
|
+
|
1582
|
+
function () {
|
1583
|
+
color.current.val('ahex', color.active.val('ahex'));
|
1584
|
+
},
|
1585
|
+
radioClicked = function (e) {
|
1586
|
+
container.find('input[type="radio"][value!="' + e.target.value + '"]').prop('checked', false);
|
1587
|
+
setColorMode.call($this, e.target.value);
|
1588
|
+
},
|
1589
|
+
currentClicked = function () {
|
1590
|
+
revertColor.call($this);
|
1591
|
+
},
|
1592
|
+
cancelClicked = function () {
|
1593
|
+
revertColor.call($this);
|
1594
|
+
$.isFunction(cancelCallback) && cancelCallback.call($this, color.active, cancelButton);
|
1595
|
+
},
|
1596
|
+
okClicked = function () {
|
1597
|
+
commitColor.call($this);
|
1598
|
+
$.isFunction(commitCallback) && commitCallback.call($this, color.active, okButton);
|
1599
|
+
},
|
1600
|
+
currentColorChanged = function (ui, context) {
|
1601
|
+
var hex = ui.val('hex');
|
1602
|
+
currentPreview.css({
|
1603
|
+
backgroundColor: hex && '#' + hex || 'transparent'
|
1604
|
+
});
|
1605
|
+
setAlpha.call($this, currentPreview, mPrecision(((ui.val('a') || 0) * 100) / 255, 4));
|
1606
|
+
},
|
1607
|
+
moveBarMouseDown = function (e) {
|
1608
|
+
elementStartX = parseInt(container.css('left'), 10) || 0;
|
1609
|
+
elementStartY = parseInt(container.css('top'), 10) || 0;
|
1610
|
+
pageStartX = e.pageX;
|
1611
|
+
pageStartY = e.pageY;
|
1612
|
+
// bind events to document to move window - we will unbind these on mouseup
|
1613
|
+
$(document).bind('mousemove', documentMouseMove).bind('mouseup', documentMouseUp);
|
1614
|
+
e.preventDefault(); // prevent attempted dragging of the column
|
1615
|
+
},
|
1616
|
+
documentMouseMove = function (e) {
|
1617
|
+
container.css({
|
1618
|
+
left: elementStartX - (pageStartX - e.pageX) + 'px',
|
1619
|
+
top: elementStartY - (pageStartY - e.pageY) + 'px'
|
1620
|
+
});
|
1621
|
+
|
1622
|
+
|
1623
|
+
return false;
|
1624
|
+
},
|
1625
|
+
documentMouseUp = function (e) {
|
1626
|
+
$(document).unbind('mousemove', documentMouseMove).unbind('mouseup', documentMouseUp);
|
1627
|
+
|
1628
|
+
return false;
|
1629
|
+
},
|
1630
|
+
quickPickClicked = function (e) {
|
1631
|
+
|
1632
|
+
color.active.val('ahex', $(this).attr('title') || null, e.target);
|
1633
|
+
return false;
|
1634
|
+
},
|
1635
|
+
commitCallback = $.isFunction($arguments[1]) && $arguments[1] || null,
|
1636
|
+
liveCallback = $.isFunction($arguments[2]) && $arguments[2] || null,
|
1637
|
+
cancelCallback = $.isFunction($arguments[3]) && $arguments[3] || null,
|
1638
|
+
show = function () {
|
1639
|
+
color.current.val('ahex', color.active.val('ahex'));
|
1640
|
+
},
|
1641
|
+
hide = function () {
|
1642
|
+
|
1643
|
+
},
|
1644
|
+
initialize = function () {
|
1645
|
+
var win = settings.window,
|
1646
|
+
popup = null;
|
1647
|
+
container = $($this);
|
1648
|
+
container.addClass('jPicker Container');
|
1649
|
+
|
1650
|
+
container.get(0).onselectstart = function (event) {
|
1651
|
+
if (event.target.nodeName.toLowerCase() !== 'input') return false;
|
1652
|
+
};
|
1653
|
+
// inject html source code - we are using a single table for this control - I know tables are considered bad, but it takes care of equal height columns and
|
1654
|
+
// this control really is tabular data, so I believe it is the right move
|
1655
|
+
var all = color.active.val('all');
|
1656
|
+
if (win.alphaPrecision < 0) win.alphaPrecision = 0;
|
1657
|
+
else if (win.alphaPrecision > 2) win.alphaPrecision = 2;
|
1658
|
+
var controlHtml = '<table class="jPicker" cellpadding="0" cellspacing="0"><tbody><tr><td rowspan="9"><div class="Map"><span class="Map1"> </span><span class="Map2"> </span><span class="Map3"> </span><img src="' + images.clientPath + images.colorMap.arrow.file + '" class="Arrow"/></div></td><td rowspan="9"><div class="Bar"><span class="Map1"> </span><span class="Map2"> </span><span class="Map3"> </span><span class="Map4"> </span><span class="Map5"> </span><span class="Map6"> </span><img src="' + images.clientPath + images.colorBar.arrow.file + '" class="Arrow"/></div></td><td colspan="2" class="Preview">' + localization.text.newColor + '<div><span class="Active" title="' + localization.tooltips.colors.newColor + '"> </span><span class="Current" title="' + localization.tooltips.colors.currentColor + '"> </span></div>' + localization.text.currentColor + '</td><td rowspan="9" class="Button"><input type="button" class="Ok" value="' + localization.text.ok + '" title="' + localization.tooltips.buttons.ok + '"/><input type="button" class="Cancel" value="' + localization.text.cancel + '" title="' + localization.tooltips.buttons.cancel + '"/><hr/><div class="Grid"> </div></td></tr><tr class="Hue"><td class="Radio"><label><input type="radio" aria-label="' + localization.tooltips.hue.radio + '" class="hue-radio" value="h"' + (settings.color.mode == 'h' ? ' checked="checked"' : '') + '/>H:</label></td><td class="Text"><input type="text" maxlength="3" value="' + (all != null ? all.h : '') + '" title="' + localization.tooltips.hue.textbox + '"/> °</td></tr><tr class="Saturation"><td class="Radio"><label><input type="radio" aria-label="' + localization.tooltips.saturation.radio + '" value="s"' + (settings.color.mode == 's' ? ' checked="checked"' : '') + '/>S:</label></td><td class="Text"><input type="text" maxlength="3" value="' + (all != null ? all.s : '') + '" title="' + localization.tooltips.saturation.textbox + '"/> %</td></tr><tr class="Value"><td class="Radio"><label><input type="radio" aria-label="' + localization.tooltips.value.radio + '" value="v"' + (settings.color.mode == 'v' ? ' checked="checked"' : '') + '/>V:</label><br/><br/></td><td class="Text"><input type="text" maxlength="3" value="' + (all != null ? all.v : '') + '" title="' + localization.tooltips.value.textbox + '"/> %<br/><br/></td></tr><tr class="Red"><td class="Radio"><label><input type="radio" aria-label="' + localization.tooltips.red.radio + '" value="r"' + (settings.color.mode == 'r' ? ' checked="checked"' : '') + '/>R:</label></td><td class="Text"><input type="text" maxlength="3" value="' + (all != null ? all.r : '') + '" title="' + localization.tooltips.red.textbox + '"/></td></tr><tr class="Green"><td class="Radio"><label><input type="radio" title="' + localization.tooltips.green.radio + '" value="g"' + (settings.color.mode == 'g' ? ' checked="checked"' : '') + '/>G:</label></td><td class="Text"><input type="text" maxlength="3" value="' + (all != null ? all.g : '') + '" title="' + localization.tooltips.green.textbox + '"/></td></tr><tr class="Blue"><td class="Radio"><label><input type="radio" aria-label="' + localization.tooltips.blue.radio + '" value="b"' + (settings.color.mode == 'b' ? ' checked="checked"' : '') + '/>B:</label></td><td class="Text"><input type="text" maxlength="3" value="' + (all != null ? all.b : '') + '" title="' + localization.tooltips.blue.textbox + '"/></td></tr><tr class="Alpha"><td class="Radio"><label><input aria-label="' + localization.tooltips.alpha.radio + '" class="alpha-radio" type="radio" value="a"' + (settings.color.mode == 'a' ? ' checked="checked"' : '') + '/>A:</label></td><td class="Text"><input type="text" maxlength="' + (3 + win.alphaPrecision) + '" value="' + (all != null ? mPrecision((all.a * 100) / 255, win.alphaPrecision) : '') + '" title="' + localization.tooltips.alpha.textbox + '"/> %</td></tr><tr class="Hex"><td colspan="2" class="Text"><label>#:<input aria-label="' + localization.tooltips.hex.textbox + '" type="text" maxlength="6" class="Hex" value="' + (all != null ? all.hex : '') + '"/></label><input type="text" maxlength="2" class="AHex" value="' + (all != null ? all.ahex.substring(6) : '') + '" title="' + localization.tooltips.hex.alpha + '"/></td></tr></tbody></table>';
|
1659
|
+
container = $($this);
|
1660
|
+
container.html(controlHtml);
|
1661
|
+
// initialize the objects to the source code just injected
|
1662
|
+
var tbody = container.find('tbody').eq(0);
|
1663
|
+
colorMapDiv = tbody.find('div.Map').eq(0);
|
1664
|
+
colorBarDiv = tbody.find('div.Bar').eq(0);
|
1665
|
+
var MapMaps = colorMapDiv.find('span'),
|
1666
|
+
BarMaps = colorBarDiv.find('span');
|
1667
|
+
colorMapL1 = MapMaps.filter('.Map1').eq(0);
|
1668
|
+
colorMapL2 = MapMaps.filter('.Map2').eq(0);
|
1669
|
+
colorMapL3 = MapMaps.filter('.Map3').eq(0);
|
1670
|
+
colorBarL1 = BarMaps.filter('.Map1').eq(0);
|
1671
|
+
colorBarL2 = BarMaps.filter('.Map2').eq(0);
|
1672
|
+
colorBarL3 = BarMaps.filter('.Map3').eq(0);
|
1673
|
+
colorBarL4 = BarMaps.filter('.Map4').eq(0);
|
1674
|
+
colorBarL5 = BarMaps.filter('.Map5').eq(0);
|
1675
|
+
colorBarL6 = BarMaps.filter('.Map6').eq(0);
|
1676
|
+
// create color pickers and maps
|
1677
|
+
colorMap = new Slider(colorMapDiv, {
|
1678
|
+
map: {
|
1679
|
+
width: images.colorMap.width,
|
1680
|
+
height: images.colorMap.height
|
1681
|
+
},
|
1682
|
+
arrow: {
|
1683
|
+
image: images.clientPath + images.colorMap.arrow.file,
|
1684
|
+
width: images.colorMap.arrow.width,
|
1685
|
+
height: images.colorMap.arrow.height
|
1686
|
+
}
|
1687
|
+
});
|
1688
|
+
colorMap.bind(mapValueChanged);
|
1689
|
+
colorBar = new Slider(colorBarDiv, {
|
1690
|
+
map: {
|
1691
|
+
width: images.colorBar.width,
|
1692
|
+
height: images.colorBar.height
|
1693
|
+
},
|
1694
|
+
arrow: {
|
1695
|
+
image: images.clientPath + images.colorBar.arrow.file,
|
1696
|
+
width: images.colorBar.arrow.width,
|
1697
|
+
height: images.colorBar.arrow.height
|
1698
|
+
}
|
1699
|
+
});
|
1700
|
+
colorBar.bind(colorBarValueChanged);
|
1701
|
+
colorPicker = new ColorValuePicker(tbody, color.active, null, win.alphaPrecision);
|
1702
|
+
var hex = all != null ? all.hex : null,
|
1703
|
+
preview = tbody.find('.Preview'),
|
1704
|
+
button = tbody.find('.Button');
|
1705
|
+
activePreview = preview.find('.Active:first').css({
|
1706
|
+
backgroundColor: hex && '#' + hex || 'transparent'
|
1707
|
+
});
|
1708
|
+
currentPreview = preview.find('.Current:first').css({
|
1709
|
+
backgroundColor: hex && '#' + hex || 'transparent'
|
1710
|
+
}).bind('click', currentClicked);
|
1711
|
+
setAlpha.call($this, currentPreview, mPrecision(color.current.val('a') * 100) / 255, 4);
|
1712
|
+
okButton = button.find('.Ok:first').bind('click', okClicked);
|
1713
|
+
cancelButton = button.find('.Cancel:first').bind('click', cancelClicked);
|
1714
|
+
grid = button.find('.Grid:first');
|
1715
|
+
setTimeout(function () {
|
1716
|
+
setImg.call($this, colorMapL1, images.clientPath + 'Maps.png');
|
1717
|
+
setImg.call($this, colorMapL2, images.clientPath + 'Maps.png');
|
1718
|
+
setImg.call($this, colorMapL3, images.clientPath + 'map-opacity.png');
|
1719
|
+
setImg.call($this, colorBarL1, images.clientPath + 'Bars.png');
|
1720
|
+
setImg.call($this, colorBarL2, images.clientPath + 'Bars.png');
|
1721
|
+
setImg.call($this, colorBarL3, images.clientPath + 'Bars.png');
|
1722
|
+
setImg.call($this, colorBarL4, images.clientPath + 'Bars.png');
|
1723
|
+
setImg.call($this, colorBarL5, images.clientPath + 'bar-opacity.png');
|
1724
|
+
setImg.call($this, colorBarL6, images.clientPath + 'AlphaBar.png');
|
1725
|
+
setImg.call($this, preview.find('div').eq(0), images.clientPath + 'preview-opacity.png');
|
1726
|
+
}, 0);
|
1727
|
+
tbody.find('td.Radio input').bind('click', radioClicked);
|
1728
|
+
// initialize quick list
|
1729
|
+
if (color.quickList && color.quickList.length > 0) {
|
1730
|
+
var html = '', i;
|
1731
|
+
for (i = 0; i < color.quickList.length; i++) {
|
1732
|
+
/* if default colors are hex strings, change them to color objects */
|
1733
|
+
if ((typeof (color.quickList[i])).toString().toLowerCase() == 'string') color.quickList[i] = new Color({
|
1734
|
+
hex: color.quickList[i]
|
1735
|
+
});
|
1736
|
+
var alpha = color.quickList[i].val('a');
|
1737
|
+
var ahex = color.quickList[i].val('ahex');
|
1738
|
+
if (!win.alphaSupport && ahex) ahex = ahex.substring(0, 6) + 'ff';
|
1739
|
+
var quickHex = color.quickList[i].val('hex');
|
1740
|
+
html += '<span class="QuickColor"' + (ahex && ' title="#' + ahex + '"' || '') + ' style="background-color:' + (quickHex && '#' + quickHex || '') + ';' + (quickHex ? '' : 'background-image:url(' + images.clientPath + 'NoColor.png)') + (win.alphaSupport && alpha && alpha < 255 ? ';opacity:' + mPrecision(alpha / 255, 4) + ';filter:Alpha(opacity=' + mPrecision(alpha / 2.55, 4) + ')' : '') + '"> </span>';
|
1741
|
+
}
|
1742
|
+
setImg.call($this, grid, images.clientPath + 'bar-opacity.png');
|
1743
|
+
grid.html(html);
|
1744
|
+
grid.find('.QuickColor').click(quickPickClicked);
|
1745
|
+
}
|
1746
|
+
setColorMode.call($this, settings.color.mode);
|
1747
|
+
color.active.bind(activeColorChanged);
|
1748
|
+
$.isFunction(liveCallback) && color.active.bind(liveCallback);
|
1749
|
+
color.current.bind(currentColorChanged);
|
1750
|
+
show.call($this);
|
1751
|
+
},
|
1752
|
+
destroy = function () {
|
1753
|
+
var elemData = $.data($this, 'wsjPicker') || $this;
|
1754
|
+
container.find('td.Radio input').unbind('click', radioClicked);
|
1755
|
+
currentPreview.unbind('click', currentClicked);
|
1756
|
+
cancelButton.unbind('click', cancelClicked);
|
1757
|
+
okButton.unbind('click', okClicked);
|
1758
|
+
container.find('.QuickColor').unbind('click', quickPickClicked);
|
1759
|
+
colorMapDiv = null;
|
1760
|
+
colorBarDiv = null;
|
1761
|
+
colorMapL1 = null;
|
1762
|
+
colorMapL2 = null;
|
1763
|
+
colorMapL3 = null;
|
1764
|
+
colorBarL1 = null;
|
1765
|
+
colorBarL2 = null;
|
1766
|
+
colorBarL3 = null;
|
1767
|
+
colorBarL4 = null;
|
1768
|
+
colorBarL5 = null;
|
1769
|
+
colorBarL6 = null;
|
1770
|
+
colorMap.destroy();
|
1771
|
+
colorMap = null;
|
1772
|
+
colorBar.destroy();
|
1773
|
+
colorBar = null;
|
1774
|
+
colorPicker.destroy();
|
1775
|
+
colorPicker = null;
|
1776
|
+
activePreview = null;
|
1777
|
+
currentPreview = null;
|
1778
|
+
okButton = null;
|
1779
|
+
cancelButton = null;
|
1780
|
+
grid = null;
|
1781
|
+
commitCallback = null;
|
1782
|
+
cancelCallback = null;
|
1783
|
+
liveCallback = null;
|
1784
|
+
container.html('');
|
1785
|
+
|
1786
|
+
for (i = 0; i < List.length; i++) {
|
1787
|
+
if (List[i] == elemData) {
|
1788
|
+
List.splice(i, 1);
|
1789
|
+
break;
|
1790
|
+
}
|
1791
|
+
}
|
1792
|
+
},
|
1793
|
+
images = settings.images, // local copies for YUI compressor
|
1794
|
+
localization = settings.localization,
|
1795
|
+
color = {
|
1796
|
+
active: (typeof (settings.color.active)).toString().toLowerCase() == 'string' ? new Color({
|
1797
|
+
ahex: !settings.window.alphaSupport && settings.color.active ? settings.color.active.substring(0, 6) + 'ff' : settings.color.active
|
1798
|
+
}) : new Color({
|
1799
|
+
ahex: !settings.window.alphaSupport && settings.color.active.val('ahex') ? settings.color.active.val('ahex').substring(0, 6) + 'ff' : settings.color.active.val('ahex')
|
1800
|
+
}),
|
1801
|
+
current: (typeof (settings.color.active)).toString().toLowerCase() == 'string' ? new Color({
|
1802
|
+
ahex: !settings.window.alphaSupport && settings.color.active ? settings.color.active.substring(0, 6) + 'ff' : settings.color.active
|
1803
|
+
}) : new Color({
|
1804
|
+
ahex: !settings.window.alphaSupport && settings.color.active.val('ahex') ? settings.color.active.val('ahex').substring(0, 6) + 'ff' : settings.color.active.val('ahex')
|
1805
|
+
}),
|
1806
|
+
quickList: settings.color.quickList
|
1807
|
+
};
|
1808
|
+
elemExtend(false, $this, // public properties, methods, and callbacks
|
1809
|
+
{
|
1810
|
+
commitCallback: commitCallback, // commitCallback function can be overridden to return the selected color to a method you specify when the user clicks "OK"
|
1811
|
+
liveCallback: liveCallback, // liveCallback function can be overridden to return the selected color to a method you specify in live mode (continuous update)
|
1812
|
+
cancelCallback: cancelCallback, // cancelCallback function can be overridden to a method you specify when the user clicks "Cancel"
|
1813
|
+
color: color,
|
1814
|
+
setColorMode: function(val){
|
1815
|
+
$('input[type="radio"][value="'+val+'"]', container).prop('checked', true).triggerHandler('click');
|
1816
|
+
},
|
1817
|
+
settings: settings,
|
1818
|
+
show: show,
|
1819
|
+
hide: hide,
|
1820
|
+
destroy: destroy // destroys this control entirely, removing all events and objects, and removing itself from the List
|
1821
|
+
});
|
1822
|
+
List.push($.data($this, 'wsjPicker') || $this);
|
1823
|
+
setTimeout(function () {
|
1824
|
+
initialize.call($this);
|
1825
|
+
}, 0);
|
1826
|
+
});
|
1827
|
+
};
|
1828
|
+
$.fn.wsjPicker.defaults = /* jPicker defaults - you can change anything in this section (such as the clientPath to your images) without fear of breaking the program */ {
|
1829
|
+
window: {
|
1830
|
+
liveUpdate: true,
|
1831
|
+
/* set false if you want the user to have to click "OK" before the binded input box updates values (always "true" for expandable picker) */
|
1832
|
+
alphaSupport: false,
|
1833
|
+
/* set to true to enable alpha picking */
|
1834
|
+
alphaPrecision: 0
|
1835
|
+
/* set decimal precision for alpha percentage display - hex codes do not map directly to percentage integers - range 0-2 */
|
1836
|
+
},
|
1837
|
+
color: {
|
1838
|
+
mode: 'h',
|
1839
|
+
/* acceptabled values "h" (hue), "s" (saturation), "v" (value), "r" (red), "g" (green), "b" (blue), "a" (alpha) */
|
1840
|
+
active: new Color({ahex: '#000000ff'}),
|
1841
|
+
/* acceptable values are any declared $.jPicker.Color object or string HEX value (e.g. #ffc000) WITH OR WITHOUT the "#" prefix */
|
1842
|
+
quickList: /* the quick pick color list */ [
|
1843
|
+
new Color({
|
1844
|
+
h: 360,
|
1845
|
+
s: 33,
|
1846
|
+
v: 100
|
1847
|
+
}), /* acceptable values are any declared $.jPicker.Color object or string HEX value (e.g. #ffc000) WITH OR WITHOUT the "#" prefix */
|
1848
|
+
new Color({
|
1849
|
+
h: 360,
|
1850
|
+
s: 66,
|
1851
|
+
v: 100
|
1852
|
+
}),
|
1853
|
+
new Color({
|
1854
|
+
h: 360,
|
1855
|
+
s: 100,
|
1856
|
+
v: 100
|
1857
|
+
}),
|
1858
|
+
new Color({
|
1859
|
+
h: 360,
|
1860
|
+
s: 100,
|
1861
|
+
v: 75
|
1862
|
+
}),
|
1863
|
+
new Color({
|
1864
|
+
h: 360,
|
1865
|
+
s: 100,
|
1866
|
+
v: 50
|
1867
|
+
}),
|
1868
|
+
new Color({
|
1869
|
+
h: 180,
|
1870
|
+
s: 0,
|
1871
|
+
v: 100
|
1872
|
+
}),
|
1873
|
+
new Color({
|
1874
|
+
h: 30,
|
1875
|
+
s: 33,
|
1876
|
+
v: 100
|
1877
|
+
}),
|
1878
|
+
new Color({
|
1879
|
+
h: 30,
|
1880
|
+
s: 66,
|
1881
|
+
v: 100
|
1882
|
+
}),
|
1883
|
+
new Color({
|
1884
|
+
h: 30,
|
1885
|
+
s: 100,
|
1886
|
+
v: 100
|
1887
|
+
}),
|
1888
|
+
new Color({
|
1889
|
+
h: 30,
|
1890
|
+
s: 100,
|
1891
|
+
v: 75
|
1892
|
+
}),
|
1893
|
+
new Color({
|
1894
|
+
h: 30,
|
1895
|
+
s: 100,
|
1896
|
+
v: 50
|
1897
|
+
}),
|
1898
|
+
new Color({
|
1899
|
+
h: 180,
|
1900
|
+
s: 0,
|
1901
|
+
v: 90
|
1902
|
+
}),
|
1903
|
+
new Color({
|
1904
|
+
h: 60,
|
1905
|
+
s: 33,
|
1906
|
+
v: 100
|
1907
|
+
}),
|
1908
|
+
new Color({
|
1909
|
+
h: 60,
|
1910
|
+
s: 66,
|
1911
|
+
v: 100
|
1912
|
+
}),
|
1913
|
+
new Color({
|
1914
|
+
h: 60,
|
1915
|
+
s: 100,
|
1916
|
+
v: 100
|
1917
|
+
}),
|
1918
|
+
new Color({
|
1919
|
+
h: 60,
|
1920
|
+
s: 100,
|
1921
|
+
v: 75
|
1922
|
+
}),
|
1923
|
+
new Color({
|
1924
|
+
h: 60,
|
1925
|
+
s: 100,
|
1926
|
+
v: 50
|
1927
|
+
}),
|
1928
|
+
new Color({
|
1929
|
+
h: 180,
|
1930
|
+
s: 0,
|
1931
|
+
v: 80
|
1932
|
+
}),
|
1933
|
+
new Color({
|
1934
|
+
h: 90,
|
1935
|
+
s: 33,
|
1936
|
+
v: 100
|
1937
|
+
}),
|
1938
|
+
new Color({
|
1939
|
+
h: 90,
|
1940
|
+
s: 66,
|
1941
|
+
v: 100
|
1942
|
+
}),
|
1943
|
+
new Color({
|
1944
|
+
h: 90,
|
1945
|
+
s: 100,
|
1946
|
+
v: 100
|
1947
|
+
}),
|
1948
|
+
new Color({
|
1949
|
+
h: 90,
|
1950
|
+
s: 100,
|
1951
|
+
v: 75
|
1952
|
+
}),
|
1953
|
+
new Color({
|
1954
|
+
h: 90,
|
1955
|
+
s: 100,
|
1956
|
+
v: 50
|
1957
|
+
}),
|
1958
|
+
new Color({
|
1959
|
+
h: 180,
|
1960
|
+
s: 0,
|
1961
|
+
v: 70
|
1962
|
+
}),
|
1963
|
+
new Color({
|
1964
|
+
h: 120,
|
1965
|
+
s: 33,
|
1966
|
+
v: 100
|
1967
|
+
}),
|
1968
|
+
new Color({
|
1969
|
+
h: 120,
|
1970
|
+
s: 66,
|
1971
|
+
v: 100
|
1972
|
+
}),
|
1973
|
+
new Color({
|
1974
|
+
h: 120,
|
1975
|
+
s: 100,
|
1976
|
+
v: 100
|
1977
|
+
}),
|
1978
|
+
new Color({
|
1979
|
+
h: 120,
|
1980
|
+
s: 100,
|
1981
|
+
v: 75
|
1982
|
+
}),
|
1983
|
+
new Color({
|
1984
|
+
h: 120,
|
1985
|
+
s: 100,
|
1986
|
+
v: 50
|
1987
|
+
}),
|
1988
|
+
new Color({
|
1989
|
+
h: 180,
|
1990
|
+
s: 0,
|
1991
|
+
v: 60
|
1992
|
+
}),
|
1993
|
+
new Color({
|
1994
|
+
h: 150,
|
1995
|
+
s: 33,
|
1996
|
+
v: 100
|
1997
|
+
}),
|
1998
|
+
new Color({
|
1999
|
+
h: 150,
|
2000
|
+
s: 66,
|
2001
|
+
v: 100
|
2002
|
+
}),
|
2003
|
+
new Color({
|
2004
|
+
h: 150,
|
2005
|
+
s: 100,
|
2006
|
+
v: 100
|
2007
|
+
}),
|
2008
|
+
new Color({
|
2009
|
+
h: 150,
|
2010
|
+
s: 100,
|
2011
|
+
v: 75
|
2012
|
+
}),
|
2013
|
+
new Color({
|
2014
|
+
h: 150,
|
2015
|
+
s: 100,
|
2016
|
+
v: 50
|
2017
|
+
}),
|
2018
|
+
new Color({
|
2019
|
+
h: 180,
|
2020
|
+
s: 0,
|
2021
|
+
v: 50
|
2022
|
+
}),
|
2023
|
+
new Color({
|
2024
|
+
h: 180,
|
2025
|
+
s: 33,
|
2026
|
+
v: 100
|
2027
|
+
}),
|
2028
|
+
new Color({
|
2029
|
+
h: 180,
|
2030
|
+
s: 66,
|
2031
|
+
v: 100
|
2032
|
+
}),
|
2033
|
+
new Color({
|
2034
|
+
h: 180,
|
2035
|
+
s: 100,
|
2036
|
+
v: 100
|
2037
|
+
}),
|
2038
|
+
new Color({
|
2039
|
+
h: 180,
|
2040
|
+
s: 100,
|
2041
|
+
v: 75
|
2042
|
+
}),
|
2043
|
+
new Color({
|
2044
|
+
h: 180,
|
2045
|
+
s: 100,
|
2046
|
+
v: 50
|
2047
|
+
}),
|
2048
|
+
new Color({
|
2049
|
+
h: 180,
|
2050
|
+
s: 0,
|
2051
|
+
v: 40
|
2052
|
+
}),
|
2053
|
+
new Color({
|
2054
|
+
h: 210,
|
2055
|
+
s: 33,
|
2056
|
+
v: 100
|
2057
|
+
}),
|
2058
|
+
new Color({
|
2059
|
+
h: 210,
|
2060
|
+
s: 66,
|
2061
|
+
v: 100
|
2062
|
+
}),
|
2063
|
+
new Color({
|
2064
|
+
h: 210,
|
2065
|
+
s: 100,
|
2066
|
+
v: 100
|
2067
|
+
}),
|
2068
|
+
new Color({
|
2069
|
+
h: 210,
|
2070
|
+
s: 100,
|
2071
|
+
v: 75
|
2072
|
+
}),
|
2073
|
+
new Color({
|
2074
|
+
h: 210,
|
2075
|
+
s: 100,
|
2076
|
+
v: 50
|
2077
|
+
}),
|
2078
|
+
new Color({
|
2079
|
+
h: 180,
|
2080
|
+
s: 0,
|
2081
|
+
v: 30
|
2082
|
+
}),
|
2083
|
+
new Color({
|
2084
|
+
h: 240,
|
2085
|
+
s: 33,
|
2086
|
+
v: 100
|
2087
|
+
}),
|
2088
|
+
new Color({
|
2089
|
+
h: 240,
|
2090
|
+
s: 66,
|
2091
|
+
v: 100
|
2092
|
+
}),
|
2093
|
+
new Color({
|
2094
|
+
h: 240,
|
2095
|
+
s: 100,
|
2096
|
+
v: 100
|
2097
|
+
}),
|
2098
|
+
new Color({
|
2099
|
+
h: 240,
|
2100
|
+
s: 100,
|
2101
|
+
v: 75
|
2102
|
+
}),
|
2103
|
+
new Color({
|
2104
|
+
h: 240,
|
2105
|
+
s: 100,
|
2106
|
+
v: 50
|
2107
|
+
}),
|
2108
|
+
new Color({
|
2109
|
+
h: 180,
|
2110
|
+
s: 0,
|
2111
|
+
v: 20
|
2112
|
+
}),
|
2113
|
+
new Color({
|
2114
|
+
h: 270,
|
2115
|
+
s: 33,
|
2116
|
+
v: 100
|
2117
|
+
}),
|
2118
|
+
new Color({
|
2119
|
+
h: 270,
|
2120
|
+
s: 66,
|
2121
|
+
v: 100
|
2122
|
+
}),
|
2123
|
+
new Color({
|
2124
|
+
h: 270,
|
2125
|
+
s: 100,
|
2126
|
+
v: 100
|
2127
|
+
}),
|
2128
|
+
new Color({
|
2129
|
+
h: 270,
|
2130
|
+
s: 100,
|
2131
|
+
v: 75
|
2132
|
+
}),
|
2133
|
+
new Color({
|
2134
|
+
h: 270,
|
2135
|
+
s: 100,
|
2136
|
+
v: 50
|
2137
|
+
}),
|
2138
|
+
new Color({
|
2139
|
+
h: 180,
|
2140
|
+
s: 0,
|
2141
|
+
v: 10
|
2142
|
+
}),
|
2143
|
+
new Color({
|
2144
|
+
h: 300,
|
2145
|
+
s: 33,
|
2146
|
+
v: 100
|
2147
|
+
}),
|
2148
|
+
new Color({
|
2149
|
+
h: 300,
|
2150
|
+
s: 66,
|
2151
|
+
v: 100
|
2152
|
+
}),
|
2153
|
+
new Color({
|
2154
|
+
h: 300,
|
2155
|
+
s: 100,
|
2156
|
+
v: 100
|
2157
|
+
}),
|
2158
|
+
new Color({
|
2159
|
+
h: 300,
|
2160
|
+
s: 100,
|
2161
|
+
v: 75
|
2162
|
+
}),
|
2163
|
+
new Color({
|
2164
|
+
h: 300,
|
2165
|
+
s: 100,
|
2166
|
+
v: 50
|
2167
|
+
}),
|
2168
|
+
new Color({
|
2169
|
+
h: 180,
|
2170
|
+
s: 0,
|
2171
|
+
v: 0
|
2172
|
+
}),
|
2173
|
+
new Color({
|
2174
|
+
h: 330,
|
2175
|
+
s: 33,
|
2176
|
+
v: 100
|
2177
|
+
}),
|
2178
|
+
new Color({
|
2179
|
+
h: 330,
|
2180
|
+
s: 66,
|
2181
|
+
v: 100
|
2182
|
+
}),
|
2183
|
+
new Color({
|
2184
|
+
h: 330,
|
2185
|
+
s: 100,
|
2186
|
+
v: 100
|
2187
|
+
}),
|
2188
|
+
new Color({
|
2189
|
+
h: 330,
|
2190
|
+
s: 100,
|
2191
|
+
v: 75
|
2192
|
+
}),
|
2193
|
+
new Color({
|
2194
|
+
h: 330,
|
2195
|
+
s: 100,
|
2196
|
+
v: 50
|
2197
|
+
}),
|
2198
|
+
new Color({
|
2199
|
+
h: 180,
|
2200
|
+
s: 0,
|
2201
|
+
v: 0
|
2202
|
+
})
|
2203
|
+
]
|
2204
|
+
},
|
2205
|
+
images: {
|
2206
|
+
clientPath: '/jPicker/images/',
|
2207
|
+
/* Path to image files */
|
2208
|
+
colorMap: {
|
2209
|
+
width: 256,
|
2210
|
+
height: 256,
|
2211
|
+
arrow: {
|
2212
|
+
file: 'mappoint.gif',
|
2213
|
+
/* ColorMap arrow icon */
|
2214
|
+
width: 15,
|
2215
|
+
height: 15
|
2216
|
+
}
|
2217
|
+
},
|
2218
|
+
colorBar: {
|
2219
|
+
width: 20,
|
2220
|
+
height: 256,
|
2221
|
+
arrow: {
|
2222
|
+
file: 'rangearrows.gif',
|
2223
|
+
/* ColorBar arrow icon */
|
2224
|
+
width: 20,
|
2225
|
+
height: 7
|
2226
|
+
}
|
2227
|
+
}
|
2228
|
+
},
|
2229
|
+
localization: /* alter these to change the text presented by the picker (e.g. different language) */ {
|
2230
|
+
text: {
|
2231
|
+
title: 'Drag Markers To Pick A Color',
|
2232
|
+
newColor: 'new',
|
2233
|
+
currentColor: 'current',
|
2234
|
+
ok: 'OK',
|
2235
|
+
cancel: 'Cancel'
|
2236
|
+
},
|
2237
|
+
tooltips: {
|
2238
|
+
colors: {
|
2239
|
+
newColor: 'New Color - Press “OK” To Commit',
|
2240
|
+
currentColor: 'Click To Revert To Original Color'
|
2241
|
+
},
|
2242
|
+
buttons: {
|
2243
|
+
ok: 'Commit To This Color Selection',
|
2244
|
+
cancel: 'Cancel And Revert To Original Color'
|
2245
|
+
},
|
2246
|
+
hue: {
|
2247
|
+
radio: 'Set To “Hue” Color Mode',
|
2248
|
+
textbox: 'Enter A “Hue” Value (0-360°)'
|
2249
|
+
},
|
2250
|
+
saturation: {
|
2251
|
+
radio: 'Set To “Saturation” Color Mode',
|
2252
|
+
textbox: 'Enter A “Saturation” Value (0-100%)'
|
2253
|
+
},
|
2254
|
+
value: {
|
2255
|
+
radio: 'Set To “Value” Color Mode',
|
2256
|
+
textbox: 'Enter A “Value” Value (0-100%)'
|
2257
|
+
},
|
2258
|
+
red: {
|
2259
|
+
radio: 'Set To “Red” Color Mode',
|
2260
|
+
textbox: 'Enter A “Red” Value (0-255)'
|
2261
|
+
},
|
2262
|
+
green: {
|
2263
|
+
radio: 'Set To “Green” Color Mode',
|
2264
|
+
textbox: 'Enter A “Green” Value (0-255)'
|
2265
|
+
},
|
2266
|
+
blue: {
|
2267
|
+
radio: 'Set To “Blue” Color Mode',
|
2268
|
+
textbox: 'Enter A “Blue” Value (0-255)'
|
2269
|
+
},
|
2270
|
+
alpha: {
|
2271
|
+
radio: 'Set To “Alpha” Color Mode',
|
2272
|
+
textbox: 'Enter A “Alpha” Value (0-100)'
|
2273
|
+
},
|
2274
|
+
hex: {
|
2275
|
+
textbox: 'Enter A “Hex” Color Value (#000000-#ffffff)',
|
2276
|
+
alpha: 'Enter A “Alpha” Value (#00-#ff)'
|
2277
|
+
}
|
2278
|
+
}
|
2279
|
+
}
|
2280
|
+
};
|
2281
|
+
})(jQuery, '1.1.6wsmod');
|
2282
|
+
|
2283
|
+
webshims.register('color-picker', function($, webshims, window, document, undefined, options){
|
2284
|
+
"use strict";
|
2285
|
+
var picker = webshims.picker;
|
2286
|
+
|
2287
|
+
picker.commonColorInit = function(data){
|
2288
|
+
var popover = data.popover;
|
2289
|
+
popover.element.on({
|
2290
|
+
wspopovershow: function(){
|
2291
|
+
data.element.triggerHandler('wsupdatevalue');
|
2292
|
+
picker._genericSetFocus.call(data, $('input.Hex', popover.element));
|
2293
|
+
}
|
2294
|
+
});
|
2295
|
+
};
|
2296
|
+
|
2297
|
+
picker.color.showPickerContent = (function(){
|
2298
|
+
var _init, curData;
|
2299
|
+
var jpicker = $('<div class="ws-jpicker" />');
|
2300
|
+
$.fn.wsjPicker.defaults.images.clientPath = webshims.cfg.basePath + 'jpicker/images/';
|
2301
|
+
var jPickerApi;
|
2302
|
+
|
2303
|
+
var fns = {
|
2304
|
+
setPicker: function(data){
|
2305
|
+
|
2306
|
+
|
2307
|
+
var mode = $(data.orig).data('colormode') || 'h';
|
2308
|
+
if(!data.alpha.length){
|
2309
|
+
jpicker.addClass('no-alpha-picker');
|
2310
|
+
if(mode == 'a'){
|
2311
|
+
mode = 'h';
|
2312
|
+
}
|
2313
|
+
} else {
|
2314
|
+
jpicker.removeClass('no-alpha-picker');
|
2315
|
+
}
|
2316
|
+
|
2317
|
+
if(mode != jPickerApi.settings.color.mode){
|
2318
|
+
jPickerApi.setColorMode(mode);
|
2319
|
+
}
|
2320
|
+
|
2321
|
+
},
|
2322
|
+
setInputColor: function(data){
|
2323
|
+
var oldAlpha;
|
2324
|
+
var colorData = jPickerApi.color.active.val();
|
2325
|
+
var value = '#'+colorData.hex;
|
2326
|
+
if(data.alpha.length){
|
2327
|
+
oldAlpha = data.alpha.prop('value');
|
2328
|
+
data.alpha.prop('value', colorData.a / (255 / (data.alpha.prop('max') || 1)));
|
2329
|
+
}
|
2330
|
+
$(data.orig).data('colormode', jPickerApi.settings.color.mode);
|
2331
|
+
picker._actions.changeInput(value, data.popover, data);
|
2332
|
+
if(data.alpha.length && oldAlpha != data.alpha.prop('value')){
|
2333
|
+
data.alpha.trigger('input').trigger('change');
|
2334
|
+
}
|
2335
|
+
return value;
|
2336
|
+
}
|
2337
|
+
// ,
|
2338
|
+
// triggerInputColor: function(data){
|
2339
|
+
// var oldAlpha;
|
2340
|
+
// var colorData = jPickerApi.color.active.val();
|
2341
|
+
// var value = '#'+colorData.hex;
|
2342
|
+
// if(data.alpha.length){
|
2343
|
+
// oldAlpha = data.alpha.prop('value');
|
2344
|
+
// data.alpha.prop('value', colorData.a / (255 / (data.alpha.prop('max') || 1)));
|
2345
|
+
// }
|
2346
|
+
// data.setInput(value);
|
2347
|
+
// if(data.alpha.length && oldAlpha != data.alpha.prop('value')){
|
2348
|
+
// data.alpha.triggerHandler('input');
|
2349
|
+
// }
|
2350
|
+
// return value;
|
2351
|
+
// }
|
2352
|
+
};
|
2353
|
+
var pickerSet = function(fn, data, value){
|
2354
|
+
if(data == curData && fns[fn]){
|
2355
|
+
fns[fn](data);
|
2356
|
+
}
|
2357
|
+
};
|
2358
|
+
var createPicker = function(data){
|
2359
|
+
|
2360
|
+
jPickerApi = jpicker.data('wsjPicker');
|
2361
|
+
|
2362
|
+
if(!jPickerApi){
|
2363
|
+
jpicker.empty().wsjPicker(
|
2364
|
+
{},
|
2365
|
+
function(color){
|
2366
|
+
if(curData){
|
2367
|
+
pickerSet('setInputColor', curData);
|
2368
|
+
}
|
2369
|
+
},
|
2370
|
+
false,
|
2371
|
+
function(color){
|
2372
|
+
if(curData){
|
2373
|
+
picker._actions.cancel('#' + color.val().hex, curData.popover, curData);
|
2374
|
+
}
|
2375
|
+
}
|
2376
|
+
);
|
2377
|
+
jPickerApi = jpicker.data('wsjPicker');
|
2378
|
+
}
|
2379
|
+
};
|
2380
|
+
|
2381
|
+
var implementPickerFor = function(data){
|
2382
|
+
createPicker();
|
2383
|
+
if( data != curData){
|
2384
|
+
if(curData){
|
2385
|
+
curData.popover.hide();
|
2386
|
+
}
|
2387
|
+
curData = data;
|
2388
|
+
data.popover.contentElement.html(jpicker);
|
2389
|
+
pickerSet('setPicker', data);
|
2390
|
+
}
|
2391
|
+
};
|
2392
|
+
|
2393
|
+
return function(data){
|
2394
|
+
if(!data._popoverinit){
|
2395
|
+
picker.commonInit(data, data.popover);
|
2396
|
+
picker.commonColorInit(data);
|
2397
|
+
}
|
2398
|
+
|
2399
|
+
var value = data.parseValue();
|
2400
|
+
implementPickerFor(data);
|
2401
|
+
|
2402
|
+
value += (data.alpha.length) ?
|
2403
|
+
$.wsjPicker.ColorMethods.intToHex( (data.alpha.prop('value') || 1) * (255 / (data.alpha.prop('max') || 1)) ) :
|
2404
|
+
'ff'
|
2405
|
+
;
|
2406
|
+
jPickerApi.color.active.val('ahex', value);
|
2407
|
+
jPickerApi.color.current.val('ahex', value);
|
2408
|
+
|
2409
|
+
data._popoverinit = true;
|
2410
|
+
};
|
2411
|
+
})();
|
2412
|
+
if(options && options._types && $.inArray('color', options._types) == -1){
|
2413
|
+
webshims.error('[type="color"] used without adding it to the types config.');
|
2414
|
+
}
|
2415
|
+
});
|