Colorpicker improvement
authorMarcel Werk <burntime@woltlab.com>
Wed, 8 May 2013 18:24:29 +0000 (20:24 +0200)
committerMarcel Werk <burntime@woltlab.com>
Wed, 8 May 2013 18:24:29 +0000 (20:24 +0200)
wcfsetup/install/files/js/WCF.ColorPicker.js

index e9134ecb40f2c54678dbfa9223f039807f3a4b83..4ddf1c7c873eb52765e79317c08f0f71236636b1 100644 (file)
@@ -237,17 +237,37 @@ WCF.ColorPicker = Class.extend({
                this._hex = $('<input type="text" maxlength="6" />').appendTo($hex.find('label'));
                
                // bind event listener
-               this._rgba.r.blur($.proxy(this._blurRgba, this));
-               this._rgba.g.blur($.proxy(this._blurRgba, this));
-               this._rgba.b.blur($.proxy(this._blurRgba, this));
-               this._rgba.a.blur($.proxy(this._blurRgba, this));
-               this._hex.blur($.proxy(this._blurHex, this));
+               this._rgba.r.blur($.proxy(this._blurRgba, this)).keyup($.proxy(this._keyUpRGBA, this));
+               this._rgba.g.blur($.proxy(this._blurRgba, this)).keyup($.proxy(this._keyUpRGBA, this));
+               this._rgba.b.blur($.proxy(this._blurRgba, this)).keyup($.proxy(this._keyUpRGBA, this));
+               this._rgba.a.blur($.proxy(this._blurRgba, this)).keyup($.proxy(this._keyUpRGBA, this));
+               this._hex.blur($.proxy(this._blurHex, this)).keyup($.proxy(this._keyUpHex, this));
                
                // submit button
                var $submitForm = $('<div class="formSubmit" />').appendTo(this._dialog);
                $('<button class="buttonPrimary">' + WCF.Language.get('wcf.global.button.save') + '</button>').appendTo($submitForm).click($.proxy(this._submit, this));
        },
        
+       /**
+        * Submits form on enter.
+        */
+       _keyUpRGBA: function(event) {
+               if (event.which == 13) {
+                       this._blurRgba();
+                       this._submit();
+               }
+       },
+       
+       /**
+        * Submits form on enter.
+        */
+       _keyUpHex: function(event) {
+               if (event.which == 13) {
+                       this._blurHex();
+                       this._submit();
+               }
+       },
+       
        /**
         * Assigns the new color for active element.
         */