/*
Copyright 2012, KISSY UI Library v1.30rc
MIT Licensed
build time: Jul 11 21:28
*/
KISSY.add("editor/plugin/maximize/cmd",function(d,k){function i(a){this.editor=a}var e=d.UA,l=e.ie,f=document,n=d.Node,g=d.Event,h=d.DOM,j;d.augment(i,{restoreWindow:function(){var a=this,b=a.editor;!1!==b.fire("beforeRestoreWindow")&&a._resize&&(g.remove(window,"resize",a._resize),a._resize=0,a._saveEditorStatus(),a._restoreState(),setTimeout(function(){a._restoreEditorStatus();b.notifySelectionChange();b.fire("afterRestoreWindow")},30))},_restoreState:function(){var a=this.editor,b=a.get("textarea"),
c=this._savedParents;if(c){for(var m=0;m<c.length;m++){var d=c[m];d.el.css("position",d.position)}this._savedParents=null}b.parent().css({height:this.iframeHeight});b.css({height:this.iframeHeight});h.css(f.body,{width:"",height:"",overflow:""});f.documentElement.style.overflow="";a=a.get("el")[0].style;a.position="static";a.width=this.editorElWidth;j.css({left:"-99999px",top:"-99999px"});window.scrollTo(this.scrollLeft,this.scrollTop);8>l&&this.editor.get("toolBarEl").removeClass("ks-editor-toolbar-padding",
void 0)},_saveSate:function(){var a=this.editor,b=[],c=a.get("el");this.iframeHeight=a.get("textarea").parent().style("height");this.editorElWidth=c.style("width");this.scrollLeft=h.scrollLeft();this.scrollTop=h.scrollTop();window.scrollTo(0,0);for(a=c.parent();a;)c=a.css("position"),"static"!=c&&(b.push({el:a,position:c}),a.css("position","static")),a=a.parent();this._savedParents=b;8>l&&this.editor.get("toolBarEl").addClass("ks-editor-toolbar-padding",void 0)},_saveEditorStatus:function(){var a=
this.editor;this.savedRanges=null;e.gecko&&a.__iframeFocus&&(this.savedRanges=(a=a.getSelection())&&a.getRanges())},_restoreEditorStatus:function(){var a=this.editor,b=a.getSelection(),c=this.savedRanges;e.gecko&&a.activateGecko();c&&b&&b.selectRanges(c);a.__iframeFocus&&b&&(a=b.getStartElement())&&a.scrollIntoView(void 0,!1)},_maximize:function(a){var b=this.editor,c=b.get("el"),d=h.viewportHeight(),e=h.viewportWidth(),g=b.get("textarea"),i=b.get("statusBarEl")?b.get("statusBarEl")[0].offsetHeight:
0,b=b.get("toolBarEl")[0].offsetHeight;l?f.body.style.overflow="hidden":h.css(f.body,{width:0,height:0,overflow:"hidden"});f.documentElement.style.overflow="hidden";c.css({position:"absolute",zIndex:k.baseZIndex(k.zIndexManager.MAXIMIZE),width:e+"px"});j.css({zIndex:k.baseZIndex(k.zIndexManager.MAXIMIZE-5),height:d+"px",width:e+"px"});c.offset({left:0,top:0});j.css({left:0,top:0});g.parent().css({height:d-i-b+"px"});g.css({height:d-i-b+"px"});!0!==a&&arguments.callee.call(this,!0)},_real:function(){var a=
this,b=a.editor;a._resize||(a._saveEditorStatus(),a._saveSate(),a._maximize(),a._resize||(a._resize=d.buffer(function(){a._maximize();b.fire("afterMaximizeWindow")},100)),g.on(window,"resize",a._resize),setTimeout(function(){a._restoreEditorStatus();b.notifySelectionChange();b.fire("afterMaximizeWindow")},30))},maximizeWindow:function(){!1!==this.editor.fire("beforeMaximizeWindow")&&(j||(j=(new n("<iframe  class='ks-editor-maximize-shim' style='position:absolute;top:-9999px;left:-9999px;' frameborder='0'>")).prependTo(f.body,
void 0)),this._real())},destroy:function(){this._resize&&(g.remove(window,"resize",this._resize),this._resize=0)}});return{init:function(a){if(!a.hasCommand("maximizeWindow")){var b=new i(a);a.addCommand("maximizeWindow",{exec:function(){b.maximizeWindow()}});a.addCommand("restoreWindow",{exec:function(){b.restoreWindow()}})}}}},{requires:["editor"]});
