1
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
|
2
|
<!--
|
3
|
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
|
4
|
* Copyright (C) 2003-2009 Frederico Caldeira Knabben
|
5
|
*
|
6
|
* == BEGIN LICENSE ==
|
7
|
*
|
8
|
* Licensed under the terms of any of the following licenses at your
|
9
|
* choice:
|
10
|
*
|
11
|
* - GNU General Public License Version 2 or later (the "GPL")
|
12
|
* http://www.gnu.org/licenses/gpl.html
|
13
|
*
|
14
|
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
|
15
|
* http://www.gnu.org/licenses/lgpl.html
|
16
|
*
|
17
|
* - Mozilla Public License Version 1.1 or later (the "MPL")
|
18
|
* http://www.mozilla.org/MPL/MPL-1.1.html
|
19
|
*
|
20
|
* == END LICENSE ==
|
21
|
*
|
22
|
* Form dialog window.
|
23
|
-->
|
24
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
25
|
<head>
|
26
|
<title></title>
|
27
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
28
|
<meta content="noindex, nofollow" name="robots" />
|
29
|
<script src="common/fck_dialog_common.js" type="text/javascript"></script>
|
30
|
<script type="text/javascript">
|
31
|
var dialog = window.parent ;
|
32
|
var oEditor = dialog.InnerDialogLoaded() ;
|
33
|
var FCK = oEditor.FCK ;
|
34
|
var FCKLang = oEditor.FCKLang ;
|
35
|
var FCKBrowserInfo = oEditor.FCKBrowserInfo ;
|
36
|
var FCKStyles = oEditor.FCKStyles ;
|
37
|
var FCKElementPath = oEditor.FCKElementPath ;
|
38
|
var FCKDomRange = oEditor.FCKDomRange ;
|
39
|
var FCKDomTools = oEditor.FCKDomTools ;
|
40
|
var FCKDomRangeIterator = oEditor.FCKDomRangeIterator ;
|
41
|
var FCKListsLib = oEditor.FCKListsLib ;
|
42
|
var AlwaysCreate = dialog.Args().CustomValue ;
|
43
|
|
44
|
String.prototype.IEquals = function()
|
45
|
{
|
46
|
var thisUpper = this.toUpperCase() ;
|
47
|
|
48
|
var aArgs = arguments ;
|
49
|
|
50
|
// The arguments could also be a single array.
|
51
|
if ( aArgs.length == 1 && aArgs[0].pop )
|
52
|
aArgs = aArgs[0] ;
|
53
|
|
54
|
for ( var i = 0 ; i < aArgs.length ; i++ )
|
55
|
{
|
56
|
if ( thisUpper == aArgs[i].toUpperCase() )
|
57
|
return true ;
|
58
|
}
|
59
|
return false ;
|
60
|
}
|
61
|
|
62
|
var CurrentContainers = [] ;
|
63
|
if ( !AlwaysCreate )
|
64
|
{
|
65
|
dialog.Selection.EnsureSelection() ;
|
66
|
CurrentContainers = FCKDomTools.GetSelectedDivContainers() ;
|
67
|
}
|
68
|
|
69
|
// Add some tabs
|
70
|
dialog.AddTab( 'General', FCKLang.DlgDivGeneralTab );
|
71
|
dialog.AddTab( 'Advanced', FCKLang.DlgDivAdvancedTab ) ;
|
72
|
|
73
|
function AddStyleOption( styleName )
|
74
|
{
|
75
|
var el = GetE( 'selStyle' ) ;
|
76
|
var opt = document.createElement( 'option' ) ;
|
77
|
opt.text = opt.value = styleName ;
|
78
|
|
79
|
if ( FCKBrowserInfo.IsIE )
|
80
|
el.add( opt ) ;
|
81
|
else
|
82
|
el.add( opt, null ) ;
|
83
|
}
|
84
|
|
85
|
function OnDialogTabChange( tabCode )
|
86
|
{
|
87
|
ShowE( 'divGeneral', tabCode == 'General' ) ;
|
88
|
ShowE( 'divAdvanced', tabCode == 'Advanced' ) ;
|
89
|
dialog.SetAutoSize( true ) ;
|
90
|
}
|
91
|
|
92
|
function GetNearestAncestorDirection( node )
|
93
|
{
|
94
|
var dir = 'ltr' ; // HTML default.
|
95
|
while ( ( node = node.parentNode ) )
|
96
|
{
|
97
|
if ( node.dir )
|
98
|
dir = node.dir ;
|
99
|
}
|
100
|
return dir ;
|
101
|
}
|
102
|
|
103
|
window.onload = function()
|
104
|
{
|
105
|
// First of all, translate the dialog box texts
|
106
|
oEditor.FCKLanguageManager.TranslatePage(document) ;
|
107
|
|
108
|
dialog.SetOkButton( true ) ;
|
109
|
dialog.SetAutoSize( true ) ;
|
110
|
|
111
|
// Popuplate the style menu
|
112
|
var styles = FCKStyles.GetStyles() ;
|
113
|
var selectableStyles = {} ;
|
114
|
for ( var i in styles )
|
115
|
{
|
116
|
if ( ! /^_FCK_/.test( i ) && styles[i].Element == 'div' )
|
117
|
selectableStyles[i] = styles[i] ;
|
118
|
}
|
119
|
if ( CurrentContainers.length <= 1 )
|
120
|
{
|
121
|
var target = CurrentContainers[0] ;
|
122
|
var match = null ;
|
123
|
for ( var i in selectableStyles )
|
124
|
{
|
125
|
if ( target && styles[i].CheckElementRemovable( target, true ) )
|
126
|
match = i ;
|
127
|
}
|
128
|
if ( !match )
|
129
|
AddStyleOption( "" ) ;
|
130
|
for ( var i in selectableStyles )
|
131
|
AddStyleOption( i ) ;
|
132
|
if ( match )
|
133
|
GetE( 'selStyle' ).value = match ;
|
134
|
|
135
|
// Set the value for other inputs
|
136
|
if ( target )
|
137
|
{
|
138
|
GetE( 'txtClass' ).value = target.className ;
|
139
|
GetE( 'txtId' ).value = target.id ;
|
140
|
GetE( 'txtLang' ).value = target.lang ;
|
141
|
GetE( 'txtInlineStyle').value = target.style.cssText ;
|
142
|
GetE( 'txtTitle' ).value = target.title ;
|
143
|
GetE( 'selLangDir').value = target.dir || GetNearestAncestorDirection( target ) ;
|
144
|
}
|
145
|
}
|
146
|
else
|
147
|
{
|
148
|
GetE( 'txtId' ).disabled = true ;
|
149
|
AddStyleOption( "" ) ;
|
150
|
for ( var i in selectableStyles )
|
151
|
AddStyleOption( i ) ;
|
152
|
}
|
153
|
}
|
154
|
|
155
|
function CreateDiv()
|
156
|
{
|
157
|
var newBlocks = [] ;
|
158
|
var range = new FCKDomRange( FCK.EditorWindow ) ;
|
159
|
range.MoveToSelection() ;
|
160
|
|
161
|
var bookmark = range.CreateBookmark() ;
|
162
|
|
163
|
// Kludge for #1592: if the bookmark nodes are in the beginning of
|
164
|
// $tagName, then move them to the nearest block element in the
|
165
|
// $tagName.
|
166
|
if ( FCKBrowserInfo.IsIE )
|
167
|
{
|
168
|
var bStart = range.GetBookmarkNode( bookmark, true ) ;
|
169
|
var bEnd = range.GetBookmarkNode( bookmark, false ) ;
|
170
|
|
171
|
var cursor ;
|
172
|
|
173
|
if ( bStart
|
174
|
&& bStart.parentNode.nodeName.IEquals( 'div' )
|
175
|
&& !bStart.previousSibling )
|
176
|
{
|
177
|
cursor = bStart ;
|
178
|
while ( ( cursor = cursor.nextSibling ) )
|
179
|
{
|
180
|
if ( FCKListsLib.BlockElements[ cursor.nodeName.toLowerCase() ] )
|
181
|
FCKDomTools.MoveNode( bStart, cursor, true ) ;
|
182
|
}
|
183
|
}
|
184
|
|
185
|
if ( bEnd
|
186
|
&& bEnd.parentNode.nodeName.IEquals( 'div' )
|
187
|
&& !bEnd.previousSibling )
|
188
|
{
|
189
|
cursor = bEnd ;
|
190
|
while ( ( cursor = cursor.nextSibling ) )
|
191
|
{
|
192
|
if ( FCKListsLib.BlockElements[ cursor.nodeName.toLowerCase() ] )
|
193
|
{
|
194
|
if ( cursor.firstChild == bStart )
|
195
|
FCKDomTools.InsertAfterNode( bStart, bEnd ) ;
|
196
|
else
|
197
|
FCKDomTools.MoveNode( bEnd, cursor, true ) ;
|
198
|
}
|
199
|
}
|
200
|
}
|
201
|
}
|
202
|
|
203
|
var iterator = new FCKDomRangeIterator( range ) ;
|
204
|
var block ;
|
205
|
|
206
|
var paragraphs = [] ;
|
207
|
while ( ( block = iterator.GetNextParagraph() ) )
|
208
|
paragraphs.push( block ) ;
|
209
|
|
210
|
// Make sure all paragraphs have the same parent.
|
211
|
var commonParent = paragraphs[0].parentNode ;
|
212
|
var tmp = [] ;
|
213
|
for ( var i = 0 ; i < paragraphs.length ; i++ )
|
214
|
{
|
215
|
block = paragraphs[i] ;
|
216
|
commonParent = FCKDomTools.GetCommonParents( block.parentNode, commonParent ).pop() ;
|
217
|
}
|
218
|
|
219
|
// The common parent must not be the following tags: table, tbody, tr, ol, ul.
|
220
|
while ( commonParent.nodeName.IEquals( 'table', 'tbody', 'tr', 'ol', 'ul' ) )
|
221
|
commonParent = commonParent.parentNode ;
|
222
|
|
223
|
// Reconstruct the block list to be processed such that all resulting blocks
|
224
|
// satisfy parentNode == commonParent.
|
225
|
var lastBlock = null ;
|
226
|
while ( paragraphs.length > 0 )
|
227
|
{
|
228
|
block = paragraphs.shift() ;
|
229
|
while ( block.parentNode != commonParent )
|
230
|
block = block.parentNode ;
|
231
|
if ( block != lastBlock )
|
232
|
tmp.push( block ) ;
|
233
|
lastBlock = block ;
|
234
|
}
|
235
|
paragraphs = tmp ;
|
236
|
|
237
|
// Split the paragraphs into groups depending on their BlockLimit element.
|
238
|
var groups = [] ;
|
239
|
var lastBlockLimit = null ;
|
240
|
for ( var i = 0 ; i < paragraphs.length ; i++ )
|
241
|
{
|
242
|
block = paragraphs[i] ;
|
243
|
var elementPath = new FCKElementPath( block ) ;
|
244
|
if ( elementPath.BlockLimit != lastBlockLimit )
|
245
|
{
|
246
|
groups.push( [] ) ;
|
247
|
lastBlockLimit = elementPath.BlockLimit ;
|
248
|
}
|
249
|
groups[groups.length - 1].push( block ) ;
|
250
|
}
|
251
|
|
252
|
// Create a DIV container for each group.
|
253
|
for ( var i = 0 ; i < groups.length ; i++ )
|
254
|
{
|
255
|
var divNode = FCK.EditorDocument.createElement( 'div' ) ;
|
256
|
groups[i][0].parentNode.insertBefore( divNode, groups[i][0] ) ;
|
257
|
for ( var j = 0 ; j < groups[i].length ; j++ )
|
258
|
FCKDomTools.MoveNode( groups[i][j], divNode ) ;
|
259
|
newBlocks.push( divNode ) ;
|
260
|
}
|
261
|
|
262
|
range.MoveToBookmark( bookmark ) ;
|
263
|
range.Select() ;
|
264
|
|
265
|
FCK.Focus() ;
|
266
|
FCK.Events.FireEvent( 'OnSelectionChange' ) ;
|
267
|
|
268
|
return newBlocks ;
|
269
|
}
|
270
|
|
271
|
function Ok()
|
272
|
{
|
273
|
oEditor.FCKUndo.SaveUndoStep() ;
|
274
|
|
275
|
if ( CurrentContainers.length < 1 )
|
276
|
CurrentContainers = CreateDiv();
|
277
|
|
278
|
var setValue = function( attrName, inputName )
|
279
|
{
|
280
|
var val = GetE( inputName ).value ;
|
281
|
for ( var i = 0 ; i < CurrentContainers.length ; i++ )
|
282
|
{
|
283
|
if ( val == '' )
|
284
|
CurrentContainers[i].removeAttribute( attrName ) ;
|
285
|
else
|
286
|
CurrentContainers[i].setAttribute( attrName, val ) ;
|
287
|
}
|
288
|
}
|
289
|
|
290
|
// Apply modifications to the DIV container according to dialog inputs.
|
291
|
if ( CurrentContainers.length == 1 )
|
292
|
{
|
293
|
setValue( 'class', 'txtClass' ) ;
|
294
|
setValue( 'id', 'txtId' ) ;
|
295
|
}
|
296
|
setValue( 'lang', 'txtLang' ) ;
|
297
|
if ( FCKBrowserInfo.IsIE )
|
298
|
{
|
299
|
for ( var i = 0 ; i < CurrentContainers.length ; i++ )
|
300
|
CurrentContainers[i].style.cssText = GetE( 'txtInlineStyle' ).value ;
|
301
|
}
|
302
|
else
|
303
|
setValue( 'style', 'txtInlineStyle' ) ;
|
304
|
setValue( 'title', 'txtTitle' ) ;
|
305
|
for ( var i = 0 ; i < CurrentContainers.length ; i++ )
|
306
|
{
|
307
|
var dir = GetE( 'selLangDir' ).value ;
|
308
|
var styleName = GetE( 'selStyle' ).value ;
|
309
|
if ( GetNearestAncestorDirection( CurrentContainers[i] ) != dir )
|
310
|
CurrentContainers[i].dir = dir ;
|
311
|
else
|
312
|
CurrentContainers[i].removeAttribute( 'dir' ) ;
|
313
|
|
314
|
if ( styleName )
|
315
|
FCKStyles.GetStyle( styleName ).ApplyToObject( CurrentContainers[i] ) ;
|
316
|
}
|
317
|
|
318
|
return true ;
|
319
|
}
|
320
|
|
321
|
</script>
|
322
|
</head>
|
323
|
<body style="overflow: hidden">
|
324
|
<div id="divGeneral">
|
325
|
<table cellspacing="0" cellpadding="0" width="100%" border="0">
|
326
|
<colgroup span="2">
|
327
|
<col width="49%" />
|
328
|
<col width="2%" />
|
329
|
<col width="49%" />
|
330
|
</colgroup>
|
331
|
<tr>
|
332
|
<td>
|
333
|
<span fcklang="DlgDivStyle">Style</span><br />
|
334
|
<select id="selStyle" style="width: 100%;">
|
335
|
</select>
|
336
|
</td>
|
337
|
<td> </td>
|
338
|
<td>
|
339
|
<span fcklang="DlgGenClass">Stylesheet Classes</span><br />
|
340
|
<input id="txtClass" style="width: 100%" type="text" />
|
341
|
</td>
|
342
|
</tr>
|
343
|
</table>
|
344
|
</div>
|
345
|
<div id="divAdvanced" style="display: none">
|
346
|
<table cellspacing="0" cellpadding="0" width="100%" border="0">
|
347
|
<colgroup span="2">
|
348
|
<col width="49%" />
|
349
|
<col width="2%" />
|
350
|
<col width="49%" />
|
351
|
</colgroup>
|
352
|
<tr>
|
353
|
<td>
|
354
|
<span fcklang="DlgGenId">Id</span><br />
|
355
|
<input style="width: 100%" type="text" id="txtId" />
|
356
|
</td>
|
357
|
<td> </td>
|
358
|
<td>
|
359
|
<span fcklang="DlgGenLangCode">Language Code</span><br />
|
360
|
<input style="width: 100%" type="text" id="txtLang" />
|
361
|
</td>
|
362
|
</tr>
|
363
|
<tr>
|
364
|
<td colspan="3"> </td>
|
365
|
</tr>
|
366
|
<tr>
|
367
|
<td colspan="3">
|
368
|
<span fcklang="DlgDivInlineStyle">Inline Style</span><br />
|
369
|
<input style="width: 100%" type="text" id="txtInlineStyle" />
|
370
|
</td>
|
371
|
</tr>
|
372
|
<tr>
|
373
|
<td colspan="3"> </td>
|
374
|
</tr>
|
375
|
<tr>
|
376
|
<td colspan="3">
|
377
|
<span fcklang="DlgGenTitle">Advisory Title</span><br />
|
378
|
<input style="width: 100%" type="text" id="txtTitle" />
|
379
|
</td>
|
380
|
</tr>
|
381
|
<tr>
|
382
|
<td> </td>
|
383
|
</tr>
|
384
|
<tr>
|
385
|
<td>
|
386
|
<span fcklang="DlgGenLangDir">Language Direction</span><br />
|
387
|
<select id="selLangDir">
|
388
|
<option fcklang="DlgGenLangDirLtr" value="ltr">Left to Right (LTR)
|
389
|
<option fcklang="DlgGenLangDirRtl" value="rtl">Right to Left (RTL)
|
390
|
</select>
|
391
|
</td>
|
392
|
</tr>
|
393
|
</table>
|
394
|
</div>
|
395
|
</body>
|
396
|
</html>
|