From 29ae1ce9ffeb1e747ebe832dfc54a0b57aae805a Mon Sep 17 00:00:00 2001 From: laurenceseo Date: Mon, 30 Sep 2013 22:58:14 +0800 Subject: laurence --- js/colorpicker.js | 99 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 65 insertions(+), 34 deletions(-) (limited to 'js') diff --git a/js/colorpicker.js b/js/colorpicker.js index 62ec343..62870fb 100644 --- a/js/colorpicker.js +++ b/js/colorpicker.js @@ -187,7 +187,7 @@ var ColorPicker = { }); addfav.click(function(){ColorPicker.addfavourites()}); openfav.click(function(){ColorPicker.openfavourites()}); - hexswitch.click(function(){ColorPicker.hexcolorswitch()}); + hexswitch.click(function(){ColorPicker.hexcolorswitch(); ColorPicker.resetfavcolor();}); $('.theswitches').hover(function(){ ColorPicker.switchhovercss(this.id, 'over') }, function(){ ColorPicker.switchhovercss(this.id, 'out') }); //-------handler for window resive---- @@ -211,16 +211,39 @@ var ColorPicker = { } return retcolor; }, - initfavpanel: function(){ + resetfavcolor: function(){ + $('.favcolor').each(function(index){ + var favcol = $(this).find('label').html(); + var rgbcol = ColorPicker.getcolorfromfavorite(favcol); + var colname = ""; + if (hexes === true) { + colname = rgbcol; + }else if(rgbs === true) { + colname = rgbtoname[rgbcol]; + }else if (names === true) { + colname = rgbtohex[rgbcol]; + } + $(this).find('label').html(colname); + }); + }, + initfavpanel: function(){ var fcolors = $('#favcolors').val(); var clist=fcolors.split(separate); for(var i=0; i < clist.length; i++) { if (clist[i] != '') { - var colname = clist[i]; + var col = ColorPicker.getcolorfromfavorite(clist[i]); + var colname = ""; + if (hexes === true) { + colname = col; + }else if(rgbs === true) { + colname = rgbtoname[col]; + }else if (names === true) { + colname = rgbtohex[col]; + } favpanel.append(' '); - } + } } }, existsfavcolor: function(fcolor) { @@ -306,6 +329,7 @@ var ColorPicker = { } bscroll = true; ColorPicker.setpaneldimension(); + ColorPicker.resetfavcolor(); } addfav.html('Add to Favorites'); curfavcolor = ""; @@ -314,39 +338,48 @@ var ColorPicker = { }, loadColorStorage: function() { var opts = $('#opt_hexswitch').val(); - names = false; - rgbs = false; - hexes = false; - if(opts == 'names') { - selectedname = namespace.val(); - selectedrgb = hextorgb[nametohex[selectedname]]; - hexswitch.html('CLICK TO SWITCH TO RGB VALUES'); - rgbs = true; - }else if(opts == 'rgbs') { - selectedname = rgbtoname[namespace.val()]; - selectedrgb = namespace.val(); - hexes = true; - hexswitch.html('CLICK TO SWITCH TO HEX VALUES') - }else if(opts == 'hexes') { - names = true; - selectedrgb = hextorgb[namespace.val()]; - selectedname = rgbtoname[selectedrgb]; - hexswitch.html('CLICK TO SWITCH TO COLOR NAMES'); + if (opts != '') + { + names = false; + rgbs = false; + hexes = false; + if(opts == 'names') { + selectedname = namespace.val(); + selectedrgb = hextorgb[nametohex[selectedname]]; + hexswitch.html('CLICK TO SWITCH TO RGB VALUES'); + rgbs = true; + }else if(opts == 'rgbs') { + selectedname = rgbtoname[namespace.val()]; + selectedrgb = namespace.val(); + hexes = true; + hexswitch.html('CLICK TO SWITCH TO HEX VALUES') + }else if(opts == 'hexes') { + names = true; + selectedrgb = hextorgb[namespace.val()]; + selectedname = rgbtoname[selectedrgb]; + hexswitch.html('CLICK TO SWITCH TO COLOR NAMES'); + } } + colornames.html(selectedname); preview.css({'background-color':selectedrgb,'border-style':'none'}); vasebackground.css('background-color',selectedrgb); infostate = parseInt($('#opt_infoswitch').val()); ColorPicker.switchcolorinfo(); - var bgOpt = $('#opt_bgColor').val(); - if (bgOpt == "bg1") + + var bgOpt = $('#opt_bgColor').val(); + if (bgOpt != '') { - $('#colorpicker').css({'background-image':'url("./images/bg.dither.gif")','background-color':'gray','background-color':'black'}); - }else if(bgOpt == "bg5"){ - $('#colorpicker').css({'background-image':"url('" + $('#opt_bgURI').val() + "')"}); - }else{ - $('#colorpicker').css({'background-image':'none','background-color':$('#' + bgOpt).html()}); - } + if (bgOpt == "bg1") + { + $('#colorpicker').css({'background-image':'url("./images/bg.dither.gif")','background-color':'gray','background-color':'black'}); + }else if(bgOpt == "bg5"){ + $('#colorpicker').css({'background-image':"url('" + $('#opt_bgURI').val() + "')"}); + }else{ + $('#colorpicker').css({'background-image':'none','background-color':$('#' + bgOpt).html()}); + } + } + $('#bgURI').val($('#opt_bgURI').val()); ColorPicker.initfavpanel(); }, @@ -384,7 +417,6 @@ var ColorPicker = { hexcolorswitch: function() { if(names == true) { hexes = false; - rgbs = false; hexswitch.html('CLICK TO SWITCH TO RGB VALUES'); namespace.val(selectedname); names = false; @@ -392,7 +424,6 @@ var ColorPicker = { $('#opt_hexswitch').val('names'); }else if(hexes == true) { rgbs = false; - names = false; hexswitch.html('CLICK TO SWITCH TO COLOR NAMES'); namespace.val(rgbtohex[selectedrgb]); hexes = false; @@ -400,15 +431,15 @@ var ColorPicker = { $('#opt_hexswitch').val('hexes'); }else if(rgbs == true) { names = false; - hexes = false; hexswitch.html('CLICK TO SWITCH TO HEX VALUES') namespace.val(selectedrgb) rgbs = false; hexes = true; $('#opt_hexswitch').val('rgbs'); - } + } }, putitin: function() { + var thecolor = ''; if (rgbs === true) { thecolor = selectedname; } if (hexes === true) { thecolor = selectedrgb; } if (names === true) { thecolor = rgbtohex[selectedrgb]; } -- cgit v1.2.3-70-g09d2