| 1 |
/** |
| 2 |
* Support Functions - Spin Icon in Buttons ------------------------------------------------------------------ */ |
| 3 |
|
| 4 |
/** |
| 5 |
* Remove spin icon from button and Enable this button. |
| 6 |
* |
| 7 |
* @param button_clicked_element_id - HTML ID attribute of this button |
| 8 |
* @return string - CSS classes that was previously in button icon |
| 9 |
*/ |
| 10 |
function wpbc_button__remove_spin(button_clicked_element_id) { |
| 11 |
|
| 12 |
var previos_classes = ''; |
| 13 |
if ( |
| 14 |
(undefined != button_clicked_element_id) |
| 15 |
&& ('' != button_clicked_element_id) |
| 16 |
) { |
| 17 |
var jElement = jQuery( '#' + button_clicked_element_id ); |
| 18 |
if ( jElement.length ) { |
| 19 |
previos_classes = wpbc_button_disable_loading_icon( jElement.get( 0 ) ); |
| 20 |
} |
| 21 |
} |
| 22 |
|
| 23 |
return previos_classes; |
| 24 |
} |
| 25 |
|
| 26 |
|
| 27 |
/** |
| 28 |
* Show Loading (rotating arrow) icon for button that has been clicked |
| 29 |
* |
| 30 |
* @param this_button - this object of specific button |
| 31 |
* @return string - CSS classes that was previously in button icon |
| 32 |
*/ |
| 33 |
function wpbc_button_enable_loading_icon(this_button) { |
| 34 |
|
| 35 |
var jButton = jQuery( this_button ); |
| 36 |
var jIcon = jButton.find( 'i' ); |
| 37 |
var previos_classes = jIcon.attr( 'class' ); |
| 38 |
|
| 39 |
jIcon.removeClass().addClass( 'menu_icon icon-1x wpbc_icn_rotate_right wpbc_spin' ); // Set Rotate icon. |
| 40 |
// jIcon.addClass( 'wpbc_animation_pause' ); // Pause animation. |
| 41 |
// jIcon.addClass( 'wpbc_ui_red' ); // Set icon color red. |
| 42 |
|
| 43 |
jIcon.attr( 'wpbc_previous_class', previos_classes ) |
| 44 |
|
| 45 |
jButton.addClass( 'disabled' ); // Disable button |
| 46 |
// We need to set here attr instead of prop, because for A elements, attribute 'disabled' do not added with jButton.prop( "disabled", true );. |
| 47 |
|
| 48 |
jButton.attr( 'wpbc_previous_onclick', jButton.attr( 'onclick' ) ); // Save this value. |
| 49 |
jButton.attr( 'onclick', '' ); // Disable actions "on click". |
| 50 |
|
| 51 |
return previos_classes; |
| 52 |
} |
| 53 |
|
| 54 |
|
| 55 |
/** |
| 56 |
* Hide Loading (rotating arrow) icon for button that was clicked and show previous icon and enable button |
| 57 |
* |
| 58 |
* @param this_button - this object of specific button |
| 59 |
* @return string - CSS classes that was previously in button icon |
| 60 |
*/ |
| 61 |
function wpbc_button_disable_loading_icon(this_button) { |
| 62 |
|
| 63 |
var jButton = jQuery( this_button ); |
| 64 |
var jIcon = jButton.find( 'i' ); |
| 65 |
|
| 66 |
var previos_classes = jIcon.attr( 'wpbc_previous_class' ); |
| 67 |
if ( |
| 68 |
(undefined != previos_classes) |
| 69 |
&& ('' != previos_classes) |
| 70 |
) { |
| 71 |
jIcon.removeClass().addClass( previos_classes ); |
| 72 |
} |
| 73 |
|
| 74 |
jButton.removeClass( 'disabled' ); // Remove Disable button. |
| 75 |
|
| 76 |
var previous_onclick = jButton.attr( 'wpbc_previous_onclick' ) |
| 77 |
if ( |
| 78 |
(undefined != previous_onclick) |
| 79 |
&& ('' != previous_onclick) |
| 80 |
) { |
| 81 |
jButton.attr( 'onclick', previous_onclick ); |
| 82 |
} |
| 83 |
|
| 84 |
return previos_classes; |
| 85 |
} |
| 86 |
|