frame.js revision d0bccce76452becc96b65acaaa684aa6fabaf386
33d85edf47749fa345d7b636b9b4b9d0d0386f44Dav Glass * Creates a wrapper around an iframe. It loads the content either from a local
33d85edf47749fa345d7b636b9b4b9d0d0386f44Dav Glass * file or from script and creates a local YUI instance bound to that new window and document.
33d85edf47749fa345d7b636b9b4b9d0d0386f44Dav Glass * @module editor
33d85edf47749fa345d7b636b9b4b9d0d0386f44Dav Glass * @submodule frame
33d85edf47749fa345d7b636b9b4b9d0d0386f44Dav Glass * Creates a wrapper around an iframe. It loads the content either from a local
33d85edf47749fa345d7b636b9b4b9d0d0386f44Dav Glass * file or from script and creates a local YUI instance bound to that new window and document.
33d85edf47749fa345d7b636b9b4b9d0d0386f44Dav Glass * @class Frame
33d85edf47749fa345d7b636b9b4b9d0d0386f44Dav Glass * @for Frame
33d85edf47749fa345d7b636b9b4b9d0d0386f44Dav Glass * @extends Base
var Frame = function() {
_ready: null,
_rendered: null,
_iframe: null,
_instance: null,
extra_css = ((this.get('extracss')) ? '<style id="extra_css">' + this.get('extracss') + '</style>' : '');
* @return {Object} Object hash of window and document references, if a YUI config was passed, it is returned.
_resolveWinDoc: function(c) {
var config = (c) ? c : {};
return config;
* takes the current EventFacade and augments it to fire on the Frame host. It adds two new properties
_onDomEvent: function(e) {
e.frameEvent = e;
initializer: function() {
emitFacade: true,
destructor: function() {
inst = null;
_DOMPaste: function(e) {
data = null;
e.frameEvent = e;
if (data) {
e.clipboardData = {
getData: function() {
return data;
e.clipboardData = null;
_defReadyFn: function() {
* @description Called once the content is available in the frame/window and calls the final use call
_onContentReady: function(e) {
if (!this._ready) {
this._ready = true;
* @description Resolves the basehref of the page the frame is created on. Only applies to dynamic content.
return href;
if (this._ready) {
return html;
if (this._ready) {
}, this, html));
return html;
if (this._ready) {
return css;
this._onContentReady();
} catch (err) {}
* @description This is a scoped version of the normal YUI.use method & is bound to this frame/window.
use: function() {
cb = false;
if (cb) {
* @param {String} cont The container to act as a delegate, if no "sel" passed, the body is assumed as the container.
if (!inst) {
if (!sel) {
getInstance: function() {
return this._instance;
* @param {String/HTMLElement/Node} node The node to render to
if (this._rendered) {
this._rendered = true;
if (node) {
this._instanceLoaded(i);
config = {
debug: false,
if (timer) {
fn();
fn();
fn();
} catch (ferr) {
show: function() {
this.focus();
hide: function() {
DOM_EVENTS: {
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; }',
//DEFAULT_CSS: 'html { } body { margin: -15px 0 0 -15px; padding: 7px 0 0 15px; display: block; background-color: #fff; font: 13px/1.22 arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small; }',
//DEFAULT_CSS: 'html { height: 95%; } body { height: 100%; padding: 7px; margin: 0 0 0 -7px; postion: relative; 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; }',
//DEFAULT_CSS: 'html { margin: 0; padding: 0; border: none; border-size: 0; } body { height: 97%; margin: 0; padding: 0; display: block; background-color: gray; font: 13px/1.22 arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small; }',
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>',
* @description The DOCTYPE to prepend to the new document when created. Should match the one on the page being served.
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">',
ATTRS: {
title: {
dir: {
lang: {
src: {
designMode: {
writeOnce: true,
value: false
content: {
basehref: {
value: false,
* @description Array of modules to include in the scoped YUI instance at render time. Default: ['none', 'selector-css2']
use: {
writeOnce: true,
* @type String/HTMLElement/Node
container: {
setter: function(n) {
return Y.one(n);
id: {
writeOnce: true,
if (!id) {
return id;
extracss: {
host: {
value: false