Permalink
Browse files

change for easy to use with other ids on the textarae fields

  • Loading branch information...
1 parent ca350a7 commit 64eb0a173ab93dc910178e2b047f0b48b56f2e84 @bueltge committed Sep 7, 2012
Showing with 42 additions and 20 deletions.
  1. +8 −0 inc/theme-options.css
  2. +11 −7 inc/theme-options.js
  3. +23 −13 inc/theme-options.php
@@ -29,6 +29,14 @@
padding: 4px 14px;
}
+#colorPickerDiv {
+ z-index: 100;
+ background: #eee;
+ border: 1px solid #ccc;
+ position: absolute;
+ display: none;
+}
+
body.rtl .image-radio-option label {
float: right;
margin: 0 2px 20px 30px;
View
@@ -2,31 +2,35 @@ var farbtastic;
( function($) {
+ // set ID or class for the textarea
+ var colorpicker = '#text-color',
+ example = '#text-color-example';
+
var pickColor = function(a) {
farbtastic.setColor(a);
- $('#text-color').val(a);
- $('#text-color-example').css('background-color', a);
+ $(colorpicker).val(a);
+ $(example).css('background-color', a);
};
$(document).ready( function() {
$('#default-color').wrapInner('<a href="#" />');
farbtastic = $.farbtastic('#colorPickerDiv', pickColor);
- pickColor( $('#text-color').val() );
+ pickColor( $(colorpicker).val() );
$('.pickcolor').click( function(e) {
$('#colorPickerDiv').show();
e.preventDefault();
});
- $('#text-color').keyup( function() {
- var a = $('#text-color').val(),
+ $(colorpicker).keyup( function() {
+ var a = $(colorpicker).val(),
b = a;
a = a.replace(/[^a-fA-F0-9]/, '');
if ( '#' + a !== b )
- $('#text-color').val(a);
+ $(colorpicker).val(a);
if ( a.length === 3 || a.length === 6 )
pickColor( '#' + a );
});
@@ -44,7 +48,7 @@ var farbtastic;
var currentDefault = $('#default-color a'),
newDefault = $(this).next().val();
- if ( $('#text-color').val() == currentDefault.text() )
+ if ( $(colorpicker).val() == currentDefault.text() )
pickColor( newDefault );
currentDefault.text( newDefault );
View
@@ -27,6 +27,9 @@ class Documentation_Options {
/**
* Init
+ *
+ * @since 08/09/2012
+ * @return void
*/
public function __construct( $args = NULL ) {
@@ -50,6 +53,9 @@ public function __construct( $args = NULL ) {
* This call to register_setting() registers a validation callback, validate(),
* which is used when the option is saved, to ensure that our option values are properly
* formatted, and safe.
+ *
+ * @since 08/09/2012
+ * @return void
*/
public function options_init() {
@@ -95,6 +101,7 @@ public function options_init() {
*
* This function is attached to the admin_menu action hook.
*
+ * @since 08/09/2012
* @return void
*/
public function add_page() {
@@ -117,6 +124,7 @@ public function add_page() {
/**
* Properly enqueue styles and scripts for our theme options page.
*
+ * @since 08/09/2012
* @return void
*/
public function admin_enqueue_scripts( $hook_suffix ) {
@@ -181,6 +189,7 @@ public function theme_options_help() {
* Returns the default options.
* Use the hook 'documentation_default_theme_options' for change via plugin
*
+ * @since 08/09/2012
* @return Array
*/
public function get_default_theme_options( $value = NULL ) {
@@ -199,6 +208,7 @@ public function get_default_theme_options( $value = NULL ) {
/**
* Returns the options array.
*
+ * @since 08/09/2012
* @return Array
*/
public function get_theme_options() {
@@ -214,14 +224,16 @@ public function get_theme_options() {
/**
* Renders the enable fonts checkbox setting field.
+ *
+ * @since 08/09/2012
+ * @return void
*/
public function settings_field_enable_fonts() {
$options = $this->options; ?>
- <label for="enable-fonts">
- <input type="text" name="<?php echo $this->option_key; ?>[rewrite_url]" id="rewrite-url" value="<?php echo $options['rewrite_url']; ?>" class="regular-text code" />
- <br /><span class="description"><?php printf( __( 'Edit an URL in Backend for the Administration Link in Frontend. Example: %s', 'documentation' ), '<code>wp-admin/edit.php</code>' ); ?> </span>
- </label>
+ <input type="text" name="<?php echo $this->option_key; ?>[rewrite_url]" id="rewrite-url" value="<?php echo $options['rewrite_url']; ?>" class="regular-text code" />
+ <br />
+ <label class="description" for="rewrite-url"><?php printf( __( 'Edit an URL in Backend for the Administration Link in Frontend. Example: %s', 'documentation' ), '<code>wp-admin/edit.php</code>' ); ?></label>
<?php
}
@@ -235,17 +247,15 @@ public function settings_field_text_color() {
$options = $this->options;
?>
- <label for="text-color">
- <input type="text" name="<?php echo $this->option_key; ?>[text_color]" id="text-color" value="<?php echo $options['text_color']; ?>" />
- <a href="#" class="pickcolor hide-if-no-js" id="text-color-example"></a>
- <input type="button" class="pickcolor button hide-if-no-js" value="<?php esc_attr_e( 'Select a Color', 'documentation' ); ?>" />
- <div id="colorPickerDiv" style="z-index: 100; background:#eee; border:1px solid #ccc; position:absolute; display:none;"></div>
- <br />
- <span class="description"><?php printf(
+ <input type="text" name="<?php echo $this->option_key; ?>[text_color]" id="text-color" value="<?php echo $options['text_color']; ?>" />
+ <a href="#" class="pickcolor hide-if-no-js" id="text-color-example"></a>
+ <input type="button" class="pickcolor button hide-if-no-js" value="<?php esc_attr_e( 'Select a Color', 'documentation' ); ?>" />
+ <div id="colorPickerDiv"></div>
+ <br />
+ <label class="description" for="text-color"><?php printf(
__( 'Fill with an hex code for the text color. Default color: %s', 'documentation' ),
'<code id="default-color">' . $this->get_default_theme_options( 'text_color' ) . '</code>'
- ); ?> </span>
- </label>
+ ); ?></label>
<?php
}

0 comments on commit 64eb0a1

Please sign in to comment.