File Editor
Directories:
.. (Back)
Files:
accordion.js
accordion.min.js
bookmarklet.js
bookmarklet.min.js
color-picker.js
color-picker.min.js
comment.js
comment.min.js
common.js
common.min.js
custom-background.js
custom-background.min.js
custom-header.js
customize-controls.js
customize-controls.min.js
customize-nav-menus.js
customize-nav-menus.min.js
customize-widgets.js
customize-widgets.min.js
dashboard.js
dashboard.min.js
edit-comments.js
edit-comments.min.js
editor-expand.js
editor-expand.min.js
editor.js
editor.min.js
farbtastic.js
gallery.js
gallery.min.js
image-edit.js
image-edit.min.js
inline-edit-post.js
inline-edit-post.min.js
inline-edit-tax.js
inline-edit-tax.min.js
iris.min.js
language-chooser.js
language-chooser.min.js
link.js
link.min.js
media-gallery.js
media-gallery.min.js
media-upload.js
media-upload.min.js
media.js
media.min.js
nav-menu.js
nav-menu.min.js
password-strength-meter.js
password-strength-meter.min.js
plugin-install.js
plugin-install.min.js
post.js
post.min.js
postbox.js
postbox.min.js
press-this.js
press-this.min.js
revisions.js
revisions.min.js
set-post-thumbnail.js
set-post-thumbnail.min.js
svg-painter.js
svg-painter.min.js
tags-box.js
tags-box.min.js
tags.js
tags.min.js
theme.js
theme.min.js
updates.js
updates.min.js
user-profile.js
user-profile.min.js
user-suggest.js
user-suggest.min.js
widgets.js
widgets.min.js
word-count.js
word-count.min.js
wp-fullscreen-stub.js
wp-fullscreen-stub.min.js
xfn.js
xfn.min.js
Create New File
Create
Edit File: color-picker.js
/* global wpColorPickerL10n */ ( function( $, undef ){ 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 ColorPicker = { options: { defaultColor: false, change: false, clear: false, hide: true, palettes: true, width: 255, mode: 'hsv' }, _create: function() { // bail early for unsupported Iris. if ( ! $.support.iris ) { return; } var self = this, el = self.element; $.extend( self.options, el.data() ); // keep close bound so it can be attached to a body listener self.close = $.proxy( self.close, self ); self.initialValue = el.val(); // 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.pickerContainer = $( _after ).insertAfter( el ); self.button = $( _button ); if ( self.options.defaultColor ) { self.button.addClass( 'wp-picker-default' ).val( wpColorPickerL10n.defaultString ); } else { self.button.addClass( 'wp-picker-clear' ).val( wpColorPickerL10n.clear ); } el.wrap( '<span class="wp-picker-input-wrap" />' ).after(self.button); el.iris( { target: self.pickerContainer, hide: self.options.hide, width: self.options.width, mode: self.options.mode, palettes: self.options.palettes, change: function( event, ui ) { self.toggler.css( { backgroundColor: ui.color.toString() } ); // check for a custom cb if ( $.isFunction( self.options.change ) ) { self.options.change.call( this, event, ui ); } } } ); el.val( self.initialValue ); self._addListeners(); if ( ! self.options.hide ) { self.toggler.click(); } }, _addListeners: function() { var self = this; // prevent any clicks inside this widget from leaking to the top and closing it self.wrap.on( 'click.wpcolorpicker', function( event ) { event.stopPropagation(); }); self.toggler.click( function(){ if ( self.toggler.hasClass( 'wp-picker-open' ) ) { self.close(); } else { self.open(); } }); self.element.change( function( event ) { var me = $( this ), val = me.val(); // Empty = clear if ( val === '' || val === '#' ) { self.toggler.css( 'backgroundColor', '' ); // fire clear callback if we have one if ( $.isFunction( self.options.clear ) ) { self.options.clear.call( this, event ); } } }); // open a keyboard-focused closed picker with space or enter self.toggler.on( 'keyup', function( event ) { if ( event.keyCode === 13 || event.keyCode === 32 ) { event.preventDefault(); self.toggler.trigger( 'click' ).next().focus(); } }); self.button.click( function( event ) { var me = $( this ); if ( me.hasClass( 'wp-picker-clear' ) ) { self.element.val( '' ); self.toggler.css( 'backgroundColor', '' ); if ( $.isFunction( self.options.clear ) ) { self.options.clear.call( this, event ); } } else if ( me.hasClass( 'wp-picker-default' ) ) { self.element.val( self.options.defaultColor ).change(); } }); }, open: function() { this.element.show().iris( 'toggle' ).focus(); this.button.removeClass( 'hidden' ); this.wrap.addClass( 'wp-picker-active' ); this.toggler.addClass( 'wp-picker-open' ); $( 'body' ).trigger( 'click.wpcolorpicker' ).on( 'click.wpcolorpicker', this.close ); }, close: function() { this.element.hide().iris( 'toggle' ); this.button.addClass( 'hidden' ); this.wrap.removeClass( 'wp-picker-active' ); this.toggler.removeClass( 'wp-picker-open' ); $( 'body' ).off( 'click.wpcolorpicker', this.close ); }, // $("#input").wpColorPicker('color') returns the current color // $("#input").wpColorPicker('color', '#bada55') to set color: function( newColor ) { if ( newColor === undef ) { return this.element.iris( 'option', 'color' ); } this.element.iris( 'option', 'color', newColor ); }, //$("#input").wpColorPicker('defaultColor') returns the current default color //$("#input").wpColorPicker('defaultColor', newDefaultColor) to set defaultColor: function( newDefaultColor ) { if ( newDefaultColor === undef ) { return this.options.defaultColor; } this.options.defaultColor = newDefaultColor; } }; $.widget( 'wp.wpColorPicker', ColorPicker ); }( jQuery ) );
Save Changes
Rename File
Rename