javascript - Save users colorpicker choice -


i'm trying allow users of site change colors within it, far, managed colors change in fact, however, when change or reload page changes disappear.

then, tried store choice in cookie, don't know wrong stills doesn't work.

i'm using following colorpicker: http://colpick.com/plugin

and here code

    <script type="text/javascript"> jquery(document).ready(function(){ /* custom background-color on elements */ var custombackgroundcolor = ".thead,.go-top,.forum_offlink,.forum_on"; /* custom text color on elements */ var customtext = "a:link,.user-name,.news-header,.newsticker,.newscontroller,.patternchanger ul li a,.fixed,.fluid,.modalcontent h1,.buttons,.solservices:hover i,a.button:link,a.button:visited,a.button:active,.postbit_buttons > a:link,.postbit_buttons > a:hover,.postbit_buttons > a:visited,.postbit_buttons > a:active"; /* custom background on elements */ var custombackground = ".navhome,.h3main span,.logincon,.signupnow,.mfp-close-btn-in,.mfp-close,.button:hover,input.button";         $('#picker').colpick({                 colorscheme:'dark',                 layout:'rgbhex',                 color:'ff8800',                 onsubmit:function(hsb,hex,rgb,el) {                 themecolor = "#"+hex;                 $(custombackgroundcolor).css("background-color", "#"+hex);             $(customtext).css("color","#"+hex);                 $(custombackground).css("background","#"+hex);                 $(el).colpickhide();                 $.cookie('customcolor',hex,{ expires: 365, path: '/'});                 },                 onbeforeshow:function() {                         $(this).colpicksetcolor(this.value);                 }                 onchange:function(hsb,hex,rgb,el) {                 $(custombackgroundcolor).css("background-color", "#" + hex);                 $(customtext).css("color", "#" + hex);                 $(custombackground).css("background", "#" + hex);                 $.cookie('customcolor',hex,{ expires: 365, path: '/'});                 }         })                 .bind('keyup', function(){                 $(this).colpicksetcolor(this.value);                 });                  if ( ($.cookie('customcolor') != null)) {                 $(custombackgroundcolor).css("background-color", "#" + $.cookie('customcolor'));                 $(customtext).css("color", "#" + $.cookie('customcolor'));                 $(custombackground).css("background", "#" + $.cookie('customcolor'));                 $("#picker").val($.cookie('customcolor'));                 }                 else{                 $(custombackgroundcolor).css("background-color","#e74c3c");                 $(customtext).css("color","#e74c3c");                 $(custombackground).css("color","#e74c3c");                 } </script> 

any highly appreciated, thank time.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -