WordPress/wp-admin/js/wp-fullscreen.min.js

1 line
8.5 KiB
JavaScript
Raw Normal View History

!function(a,b){function c(){m.removeClass("wp-dfw-show-ui")}function d(b){g.$dfwWrap.parents().each(function(c,d){var e,f=a(d);return b?(d.style.position&&f.data("wp-dfw-css-position",d.style.position),f.css("position","static")):(e=f.data("wp-dfw-css-position"),e=e||"",f.css("position",e)),"BODY"===d.nodeName?!1:void 0})}var e,f,g,h,i,j,k=0,l="transitionend webkitTransitionEnd",m=a(document.body),n=a(document);j=function(){this.topics={},this.subscribe=function(a,b){return this.topics[a]||(this.topics[a]=[]),this.topics[a].push(b),b},this.unsubscribe=function(a,b){var c,d,e=this.topics[a];if(!e)return b||[];if(b){for(c=0,d=e.length;d>c;c++)b==e[c]&&e.splice(c,1);return b}return this.topics[a]=[],e},this.publish=function(a,b){var c,d,e,f=this.topics[a];if(f){for(b=b||[],c=0,d=f.length;d>c;c++)e=f[c].apply(null,b)===!1||e;return!e}}},e={},f=e.pubsub=new j,g=e.settings={visible:!1,mode:"tinymce",id:"",title_id:"",timer:0,toolbar_shown:!1},h=e.toggleUI=function(a){clearTimeout(i),m.hasClass("wp-dfw-show-ui")&&"show"!==a?"autohide"!==a&&m.removeClass("wp-dfw-show-ui"):m.addClass("wp-dfw-show-ui"),"autohide"===a&&(i=setTimeout(c,2e3))},e.on=function(){var c,d,f;if(!g.visible){if(g.$fullscreenFader||e.ui.init(),"object"==typeof b.wp_fullscreen_settings&&a.extend(g,b.wp_fullscreen_settings),c=g.id||b.wpActiveEditor,!c){if(!g.hasTinymce)return;c=tinymce.activeEditor.id}g.id=c,d=g.$dfwWrap=a("#wp-"+c+"-wrap"),d.length&&(g.$dfwTextarea=a("#"+c),g.$editorContainer=d.find(".wp-editor-container"),k=n.scrollTop(),g.hasTinymce&&(g.editor=tinymce.get(c)),g.editor&&!g.editor.isHidden()?(g.origHeight=a("#"+c+"_ifr").height(),g.mode="tinymce"):(g.origHeight=g.$dfwTextarea.height(),g.mode="html"),f="undefined"==typeof b.adminpage||"post-php"!==b.adminpage&&"post-new-php"!==b.adminpage?c+"-title":"title",g.$dfwTitle=a("#"+f),g.$dfwTitle.length||(g.$dfwTitle=null),e.ui.fade("show","showing","shown"))}},e.off=function(){g.visible&&e.ui.fade("hide","hiding","hidden")},e.switchmode=function(a){var b=g.mode;return a&&g.visible&&g.hasTinymce&&"undefined"!=typeof switchEditors?b==a?b:("tinymce"!==a||g.editor||(g.editor=tinymce.get(g.id),!g.editor&&"undefined"!=typeof tinyMCEPreInit&&tinyMCEPreInit.mceInit&&tinyMCEPreInit.mceInit[g.id]&&(tinyMCEPreInit.mceInit[g.id].wp_fullscreen=!0)),g.mode=a,switchEditors.go(g.id,a),e.refreshButtons(!0),"html"===a&&setTimeout(e.resizeTextarea,200),a):b},e.save=function(){var c=a("#hiddenaction"),d=c.val(),e=a("#wp-fullscreen-save .spinner"),f=a("#wp-fullscreen-save .wp-fullscreen-saved-message"),h=a("#wp-fullscreen-save .wp-fullscreen-error-message");e.addClass("is-active"),h.hide(),f.hide(),c.val("wp-fullscreen-save-post"),g.editor&&!g.editor.isHidden()&&g.editor.save(),a.ajax({url:b.ajaxurl,type:"post",data:a("form#post").serialize(),dataType:"json"}).done(function(b){e.removeClass("is-active"),b&&b.success?(f.show(),setTimeout(function(){f.fadeOut(300)},3e3),b.data&&b.data.last_edited&&a("#wp-fullscreen-save input").attr("title",b.data.last_edited)):h.show()}).fail(function(){e.removeClass("is-active"),h.show()}),c.val(d)},e.dfwWidth=function(b,c){var d;return b&&-1!==b.toString().indexOf("%")?(g.$editorContainer.css("width",b),g.$statusbar.css("width",b),void(g.$dfwTitle&&g.$dfwTitle.css("width",b))):b?(c?d=b:(d=g.$editorContainer.width(),d+=b),void(200>d||d>1200||(g.$editorContainer.width(d),g.$statusbar.width(d),g.$dfwTitle&&g.$dfwTitle.width(d-16),setUserSetting("dfw_width",d)))):(d=a("#wp-fullscreen-body").data("theme-width")||800,g.$editorContainer.width(d),g.$statusbar.width(d),g.$dfwTitle&&g.$dfwTitle.width(d-16),void deleteUserSetting("dfw_width"))},f.subscribe("show",function(){var b=a("#last-edit").text();b&&a("#wp-fullscreen-save input").attr("title",b)}),f.subscribe("showing",function(){m.addClass("wp-fullscreen-active"),g.$dfwWrap.addClass("wp-fullscreen-wrap"),g.$dfwTitle&&(g.$dfwTitle.after('<span id="wp-fullscreen-title-placeholder">'),g.$dfwWrap.prepend(g.$dfwTitle.addClass("wp-fullscreen-title"))),e.refreshButtons(),d(!0),a("#wpadminbar").hide(),h("autohide"),e.bind_resize(),g.editor&&g.edit