From 2a0aeea47d74f3aac6d09398783b8d60c6c513d7 Mon Sep 17 00:00:00 2001 From: "Sergio P.A" <23r9i0@gmail.com> Date: Tue, 1 Dec 2015 11:12:42 +0100 Subject: [PATCH] Revert "Small change" --- src/wp-color-picker-alpha.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/wp-color-picker-alpha.js b/src/wp-color-picker-alpha.js index f1242ca..0d040cf 100644 --- a/src/wp-color-picker-alpha.js +++ b/src/wp-color-picker-alpha.js @@ -31,8 +31,11 @@ if ( this.error ) return ''; - if ( hex.length < 6 ) - hex = ( '00000' + hex ).substr( -6 ); + if ( hex.length < 6 ) { + for ( var i = 6 - hex.length - 1; i >= 0; i-- ) { + hex = '0' + hex; + } + } return '#' + hex; }; @@ -60,7 +63,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 ).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 ); @@ -207,7 +210,7 @@ self.options.defaultWidth = el.width(); // Update width for input - if ( self._color._alpha < 1 || self._color.toString().indexOf('rgb') != -1 ) { + if ( self._color._alpha < 1 || self._color.toString().indexOf('rgb') != 1 ) { el.width( parseInt( self.options.defaultWidth + self.options.customWidth ) ); } @@ -342,4 +345,4 @@ // Auto Call plugin is class is color-picker jQuery( document ).ready( function( $ ) { $( '.color-picker' ).wpColorPicker(); -} ); +} ); \ No newline at end of file