X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=js%2Fuserdesign.go.js;h=eb4dece095efe77b302e8d61c4db3ac60f81c5dd;hb=42601b1ff0f054223ca7fb11c50aa236a87d07fa;hp=833b19adcb50ebd3c4715f0a69f5bb584124afed;hpb=abd74673921cd119e05089d3cce2f0a37fdb49fe;p=quix0rs-gnu-social.git diff --git a/js/userdesign.go.js b/js/userdesign.go.js index 833b19adcb..eb4dece095 100644 --- a/js/userdesign.go.js +++ b/js/userdesign.go.js @@ -1,17 +1,48 @@ /** Init for Farbtastic library and page setup * - * @package Laconica - * @author Sarven Capadisli - * @copyright 2009 Control Yourself, Inc. + * @package StatusNet + * @author Sarven Capadisli + * @copyright 2009 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 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').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))) { case 1: default: - $('html, body').css({'background-color':C}); + $('body').css({'background-color':C}); break; case 2: $('#content, #site_nav_local_views .current a').css({'background-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() { @@ -90,6 +121,7 @@ $(document).ready(function() { }); $('#design_background-image_on').focus(function() { $('body').css({'background-image':'url('+$('#design_background-image_onoff img')[0].src+')'}); + $('body').css({'background-attachment': 'fixed'}); }); $('#design_background-image_repeat').click(function() {