_comment.php
2 years ago
_db.php
2 years ago
_hidden.php
2 years ago
_label.php
2 years ago
_row.php
2 years ago
attachment.php
2 years ago
checkbox.php
2 years ago
cleditor.php
2 years ago
codemirror.php
2 years ago
color.php
2 years ago
currency.php
2 years ago
date.php
2 years ago
datetime.php
2 years ago
email.php
2 years ago
link.php
2 years ago
number.php
2 years ago
oembed.php
2 years ago
password.php
2 years ago
phone.php
2 years ago
radio.php
2 years ago
select.php
2 years ago
slider.php
2 years ago
slug.php
2 years ago
text.php
2 years ago
textarea.php
2 years ago
time.php
2 years ago
tinymce.php
2 years ago
website.php
2 years ago
color.php
56 lines
| 1 | <?php |
| 2 | // Don't load directly. |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | die( '-1' ); |
| 5 | } |
| 6 | |
| 7 | wp_enqueue_style( 'wp-color-picker' ); |
| 8 | |
| 9 | if ( ! is_admin() ) { |
| 10 | wp_enqueue_script( |
| 11 | 'iris', admin_url( 'js/iris.min.js' ), array( |
| 12 | 'jquery-ui-draggable', |
| 13 | 'jquery-ui-slider', |
| 14 | 'jquery-touch-punch', |
| 15 | ) |
| 16 | ); |
| 17 | wp_enqueue_script( 'wp-color-picker', admin_url( 'js/color-picker.min.js' ), array( 'iris' ), '3.5', true ); |
| 18 | $colorpicker_l10n = array( |
| 19 | 'clear' => __( 'Clear' ), |
| 20 | 'defaultString' => __( 'Default' ), |
| 21 | 'pick' => __( 'Select Color' ), |
| 22 | 'current' => __( 'Current Color' ), |
| 23 | ); |
| 24 | wp_localize_script( 'wp-color-picker', 'wpColorPickerL10n', $colorpicker_l10n ); |
| 25 | } else { |
| 26 | wp_enqueue_script( 'wp-color-picker' ); |
| 27 | } |
| 28 | |
| 29 | $attributes = array(); |
| 30 | $attributes['type'] = 'text'; |
| 31 | $attributes['value'] = $value; |
| 32 | $attributes['tabindex'] = 2; |
| 33 | $attributes = PodsForm::merge_attributes( $attributes, $name, $form_field_type, $options ); |
| 34 | ?> |
| 35 | <input<?php PodsForm::attributes( $attributes, $name, $form_field_type, $options ); ?> /> |
| 36 | |
| 37 | <script type="text/javascript"> |
| 38 | jQuery( function () { |
| 39 | jQuery( '#color_<?php echo esc_js( $attributes['id'] ); ?>' ).hide(); |
| 40 | |
| 41 | var pods_wp_color_obj_<?php echo esc_js( pods_js_name( $attributes['id'] ) ); ?> = jQuery( '#<?php echo esc_js( $attributes['id'] ); ?>' ).wpColorPicker(); |
| 42 | |
| 43 | pods_wp_color_obj_<?php echo esc_js( pods_js_name( $attributes['id'] ) ); ?>.parents( '.wp-picker-container' ).find( '.iris-slider-offset' ).removeClass( 'ui-widget-content ui-slider-vertical' ); |
| 44 | |
| 45 | jQuery( '#<?php echo esc_js( $attributes['id'] ); ?>' ).on( 'focus blur', function () { |
| 46 | jQuery( '#color_<?php echo esc_js( $attributes['id'] ); ?>' ).slideToggle(); |
| 47 | } ); |
| 48 | |
| 49 | jQuery( '#<?php echo esc_js( $attributes['id'] ); ?>' ).on( 'keyup', function () { |
| 50 | var color = jQuery( this ).val(); |
| 51 | |
| 52 | if ( '' != color.replace( '#', '' ) && color.match( '#' ) )pods_wp_color_obj_<?php echo esc_js( pods_js_name( $attributes['id'] ) ); ?>.wpColorPicker( 'color', color ); |
| 53 | } ); |
| 54 | } ); |
| 55 | </script> |
| 56 |