import v2.0.0.0_RC3 | 2012-07-01
https://github.com/lucanos/CommunityID -> http://www.itadmins.net/archives/357
This commit is contained in:
396
fckeditor/editor/dialog/fck_div.html
Normal file
396
fckeditor/editor/dialog/fck_div.html
Normal file
@ -0,0 +1,396 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
|
||||
<!--
|
||||
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
|
||||
* Copyright (C) 2003-2009 Frederico Caldeira Knabben
|
||||
*
|
||||
* == BEGIN LICENSE ==
|
||||
*
|
||||
* Licensed under the terms of any of the following licenses at your
|
||||
* choice:
|
||||
*
|
||||
* - GNU General Public License Version 2 or later (the "GPL")
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
*
|
||||
* - Mozilla Public License Version 1.1 or later (the "MPL")
|
||||
* http://www.mozilla.org/MPL/MPL-1.1.html
|
||||
*
|
||||
* == END LICENSE ==
|
||||
*
|
||||
* Form dialog window.
|
||||
-->
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title></title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta content="noindex, nofollow" name="robots" />
|
||||
<script src="common/fck_dialog_common.js" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
var dialog = window.parent ;
|
||||
var oEditor = dialog.InnerDialogLoaded() ;
|
||||
var FCK = oEditor.FCK ;
|
||||
var FCKLang = oEditor.FCKLang ;
|
||||
var FCKBrowserInfo = oEditor.FCKBrowserInfo ;
|
||||
var FCKStyles = oEditor.FCKStyles ;
|
||||
var FCKElementPath = oEditor.FCKElementPath ;
|
||||
var FCKDomRange = oEditor.FCKDomRange ;
|
||||
var FCKDomTools = oEditor.FCKDomTools ;
|
||||
var FCKDomRangeIterator = oEditor.FCKDomRangeIterator ;
|
||||
var FCKListsLib = oEditor.FCKListsLib ;
|
||||
var AlwaysCreate = dialog.Args().CustomValue ;
|
||||
|
||||
String.prototype.IEquals = function()
|
||||
{
|
||||
var thisUpper = this.toUpperCase() ;
|
||||
|
||||
var aArgs = arguments ;
|
||||
|
||||
// The arguments could also be a single array.
|
||||
if ( aArgs.length == 1 && aArgs[0].pop )
|
||||
aArgs = aArgs[0] ;
|
||||
|
||||
for ( var i = 0 ; i < aArgs.length ; i++ )
|
||||
{
|
||||
if ( thisUpper == aArgs[i].toUpperCase() )
|
||||
return true ;
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
|
||||
var CurrentContainers = [] ;
|
||||
if ( !AlwaysCreate )
|
||||
{
|
||||
dialog.Selection.EnsureSelection() ;
|
||||
CurrentContainers = FCKDomTools.GetSelectedDivContainers() ;
|
||||
}
|
||||
|
||||
// Add some tabs
|
||||
dialog.AddTab( 'General', FCKLang.DlgDivGeneralTab );
|
||||
dialog.AddTab( 'Advanced', FCKLang.DlgDivAdvancedTab ) ;
|
||||
|
||||
function AddStyleOption( styleName )
|
||||
{
|
||||
var el = GetE( 'selStyle' ) ;
|
||||
var opt = document.createElement( 'option' ) ;
|
||||
opt.text = opt.value = styleName ;
|
||||
|
||||
if ( FCKBrowserInfo.IsIE )
|
||||
el.add( opt ) ;
|
||||
else
|
||||
el.add( opt, null ) ;
|
||||
}
|
||||
|
||||
function OnDialogTabChange( tabCode )
|
||||
{
|
||||
ShowE( 'divGeneral', tabCode == 'General' ) ;
|
||||
ShowE( 'divAdvanced', tabCode == 'Advanced' ) ;
|
||||
dialog.SetAutoSize( true ) ;
|
||||
}
|
||||
|
||||
function GetNearestAncestorDirection( node )
|
||||
{
|
||||
var dir = 'ltr' ; // HTML default.
|
||||
while ( ( node = node.parentNode ) )
|
||||
{
|
||||
if ( node.dir )
|
||||
dir = node.dir ;
|
||||
}
|
||||
return dir ;
|
||||
}
|
||||
|
||||
window.onload = function()
|
||||
{
|
||||
// First of all, translate the dialog box texts
|
||||
oEditor.FCKLanguageManager.TranslatePage(document) ;
|
||||
|
||||
dialog.SetOkButton( true ) ;
|
||||
dialog.SetAutoSize( true ) ;
|
||||
|
||||
// Popuplate the style menu
|
||||
var styles = FCKStyles.GetStyles() ;
|
||||
var selectableStyles = {} ;
|
||||
for ( var i in styles )
|
||||
{
|
||||
if ( ! /^_FCK_/.test( i ) && styles[i].Element == 'div' )
|
||||
selectableStyles[i] = styles[i] ;
|
||||
}
|
||||
if ( CurrentContainers.length <= 1 )
|
||||
{
|
||||
var target = CurrentContainers[0] ;
|
||||
var match = null ;
|
||||
for ( var i in selectableStyles )
|
||||
{
|
||||
if ( target && styles[i].CheckElementRemovable( target, true ) )
|
||||
match = i ;
|
||||
}
|
||||
if ( !match )
|
||||
AddStyleOption( "" ) ;
|
||||
for ( var i in selectableStyles )
|
||||
AddStyleOption( i ) ;
|
||||
if ( match )
|
||||
GetE( 'selStyle' ).value = match ;
|
||||
|
||||
// Set the value for other inputs
|
||||
if ( target )
|
||||
{
|
||||
GetE( 'txtClass' ).value = target.className ;
|
||||
GetE( 'txtId' ).value = target.id ;
|
||||
GetE( 'txtLang' ).value = target.lang ;
|
||||
GetE( 'txtInlineStyle').value = target.style.cssText ;
|
||||
GetE( 'txtTitle' ).value = target.title ;
|
||||
GetE( 'selLangDir').value = target.dir || GetNearestAncestorDirection( target ) ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GetE( 'txtId' ).disabled = true ;
|
||||
AddStyleOption( "" ) ;
|
||||
for ( var i in selectableStyles )
|
||||
AddStyleOption( i ) ;
|
||||
}
|
||||
}
|
||||
|
||||
function CreateDiv()
|
||||
{
|
||||
var newBlocks = [] ;
|
||||
var range = new FCKDomRange( FCK.EditorWindow ) ;
|
||||
range.MoveToSelection() ;
|
||||
|
||||
var bookmark = range.CreateBookmark() ;
|
||||
|
||||
// Kludge for #1592: if the bookmark nodes are in the beginning of
|
||||
// $tagName, then move them to the nearest block element in the
|
||||
// $tagName.
|
||||
if ( FCKBrowserInfo.IsIE )
|
||||
{
|
||||
var bStart = range.GetBookmarkNode( bookmark, true ) ;
|
||||
var bEnd = range.GetBookmarkNode( bookmark, false ) ;
|
||||
|
||||
var cursor ;
|
||||
|
||||
if ( bStart
|
||||
&& bStart.parentNode.nodeName.IEquals( 'div' )
|
||||
&& !bStart.previousSibling )
|
||||
{
|
||||
cursor = bStart ;
|
||||
while ( ( cursor = cursor.nextSibling ) )
|
||||
{
|
||||
if ( FCKListsLib.BlockElements[ cursor.nodeName.toLowerCase() ] )
|
||||
FCKDomTools.MoveNode( bStart, cursor, true ) ;
|
||||
}
|
||||
}
|
||||
|
||||
if ( bEnd
|
||||
&& bEnd.parentNode.nodeName.IEquals( 'div' )
|
||||
&& !bEnd.previousSibling )
|
||||
{
|
||||
cursor = bEnd ;
|
||||
while ( ( cursor = cursor.nextSibling ) )
|
||||
{
|
||||
if ( FCKListsLib.BlockElements[ cursor.nodeName.toLowerCase() ] )
|
||||
{
|
||||
if ( cursor.firstChild == bStart )
|
||||
FCKDomTools.InsertAfterNode( bStart, bEnd ) ;
|
||||
else
|
||||
FCKDomTools.MoveNode( bEnd, cursor, true ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var iterator = new FCKDomRangeIterator( range ) ;
|
||||
var block ;
|
||||
|
||||
var paragraphs = [] ;
|
||||
while ( ( block = iterator.GetNextParagraph() ) )
|
||||
paragraphs.push( block ) ;
|
||||
|
||||
// Make sure all paragraphs have the same parent.
|
||||
var commonParent = paragraphs[0].parentNode ;
|
||||
var tmp = [] ;
|
||||
for ( var i = 0 ; i < paragraphs.length ; i++ )
|
||||
{
|
||||
block = paragraphs[i] ;
|
||||
commonParent = FCKDomTools.GetCommonParents( block.parentNode, commonParent ).pop() ;
|
||||
}
|
||||
|
||||
// The common parent must not be the following tags: table, tbody, tr, ol, ul.
|
||||
while ( commonParent.nodeName.IEquals( 'table', 'tbody', 'tr', 'ol', 'ul' ) )
|
||||
commonParent = commonParent.parentNode ;
|
||||
|
||||
// Reconstruct the block list to be processed such that all resulting blocks
|
||||
// satisfy parentNode == commonParent.
|
||||
var lastBlock = null ;
|
||||
while ( paragraphs.length > 0 )
|
||||
{
|
||||
block = paragraphs.shift() ;
|
||||
while ( block.parentNode != commonParent )
|
||||
block = block.parentNode ;
|
||||
if ( block != lastBlock )
|
||||
tmp.push( block ) ;
|
||||
lastBlock = block ;
|
||||
}
|
||||
paragraphs = tmp ;
|
||||
|
||||
// Split the paragraphs into groups depending on their BlockLimit element.
|
||||
var groups = [] ;
|
||||
var lastBlockLimit = null ;
|
||||
for ( var i = 0 ; i < paragraphs.length ; i++ )
|
||||
{
|
||||
block = paragraphs[i] ;
|
||||
var elementPath = new FCKElementPath( block ) ;
|
||||
if ( elementPath.BlockLimit != lastBlockLimit )
|
||||
{
|
||||
groups.push( [] ) ;
|
||||
lastBlockLimit = elementPath.BlockLimit ;
|
||||
}
|
||||
groups[groups.length - 1].push( block ) ;
|
||||
}
|
||||
|
||||
// Create a DIV container for each group.
|
||||
for ( var i = 0 ; i < groups.length ; i++ )
|
||||
{
|
||||
var divNode = FCK.EditorDocument.createElement( 'div' ) ;
|
||||
groups[i][0].parentNode.insertBefore( divNode, groups[i][0] ) ;
|
||||
for ( var j = 0 ; j < groups[i].length ; j++ )
|
||||
FCKDomTools.MoveNode( groups[i][j], divNode ) ;
|
||||
newBlocks.push( divNode ) ;
|
||||
}
|
||||
|
||||
range.MoveToBookmark( bookmark ) ;
|
||||
range.Select() ;
|
||||
|
||||
FCK.Focus() ;
|
||||
FCK.Events.FireEvent( 'OnSelectionChange' ) ;
|
||||
|
||||
return newBlocks ;
|
||||
}
|
||||
|
||||
function Ok()
|
||||
{
|
||||
oEditor.FCKUndo.SaveUndoStep() ;
|
||||
|
||||
if ( CurrentContainers.length < 1 )
|
||||
CurrentContainers = CreateDiv();
|
||||
|
||||
var setValue = function( attrName, inputName )
|
||||
{
|
||||
var val = GetE( inputName ).value ;
|
||||
for ( var i = 0 ; i < CurrentContainers.length ; i++ )
|
||||
{
|
||||
if ( val == '' )
|
||||
CurrentContainers[i].removeAttribute( attrName ) ;
|
||||
else
|
||||
CurrentContainers[i].setAttribute( attrName, val ) ;
|
||||
}
|
||||
}
|
||||
|
||||
// Apply modifications to the DIV container according to dialog inputs.
|
||||
if ( CurrentContainers.length == 1 )
|
||||
{
|
||||
setValue( 'class', 'txtClass' ) ;
|
||||
setValue( 'id', 'txtId' ) ;
|
||||
}
|
||||
setValue( 'lang', 'txtLang' ) ;
|
||||
if ( FCKBrowserInfo.IsIE )
|
||||
{
|
||||
for ( var i = 0 ; i < CurrentContainers.length ; i++ )
|
||||
CurrentContainers[i].style.cssText = GetE( 'txtInlineStyle' ).value ;
|
||||
}
|
||||
else
|
||||
setValue( 'style', 'txtInlineStyle' ) ;
|
||||
setValue( 'title', 'txtTitle' ) ;
|
||||
for ( var i = 0 ; i < CurrentContainers.length ; i++ )
|
||||
{
|
||||
var dir = GetE( 'selLangDir' ).value ;
|
||||
var styleName = GetE( 'selStyle' ).value ;
|
||||
if ( GetNearestAncestorDirection( CurrentContainers[i] ) != dir )
|
||||
CurrentContainers[i].dir = dir ;
|
||||
else
|
||||
CurrentContainers[i].removeAttribute( 'dir' ) ;
|
||||
|
||||
if ( styleName )
|
||||
FCKStyles.GetStyle( styleName ).ApplyToObject( CurrentContainers[i] ) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body style="overflow: hidden">
|
||||
<div id="divGeneral">
|
||||
<table cellspacing="0" cellpadding="0" width="100%" border="0">
|
||||
<colgroup span="2">
|
||||
<col width="49%" />
|
||||
<col width="2%" />
|
||||
<col width="49%" />
|
||||
</colgroup>
|
||||
<tr>
|
||||
<td>
|
||||
<span fcklang="DlgDivStyle">Style</span><br />
|
||||
<select id="selStyle" style="width: 100%;">
|
||||
</select>
|
||||
</td>
|
||||
<td> </td>
|
||||
<td>
|
||||
<span fcklang="DlgGenClass">Stylesheet Classes</span><br />
|
||||
<input id="txtClass" style="width: 100%" type="text" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div id="divAdvanced" style="display: none">
|
||||
<table cellspacing="0" cellpadding="0" width="100%" border="0">
|
||||
<colgroup span="2">
|
||||
<col width="49%" />
|
||||
<col width="2%" />
|
||||
<col width="49%" />
|
||||
</colgroup>
|
||||
<tr>
|
||||
<td>
|
||||
<span fcklang="DlgGenId">Id</span><br />
|
||||
<input style="width: 100%" type="text" id="txtId" />
|
||||
</td>
|
||||
<td> </td>
|
||||
<td>
|
||||
<span fcklang="DlgGenLangCode">Language Code</span><br />
|
||||
<input style="width: 100%" type="text" id="txtLang" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<span fcklang="DlgDivInlineStyle">Inline Style</span><br />
|
||||
<input style="width: 100%" type="text" id="txtInlineStyle" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<span fcklang="DlgGenTitle">Advisory Title</span><br />
|
||||
<input style="width: 100%" type="text" id="txtTitle" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span fcklang="DlgGenLangDir">Language Direction</span><br />
|
||||
<select id="selLangDir">
|
||||
<option fcklang="DlgGenLangDirLtr" value="ltr">Left to Right (LTR)
|
||||
<option fcklang="DlgGenLangDirRtl" value="rtl">Right to Left (RTL)
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user