]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/js/color-picker.js
WordPress 4.7-scripts
[autoinstalls/wordpress.git] / wp-admin / js / color-picker.js
index 96f55daedb58cbb6b9558c25968d3c7c4cee2cbd..807ff2a14c2e4a58dc91ed0222c18fdd0001c067 100644 (file)
                        hide: true,
                        palettes: true,
                        width: 255,
-                       mode: 'hsv'
+                       mode: 'hsv',
+                       type: 'full',
+                       slider: 'horizontal'
+               },
+               _createHueOnly: function() {
+                       var self = this,
+                               el = self.element,
+                               color;
+
+                       // hide input
+                       el.hide();
+                       // max saturated color for hue to be obvious
+                       color = 'hsl(' + el.val() + ', 100, 50)';
+
+                       el.iris( {
+                               mode: 'hsl',
+                               type: 'hue',
+                               hide: false,
+                               color: color,
+                               change: function( event, ui ) {
+                                       if ( $.isFunction( self.options.change ) ) {
+                                               self.options.change.call( this, event, ui );
+                                       }
+                               },
+                               width: self.options.width,
+                               slider: self.options.slider
+                       } );
                },
                _create: function() {
                        // bail early for unsupported Iris.
 
                        $.extend( self.options, el.data() );
 
+                       // hue-only gets created differently
+                       if ( self.options.type === 'hue' ) {
+                               return self._createHueOnly();
+                       }
+
                        // keep close bound so it can be attached to a body listener
                        self.close = $.proxy( self.close, self );
 
                        if ( newColor === undef ) {
                                return this.element.iris( 'option', 'color' );
                        }
-
                        this.element.iris( 'option', 'color', newColor );
                },
                //$("#input").wpColorPicker('defaultColor') returns the current default color