| 1 |
( function ( $ ) { |
| 2 |
/** |
| 3 |
* Function to add the custom Class to the color picker to add a separator. |
| 4 |
* This is used to add the add a heading to display the CartFlows Colors. |
| 5 |
*/ |
| 6 |
const add_color_pallet_separator = function () { |
| 7 |
$( document ).on( |
| 8 |
'click', |
| 9 |
'.block-editor-panel-color-gradient-settings__dropdown, .component-color-indicator', |
| 10 |
function () { |
| 11 |
$( '.components-circular-option-picker__option' ).each( |
| 12 |
function () { |
| 13 |
const color_separator = $( this ); |
| 14 |
let color_separator_wrapper = ''; |
| 15 |
|
| 16 |
if ( |
| 17 |
color_separator.attr( 'aria-label' ) === |
| 18 |
'Color: CartFlows Separator' |
| 19 |
) { |
| 20 |
color_separator_wrapper = color_separator.closest( |
| 21 |
'.components-circular-option-picker__option-wrapper' |
| 22 |
); |
| 23 |
|
| 24 |
if ( |
| 25 |
! color_separator_wrapper.hasClass( |
| 26 |
'wcf-color-pallet-separator' |
| 27 |
) |
| 28 |
) { |
| 29 |
color_separator_wrapper.addClass( |
| 30 |
'wcf-color-pallet-separator' |
| 31 |
); |
| 32 |
color_separator.addClass( |
| 33 |
'wcf-color-pallet-separator--button' |
| 34 |
); |
| 35 |
color_separator.append( |
| 36 |
'<span class="wcf-color-pallet-separator--heading">CartFlows Global Colors</span>' |
| 37 |
); |
| 38 |
} |
| 39 |
} |
| 40 |
} |
| 41 |
); |
| 42 |
} |
| 43 |
); |
| 44 |
}; |
| 45 |
|
| 46 |
$( function () { |
| 47 |
add_color_pallet_separator(); |
| 48 |
} ); |
| 49 |
} )( jQuery ); |
| 50 |
|