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