X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=js%2Fuserdesign.go.js;h=eb4dece095efe77b302e8d61c4db3ac60f81c5dd;hb=6bf29ff68443cbedb26c41af96c9c2adfffc5288;hp=b54b492cce34ed52e6c7efed3dc29d027bd899ed;hpb=164588ef0fd2c9c9f1858f1d21d6758356ce7885;p=quix0rs-gnu-social.git diff --git a/js/userdesign.go.js b/js/userdesign.go.js index b54b492cce..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() { @@ -89,11 +120,11 @@ $(document).ready(function() { $('body').css({'background-image':'none'}); }); $('#design_background-image_on').focus(function() { - var bis = $('#design_background-image_onoff img')[0].src; - $('body').css({'background-image':'url('+bis+')'}); + $('body').css({'background-image':'url('+$('#design_background-image_onoff img')[0].src+')'}); + $('body').css({'background-attachment': 'fixed'}); }); $('#design_background-image_repeat').click(function() { ($(this)[0].checked) ? $('body').css({'background-repeat':'repeat'}) : $('body').css({'background-repeat':'no-repeat'}); }); -}); \ No newline at end of file +});