X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/6e39d509471fe9b4e2660e0d1631b350d0c66f40..2e847cf21b8ab9d15fa167b315ca5b2fa92638fc:/src/widgets/form/HtmlEditor.js diff --git a/src/widgets/form/HtmlEditor.js b/src/widgets/form/HtmlEditor.js index df1fbb3a..3c2965d0 100644 --- a/src/widgets/form/HtmlEditor.js +++ b/src/widgets/form/HtmlEditor.js @@ -1,6 +1,6 @@ /*! - * Ext JS Library 3.1.0 - * Copyright(c) 2006-2009 Ext JS, LLC + * Ext JS Library 3.1.1 + * Copyright(c) 2006-2010 Ext JS, LLC * licensing@extjs.com * http://www.extjs.com/license */ @@ -201,7 +201,7 @@ Ext.form.HtmlEditor = Ext.extend(Ext.form.Field, { createToolbar : function(editor){ var items = []; var tipsEnabled = Ext.QuickTips && Ext.QuickTips.isEnabled(); - + function btn(id, toggle, handler){ return { @@ -227,7 +227,7 @@ Ext.form.HtmlEditor = Ext.extend(Ext.form.Field, { html: this.createFontOptions() } }); - + items.push( fontSelectItem, '-' @@ -338,16 +338,16 @@ Ext.form.HtmlEditor = Ext.extend(Ext.form.Field, { ); } } - + // build the toolbar var tb = new Ext.Toolbar({ renderTo: this.wrap.dom.firstChild, items: items }); - + if (fontSelectItem) { this.fontSelect = fontSelectItem.el; - + this.mon(this.fontSelect, 'change', function(){ var font = this.fontSelect.dom.value; this.relayCmd('fontname', font); @@ -360,9 +360,7 @@ Ext.form.HtmlEditor = Ext.extend(Ext.form.Field, { this.mon(tb.el, 'click', function(e){ e.preventDefault(); }); - - - + this.tb = tb; }, @@ -377,24 +375,27 @@ Ext.form.HtmlEditor = Ext.extend(Ext.form.Field, { }, setReadOnly: function(readOnly){ - if(this.initialized){ - var newDM = readOnly ? 'off' : 'on', - doc = this.getDoc(); - if(String(doc.designMode).toLowerCase() != newDM){ - doc.designMode = newDM; - } - this.disableItems(!readOnly); - } + Ext.form.HtmlEditor.superclass.setReadOnly.call(this, readOnly); + if(this.initialized){ + this.setDesignMode(!readOnly); + var bd = this.getEditorBody(); + if(bd){ + bd.style.cursor = this.readOnly ? 'default' : 'text'; + } + this.disableItems(readOnly); + } }, /** * Protected method that will not generally be called directly. It * is called when the editor initializes the iframe with HTML contents. Override this method if you * want to change the initialization markup of the iframe (e.g. to add stylesheets). + * + * Note: IE8-Standards has unwanted scroller behavior, so the default meta tag forces IE7 compatibility */ getDocMarkup : function(){ - return ''; + return ''; }, // private @@ -429,8 +430,8 @@ Ext.form.HtmlEditor = Ext.extend(Ext.form.Field, { this.createToolbar(this); this.disableItems(true); - // is this needed? - // this.tb.doLayout(); + + this.tb.doLayout(); this.createIFrame(); @@ -445,9 +446,9 @@ Ext.form.HtmlEditor = Ext.extend(Ext.form.Field, { var iframe = document.createElement('iframe'); iframe.name = Ext.id(); iframe.frameBorder = '0'; - iframe.src = Ext.SSL_SECURE_URL; - this.wrap.dom.appendChild(iframe); + iframe.style.overflow = 'auto'; + this.wrap.dom.appendChild(iframe); this.iframe = iframe; this.monitorTask = Ext.TaskMgr.start({ @@ -471,7 +472,7 @@ Ext.form.HtmlEditor = Ext.extend(Ext.form.Field, { var doc = this.getDoc(); if(doc.body || doc.readyState == 'complete'){ Ext.TaskMgr.stop(task); - doc.designMode="on"; + this.setDesignMode(true); this.initEditor.defer(10, this); } }, @@ -489,12 +490,34 @@ Ext.form.HtmlEditor = Ext.extend(Ext.form.Field, { if(!doc){ return; } - if(!doc.editorInitialized || String(doc.designMode).toLowerCase() != 'on'){ + if(!doc.editorInitialized || this.getDesignMode() != 'on'){ this.initFrame(); } } }, - + + /* private + * set current design mode. To enable, mode can be true or 'on', off otherwise + */ + setDesignMode : function(mode){ + var doc ; + if(doc = this.getDoc()){ + if(this.readOnly){ + mode = false; + } + doc.designMode = (/on|true/i).test(String(mode).toLowerCase()) ?'on':'off'; + } + + }, + + // private + getDesignMode : function(){ + var doc = this.getDoc(); + if(!doc){ return ''; } + return String(doc.designMode).toLowerCase(); + + }, + disableItems: function(disabled){ if(this.fontSelect){ this.fontSelect.dom.disabled = disabled; @@ -538,7 +561,7 @@ Ext.form.HtmlEditor = Ext.extend(Ext.form.Field, { } this.sourceEditMode = sourceEditMode === true; var btn = this.tb.getComponent('sourceedit'); - + if(btn.pressed !== this.sourceEditMode){ btn.toggle(this.sourceEditMode); if(!btn.xtbHidden){ @@ -553,8 +576,8 @@ Ext.form.HtmlEditor = Ext.extend(Ext.form.Field, { this.el.dom.removeAttribute('tabIndex'); this.el.focus(); }else{ - if(this.initialized && !this.readOnly){ - this.disableItems(false); + if(this.initialized){ + this.disableItems(this.readOnly); } this.pushValue(); this.iframe.className = ''; @@ -668,14 +691,13 @@ Ext.form.HtmlEditor = Ext.extend(Ext.form.Field, { this.getEditorBody().innerHTML = v; if(Ext.isGecko){ // Gecko hack, see: https://bugzilla.mozilla.org/show_bug.cgi?id=232791#c8 - var d = this.getDoc(), - mode = d.designMode.toLowerCase(); - - d.designMode = mode.toggle('on', 'off'); - d.designMode = mode; + this.setDesignMode(false); //toggle off first + } + this.setDesignMode(true); this.fireEvent('push', this, v); } + } }, @@ -701,12 +723,12 @@ Ext.form.HtmlEditor = Ext.extend(Ext.form.Field, { ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat'), doc, fn; - + ss['background-attachment'] = 'fixed'; // w3c dbody.bgProperties = 'fixed'; // ie Ext.DomHelper.applyStyles(dbody, ss); - + doc = this.getDoc(); if(doc){ @@ -765,7 +787,7 @@ Ext.form.HtmlEditor = Ext.extend(Ext.form.Field, { this.wrap.remove(); } } - + if(this.el){ this.el.removeAllListeners(); this.el.remove(); @@ -776,7 +798,7 @@ Ext.form.HtmlEditor = Ext.extend(Ext.form.Field, { // private onFirstFocus : function(){ this.activated = true; - this.disableItems(false); + this.disableItems(this.readOnly); if(Ext.isGecko){ // prevent silly gecko errors this.win.focus(); var s = this.win.getSelection(); @@ -846,7 +868,7 @@ Ext.form.HtmlEditor = Ext.extend(Ext.form.Field, { return; } - var btns = this.tb.items.map, + var btns = this.tb.items.map, doc = this.getDoc(); if(this.enableFont && !Ext.isSafari2){ @@ -963,7 +985,7 @@ Ext.form.HtmlEditor = Ext.extend(Ext.form.Field, { fixKeys : function(){ // load time branching for fastest keydown performance if(Ext.isIE){ return function(e){ - var k = e.getKey(), + var k = e.getKey(), doc = this.getDoc(), r; if(k == e.TAB){