frame-min.js revision 91085c33d52b89808c10ff61e5a94d7b35d57d65
YUI.add("frame",function(B){var A=function(){A.superclass.constructor.apply(this,arguments);};B.extend(A,B.Base,{_ready:null,_rendered:null,_iframe:null,_instance:null,_create:function(C){var I,H,E,G;this._iframe=B.Node.create(A.HTML);this._iframe.setStyle("visibility","hidden");this._iframe.set("src",this.get("src"));this.get("container").append(this._iframe);var D="",F=((this.get("extracss"))?'<style id="extra_css">'+this.get("extracss")+"</style>":"");D=B.substitute(A.PAGE_HTML,{DIR:this.get("dir"),LANG:this.get("lang"),TITLE:this.get("title"),META:A.META,CONTENT:this.get("content"),BASE_HREF:this.get("basehref"),DEFAULT_CSS:A.DEFAULT_CSS,EXTRA_CSS:F});if(B.config.doc.compatMode!="BackCompat"){D=A.DOC_TYPE+"\n"+D;}else{}E=this._resolveWinDoc();E.doc.open();E.doc.write(D);E.doc.close();if(this.get("designMode")){E.doc.designMode="on";}if(!E.doc.documentElement){var J=B.later(1,this,function(){if(E.doc&&E.doc.documentElement){C(E);J.cancel();}},null,true);}else{C(E);}},_resolveWinDoc:function(D){var C=(D)?D:{};C.win=B.Node.getDOMNode(this._iframe.get("contentWindow"));C.doc=B.Node.getDOMNode(this._iframe.get("contentWindow.document"));if(!C.doc){C.doc=B.config.doc;}if(!C.win){C.win=B.config.win;}return C;},_onDomEvent:function(E){var D,C=this._instance.one("win");E.frameX=E.frameY=0;if(E.pageX>0||E.pageY>0){D=this._iframe.getXY();E.frameX=D[0]+E.pageX-C.get("scrollLeft");E.frameY=D[1]+E.pageY-C.get("scrollTop");}E.frameTarget=E.target;E.frameCurrentTarget=E.currentTarget;E.frameEvent=E;this.fire("dom:"+E.type,E);},initializer:function(){this.publish("ready",{emitFacade:true,defaultFn:this._defReadyFn});},destructor:function(){var C=this.getInstance();C.one("doc").detachAll();C=null;this._iframe.remove();},_DOMPaste:function(F){var D=this.getInstance(),C="",E=D.config.win;if(F._event.originalTarget){C=F._event.originalTarget;}if(F._event.clipboardData){C=F._event.clipboardData.getData("Text");}if(E.clipboardData){C=E.clipboardData.getData("Text");if(C==""){if(!E.clipboardData.setData("Text",C)){C=null;}}}F.frameTarget=F.target;F.frameCurrentTarget=F.currentTarget;F.frameEvent=F;if(C){F.clipboardData={data:C,getData:function(){return C;}};}else{F.clipboardData=null;}this.fire("dom:paste",F);},_defReadyFn:function(){var D=this.getInstance(),C=B.bind(this._onDomEvent,this);D.Node.DOM_EVENTS.paste=1;B.each(A.DOM_EVENTS,function(F,E){if(F===1){if(E!=="focus"&&E!=="blur"&&E!=="paste"){D.on(E,C,D.config.doc);}}});D.on("paste",B.bind(this._DOMPaste,this),D.one("body"));D.on("focus",C,D.config.win);D.on("blur",C,D.config.win);D._use=D.use;D.use=B.bind(this.use,this);this._iframe.setStyles({visibility:"inherit"});D.one("body").setStyle("display","block");},_onContentReady:function(E){if(!this._ready){this._ready=true;var D=this.getInstance(),C=B.clone(this.get("use"));this.fire("contentready");if(E){D.config.doc=B.Node.getDOMNode(E.target);}C.push(B.bind(function(){this.fire("ready");},this));D.use.apply(D,C);D.one("doc").get("documentElement").addClass("yui-js-enabled");}},_resolveBaseHref:function(C){if(!C||C===""){C=B.config.doc.location.href;if(C.indexOf("?")!==-1){C=C.substring(0,C.indexOf("?"));}C=C.substring(0,C.lastIndexOf("/"))+"/";}return C;},_getHTML:function(C){if(this._ready){var D=this.getInstance();C=D.one("body").get("innerHTML");}return C;},_setHTML:function(C){if(this._ready){var D=this.getInstance();D.one("body").set("innerHTML",C);}else{this.on("contentready",B.bind(function(E,G){var F=this.getInstance();F.one("body").set("innerHTML",E);},this,C));}return C;},_setExtraCSS:function(C){if(this._ready){var E=this.getInstance(),D=E.get("#extra_css");D.remove();E.one("head").append('<style id="extra_css">'+C+"</style>");}return C;},_instanceLoaded:function(C){this._instance=C;this._onContentReady();var D=this._instance.config.doc;if(this.get("designMode")){if(!B.UA.ie){this._instance.on("domready",function(F){try{D.execCommand("styleWithCSS",false,false);D.execCommand("insertbronreturn",false,false);}catch(E){}});}}},use:function(){var E=this.getInstance(),D=B.Array(arguments),C=false;if(B.Lang.isFunction(D[D.length-1])){C=D.pop();}if(C){D.push(function(){C.apply(E,arguments);});}E._use.apply(E,D);},delegate:function(E,D,C,G){var F=this.getInstance();if(!F){return false;}if(!G){G=C;C="body";}return F.delegate(E,D,C,G);},getInstance:function(){return this._instance;},render:function(C){if(this._rendered){return this;}this._rendered=true;if(C){this.set("container",C);}this._create(B.bind(function(G){var I,J,D=B.bind(function(K){this._instanceLoaded(K);},this),F=B.clone(this.get("use")),E={debug:false,win:G.win,doc:G.doc},H=B.bind(function(){E=this._resolveWinDoc(E);I=YUI(E);try{I.use("node-base",D);if(J){clearInterval(J);}}catch(K){J=setInterval(function(){H();},350);}},this);F.push(H);B.use.apply(B,F);},this));return this;},focus:function(C){if(B.UA.ie||B.UA.gecko){this.getInstance().one("win").focus();if(B.Lang.isFunction(C)){C();}}else{try{B.one("win").focus();B.later(100,this,function(){this.getInstance().one("win").focus();if(B.Lang.isFunction(C)){C();}});}catch(D){}}return this;},show:function(){this._iframe.setStyles({position:"static",left:""});if(B.UA.gecko){try{this._instance.config.doc.designMode="on";}catch(C){}this.focus();}return this;},hide:function(){this._iframe.setStyles({position:"absolute",left:"-999999px"});return this;}},{DOM_EVENTS:{paste:1,mouseup:1,mousedown:1,keyup:1,keydown:1,keypress:1},DEFAULT_CSS:"html { height: 95%; } body { padding: 7px; background-color: #fff; font: 13px/1.22 arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small; } a, a:visited, a:hover { color: blue !important; text-decoration: underline !important; cursor: text !important; } img { cursor: pointer !important; border: none; }",HTML:'<iframe border="0" frameBorder="0" marginWidth="0" marginHeight="0" leftMargin="0" topMargin="0" allowTransparency="true" width="100%" height="99%"></iframe>',PAGE_HTML:'<html dir="{DIR}" lang="{LANG}"><head><title>{TITLE}</title>{META}<base href="{BASE_HREF}"/><style id="editor_css">{DEFAULT_CSS}</style>{EXTRA_CSS}</head><body>{CONTENT}</body></html>',DOC_TYPE:'<!DOCTYPE HTML PUBLIC "-/'+"/W3C/"+"/DTD HTML 4.01/"+'/EN" "http:/'+'/www.w3.org/TR/html4/strict.dtd">',META:'<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/><meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">',NAME:"frame",ATTRS:{title:{value:"Blank Page"},dir:{value:"ltr"},lang:{value:"en-US"},src:{value:"javascript"+((B.UA.ie)?":false":":")+";"},designMode:{writeOnce:true,value:false},content:{value:"<br>",setter:"_setHTML",getter:"_getHTML"},basehref:{value:false,getter:"_resolveBaseHref"},use:{writeOnce:true,value:["substitute","node","node-style","selector-css3"]},container:{value:"body",setter:function(C){return B.one(C);