]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Removed default values from <input>s. JavaScript will now get the
authorSarven Capadisli <csarven@controlyourself.ca>
Thu, 30 Jul 2009 20:44:51 +0000 (20:44 +0000)
committerSarven Capadisli <csarven@controlyourself.ca>
Thu, 30 Jul 2009 20:44:51 +0000 (20:44 +0000)
colours from the theme. This approach removes data that was
previously available in HTML. It was only necessary if the user wanted
to know the site's default values.

js/userdesign.go.js
lib/designsettings.php

index dda86294ed99abda715578176d12adf860c3a397..70dd9c7de7408d994d817a1f68df33ccd5603f99 100644 (file)
@@ -7,6 +7,35 @@
  * @link      http://laconi.ca/
  */
 $(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) {
+        rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
+        function hex(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];
+        }
+        return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
+    }
+
     function UpdateColors(S) {
         C = $(S).val();
         switch (parseInt(S.id.slice(-1))) {
@@ -55,7 +84,7 @@ $(document).ready(function() {
 
         f = $.farbtastic('#color-picker', SynchColors);
         swatches = $('#settings_design_color .swatch');
-
+        swatches.each(InitColors);
         swatches
             .each(SynchColors)
             .blur(function() {
index fbffdb208f1e73a35e03497768f61e8f304beadc..1b0e62166926ac7dbe60db6b5b1a8058fd862b68 100644 (file)
@@ -182,7 +182,7 @@ class DesignSettingsAction extends AccountSettingsAction
                                           'class' => 'swatch',
                                           'maxlength' => '7',
                                           'size' => '7',
-                                          'value' => '#' . $bgcolor->hexValue()));
+                                          'value' => ''));
             $this->elementEnd('li');
 
             $ccolor = new WebColor($design->contentcolor);
@@ -195,7 +195,7 @@ class DesignSettingsAction extends AccountSettingsAction
                                           'class' => 'swatch',
                                           'maxlength' => '7',
                                           'size' => '7',
-                                          'value' => '#' . $ccolor->hexValue()));
+                                          'value' => ''));
             $this->elementEnd('li');
 
             $sbcolor = new WebColor($design->sidebarcolor);
@@ -208,7 +208,7 @@ class DesignSettingsAction extends AccountSettingsAction
                                         'class' => 'swatch',
                                         'maxlength' => '7',
                                         'size' => '7',
-                                        'value' => '#' . $sbcolor->hexValue()));
+                                        'value' => ''));
             $this->elementEnd('li');
 
             $tcolor = new WebColor($design->textcolor);
@@ -221,7 +221,7 @@ class DesignSettingsAction extends AccountSettingsAction
                                         'class' => 'swatch',
                                         'maxlength' => '7',
                                         'size' => '7',
-                                        'value' => '#' . $tcolor->hexValue()));
+                                        'value' => ''));
             $this->elementEnd('li');
 
             $lcolor = new WebColor($design->linkcolor);
@@ -234,7 +234,7 @@ class DesignSettingsAction extends AccountSettingsAction
                                          'class' => 'swatch',
                                          'maxlength' => '7',
                                          'size' => '7',
-                                         'value' => '#' . $lcolor->hexValue()));
+                                         'value' => ''));
             $this->elementEnd('li');
 
         } catch (WebColorException $e) {