]>
Commit | Line | Data |
---|---|---|
6527f429 DM |
1 | /**\r |
2 | * Layout class for {@link Ext.form.field.HtmlEditor} fields. Sizes textarea and iframe elements.\r | |
3 | * @private\r | |
4 | */\r | |
5 | Ext.define('Ext.layout.component.field.HtmlEditor', {\r | |
6 | extend: 'Ext.layout.component.field.FieldContainer',\r | |
7 | alias: ['layout.htmleditor'],\r | |
8 | \r | |
9 | type: 'htmleditor',\r | |
10 | \r | |
11 | naturalHeight: 150,\r | |
12 | naturalWidth: 300,\r | |
13 | \r | |
14 | beginLayout: function(ownerContext) {\r | |
15 | var owner = this.owner,\r | |
16 | dom;\r | |
17 | \r | |
18 | // In gecko, it can cause the browser to hang if we're running a layout with\r | |
19 | // a heap of data in the textarea (think several images with data urls).\r | |
20 | // So clear the value at the start, then re-insert it once we're done\r | |
21 | if (Ext.isGecko) {\r | |
22 | dom = owner.textareaEl.dom;\r | |
23 | this.lastValue = dom.value;\r | |
24 | dom.value = '';\r | |
25 | }\r | |
26 | this.callParent(arguments);\r | |
27 | \r | |
28 | ownerContext.toolbarContext = ownerContext.context.getCmp(owner.toolbar);\r | |
29 | ownerContext.inputCmpContext = ownerContext.context.getCmp(owner.inputCmp);\r | |
30 | ownerContext.bodyCellContext = ownerContext.getEl('bodyEl');\r | |
31 | ownerContext.textAreaContext = ownerContext.getEl('textareaEl');\r | |
32 | ownerContext.iframeContext = ownerContext.getEl('iframeEl');\r | |
33 | },\r | |
34 | \r | |
35 | beginLayoutCycle: function(ownerContext) {\r | |
36 | var me = this,\r | |
37 | widthModel = ownerContext.widthModel,\r | |
38 | heightModel = ownerContext.heightModel,\r | |
39 | owner = me.owner,\r | |
40 | iframeEl = owner.iframeEl,\r | |
41 | textareaEl = owner.textareaEl,\r | |
42 | height = (heightModel.natural || heightModel.shrinkWrap) ? me.naturalHeight : '';\r | |
43 | \r | |
44 | me.callParent(arguments);\r | |
45 | if (widthModel.shrinkWrap) {\r | |
46 | iframeEl.setStyle('width', '');\r | |
47 | textareaEl.setStyle('width', '');\r | |
48 | } else if (widthModel.natural) {\r | |
49 | ownerContext.bodyCellContext.setWidth(me.naturalWidth);\r | |
50 | }\r | |
51 | \r | |
52 | iframeEl.setStyle('height', height);\r | |
53 | textareaEl.setStyle('height', height);\r | |
54 | },\r | |
55 | \r | |
56 | finishedLayout: function(){\r | |
57 | var owner = this.owner;\r | |
58 | \r | |
59 | this.callParent(arguments);\r | |
60 | if (Ext.isGecko) {\r | |
61 | owner.textareaEl.dom.value = this.lastValue;\r | |
62 | }\r | |
63 | }\r | |
64 | }); |