123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401 |
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
- <!--
- * FCKeditor - The text editor for Internet - http://www.fckeditor.net
- * Copyright (C) 2003-2010 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>
- <style type="text/css">
- body, td, input, textarea, select, label { font-family: Arial, Verdana, Geneva, helvetica, sans-serif; font-size: 11px; }
- </style>
- </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>
|