[wp-trac] [WordPress Trac] #19449: Fix Farbtastic to make it work with empty input fields, too

WordPress Trac noreply at wordpress.org
Wed Aug 21 19:51:22 UTC 2013


#19449: Fix Farbtastic to make it work with empty input fields, too
--------------------------------+----------------------
 Reporter:  BytesForAll         |       Owner:
     Type:  enhancement         |      Status:  closed
 Priority:  normal              |   Milestone:
Component:  External Libraries  |     Version:  3.3
 Severity:  normal              |  Resolution:  wontfix
 Keywords:                      |
--------------------------------+----------------------
Changes (by SergeyBiryukov):

 * milestone:  Awaiting Review =>


Old description:

> Farbtastic requires that the color input field has either a color value
> or at least a '#' character. If it's empty it won't work. This seems like
> an artificial limitation and requires workarounds if the integrated
> Farbtastic is used for input fields that may be empty, i.e. for theme or
> plugin options where the color is optional. If the color fields has a
> default value there's no issue but having empty color fields is a useful
> and valid use case.
>
> This could be fixed in /wp-admin/js/farbtastic.js, line 192
>
> Old:
> if (this.value && this.value != fb.color) {
>
> New:
> if (this.value != fb.color) {
>

> Looks like WP is working around this for the 'custom background' for
> themes (which is empty by default) by adding a hardcoded '#' and saving
> the background-color without '#'
>
> /wp-includes/theme.php, line 1772:
> $style = $color ? "background-color: #$color;" : '';
>
> /wp-admin/custom-background.php, line 303:
> <input type="text" name="background-color" id="background-color"
> value="#<?php echo esc_attr(get_background_color()) ?>" />

New description:

 Farbtastic requires that the color input field has either a color value or
 at least a '#' character. If it's empty it won't work. This seems like an
 artificial limitation and requires workarounds if the integrated
 Farbtastic is used for input fields that may be empty, i.e. for theme or
 plugin options where the color is optional. If the color fields has a
 default value there's no issue but having empty color fields is a useful
 and valid use case.

 This could be fixed in /wp-admin/js/farbtastic.js, line 192

 Old:
 {{{
 if (this.value && this.value != fb.color) {
 }}}

 New:
 {{{
 if (this.value != fb.color) {
 }}}

 Looks like WP is working around this for the 'custom background' for
 themes (which is empty by default) by adding a hardcoded '#' and saving
 the background-color without '#'

 /wp-includes/theme.php, line 1772:
 {{{
 $style = $color ? "background-color: #$color;" : '';
 }}}

 /wp-admin/custom-background.php, line 303:
 {{{
 <input type="text" name="background-color" id="background-color"
 value="#<?php echo esc_attr(get_background_color()) ?>" />
 }}}

--

--
Ticket URL: <http://core.trac.wordpress.org/ticket/19449#comment:2>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list