X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=js%2Fuserdesign.go.js;h=5dd1401268c91b5b6015f90716358dba5c25eca4;hb=a4d04d24de59f2694aaeb65dda50afe40a58b931;hp=dda86294ed99abda715578176d12adf860c3a397;hpb=bb1548451ae39cda7a4c6212bee204a9d38e6ba7;p=quix0rs-gnu-social.git diff --git a/js/userdesign.go.js b/js/userdesign.go.js index dda86294ed..5dd1401268 100644 --- a/js/userdesign.go.js +++ b/js/userdesign.go.js @@ -1,12 +1,43 @@ /** Init for Farbtastic library and page setup * - * @package Laconica - * @author Sarven Capadisli - * @copyright 2009 Control Yourself, Inc. + * @package StatusNet + * @author Sarven Capadisli + * @copyright 2009-2011 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ + * @link http://status.net/ */ -$(document).ready(function() { +$(function() { + function InitColors(i, E) { + switch (parseInt(E.id.slice(-1))) { + case 1: default: + $(E).val(rgb2hex($('body').css('background-color'))); + break; + case 2: + $(E).val(rgb2hex($('#content').css('background-color'))); + break; + case 3: + $(E).val(rgb2hex($('#aside_primary_wrapper, #site_nav_local_views_wrapper').css('background-color'))); + break; + case 4: + $(E).val(rgb2hex($('html body').css('color'))); + break; + case 5: + $(E).val(rgb2hex($('a').css('color'))); + break; + } + } + + function rgb2hex(rgb) { + if (rgb.slice(0,1) == '#') { return rgb; } + rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/); + return '#' + dec2hex(rgb[1]) + dec2hex(rgb[2]) + dec2hex(rgb[3]); + } + /* dec2hex written by R0bb13 */ + function dec2hex(x) { + hexDigits = new Array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); + return isNaN(x) ? '00' : hexDigits[(x - x % 16) / 16] + hexDigits[x % 16]; + } + function UpdateColors(S) { C = $(S).val(); switch (parseInt(S.id.slice(-1))) { @@ -14,10 +45,10 @@ $(document).ready(function() { $('body').css({'background-color':C}); break; case 2: - $('#content, #site_nav_local_views .current a').css({'background-color':C}); + $('#content').css({'background-color':C}); break; case 3: - $('#aside_primary').css({'background-color':C}); + $('#aside_primary_wrapper, #site_nav_local_views_wrapper').css({'background-color':C}); break; case 4: $('html body').css({'color':C}); @@ -55,7 +86,7 @@ $(document).ready(function() { f = $.farbtastic('#color-picker', SynchColors); swatches = $('#settings_design_color .swatch'); - + swatches.each(InitColors); swatches .each(SynchColors) .blur(function() { @@ -76,11 +107,11 @@ $(document).ready(function() { var f, swatches; InitFarbtastic(); - $('#form_settings_design').bind('reset', function(){ + $('#form_settings_design').on('reset', function(){ setTimeout(function(){ swatches.each(function(){UpdateColors(this);}); $('#color-picker').remove(); - swatches.unbind(); + swatches.off(); InitFarbtastic(); },10); });