| 1 |
/** |
| 2 |
* Inline notification functionality. |
| 3 |
* |
| 4 |
* @package WPZincDashboardWidget |
| 5 |
* @author WP Zinc |
| 6 |
*/ |
| 7 |
|
| 8 |
/** |
| 9 |
* Show a success message. |
| 10 |
* |
| 11 |
* @since 1.0.0 |
| 12 |
* |
| 13 |
* @param string message Success Message to display. |
| 14 |
*/ |
| 15 |
function wpzinc_notification_show_success_message( message ) { |
| 16 |
|
| 17 |
wpzinc_notification_show( message, 'success' ); |
| 18 |
|
| 19 |
} |
| 20 |
|
| 21 |
/** |
| 22 |
* Show a warning message. |
| 23 |
* |
| 24 |
* @since 1.0.0 |
| 25 |
* |
| 26 |
* @param string message Warning Message to display. |
| 27 |
*/ |
| 28 |
function wpzinc_notification_show_warning_message( message ) { |
| 29 |
|
| 30 |
wpzinc_notification_show( message, 'warning' ); |
| 31 |
|
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* Show an error message. |
| 36 |
* |
| 37 |
* @since 1.0.0 |
| 38 |
* |
| 39 |
* @param string message Error Message to display. |
| 40 |
*/ |
| 41 |
function wpzinc_notification_show_error_message( message ) { |
| 42 |
|
| 43 |
wpzinc_notification_show( message, 'error' ); |
| 44 |
|
| 45 |
} |
| 46 |
|
| 47 |
/** |
| 48 |
* Show a message. |
| 49 |
* |
| 50 |
* @since 1.0.0 |
| 51 |
* |
| 52 |
* @param string message Message to display. |
| 53 |
* @param string type Message Type (success,warning,error) |
| 54 |
*/ |
| 55 |
function wpzinc_notification_show( message, type ) { |
| 56 |
|
| 57 |
jQuery( '.wpzinc-notification' ).text( message ); |
| 58 |
jQuery( '.wpzinc-notification' ).addClass( 'wpzinc-notification-' + type ); |
| 59 |
jQuery( '.wpzinc-notification' ).fadeIn( 'fast' ); |
| 60 |
|
| 61 |
setTimeout( |
| 62 |
function () { |
| 63 |
jQuery( '.wpzinc-notification' ).fadeOut( |
| 64 |
'fast', |
| 65 |
function () { |
| 66 |
jQuery( '.wpzinc-notification' ).removeClass( 'wpzinc-notification-' + type ); |
| 67 |
jQuery( '.wpzinc-notification' ).hide(); |
| 68 |
} |
| 69 |
); |
| 70 |
}, |
| 71 |
2000 |
| 72 |
); |
| 73 |
|
| 74 |
} |
| 75 |
|