1 | /*
|
---|
2 | Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
|
---|
3 | For licensing, see LICENSE.html or http://ckeditor.com/license
|
---|
4 | */
|
---|
5 |
|
---|
6 | CKEDITOR.themes.add( 'default', (function()
|
---|
7 | {
|
---|
8 | return {
|
---|
9 | build : function( editor, themePath )
|
---|
10 | {
|
---|
11 | var name = editor.name,
|
---|
12 | element = editor.element,
|
---|
13 | elementMode = editor.elementMode;
|
---|
14 |
|
---|
15 | if ( !element || elementMode == CKEDITOR.ELEMENT_MODE_NONE )
|
---|
16 | return;
|
---|
17 |
|
---|
18 | if ( elementMode == CKEDITOR.ELEMENT_MODE_REPLACE )
|
---|
19 | element.hide();
|
---|
20 |
|
---|
21 | // Get the HTML for the predefined spaces.
|
---|
22 | var topHtml = editor.fire( 'themeSpace', { space : 'top', html : '' } ).html;
|
---|
23 | var contentsHtml = editor.fire( 'themeSpace', { space : 'contents', html : '' } ).html;
|
---|
24 | var bottomHtml = editor.fireOnce( 'themeSpace', { space : 'bottom', html : '' } ).html;
|
---|
25 |
|
---|
26 | var height = contentsHtml && editor.config.height;
|
---|
27 |
|
---|
28 | var tabIndex = editor.config.tabIndex || editor.element.getAttribute( 'tabindex' ) || 0;
|
---|
29 |
|
---|
30 | // The editor height is considered only if the contents space got filled.
|
---|
31 | if ( !contentsHtml )
|
---|
32 | height = 'auto';
|
---|
33 | else if ( !isNaN( height ) )
|
---|
34 | height += 'px';
|
---|
35 |
|
---|
36 | var style = '';
|
---|
37 | var width = editor.config.width;
|
---|
38 |
|
---|
39 | if ( width )
|
---|
40 | {
|
---|
41 | if ( !isNaN( width ) )
|
---|
42 | width += 'px';
|
---|
43 |
|
---|
44 | style += "width: " + width + ";";
|
---|
45 | }
|
---|
46 |
|
---|
47 | var container = CKEDITOR.dom.element.createFromHtml( [
|
---|
48 | '<span' +
|
---|
49 | ' id="cke_', name, '"' +
|
---|
50 | ' onmousedown="return false;"' +
|
---|
51 | ' class="', editor.skinClass, '"' +
|
---|
52 | ' dir="', editor.lang.dir, '"' +
|
---|
53 | ' title="', ( CKEDITOR.env.gecko ? ' ' : '' ), '"' +
|
---|
54 | ' lang="', editor.langCode, '"' +
|
---|
55 | ' tabindex="' + tabIndex + '"' +
|
---|
56 | ( style ? ' style="' + style + '"' : '' ) +
|
---|
57 | '>' +
|
---|
58 | '<span class="' , CKEDITOR.env.cssClass, '">' +
|
---|
59 | '<span class="cke_wrapper cke_', editor.lang.dir, '">' +
|
---|
60 | '<table class="cke_editor" border="0" cellspacing="0" cellpadding="0"><tbody>' +
|
---|
61 | '<tr', topHtml ? '' : ' style="display:none"', '><td id="cke_top_' , name, '" class="cke_top">' , topHtml , '</td></tr>' +
|
---|
62 | '<tr', contentsHtml ? '' : ' style="display:none"', '><td id="cke_contents_', name, '" class="cke_contents" style="height:', height, '">', contentsHtml, '</td></tr>' +
|
---|
63 | '<tr', bottomHtml ? '' : ' style="display:none"', '><td id="cke_bottom_' , name, '" class="cke_bottom">' , bottomHtml , '</td></tr>' +
|
---|
64 | '</tbody></table>' +
|
---|
65 | //Hide the container when loading skins, later restored by skin css.
|
---|
66 | '<style>.', editor.skinClass, '{visibility:hidden;}</style>' +
|
---|
67 | '</span>' +
|
---|
68 | '</span>' +
|
---|
69 | '</span>' ].join( '' ) );
|
---|
70 |
|
---|
71 | container.getChild( [0, 0, 0, 0, 0] ).unselectable();
|
---|
72 | container.getChild( [0, 0, 0, 0, 2] ).unselectable();
|
---|
73 |
|
---|
74 | if ( elementMode == CKEDITOR.ELEMENT_MODE_REPLACE )
|
---|
75 | container.insertAfter( element );
|
---|
76 | else
|
---|
77 | element.append( container );
|
---|
78 |
|
---|
79 | /**
|
---|
80 | * The DOM element that holds the main editor interface.
|
---|
81 | * @name CKEDITOR.editor.prototype.container
|
---|
82 | * @type CKEDITOR.dom.element
|
---|
83 | * @example
|
---|
84 | * var editor = CKEDITOR.instances.editor1;
|
---|
85 | * alert( <b>editor.container</b>.getName() ); "span"
|
---|
86 | */
|
---|
87 | editor.container = container;
|
---|
88 |
|
---|
89 | // Disable browser context menu for editor's chrome.
|
---|
90 | container.disableContextMenu();
|
---|
91 |
|
---|
92 | editor.fireOnce( 'themeLoaded' );
|
---|
93 | editor.fireOnce( 'uiReady' );
|
---|
94 | },
|
---|
95 |
|
---|
96 | buildDialog : function( editor )
|
---|
97 | {
|
---|
98 | var baseIdNumber = CKEDITOR.tools.getNextNumber();
|
---|
99 |
|
---|
100 | var element = CKEDITOR.dom.element.createFromHtml( [
|
---|
101 | '<div id="cke_' + editor.name.replace('.', '\\.') + '_dialog" class="cke_skin_', editor.skinName,
|
---|
102 | '" dir="', editor.lang.dir, '"' +
|
---|
103 | ' lang="', editor.langCode, '"' +
|
---|
104 | '>' +
|
---|
105 |
|
---|
106 | '<div class="cke_dialog', ' ' + CKEDITOR.env.cssClass,
|
---|
107 | ' cke_', editor.lang.dir, '" style="position:absolute">' +
|
---|
108 | '<div class="%body">' +
|
---|
109 | '<div id="%title#" class="%title"></div>' +
|
---|
110 | '<div id="%close_button#" class="%close_button">' +
|
---|
111 | '<span>X</span>' +
|
---|
112 | '</div>' +
|
---|
113 | '<div id="%tabs#" class="%tabs"></div>' +
|
---|
114 | '<div id="%contents#" class="%contents"></div>' +
|
---|
115 | '<div id="%footer#" class="%footer"></div>' +
|
---|
116 | '</div>' +
|
---|
117 | '<div id="%tl#" class="%tl"></div>' +
|
---|
118 | '<div id="%tc#" class="%tc"></div>' +
|
---|
119 | '<div id="%tr#" class="%tr"></div>' +
|
---|
120 | '<div id="%ml#" class="%ml"></div>' +
|
---|
121 | '<div id="%mr#" class="%mr"></div>' +
|
---|
122 | '<div id="%bl#" class="%bl"></div>' +
|
---|
123 | '<div id="%bc#" class="%bc"></div>' +
|
---|
124 | '<div id="%br#" class="%br"></div>' +
|
---|
125 | '</div>',
|
---|
126 |
|
---|
127 | //Hide the container when loading skins, later restored by skin css.
|
---|
128 | ( CKEDITOR.env.ie ? '' : '<style>.cke_dialog{visibility:hidden;}</style>' ),
|
---|
129 |
|
---|
130 | '</div>'
|
---|
131 | ].join( '' )
|
---|
132 | .replace( /#/g, '_' + baseIdNumber )
|
---|
133 | .replace( /%/g, 'cke_dialog_' ) );
|
---|
134 |
|
---|
135 | var body = element.getChild( [ 0, 0 ] );
|
---|
136 |
|
---|
137 | // Make the Title and Close Button unselectable.
|
---|
138 | body.getChild( 0 ).unselectable();
|
---|
139 | body.getChild( 1 ).unselectable();
|
---|
140 |
|
---|
141 |
|
---|
142 | return {
|
---|
143 | element : element,
|
---|
144 | parts :
|
---|
145 | {
|
---|
146 | dialog : element.getChild( 0 ),
|
---|
147 | title : body.getChild( 0 ),
|
---|
148 | close : body.getChild( 1 ),
|
---|
149 | tabs : body.getChild( 2 ),
|
---|
150 | contents : body.getChild( 3 ),
|
---|
151 | footer : body.getChild( 4 )
|
---|
152 | }
|
---|
153 | };
|
---|
154 | },
|
---|
155 |
|
---|
156 | destroy : function( editor )
|
---|
157 | {
|
---|
158 | var container = editor.container,
|
---|
159 | panels = editor.panels;
|
---|
160 |
|
---|
161 | /*
|
---|
162 | * IE BUG: Removing the editor DOM elements while the selection is inside
|
---|
163 | * the editing area would break IE7/8's selection system. So we need to put
|
---|
164 | * the selection back to the parent document without scrolling the window.
|
---|
165 | * (#3812)
|
---|
166 | */
|
---|
167 | if ( CKEDITOR.env.ie )
|
---|
168 | {
|
---|
169 | container.setStyle( 'display', 'none' );
|
---|
170 |
|
---|
171 | var $range = document.body.createTextRange();
|
---|
172 | $range.moveToElementText( container.$ );
|
---|
173 | try
|
---|
174 | {
|
---|
175 | // Putting the selection to a display:none element - this will certainly
|
---|
176 | // fail. But! We've just put the selection document back to the parent
|
---|
177 | // document without scrolling the window!
|
---|
178 | $range.select();
|
---|
179 | }
|
---|
180 | catch ( e ) {}
|
---|
181 | }
|
---|
182 |
|
---|
183 | if ( container )
|
---|
184 | container.remove();
|
---|
185 |
|
---|
186 | for( var i = 0 ; panels && i < panels.length ; i++ )
|
---|
187 | panels[ i ].remove();
|
---|
188 |
|
---|
189 | if ( editor.elementMode == CKEDITOR.ELEMENT_MODE_REPLACE )
|
---|
190 | {
|
---|
191 | editor.element.show();
|
---|
192 | delete editor.element;
|
---|
193 | }
|
---|
194 | }
|
---|
195 | };
|
---|
196 | })() );
|
---|
197 |
|
---|
198 | CKEDITOR.editor.prototype.getThemeSpace = function( spaceName )
|
---|
199 | {
|
---|
200 | var spacePrefix = 'cke_' + spaceName;
|
---|
201 | var space = this._[ spacePrefix ] ||
|
---|
202 | ( this._[ spacePrefix ] = CKEDITOR.document.getById( spacePrefix + '_' + this.name ) );
|
---|
203 | return space;
|
---|
204 | };
|
---|
205 |
|
---|
206 | CKEDITOR.editor.prototype.resize = function( width, height, isContentHeight, resizeInner )
|
---|
207 | {
|
---|
208 | var numberRegex = /^\d+$/;
|
---|
209 | if ( numberRegex.test( width ) )
|
---|
210 | width += 'px';
|
---|
211 |
|
---|
212 | var contents = CKEDITOR.document.getById( 'cke_contents_' + this.name );
|
---|
213 | var outer = resizeInner ? contents.getAscendant( 'table' ).getParent()
|
---|
214 | : contents.getAscendant( 'table' ).getParent().getParent().getParent();
|
---|
215 |
|
---|
216 | // Resize the width first.
|
---|
217 | // WEBKIT BUG: Webkit requires that we put the editor off from display when we
|
---|
218 | // resize it. If we don't, the browser crashes!
|
---|
219 | CKEDITOR.env.webkit && outer.setStyle( 'display', 'none' );
|
---|
220 | outer.setStyle( 'width', width );
|
---|
221 | if ( CKEDITOR.env.webkit )
|
---|
222 | {
|
---|
223 | outer.$.offsetWidth;
|
---|
224 | outer.setStyle( 'display', '' );
|
---|
225 | }
|
---|
226 |
|
---|
227 | // Get the height delta between the outer table and the content area.
|
---|
228 | // If we're setting the content area's height, then we don't need the delta.
|
---|
229 | var delta = isContentHeight ? 0 : ( outer.$.offsetHeight || 0 ) - ( contents.$.clientHeight || 0 );
|
---|
230 | contents.setStyle( 'height', Math.max( height - delta, 0 ) + 'px' );
|
---|
231 |
|
---|
232 | // Emit a resize event.
|
---|
233 | this.fire( 'resize' );
|
---|
234 | };
|
---|
235 |
|
---|
236 | CKEDITOR.editor.prototype.getResizable = function()
|
---|
237 | {
|
---|
238 | return this.container.getChild( [ 0, 0 ] );
|
---|
239 | };
|
---|