|
| 1 | +advanced_cron_manager.notify = function( notification, icon ) { |
| 2 | + |
| 3 | + if ( typeof icon == 'undefined' ) { |
| 4 | + icon = ''; |
| 5 | + } else { |
| 6 | + icon = '<span class="dashicons dashicons-' + icon + '"></span>'; |
| 7 | + } |
| 8 | + |
| 9 | + Materialize.toast( icon + notification, 4000 ); |
| 10 | + |
| 11 | +}; |
| 12 | + |
| 13 | +advanced_cron_manager.ajax_messages = function( response ) { |
| 14 | + |
| 15 | + if ( response.success == true ) { |
| 16 | + advanced_cron_manager.notify( response.data, 'yes' ); |
| 17 | + } else { |
| 18 | + jQuery.each( response.data, function( number, error ) { |
| 19 | + advanced_cron_manager.notify( error, 'warning' ); |
| 20 | + } ); |
| 21 | + } |
| 22 | + |
| 23 | +}; |
| 24 | + |
| 25 | +function ACM_Slidebar() { |
| 26 | + this.container = jQuery( '.slidebar' ); |
| 27 | + this.overlay = jQuery( '.slidebar-overlay' ); |
| 28 | + this.close_button = jQuery( '.slidebar .close' ); |
| 29 | + |
| 30 | + this.close_button.click( { slidebar: this }, function( event ) { |
| 31 | + event.data.slidebar.close(); |
| 32 | + } ); |
| 33 | + |
| 34 | + this.overlay.click( { slidebar: this }, function( event ) { |
| 35 | + event.data.slidebar.close(); |
| 36 | + } ); |
| 37 | + |
| 38 | + this.open = function() { |
| 39 | + |
| 40 | + this.container.animate( { |
| 41 | + 'margin-right': 0 |
| 42 | + }, 400, 'easeInOutSine' ); |
| 43 | + |
| 44 | + this.overlay.fadeIn( 400 ); |
| 45 | + |
| 46 | + }; |
| 47 | + |
| 48 | + this.close = function() { |
| 49 | + |
| 50 | + var $form = this.container.find( '.content .form' ); |
| 51 | + |
| 52 | + this.container.animate( { |
| 53 | + 'margin-right': '-' + ( this.container.outerWidth() + 5 ) |
| 54 | + }, 400, 'easeInOutSine', function () { |
| 55 | + $form.html( '' ); |
| 56 | + } ); |
| 57 | + |
| 58 | + this.overlay.fadeOut( 400 ); |
| 59 | + |
| 60 | + }; |
| 61 | + |
| 62 | + this.wait = function() { |
| 63 | + this.container.find( '.content' ).addClass( 'loading' ); |
| 64 | + }; |
| 65 | + |
| 66 | + this.fulfill = function( html ) { |
| 67 | + this.container.find( '.content .form' ).html( html ); |
| 68 | + this.container.find( '.content' ).removeClass( 'loading' ); |
| 69 | + }; |
| 70 | + |
| 71 | + this.form_process_start = function( html ) { |
| 72 | + this.container.find( '.content .send-form' ).attr( 'disabled', true ); |
| 73 | + this.container.find( '.content .spinner' ).css( 'visibility', 'visible' ); |
| 74 | + }; |
| 75 | + |
| 76 | + this.form_process_stop = function( html ) { |
| 77 | + this.container.find( '.content .send-form' ).attr( 'disabled', false ); |
| 78 | + this.container.find( '.content .spinner' ).css( 'visibility', 'hidden' ); |
| 79 | + }; |
| 80 | + |
| 81 | +}; |
| 82 | + |
| 83 | +advanced_cron_manager.slidebar = new ACM_Slidebar; |
0 commit comments