1
|
!function(e,t,i){var n={initialize:function(){var t=this;t.checkbox=e("#public-post-preview"),t.link=e("#public-post-preview-link"),t.linkInput=t.link.find("input"),t.nonce=e("#public_post_preview_wpnonce"),t.status=e("#public-post-preview-ajax"),t.status.css("opacity",0),t.checkbox.bind("change",(function(){t.change()})),t.linkInput.on("focus",(function(){e(this).select()}))},change:function(){var t=this,n=t.checkbox.prop("checked")?"true":"false";t.checkbox.prop("disabled","disabled"),t.request({_ajax_nonce:t.nonce.val(),checked:n,post_ID:e("#post_ID").val()},(function(e){e.success&&("true"===n?(t.status.text(i.enabled),t._pulsate(t.status,"green")):(t.status.text(i.disabled),t._pulsate(t.status,"red")),e.data&&e.data.preview_url?t.linkInput.val(e.data.preview_url):t.linkInput.val(""),t.link.toggle()),t.checkbox.prop("disabled","")}))},request:function(i,n){e.ajax({type:"POST",url:t,data:e.extend(i,{action:"public-post-preview"}),success:n})},_pulsate:function(e,t){e.css("color",t).animate({opacity:1},600,"linear").animate({opacity:0},600,"linear",(function(){e.empty()}))}};e(n.initialize())}(window.jQuery,window.ajaxurl,window.DSPublicPostPreviewL10n);
|