- // private\r
- adjustFont: function(btn){\r
- var adjust = btn.getItemId() == 'increasefontsize' ? 1 : -1;\r
-\r
- var v = parseInt(this.doc.queryCommandValue('FontSize') || 2, 10);\r
- if((Ext.isSafari && !Ext.isSafari2) || Ext.isChrome || Ext.isAir){\r
- // Safari 3 values\r
- // 1 = 10px, 2 = 13px, 3 = 16px, 4 = 18px, 5 = 24px, 6 = 32px\r
- if(v <= 10){\r
- v = 1 + adjust;\r
- }else if(v <= 13){\r
- v = 2 + adjust;\r
- }else if(v <= 16){\r
- v = 3 + adjust;\r
- }else if(v <= 18){\r
- v = 4 + adjust;\r
- }else if(v <= 24){\r
- v = 5 + adjust;\r
- }else {\r
- v = 6 + adjust;\r
- }\r
- v = v.constrain(1, 6);\r
- }else{\r
- if(Ext.isSafari){ // safari\r
- adjust *= 2;\r
- }\r
- v = Math.max(1, v+adjust) + (Ext.isSafari ? 'px' : 0);\r
- }\r
- this.execCmd('FontSize', v);\r
- },\r
-\r
- // private\r
- onEditorEvent : function(e){\r
- this.updateToolbar();\r
- },\r
-\r
-\r
- <div id="method-Ext.form.HtmlEditor-updateToolbar"></div>/**\r
- * Protected method that will not generally be called directly. It triggers\r
- * a toolbar update by reading the markup state of the current selection in the editor.\r
- */\r
- updateToolbar: function(){\r
-\r
- if(!this.activated){\r
- this.onFirstFocus();\r
- return;\r
- }\r
-\r
- var btns = this.tb.items.map, doc = this.doc;\r
-\r
- if(this.enableFont && !Ext.isSafari2){\r
- var name = (this.doc.queryCommandValue('FontName')||this.defaultFont).toLowerCase();\r
- if(name != this.fontSelect.dom.value){\r
- this.fontSelect.dom.value = name;\r
- }\r
- }\r
- if(this.enableFormat){\r
- btns.bold.toggle(doc.queryCommandState('bold'));\r
- btns.italic.toggle(doc.queryCommandState('italic'));\r
- btns.underline.toggle(doc.queryCommandState('underline'));\r
- }\r
- if(this.enableAlignments){\r
- btns.justifyleft.toggle(doc.queryCommandState('justifyleft'));\r
- btns.justifycenter.toggle(doc.queryCommandState('justifycenter'));\r
- btns.justifyright.toggle(doc.queryCommandState('justifyright'));\r
- }\r
- if(!Ext.isSafari2 && this.enableLists){\r
- btns.insertorderedlist.toggle(doc.queryCommandState('insertorderedlist'));\r
- btns.insertunorderedlist.toggle(doc.queryCommandState('insertunorderedlist'));\r
- }\r
- \r
- Ext.menu.MenuMgr.hideAll();\r
-\r
- this.syncValue();\r
- },\r
-\r
- // private\r
- relayBtnCmd : function(btn){\r
- this.relayCmd(btn.getItemId());\r
- },\r
-\r
- <div id="method-Ext.form.HtmlEditor-relayCmd"></div>/**\r
- * Executes a Midas editor command on the editor document and performs necessary focus and\r
- * toolbar updates. <b>This should only be called after the editor is initialized.</b>\r
- * @param {String} cmd The Midas command\r
- * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)\r
- */\r
- relayCmd : function(cmd, value){\r
- (function(){\r
- this.focus();\r
- this.execCmd(cmd, value);\r
- this.updateToolbar();\r
- }).defer(10, this);\r
- },\r
-\r
- <div id="method-Ext.form.HtmlEditor-execCmd"></div>/**\r
- * Executes a Midas editor command directly on the editor document.\r
- * For visual commands, you should use {@link #relayCmd} instead.\r
- * <b>This should only be called after the editor is initialized.</b>\r
- * @param {String} cmd The Midas command\r
- * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)\r
- */\r
- execCmd : function(cmd, value){\r
- this.doc.execCommand(cmd, false, value === undefined ? null : value);\r
- this.syncValue();\r
- },\r
-\r
- // private\r
- applyCommand : function(e){\r
- if(e.ctrlKey){\r
- var c = e.getCharCode(), cmd;\r
- if(c > 0){\r
- c = String.fromCharCode(c);\r
- switch(c){\r
- case 'b':\r
- cmd = 'bold';\r
- break;\r
- case 'i':\r
- cmd = 'italic';\r
- break;\r
- case 'u':\r
- cmd = 'underline';\r
- break;\r
- }\r
- if(cmd){\r
- this.win.focus();\r
- this.execCmd(cmd);\r
- this.deferFocus();\r
- e.preventDefault();\r
- }\r
- }\r
- }\r
- },\r
-\r
- <div id="method-Ext.form.HtmlEditor-insertAtCursor"></div>/**\r
- * Inserts the passed text at the current cursor position. Note: the editor must be initialized and activated\r
- * to insert text.\r
- * @param {String} text\r
- */\r
- insertAtCursor : function(text){\r
- if(!this.activated){\r
- return;\r
- }\r
- if(Ext.isIE){\r
- this.win.focus();\r
- var r = this.doc.selection.createRange();\r
- if(r){\r
- r.collapse(true);\r
- r.pasteHTML(text);\r
- this.syncValue();\r
- this.deferFocus();\r
- }\r
- }else{\r
- this.win.focus();\r
- this.execCmd('InsertHTML', text);\r
- this.deferFocus();\r
- }\r
- },\r
-\r
- // private\r
- fixKeys : function(){ // load time branching for fastest keydown performance\r
- if(Ext.isIE){\r
- return function(e){\r
- var k = e.getKey(), r;\r
- if(k == e.TAB){\r
- e.stopEvent();\r
- r = this.doc.selection.createRange();\r
- if(r){\r
- r.collapse(true);\r
- r.pasteHTML(' ');\r
- this.deferFocus();\r
- }\r
- }else if(k == e.ENTER){\r
- r = this.doc.selection.createRange();\r
- if(r){\r
- var target = r.parentElement();\r
- if(!target || target.tagName.toLowerCase() != 'li'){\r
- e.stopEvent();\r
- r.pasteHTML('<br />');\r
- r.collapse(false);\r
- r.select();\r
- }\r
- }\r
- }\r
- };\r
- }else if(Ext.isOpera){\r
- return function(e){\r
- var k = e.getKey();\r
- if(k == e.TAB){\r
- e.stopEvent();\r
- this.win.focus();\r
- this.execCmd('InsertHTML',' ');\r
- this.deferFocus();\r
- }\r
- };\r
- }else if(Ext.isWebKit){\r
- return function(e){\r
- var k = e.getKey();\r
- if(k == e.TAB){\r
- e.stopEvent();\r
- this.execCmd('InsertText','\t');\r
- this.deferFocus();\r
- }else if(k == e.ENTER){\r
- e.stopEvent();\r
- this.execCmd('InsertHtml','<br /><br />');\r
- this.deferFocus();\r
- }\r
- };\r
- }\r
- }(),\r
-\r
- <div id="method-Ext.form.HtmlEditor-getToolbar"></div>/**\r
- * Returns the editor's toolbar. <b>This is only available after the editor has been rendered.</b>\r
- * @return {Ext.Toolbar}\r
- */\r
- getToolbar : function(){\r
- return this.tb;\r
- },\r
-\r
- <div id="prop-Ext.form.HtmlEditor-buttonTips"></div>/**\r
- * Object collection of toolbar tooltips for the buttons in the editor. The key\r
- * is the command id associated with that button and the value is a valid QuickTips object.\r
- * For example:\r
-<pre><code>\r
-{\r
- bold : {\r
- title: 'Bold (Ctrl+B)',\r
- text: 'Make the selected text bold.',\r
- cls: 'x-html-editor-tip'\r
- },\r
- italic : {\r
- title: 'Italic (Ctrl+I)',\r
- text: 'Make the selected text italic.',\r
- cls: 'x-html-editor-tip'\r
- },\r
- ...\r
-</code></pre>\r
- * @type Object\r
- */\r
- buttonTips : {\r
- bold : {\r
- title: 'Bold (Ctrl+B)',\r
- text: 'Make the selected text bold.',\r
- cls: 'x-html-editor-tip'\r
- },\r
- italic : {\r
- title: 'Italic (Ctrl+I)',\r
- text: 'Make the selected text italic.',\r
- cls: 'x-html-editor-tip'\r
- },\r
- underline : {\r
- title: 'Underline (Ctrl+U)',\r
- text: 'Underline the selected text.',\r
- cls: 'x-html-editor-tip'\r
- },\r
- increasefontsize : {\r
- title: 'Grow Text',\r
- text: 'Increase the font size.',\r
- cls: 'x-html-editor-tip'\r
- },\r
- decreasefontsize : {\r
- title: 'Shrink Text',\r
- text: 'Decrease the font size.',\r
- cls: 'x-html-editor-tip'\r
- },\r
- backcolor : {\r
- title: 'Text Highlight Color',\r
- text: 'Change the background color of the selected text.',\r
- cls: 'x-html-editor-tip'\r
- },\r
- forecolor : {\r
- title: 'Font Color',\r
- text: 'Change the color of the selected text.',\r
- cls: 'x-html-editor-tip'\r
- },\r
- justifyleft : {\r
- title: 'Align Text Left',\r
- text: 'Align text to the left.',\r
- cls: 'x-html-editor-tip'\r
- },\r
- justifycenter : {\r
- title: 'Center Text',\r
- text: 'Center text in the editor.',\r
- cls: 'x-html-editor-tip'\r
- },\r
- justifyright : {\r
- title: 'Align Text Right',\r
- text: 'Align text to the right.',\r
- cls: 'x-html-editor-tip'\r
- },\r
- insertunorderedlist : {\r
- title: 'Bullet List',\r
- text: 'Start a bulleted list.',\r
- cls: 'x-html-editor-tip'\r
- },\r
- insertorderedlist : {\r
- title: 'Numbered List',\r
- text: 'Start a numbered list.',\r
- cls: 'x-html-editor-tip'\r
- },\r
- createlink : {\r
- title: 'Hyperlink',\r
- text: 'Make the selected text a hyperlink.',\r
- cls: 'x-html-editor-tip'\r
- },\r
- sourceedit : {\r
- title: 'Source Edit',\r
- text: 'Switch to source editing mode.',\r
- cls: 'x-html-editor-tip'\r
- }\r
- }\r
-\r
- // hide stuff that is not compatible\r
- <div id="event-Ext.form.HtmlEditor-blur"></div>/**\r
- * @event blur\r
- * @hide\r
- */\r
- <div id="event-Ext.form.HtmlEditor-change"></div>/**\r
- * @event change\r
- * @hide\r
- */\r
- <div id="event-Ext.form.HtmlEditor-focus"></div>/**\r
- * @event focus\r
- * @hide\r
- */\r
- <div id="event-Ext.form.HtmlEditor-specialkey"></div>/**\r
- * @event specialkey\r
- * @hide\r
- */\r
- <div id="cfg-Ext.form.HtmlEditor-fieldClass"></div>/**\r
- * @cfg {String} fieldClass @hide\r
- */\r
- <div id="cfg-Ext.form.HtmlEditor-focusClass"></div>/**\r
- * @cfg {String} focusClass @hide\r
- */\r
- <div id="cfg-Ext.form.HtmlEditor-autoCreate"></div>/**\r
- * @cfg {String} autoCreate @hide\r
- */\r
- <div id="cfg-Ext.form.HtmlEditor-inputType"></div>/**\r
- * @cfg {String} inputType @hide\r
- */\r
- <div id="cfg-Ext.form.HtmlEditor-invalidClass"></div>/**\r
- * @cfg {String} invalidClass @hide\r
- */\r
- <div id="cfg-Ext.form.HtmlEditor-invalidText"></div>/**\r
- * @cfg {String} invalidText @hide\r
- */\r
- <div id="cfg-Ext.form.HtmlEditor-msgFx"></div>/**\r
- * @cfg {String} msgFx @hide\r
- */\r
- <div id="cfg-Ext.form.HtmlEditor-validateOnBlur"></div>/**\r
- * @cfg {String} validateOnBlur @hide\r
- */\r
- <div id="cfg-Ext.form.HtmlEditor-allowDomMove"></div>/**\r
- * @cfg {Boolean} allowDomMove @hide\r
- */\r
- <div id="cfg-Ext.form.HtmlEditor-applyTo"></div>/**\r
- * @cfg {String} applyTo @hide\r
- */\r
- <div id="cfg-Ext.form.HtmlEditor-autoHeight"></div>/**\r
- * @cfg {String} autoHeight @hide\r
- */\r
- <div id="cfg-Ext.form.HtmlEditor-autoWidth"></div>/**\r
- * @cfg {String} autoWidth @hide\r
- */\r
- <div id="cfg-Ext.form.HtmlEditor-cls"></div>/**\r
- * @cfg {String} cls @hide\r
- */\r
- <div id="cfg-Ext.form.HtmlEditor-disabled"></div>/**\r
- * @cfg {String} disabled @hide\r
- */\r
- <div id="cfg-Ext.form.HtmlEditor-disabledClass"></div>/**\r
- * @cfg {String} disabledClass @hide\r
- */\r
- <div id="cfg-Ext.form.HtmlEditor-msgTarget"></div>/**\r
- * @cfg {String} msgTarget @hide\r
- */\r
- <div id="cfg-Ext.form.HtmlEditor-readOnly"></div>/**\r
- * @cfg {String} readOnly @hide\r
- */\r
- <div id="cfg-Ext.form.HtmlEditor-style"></div>/**\r
- * @cfg {String} style @hide\r
- */\r
- <div id="cfg-Ext.form.HtmlEditor-validationDelay"></div>/**\r
- * @cfg {String} validationDelay @hide\r
- */\r
- <div id="cfg-Ext.form.HtmlEditor-validationEvent"></div>/**\r
- * @cfg {String} validationEvent @hide\r
- */\r
- <div id="cfg-Ext.form.HtmlEditor-tabIndex"></div>/**\r
- * @cfg {String} tabIndex @hide\r
- */\r
- <div id="prop-Ext.form.HtmlEditor-disabled"></div>/**\r
- * @property disabled\r
- * @hide\r
- */\r
- <div id="method-Ext.form.HtmlEditor-applyToMarkup"></div>/**\r
- * @method applyToMarkup\r
- * @hide\r
- */\r
- <div id="method-Ext.form.HtmlEditor-disable"></div>/**\r
- * @method disable\r
- * @hide\r
- */\r
- <div id="method-Ext.form.HtmlEditor-enable"></div>/**\r
- * @method enable\r
- * @hide\r
- */\r
- <div id="method-Ext.form.HtmlEditor-validate"></div>/**\r
- * @method validate\r
- * @hide\r
- */\r
- <div id="event-Ext.form.HtmlEditor-valid"></div>/**\r
- * @event valid\r
- * @hide\r
- */\r
- <div id="method-Ext.form.HtmlEditor-setDisabled"></div>/**\r
- * @method setDisabled\r
- * @hide\r
- */\r
- <div id="cfg-Ext.form.HtmlEditor-null"></div>/**\r
- * @cfg keys\r
- * @hide\r
- */\r
-});\r
-Ext.reg('htmleditor', Ext.form.HtmlEditor);</pre>
-</body>
+ disableItems: function(disabled){
+ if(this.fontSelect){
+ this.fontSelect.dom.disabled = disabled;
+ }
+ this.tb.items.each(function(item){
+ if(item.getItemId() != 'sourceedit'){
+ item.setDisabled(disabled);
+ }
+ });
+ },
+
+ // private
+ onResize : function(w, h){
+ Ext.form.HtmlEditor.superclass.onResize.apply(this, arguments);
+ if(this.el && this.iframe){
+ if(Ext.isNumber(w)){
+ var aw = w - this.wrap.getFrameWidth('lr');
+ this.el.setWidth(aw);
+ this.tb.setWidth(aw);
+ this.iframe.style.width = Math.max(aw, 0) + 'px';
+ }
+ if(Ext.isNumber(h)){
+ var ah = h - this.wrap.getFrameWidth('tb') - this.tb.el.getHeight();
+ this.el.setHeight(ah);
+ this.iframe.style.height = Math.max(ah, 0) + 'px';
+ var bd = this.getEditorBody();
+ if(bd){
+ bd.style.height = Math.max((ah - (this.iframePad*2)), 0) + 'px';
+ }
+ }
+ }
+ },
+
+ <div id="method-Ext.form.HtmlEditor-toggleSourceEdit"></div>/**
+ * Toggles the editor between standard and source edit mode.
+ * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
+ */
+ toggleSourceEdit : function(sourceEditMode){
+ if(sourceEditMode === undefined){
+ sourceEditMode = !this.sourceEditMode;
+ }
+ this.sourceEditMode = sourceEditMode === true;
+ var btn = this.tb.getComponent('sourceedit');
+
+ if(btn.pressed !== this.sourceEditMode){
+ btn.toggle(this.sourceEditMode);
+ if(!btn.xtbHidden){
+ return;
+ }
+ }
+ if(this.sourceEditMode){
+ this.disableItems(true);
+ this.syncValue();
+ this.iframe.className = 'x-hidden';
+ this.el.removeClass('x-hidden');
+ this.el.dom.removeAttribute('tabIndex');
+ this.el.focus();
+ }else{
+ if(this.initialized){
+ this.disableItems(this.readOnly);
+ }
+ this.pushValue();
+ this.iframe.className = '';
+ this.el.addClass('x-hidden');
+ this.el.dom.setAttribute('tabIndex', -1);
+ this.deferFocus();
+ }
+ var lastSize = this.lastSize;
+ if(lastSize){
+ delete this.lastSize;
+ this.setSize(lastSize);
+ }
+ this.fireEvent('editmodechange', this, this.sourceEditMode);
+ },
+
+ // private used internally
+ createLink : function(){
+ var url = prompt(this.createLinkText, this.defaultLinkValue);
+ if(url && url != 'http:/'+'/'){
+ this.relayCmd('createlink', url);
+ }
+ },
+
+ // private
+ initEvents : function(){
+ this.originalValue = this.getValue();
+ },
+
+ <div id="method-Ext.form.HtmlEditor-markInvalid"></div>/**
+ * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
+ * @method
+ */
+ markInvalid : Ext.emptyFn,
+
+ <div id="method-Ext.form.HtmlEditor-clearInvalid"></div>/**
+ * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
+ * @method
+ */
+ clearInvalid : Ext.emptyFn,
+
+ // docs inherit from Field
+ setValue : function(v){
+ Ext.form.HtmlEditor.superclass.setValue.call(this, v);
+ this.pushValue();
+ return this;
+ },
+
+ <div id="method-Ext.form.HtmlEditor-cleanHtml"></div>/**
+ * Protected method that will not generally be called directly. If you need/want
+ * custom HTML cleanup, this is the method you should override.
+ * @param {String} html The HTML to be cleaned
+ * @return {String} The cleaned HTML
+ */
+ cleanHtml: function(html) {
+ html = String(html);
+ if(Ext.isWebKit){ // strip safari nonsense
+ html = html.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi, '');
+ }
+
+ /*
+ * Neat little hack. Strips out all the non-digit characters from the default
+ * value and compares it to the character code of the first character in the string
+ * because it can cause encoding issues when posted to the server.
+ */
+ if(html.charCodeAt(0) == this.defaultValue.replace(/\D/g, '')){
+ html = html.substring(1);
+ }
+ return html;
+ },
+
+ <div id="method-Ext.form.HtmlEditor-syncValue"></div>/**
+ * Protected method that will not generally be called directly. Syncs the contents
+ * of the editor iframe with the textarea.
+ */
+ syncValue : function(){
+ if(this.initialized){
+ var bd = this.getEditorBody();
+ var html = bd.innerHTML;
+ if(Ext.isWebKit){
+ var bs = bd.getAttribute('style'); // Safari puts text-align styles on the body element!
+ var m = bs.match(/text-align:(.*?);/i);
+ if(m && m[1]){
+ html = '<div style="'+m[0]+'">' + html + '</div>';
+ }
+ }
+ html = this.cleanHtml(html);
+ if(this.fireEvent('beforesync', this, html) !== false){
+ this.el.dom.value = html;
+ this.fireEvent('sync', this, html);
+ }
+ }
+ },
+
+ //docs inherit from Field
+ getValue : function() {
+ this[this.sourceEditMode ? 'pushValue' : 'syncValue']();
+ return Ext.form.HtmlEditor.superclass.getValue.call(this);
+ },
+
+ <div id="method-Ext.form.HtmlEditor-pushValue"></div>/**
+ * Protected method that will not generally be called directly. Pushes the value of the textarea
+ * into the iframe editor.
+ */
+ pushValue : function(){
+ if(this.initialized){
+ var v = this.el.dom.value;
+ if(!this.activated && v.length < 1){
+ v = this.defaultValue;
+ }
+ if(this.fireEvent('beforepush', this, v) !== false){
+ this.getEditorBody().innerHTML = v;
+ if(Ext.isGecko){
+ // Gecko hack, see: https://bugzilla.mozilla.org/show_bug.cgi?id=232791#c8
+ this.setDesignMode(false); //toggle off first\r
+\r
+ }
+ this.setDesignMode(true);\r
+ this.fireEvent('push', this, v);
+ }
+\r
+ }
+ },
+
+ // private
+ deferFocus : function(){
+ this.focus.defer(10, this);
+ },
+
+ // docs inherit from Field
+ focus : function(){
+ if(this.win && !this.sourceEditMode){
+ this.win.focus();
+ }else{
+ this.el.focus();
+ }
+ },
+
+ // private
+ initEditor : function(){
+ //Destroying the component during/before initEditor can cause issues.
+ try{
+ var dbody = this.getEditorBody(),
+ 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){
+ try{
+ Ext.EventManager.removeAll(doc);
+ }catch(e){}
+ }
+
+ /*
+ * We need to use createDelegate here, because when using buffer, the delayed task is added
+ * as a property to the function. When the listener is removed, the task is deleted from the function.
+ * Since onEditorEvent is shared on the prototype, if we have multiple html editors, the first time one of the editors
+ * is destroyed, it causes the fn to be deleted from the prototype, which causes errors. Essentially, we're just anonymizing the function.
+ */
+ fn = this.onEditorEvent.createDelegate(this);
+ Ext.EventManager.on(doc, {
+ mousedown: fn,
+ dblclick: fn,
+ click: fn,
+ keyup: fn,
+ buffer:100
+ });
+
+ if(Ext.isGecko){
+ Ext.EventManager.on(doc, 'keypress', this.applyCommand, this);
+ }
+ if(Ext.isIE || Ext.isWebKit || Ext.isOpera){
+ Ext.EventManager.on(doc, 'keydown', this.fixKeys, this);
+ }
+ doc.editorInitialized = true;
+ this.initialized = true;
+ this.pushValue();
+ this.setReadOnly(this.readOnly);
+ this.fireEvent('initialize', this);
+ }catch(e){}
+ },
+
+ // private
+ onDestroy : function(){
+ if(this.monitorTask){
+ Ext.TaskMgr.stop(this.monitorTask);
+ }
+ if(this.rendered){
+ Ext.destroy(this.tb);
+ var doc = this.getDoc();
+ if(doc){
+ try{
+ Ext.EventManager.removeAll(doc);
+ for (var prop in doc){
+ delete doc[prop];
+ }
+ }catch(e){}
+ }
+ if(this.wrap){
+ this.wrap.dom.innerHTML = '';
+ this.wrap.remove();
+ }
+ }
+
+ if(this.el){
+ this.el.removeAllListeners();
+ this.el.remove();
+ }
+ this.purgeListeners();
+ },
+
+ // private
+ onFirstFocus : function(){
+ this.activated = true;
+ this.disableItems(this.readOnly);
+ if(Ext.isGecko){ // prevent silly gecko errors
+ this.win.focus();
+ var s = this.win.getSelection();
+ if(!s.focusNode || s.focusNode.nodeType != 3){
+ var r = s.getRangeAt(0);
+ r.selectNodeContents(this.getEditorBody());
+ r.collapse(true);
+ this.deferFocus();
+ }
+ try{
+ this.execCmd('useCSS', true);
+ this.execCmd('styleWithCSS', false);
+ }catch(e){}
+ }
+ this.fireEvent('activate', this);
+ },
+
+ // private
+ adjustFont: function(btn){
+ var adjust = btn.getItemId() == 'increasefontsize' ? 1 : -1,
+ doc = this.getDoc(),
+ v = parseInt(doc.queryCommandValue('FontSize') || 2, 10);
+ if((Ext.isSafari && !Ext.isSafari2) || Ext.isChrome || Ext.isAir){
+ // Safari 3 values
+ // 1 = 10px, 2 = 13px, 3 = 16px, 4 = 18px, 5 = 24px, 6 = 32px
+ if(v <= 10){
+ v = 1 + adjust;
+ }else if(v <= 13){
+ v = 2 + adjust;
+ }else if(v <= 16){
+ v = 3 + adjust;
+ }else if(v <= 18){
+ v = 4 + adjust;
+ }else if(v <= 24){
+ v = 5 + adjust;
+ }else {
+ v = 6 + adjust;
+ }
+ v = v.constrain(1, 6);
+ }else{
+ if(Ext.isSafari){ // safari
+ adjust *= 2;
+ }
+ v = Math.max(1, v+adjust) + (Ext.isSafari ? 'px' : 0);
+ }
+ this.execCmd('FontSize', v);
+ },
+
+ // private
+ onEditorEvent : function(e){
+ this.updateToolbar();
+ },
+
+
+ <div id="method-Ext.form.HtmlEditor-updateToolbar"></div>/**
+ * Protected method that will not generally be called directly. It triggers
+ * a toolbar update by reading the markup state of the current selection in the editor.
+ */
+ updateToolbar: function(){
+
+ if(this.readOnly){
+ return;
+ }
+
+ if(!this.activated){
+ this.onFirstFocus();
+ return;
+ }
+
+ var btns = this.tb.items.map,
+ doc = this.getDoc();
+
+ if(this.enableFont && !Ext.isSafari2){
+ var name = (doc.queryCommandValue('FontName')||this.defaultFont).toLowerCase();
+ if(name != this.fontSelect.dom.value){
+ this.fontSelect.dom.value = name;
+ }
+ }
+ if(this.enableFormat){
+ btns.bold.toggle(doc.queryCommandState('bold'));
+ btns.italic.toggle(doc.queryCommandState('italic'));
+ btns.underline.toggle(doc.queryCommandState('underline'));
+ }
+ if(this.enableAlignments){
+ btns.justifyleft.toggle(doc.queryCommandState('justifyleft'));
+ btns.justifycenter.toggle(doc.queryCommandState('justifycenter'));
+ btns.justifyright.toggle(doc.queryCommandState('justifyright'));
+ }
+ if(!Ext.isSafari2 && this.enableLists){
+ btns.insertorderedlist.toggle(doc.queryCommandState('insertorderedlist'));
+ btns.insertunorderedlist.toggle(doc.queryCommandState('insertunorderedlist'));
+ }
+
+ Ext.menu.MenuMgr.hideAll();
+
+ this.syncValue();
+ },
+
+ // private
+ relayBtnCmd : function(btn){
+ this.relayCmd(btn.getItemId());
+ },
+
+ <div id="method-Ext.form.HtmlEditor-relayCmd"></div>/**
+ * Executes a Midas editor command on the editor document and performs necessary focus and
+ * toolbar updates. <b>This should only be called after the editor is initialized.</b>
+ * @param {String} cmd The Midas command
+ * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
+ */
+ relayCmd : function(cmd, value){
+ (function(){
+ this.focus();
+ this.execCmd(cmd, value);
+ this.updateToolbar();
+ }).defer(10, this);
+ },
+
+ <div id="method-Ext.form.HtmlEditor-execCmd"></div>/**
+ * Executes a Midas editor command directly on the editor document.
+ * For visual commands, you should use {@link #relayCmd} instead.
+ * <b>This should only be called after the editor is initialized.</b>
+ * @param {String} cmd The Midas command
+ * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
+ */
+ execCmd : function(cmd, value){
+ var doc = this.getDoc();
+ doc.execCommand(cmd, false, value === undefined ? null : value);
+ this.syncValue();
+ },
+
+ // private
+ applyCommand : function(e){
+ if(e.ctrlKey){
+ var c = e.getCharCode(), cmd;
+ if(c > 0){
+ c = String.fromCharCode(c);
+ switch(c){
+ case 'b':
+ cmd = 'bold';
+ break;
+ case 'i':
+ cmd = 'italic';
+ break;
+ case 'u':
+ cmd = 'underline';
+ break;
+ }
+ if(cmd){
+ this.win.focus();
+ this.execCmd(cmd);
+ this.deferFocus();
+ e.preventDefault();
+ }
+ }
+ }
+ },
+
+ <div id="method-Ext.form.HtmlEditor-insertAtCursor"></div>/**
+ * Inserts the passed text at the current cursor position. Note: the editor must be initialized and activated
+ * to insert text.
+ * @param {String} text
+ */
+ insertAtCursor : function(text){
+ if(!this.activated){
+ return;
+ }
+ if(Ext.isIE){
+ this.win.focus();
+ var doc = this.getDoc(),
+ r = doc.selection.createRange();
+ if(r){
+ r.pasteHTML(text);
+ this.syncValue();
+ this.deferFocus();
+ }
+ }else{
+ this.win.focus();
+ this.execCmd('InsertHTML', text);
+ this.deferFocus();
+ }
+ },
+
+ // private
+ fixKeys : function(){ // load time branching for fastest keydown performance
+ if(Ext.isIE){
+ return function(e){
+ var k = e.getKey(),
+ doc = this.getDoc(),
+ r;
+ if(k == e.TAB){
+ e.stopEvent();
+ r = doc.selection.createRange();
+ if(r){
+ r.collapse(true);
+ r.pasteHTML(' ');
+ this.deferFocus();
+ }
+ }else if(k == e.ENTER){
+ r = doc.selection.createRange();
+ if(r){
+ var target = r.parentElement();
+ if(!target || target.tagName.toLowerCase() != 'li'){
+ e.stopEvent();
+ r.pasteHTML('<br />');
+ r.collapse(false);
+ r.select();
+ }
+ }
+ }
+ };
+ }else if(Ext.isOpera){
+ return function(e){
+ var k = e.getKey();
+ if(k == e.TAB){
+ e.stopEvent();
+ this.win.focus();
+ this.execCmd('InsertHTML',' ');
+ this.deferFocus();
+ }
+ };
+ }else if(Ext.isWebKit){
+ return function(e){
+ var k = e.getKey();
+ if(k == e.TAB){
+ e.stopEvent();
+ this.execCmd('InsertText','\t');
+ this.deferFocus();
+ }else if(k == e.ENTER){
+ e.stopEvent();
+ this.execCmd('InsertHtml','<br /><br />');
+ this.deferFocus();
+ }
+ };
+ }
+ }(),
+
+ <div id="method-Ext.form.HtmlEditor-getToolbar"></div>/**
+ * Returns the editor's toolbar. <b>This is only available after the editor has been rendered.</b>
+ * @return {Ext.Toolbar}
+ */
+ getToolbar : function(){
+ return this.tb;
+ },
+
+ <div id="prop-Ext.form.HtmlEditor-buttonTips"></div>/**
+ * Object collection of toolbar tooltips for the buttons in the editor. The key
+ * is the command id associated with that button and the value is a valid QuickTips object.
+ * For example:
+<pre><code>
+{
+ bold : {
+ title: 'Bold (Ctrl+B)',
+ text: 'Make the selected text bold.',
+ cls: 'x-html-editor-tip'
+ },
+ italic : {
+ title: 'Italic (Ctrl+I)',
+ text: 'Make the selected text italic.',
+ cls: 'x-html-editor-tip'
+ },
+ ...
+</code></pre>
+ * @type Object
+ */
+ buttonTips : {
+ bold : {
+ title: 'Bold (Ctrl+B)',
+ text: 'Make the selected text bold.',
+ cls: 'x-html-editor-tip'
+ },
+ italic : {
+ title: 'Italic (Ctrl+I)',
+ text: 'Make the selected text italic.',
+ cls: 'x-html-editor-tip'
+ },
+ underline : {
+ title: 'Underline (Ctrl+U)',
+ text: 'Underline the selected text.',
+ cls: 'x-html-editor-tip'
+ },
+ increasefontsize : {
+ title: 'Grow Text',
+ text: 'Increase the font size.',
+ cls: 'x-html-editor-tip'
+ },
+ decreasefontsize : {
+ title: 'Shrink Text',
+ text: 'Decrease the font size.',
+ cls: 'x-html-editor-tip'
+ },
+ backcolor : {
+ title: 'Text Highlight Color',
+ text: 'Change the background color of the selected text.',
+ cls: 'x-html-editor-tip'
+ },
+ forecolor : {
+ title: 'Font Color',
+ text: 'Change the color of the selected text.',
+ cls: 'x-html-editor-tip'
+ },
+ justifyleft : {
+ title: 'Align Text Left',
+ text: 'Align text to the left.',
+ cls: 'x-html-editor-tip'
+ },
+ justifycenter : {
+ title: 'Center Text',
+ text: 'Center text in the editor.',
+ cls: 'x-html-editor-tip'
+ },
+ justifyright : {
+ title: 'Align Text Right',
+ text: 'Align text to the right.',
+ cls: 'x-html-editor-tip'
+ },
+ insertunorderedlist : {
+ title: 'Bullet List',
+ text: 'Start a bulleted list.',
+ cls: 'x-html-editor-tip'
+ },
+ insertorderedlist : {
+ title: 'Numbered List',
+ text: 'Start a numbered list.',
+ cls: 'x-html-editor-tip'
+ },
+ createlink : {
+ title: 'Hyperlink',
+ text: 'Make the selected text a hyperlink.',
+ cls: 'x-html-editor-tip'
+ },
+ sourceedit : {
+ title: 'Source Edit',
+ text: 'Switch to source editing mode.',
+ cls: 'x-html-editor-tip'
+ }
+ }
+
+ // hide stuff that is not compatible
+ <div id="event-Ext.form.HtmlEditor-blur"></div>/**
+ * @event blur
+ * @hide
+ */
+ <div id="event-Ext.form.HtmlEditor-change"></div>/**
+ * @event change
+ * @hide
+ */
+ <div id="event-Ext.form.HtmlEditor-focus"></div>/**
+ * @event focus
+ * @hide
+ */
+ <div id="event-Ext.form.HtmlEditor-specialkey"></div>/**
+ * @event specialkey
+ * @hide
+ */
+ <div id="cfg-Ext.form.HtmlEditor-fieldClass"></div>/**
+ * @cfg {String} fieldClass @hide
+ */
+ <div id="cfg-Ext.form.HtmlEditor-focusClass"></div>/**
+ * @cfg {String} focusClass @hide
+ */
+ <div id="cfg-Ext.form.HtmlEditor-autoCreate"></div>/**
+ * @cfg {String} autoCreate @hide
+ */
+ <div id="cfg-Ext.form.HtmlEditor-inputType"></div>/**
+ * @cfg {String} inputType @hide
+ */
+ <div id="cfg-Ext.form.HtmlEditor-invalidClass"></div>/**
+ * @cfg {String} invalidClass @hide
+ */
+ <div id="cfg-Ext.form.HtmlEditor-invalidText"></div>/**
+ * @cfg {String} invalidText @hide
+ */
+ <div id="cfg-Ext.form.HtmlEditor-msgFx"></div>/**
+ * @cfg {String} msgFx @hide
+ */
+ <div id="cfg-Ext.form.HtmlEditor-validateOnBlur"></div>/**
+ * @cfg {String} validateOnBlur @hide
+ */
+ <div id="cfg-Ext.form.HtmlEditor-allowDomMove"></div>/**
+ * @cfg {Boolean} allowDomMove @hide
+ */
+ <div id="cfg-Ext.form.HtmlEditor-applyTo"></div>/**
+ * @cfg {String} applyTo @hide
+ */
+ <div id="cfg-Ext.form.HtmlEditor-autoHeight"></div>/**
+ * @cfg {String} autoHeight @hide
+ */
+ <div id="cfg-Ext.form.HtmlEditor-autoWidth"></div>/**
+ * @cfg {String} autoWidth @hide
+ */
+ <div id="cfg-Ext.form.HtmlEditor-cls"></div>/**
+ * @cfg {String} cls @hide
+ */
+ <div id="cfg-Ext.form.HtmlEditor-disabled"></div>/**
+ * @cfg {String} disabled @hide
+ */
+ <div id="cfg-Ext.form.HtmlEditor-disabledClass"></div>/**
+ * @cfg {String} disabledClass @hide
+ */
+ <div id="cfg-Ext.form.HtmlEditor-msgTarget"></div>/**
+ * @cfg {String} msgTarget @hide
+ */
+ <div id="cfg-Ext.form.HtmlEditor-readOnly"></div>/**
+ * @cfg {String} readOnly @hide
+ */
+ <div id="cfg-Ext.form.HtmlEditor-style"></div>/**
+ * @cfg {String} style @hide
+ */
+ <div id="cfg-Ext.form.HtmlEditor-validationDelay"></div>/**
+ * @cfg {String} validationDelay @hide
+ */
+ <div id="cfg-Ext.form.HtmlEditor-validationEvent"></div>/**
+ * @cfg {String} validationEvent @hide
+ */
+ <div id="cfg-Ext.form.HtmlEditor-tabIndex"></div>/**
+ * @cfg {String} tabIndex @hide
+ */
+ <div id="prop-Ext.form.HtmlEditor-disabled"></div>/**
+ * @property disabled
+ * @hide
+ */
+ <div id="method-Ext.form.HtmlEditor-applyToMarkup"></div>/**
+ * @method applyToMarkup
+ * @hide
+ */
+ <div id="method-Ext.form.HtmlEditor-disable"></div>/**
+ * @method disable
+ * @hide
+ */
+ <div id="method-Ext.form.HtmlEditor-enable"></div>/**
+ * @method enable
+ * @hide
+ */
+ <div id="method-Ext.form.HtmlEditor-validate"></div>/**
+ * @method validate
+ * @hide
+ */
+ <div id="event-Ext.form.HtmlEditor-valid"></div>/**
+ * @event valid
+ * @hide
+ */
+ <div id="method-Ext.form.HtmlEditor-setDisabled"></div>/**
+ * @method setDisabled
+ * @hide
+ */
+ <div id="cfg-Ext.form.HtmlEditor-null"></div>/**
+ * @cfg keys
+ * @hide
+ */
+});
+Ext.reg('htmleditor', Ext.form.HtmlEditor);</pre> \r
+</body>\r