Skip to content

Commit 43fcff1

Browse files
committed
[refactor] helper colour convert naming
1 parent b9f5911 commit 43fcff1

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

‎src/js/helper.js‎

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -659,13 +659,13 @@ var helper = (function(){
659659
};
660660
};
661661

662-
varconvert={
662+
varconvertColor={
663663
rgb: {},
664664
hsl: {},
665665
hex: {}
666666
};
667667

668-
convert.rgb.hsl=function(rgb){
668+
convertColor.rgb.hsl=function(rgb){
669669
constr=rgb[0]/255;
670670
constg=rgb[1]/255;
671671
constb=rgb[2]/255;
@@ -704,8 +704,8 @@ var helper = (function(){
704704
return[h,s*100,l*100];
705705
};
706706

707-
convert.rgb.lab=function(rgb){
708-
constxyz=convert.rgb.xyz(rgb);
707+
convertColor.rgb.lab=function(rgb){
708+
constxyz=convertColor.rgb.xyz(rgb);
709709
letx=xyz[0];
710710
lety=xyz[1];
711711
letz=xyz[2];
@@ -725,7 +725,7 @@ var helper = (function(){
725725
return[l,a,b];
726726
};
727727

728-
convert.rgb.xyz=function(rgb){
728+
convertColor.rgb.xyz=function(rgb){
729729
letr=rgb[0]/255;
730730
letg=rgb[1]/255;
731731
letb=rgb[2]/255;
@@ -742,7 +742,7 @@ var helper = (function(){
742742
return[x*100,y*100,z*100];
743743
};
744744

745-
convert.rgb.hex=function(args){
745+
convertColor.rgb.hex=function(args){
746746
constinteger=((Math.round(args[0])&0xFF)<<16)+
747747
((Math.round(args[1])&0xFF)<<8)+
748748
(Math.round(args[2])&0xFF);
@@ -751,7 +751,7 @@ var helper = (function(){
751751
return'000000'.substring(string.length)+string;
752752
};
753753

754-
convert.hsl.rgb=function(hsl){
754+
convertColor.hsl.rgb=function(hsl){
755755
consth=hsl[0]/360;
756756
consts=hsl[1]/100;
757757
constl=hsl[2]/100;
@@ -799,7 +799,7 @@ var helper = (function(){
799799
returnrgb;
800800
};
801801

802-
convert.hex.rgb=function(args){
802+
convertColor.hex.rgb=function(args){
803803
constmatch=args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
804804
if(!match){
805805
return[0,0,0];
@@ -821,7 +821,6 @@ var helper = (function(){
821821
return[r,g,b];
822822
};
823823

824-
825824
// exposed methods
826825
return{
827826
e: e,
@@ -850,7 +849,7 @@ var helper = (function(){
850849
ordinalNumber: ordinalNumber,
851850
isJsonString: isJsonString,
852851
isHexNumber: isHexNumber,
853-
convert: convert
852+
convertColor: convertColor
854853
};
855854

856855
})();

‎src/js/theme.js‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ var theme = (function(){
2121

2222
mod.color={
2323
hsl: function(){
24-
varhsl=helper.convert.rgb.hsl([state.get.current().theme.color.rgb.r,state.get.current().theme.color.rgb.g,state.get.current().theme.color.rgb.b]);
24+
varhsl=helper.convertColor.rgb.hsl([state.get.current().theme.color.rgb.r,state.get.current().theme.color.rgb.g,state.get.current().theme.color.rgb.b]);
2525
state.get.current().theme.color.hsl.h=parseInt(hsl[0],10);
2626
state.get.current().theme.color.hsl.s=parseInt(hsl[1],10);
2727
state.get.current().theme.color.hsl.l=parseInt(hsl[2],10);
2828
},
2929
rgb: function(){
30-
varrgb=helper.convert.hsl.rgb([state.get.current().theme.color.hsl.h,state.get.current().theme.color.hsl.s,state.get.current().theme.color.hsl.l]);
30+
varrgb=helper.convertColor.hsl.rgb([state.get.current().theme.color.hsl.h,state.get.current().theme.color.hsl.s,state.get.current().theme.color.hsl.l]);
3131
state.get.current().theme.color.rgb.r=parseInt(rgb[0],10);
3232
state.get.current().theme.color.rgb.g=parseInt(rgb[1],10);
3333
state.get.current().theme.color.rgb.b=parseInt(rgb[2],10);
@@ -133,7 +133,7 @@ var theme = (function(){
133133
varlMod=4;
134134
varhtml=helper.e("html");
135135

136-
varhsl=helper.convert.rgb.hsl([state.get.current().theme.color.rgb.r,state.get.current().theme.color.rgb.g,state.get.current().theme.color.rgb.b]);
136+
varhsl=helper.convertColor.rgb.hsl([state.get.current().theme.color.rgb.r,state.get.current().theme.color.rgb.g,state.get.current().theme.color.rgb.b]);
137137

138138
// base color
139139
html.style.setProperty("--theme-shade",state.get.current().theme.color.rgb.r+", "+state.get.current().theme.color.rgb.g+", "+state.get.current().theme.color.rgb.b);
@@ -142,7 +142,7 @@ var theme = (function(){
142142
varh=hsl[0];
143143
vars=(hsl[1]-(sMod*i));
144144
varl=(hsl[2]-(lMod*i));
145-
varrgb=helper.convert.hsl.rgb([h,s,l]);
145+
varrgb=helper.convertColor.hsl.rgb([h,s,l]);
146146
varnumber;
147147
if(i<10){
148148
number="0"+i;
@@ -156,7 +156,7 @@ var theme = (function(){
156156
varh=hsl[0];
157157
vars=(hsl[1]+(sMod*i));
158158
varl=(hsl[2]+(lMod*i));
159-
varrgb=helper.convert.hsl.rgb([h,s,l]);
159+
varrgb=helper.convertColor.hsl.rgb([h,s,l]);
160160
varnumber;
161161
if(i<10){
162162
number="0"+i;

0 commit comments

Comments
(0)