]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/js/color-picker.js
WordPress 3.9.2
[autoinstalls/wordpress.git] / wp-admin / js / color-picker.js
index 393f2ff9c8493cbc7ea5ae58b581c68bb398b6fa..1cc0a13bc693886772240a3279c4eecbafdce155 100644 (file)
@@ -1,13 +1,15 @@
+/* global wpColorPickerL10n:true */
 ( function( $, undef ){
 
-       // html stuff
-       var _before = '<a tabindex="0" class="wp-color-result" />',
+       var ColorPicker,
+               // html stuff
+               _before = '<a tabindex="0" class="wp-color-result" />',
                _after = '<div class="wp-picker-holder" />',
                _wrap = '<div class="wp-picker-container" />',
                _button = '<input type="button" class="button button-small hidden" />';
 
        // jQuery UI Widget constructor
-       var ColorPicker = {
+       ColorPicker = {
                options: {
                        defaultColor: false,
                        change: false,
                        palettes: true
                },
                _create: function() {
-                       // bail early for IE < 8
-                       if ( $.browser.msie && parseInt( $.browser.version, 10 ) < 8 )
+                       // bail early for unsupported Iris.
+                       if ( ! $.support.iris )
                                return;
-                       var self = this;
-                       var el = self.element;
+                       var self = this,
+                               el = self.element;
+
                        $.extend( self.options, el.data() );
 
                        self.initialValue = el.val();
@@ -28,7 +31,7 @@
                        // Set up HTML structure, hide things
                        el.addClass( 'wp-color-picker' ).hide().wrap( _wrap );
                        self.wrap = el.parent();
-                       self.toggler = $( _before ).insertBefore( el ).css( { backgroundColor: self.initialValue } ).attr( "title", wpColorPickerL10n.pick ).attr( "data-current", wpColorPickerL10n.current );
+                       self.toggler = $( _before ).insertBefore( el ).css( { backgroundColor: self.initialValue } ).attr( 'title', wpColorPickerL10n.pick ).attr( 'data-current', wpColorPickerL10n.current );
                        self.pickerContainer = $( _after ).insertAfter( el );
                        self.button = $( _button );
 
@@ -68,9 +71,9 @@
 
                                // close picker when you click outside it
                                if ( self.toggler.hasClass( 'wp-picker-open' ) )
-                                       $( "body" ).on( 'click', { wrap: self.wrap, toggler: self.toggler }, self._bodyListener );
+                                       $( 'body' ).on( 'click', { wrap: self.wrap, toggler: self.toggler }, self._bodyListener );
                                else
-                                       $( "body" ).off( 'click', self._bodyListener );
+                                       $( 'body' ).off( 'click', self._bodyListener );
                        });
 
                        self.element.change(function( event ) {
                // $("#input").wpColorPicker('color', '#bada55') to set
                color: function( newColor ) {
                        if ( newColor === undef )
-                               return this.element.iris( "option", "color" );
+                               return this.element.iris( 'option', 'color' );
 
-                       this.element.iris( "option", "color", newColor );
+                       this.element.iris( 'option', 'color', newColor );
                },
                //$("#input").wpColorPicker('defaultColor') returns the current default color
                //$("#input").wpColorPicker('defaultColor', newDefaultColor) to set
 
                        this.options.defaultColor = newDefaultColor;
                }
-       }
+       };
 
        $.widget( 'wp.wpColorPicker', ColorPicker );
-}( jQuery ) );
\ No newline at end of file
+}( jQuery ) );