pc1
(pc)
February 24, 2016, 4:51am
1
Hi,
I am trying to integrate a custom field in my custom module plugin. I am using this colorpicker.
My code looks like this -
add_action('fl_builder_control_uabb-color', 'fl_uabb_color', 1, 4);
add_action( 'wp_enqueue_scripts', 'fl_uabb_color_assets', 100 );
/**
* Custom fields
*/
function fl_uabb_color($name, $value, $field, $settings) {
echo '<input type="text" class="cs-wp-color-picker" />';
}
/**
* Custom field styles and scripts
*/
function fl_uabb_color_assets() {
if ( class_exists( 'FLBuilderModel' ) && FLBuilderModel::is_builder_active() ) {
wp_enqueue_style( 'wp-color-picker' );
wp_enqueue_style( 'cs-wp-color-picker', BB_ULTIMATE_ADDON_URL . 'fields/color-picker/css/cs-wp-color-picker.min.css', array( 'wp-color-picker' ), '1.0.0', 'all' );
wp_enqueue_script(
'iris',
admin_url( 'js/iris.min.js' ),
array( 'jquery-ui-draggable', 'jquery-ui-slider', 'jquery-touch-punch' ),
false,
1
);
wp_enqueue_script(
'wp-color-picker-new',
admin_url( 'js/color-picker.min.js' ),
array( 'iris' ),
false,
1
);
wp_enqueue_script( 'cs-wp-color-picker', BB_ULTIMATE_ADDON_URL . 'fields/color-picker/js/cs-wp-color-picker.min.js', array( 'wp-color-picker-new' ), '1.0.0', true );
$colorpicker_l10n = array(
'clear' => __( 'Clear' ),
'defaultString' => __( 'Default' ),
'pick' => __( 'Select Color' ),
'current' => __( 'Current Color' ),
);
wp_localize_script( 'wp-color-picker-new', 'wpColorPickerL10n', $colorpicker_l10n );
}
}
But this has modified the existing color picker in such a away - http://goo.gl/s33T8A
The color gradient vanishes. Please help me to debug the exact conflict. Also tell the ways to integrate this color picker into my plugin.
bencarlo
(Ben Carlo)
February 24, 2016, 8:33am
2
Hey Nik,
I’ve moved your thread to the Custom Module section. Also, I’ve already assigned another member of our team to assist you with your concern.
Ben
justin
(Justin Busa)
February 24, 2016, 9:25am
3
Hey Nik,
Our picker is built on Iris as well, so it looks like there is a conflict there somewhere. I’ll have to do some digging, so I’ve filed an issue to get this fixed.
Thanks!
Justin
pc1
(pc)
March 29, 2016, 5:29am
4
Hi Justin,
Is there any update on the conflict which I mentioned above? All I needed was a RGBA option using this color picker. Can you please guide me with it?
justin
(Justin Busa)
March 29, 2016, 10:17am
5
Hey PC,
That conflict will be resolved in the 1.7.6 update going out today. Give that a shot and let me know how it goes.
Justin
pc1
(pc)
March 31, 2016, 4:43am
6
Hi Justin,
It seems the conflict is resolved. I have also integrated custom color picker. Seems it works fine. But I need your help with preview section. How do I make it live preview like other fields? How does preview work for custom fields? Also if I do not pass the preview array to the field, it should work with AJAX call, like in other fields. But doesn’t work so. Guide me with it too!
justin
(Justin Busa)
March 31, 2016, 9:18am
7
Hi pc,
I don’t think that’s currently possible, but if you send me a copy of your module to test, I can find a solution for you.
Thanks,
Justin
pc1
(pc)
April 4, 2016, 4:01am
9
Hi Justin,
Hope your weekend was good! Any update with the custom color picker?
justin
(Justin Busa)
April 4, 2016, 9:18am
10
Hi pc,
I did, thanks! I’m a bit behind on support but will be having a look at this today.
Justin
justin
(Justin Busa)
April 4, 2016, 10:07am
11
Hi pc,
There might be a better preview API we can implement in the future, but for now, this should work for you…
$( 'body' ).delegate( '.cs-wp-color-picker', 'change', function( e ){
var input = $( this ),
preview = input.closest( '.fl-field' ).data( 'preview' ),
i = null;
if ( 'css' == preview.type ) {
if ( 'undefined' != typeof preview.rules ) {
for ( i in preview.rules ) {
FLBuilder.preview._previewCSS( preview.rules[ i ], e );
}
}
else {
FLBuilder.preview._previewCSS( preview, e );
}
}
} );
Let me know if you have any questions about that.
Justin
pc1
(pc)
April 4, 2016, 11:44pm
12
Hi Justin,
Thanks you very much for your help! Finally, we are able to resolve color picker issue & its working perfect now.
RGBA Color Picker - http://bsf.io/p8vws
Regards,
Pratik