| 1 |
/** |
| 2 |
* EVENTS |
| 3 |
*/ |
| 4 |
jQuery( document ).ready( function ($) { |
| 5 |
|
| 6 |
jQuery( document ).on( 'click', '.stateless-admin-notice.ud-admin-notice .button-action', function(e){ |
| 7 |
var _this = jQuery( this ); |
| 8 |
if(_this.attr('href') != '#'){ |
| 9 |
return; |
| 10 |
} |
| 11 |
|
| 12 |
e.preventDefault(); |
| 13 |
|
| 14 |
|
| 15 |
var data = { |
| 16 |
action: 'stateless_enable_notice_button_action', |
| 17 |
key: _this.data('key'), |
| 18 |
} |
| 19 |
|
| 20 |
jQuery.post( ajaxurl, data, function ( result_data ) { |
| 21 |
if( result_data.success == '1' ) { |
| 22 |
_this.closest('.ud-admin-notice').remove(); |
| 23 |
|
| 24 |
var key = _this.attr('data-key'); |
| 25 |
key = key.replace('button_secondary_', ''); |
| 26 |
$("#" + key + " option[value=" + key +"]").attr('selected', 'selected'); |
| 27 |
$("#" + key).val('true'); |
| 28 |
} else if ( result_data.success == '0' ) { |
| 29 |
// alert(result_data.error); |
| 30 |
} |
| 31 |
}, "json" ); |
| 32 |
return false; |
| 33 |
}); |
| 34 |
|
| 35 |
jQuery( '.stateless-admin-notice.ud-admin-notice' ).off( 'click', '.dismiss'); |
| 36 |
jQuery( document ).on( 'click', '.stateless-admin-notice.ud-admin-notice .dismiss-warning', function(e){ |
| 37 |
e.preventDefault(); |
| 38 |
|
| 39 |
var _this = jQuery( this ); |
| 40 |
|
| 41 |
var data = { |
| 42 |
action: 'stateless_notice_dismiss', |
| 43 |
key: _this.data('key'), |
| 44 |
} |
| 45 |
|
| 46 |
jQuery.post( ajaxurl, data, function ( result_data ) { |
| 47 |
if( result_data.success == '1' ) { |
| 48 |
_this.closest('.ud-admin-notice').remove(); |
| 49 |
} else if ( result_data.success == '0' ) { |
| 50 |
// alert(result_data.error); |
| 51 |
} |
| 52 |
}, "json" ); |
| 53 |
return false; |
| 54 |
}); |
| 55 |
|
| 56 |
jQuery('#stless_settings_tab .sm-mode input[type=radio]').on('change', function(){ |
| 57 |
|
| 58 |
if($(this).val() == 'stateless' || $(this).val() == 'ephemeral'){ |
| 59 |
var notice = jQuery('#stateless-notice-stateless-cache-busting'); |
| 60 |
if(!notice.length){ |
| 61 |
notice = jQuery(jQuery('#template-stateless-cache-busting').html()); |
| 62 |
notice.appendTo("#stateless-settings-page-title"); |
| 63 |
} |
| 64 |
jQuery('#stateless-notice-stateless-cache-busting').show(); |
| 65 |
} |
| 66 |
else{ |
| 67 |
jQuery('#stateless-notice-stateless-cache-busting').hide(); |
| 68 |
} |
| 69 |
|
| 70 |
}); |
| 71 |
|
| 72 |
} ); |