2013-08-07 01:49:02 -04:00
|
|
|
var PubSub,fullscreen,wptitlehint;PubSub=function(){this.topics={}},PubSub.prototype.subscribe=function(a,b){return this.topics[a]||(this.topics[a]=[]),this.topics[a].push(b),b},PubSub.prototype.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},PubSub.prototype.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}},function(a){var b,c,d,e;fullscreen=b={},c=b.pubsub=new PubSub,timer=0,block=!1,e=b.settings={visible:!1,mode:"tinymce",editor_id:"content",title_id:"",timer:0,toolbar_shown:!1},d=b.bounder=function(b,d,f,g){function h(){c.publish(d),e.timer=0}var i,j;f=f||1250,g&&(i=g.pageY||g.clientY||g.offsetY,j=a(document).scrollTop(),g.isDefaultPrevented||(i=135+i),i-j>120)||block||(block=!0,setTimeout(function(){block=!1},400),e.timer?clearTimeout(e.timer):c.publish(b),e.timer=setTimeout(h,f))},b.on=function(){e.visible||("object"==typeof wp_fullscreen_settings&&a.extend(e,wp_fullscreen_settings),e.editor_id=wpActiveEditor||"content",a("input#title").length&&"content"==e.editor_id?e.title_id="title":a("input#"+e.editor_id+"-title").length?e.title_id=e.editor_id+"-title":a("#wp-fullscreen-title, #wp-fullscreen-title-prompt-text").hide(),e.mode=a("#"+e.editor_id).is(":hidden")?"tinymce":"html",e.qt_canvas=a("#"+e.editor_id).get(0),e.element||b.ui.init(),e.is_mce_on=e.has_tinymce&&"undefined"!=typeof tinyMCE.get(e.editor_id),b.ui.fade("show","showing","shown"))},b.off=function(){e.visible&&b.ui.fade("hide","hiding","hidden")},b.switchmode=function(a){var b=e.mode;return a&&e.visible&&e.has_tinymce?b==a?b:(c.publish("switchMode",[b,a]),e.mode=a,c.publish("switchedMode",[b,a]),a):b},b.save=function(){var c=a("#hiddenaction"),d=c.val(),e=a("#wp-fullscreen-save .spinner"),f=a("#wp-fullscreen-save span");e.show(),b.savecontent(),c.val("wp-fullscreen-save-post"),a.post(ajaxurl,a("form#post").serialize(),function(b){e.hide(),f.show(),setTimeout(function(){f.fadeOut(1e3)},3e3),b.last_edited&&a("#wp-fullscreen-save input").attr("title",b.last_edited)},"json"),c.val(d)},b.savecontent=function(){var b,c;e.title_id&&a("#"+e.title_id).val(a("#wp-fullscreen-title").val()),c="tinymce"===e.mode&&(b=tinyMCE.get("wp_mce_fullscreen"))?b.save():a("#wp_mce_fullscreen").val(),a("#"+e.editor_id).val(c),a(document).triggerHandler("wpcountwords",[c])},set_title_hint=function(a){a.val().length?a.siblings("label").css("visibility","hidden"):a.siblings("label").css("visibility","")},b.dfw_width=function(b){var c=a("#wp-fullscreen-wrap"),d=c.width();return b?(d=b+d,200>d||d>1200||(c.width(d),setUserSetting("dfw_width",d)),void 0):(c.width(a("#wp-fullscreen-central-toolbar").width()),deleteUserSetting("dfw_width"),void 0)},c.subscribe("showToolbar",function(){e.toolbars.removeClass("fade-1000").addClass("fade-300"),b.fade.In(e.toolbars,300,function(){c.publish("toolbarShown")},!0),a("#wp-fullscreen-body").addClass("wp-fullscreen-focus"),e.toolbar_shown=!0}),c.subscribe("hideToolbar",function(){e.toolbars.removeClass("fade-300").addClass("fade-1000"),b.fade.Out(e.toolbars,1e3,function(){c.publish("toolbarHidden")},!0),a("#wp-fullscreen-body").removeClass("wp-fullscreen-focus")}),c.subscribe("toolbarShown",function(){e.toolbars.removeClass("fade-300")}),c.subscribe("toolbarHidden",function(){e.toolbars.removeClass("fade-1000"),e.toolbar_shown=!1}),c.subscribe("show",function(){var b;e.title_id&&(b=a("#wp-fullscreen-title").val(a("#"+e.title_id).val()),set_title_hint(b)),a("#wp-fullscreen-save input").attr("title",a("#last-edit").text()),e.textarea_obj.value=e.qt_canvas.value,e.has_tinymce&&"tinymce"===e.mode&&tinyMCE.execCommand("wpFullScreenInit"),e.orig_y=a(window).scrollTop()}),c.subscribe("showing",function(){a(document.body).addClass("fullscreen-active"),b.refresh_buttons(),a(document).bind("mousemove.fullscreen",function(a){d("showToolbar","hideToolbar",2e3,a)}),d("showToolbar","hideToolbar",2e3),b.bind_resize(),setTimeout(b.resize_textarea,200),scrollTo(0,0),a("#w
|