(function(d){var b=false;var c=function(){};var e=null;var a=null;tinymce.ScriptLoader.add(tinymce.PluginManager.urls.mt_fullscreen+"/langs/plugin.js");tinymce.create("tinymce.plugins.MTFullScreenPlugin",{init:function(l,g){var k=this;k.buttonIDs={};tinymce.DOM.loadCSS(g+"/css/mt_fullscreen.css");var h,o,j,f,m,i;function n(p){d.each(i,function(q,r){if(tinyMCE.editors[r]){p.apply(tinyMCE.editors[r],[])}})}l.addCommand("mtFullScreenUpdateFitToWindow",function(){if(!b){return}var p=new Date();if(a&&p-a<150){return}a=p;var q=f.height();c=function(){var r=j.find("table:visible");var u=j.find(".mceIframeContainer:visible");var s=r.width()-u.width();var t=r.height()-u.height()+q;n(function(){this.theme.resizeTo(h.width()-s,h.height()-t,false,true)})}});l.addCommand("mtFullScreenFitToWindow",function(){if(c){c()}});l.addCommand("mtFullScreenIsEnabled",function(){return b?"enabled":""});l.addCommand("mtFullScreen",function(){if(!b){e=l.execCommand("mtGetEditorSize");j.addClass("fullscreen_editor").css({width:"100%",margin:"0",padding:"0"});d("body").addClass("fullscreen_editor_screen");n(function(){d("#"+this.id+"_resize").hide()});b=true;l.execCommand("mtFullScreenUpdateFitToWindow");c();h.bind("resize.mt_fullscreen",c)}else{l.execCommand("mtRestoreEditorSize",e);j.removeClass("fullscreen_editor").css({width:"",margin:"",padding:""});d("body").removeClass("fullscreen_editor_screen");n(function(){d("#"+this.id+"_resize").show()});b=false;c=function(){};h.unbind("resize.mt_fullscreen")}n(function(){this.nodeChanged()})});l.addMTButton("mt_fullscreen",{title:"mt.fullscreen",cmd:"mtFullScreen"});l.onInit.add(function(p){h=d(window);o=d(p.getContainer());j=o.closest("#text-field");f=j.find(".editor-header");m=f.find(".tab");if(f.length==0||m.length==0){j=o.closest(".field-content")}c=function(){};i=j.find("textarea").map(function(){return this.id})});l.onNodeChange.add(function(q,p){d.each(k.buttonIDs.mt_fullscreen||[],function(){p.setActive(this,b)})})},createControl:function(g,f){var h=f.editor;if(g=="mt_fullscreen"){var i=h.buttons[g];if(!this.buttonIDs[g]){this.buttonIDs[g]=[]}var j=g+"_"+this.buttonIDs[g].length;this.buttonIDs[g].push(j);return f.createButton(j,d.extend({},i,{"class":"mce_"+g}))}return null},getInfo:function(){return{longname:"MTFullscreen",author:"Six Apart, Ltd",authorurl:"",infourl:"",version:"1.0"}}});tinymce.PluginManager.add("mt_fullscreen",tinymce.plugins.MTFullScreenPlugin,["mt"])})(jQuery);