code
stringlengths
1
2.08M
language
stringclasses
1 value
/* * 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 == * * Defines the FCKToolbarSet object that is used to load and draw the * toolbar. */ function FCKToolbarSet_Create( overhideLocation ) { var oToolbarSet ; var sLocation = overhideLocation || FCKConfig.ToolbarLocation ; switch ( sLocation ) { case 'In' : document.getElementById( 'xToolbarRow' ).style.display = '' ; oToolbarSet = new FCKToolbarSet( document ) ; break ; case 'None' : oToolbarSet = new FCKToolbarSet( document ) ; break ; // case 'OutTop' : // Not supported. default : FCK.Events.AttachEvent( 'OnBlur', FCK_OnBlur ) ; FCK.Events.AttachEvent( 'OnFocus', FCK_OnFocus ) ; var eToolbarTarget ; // Out:[TargetWindow]([TargetId]) var oOutMatch = sLocation.match( /^Out:(.+)\((\w+)\)$/ ) ; if ( oOutMatch ) { if ( FCKBrowserInfo.IsAIR ) FCKAdobeAIR.ToolbarSet_GetOutElement( window, oOutMatch ) ; else eToolbarTarget = eval( 'parent.' + oOutMatch[1] ).document.getElementById( oOutMatch[2] ) ; } else { // Out:[TargetId] oOutMatch = sLocation.match( /^Out:(\w+)$/ ) ; if ( oOutMatch ) eToolbarTarget = parent.document.getElementById( oOutMatch[1] ) ; } if ( !eToolbarTarget ) { alert( 'Invalid value for "ToolbarLocation"' ) ; return arguments.callee( 'In' ); } // If it is a shared toolbar, it may be already available in the target element. oToolbarSet = eToolbarTarget.__FCKToolbarSet ; if ( oToolbarSet ) break ; // Create the IFRAME that will hold the toolbar inside the target element. var eToolbarIFrame = FCKTools.GetElementDocument( eToolbarTarget ).createElement( 'iframe' ) ; eToolbarIFrame.src = 'javascript:void(0)' ; eToolbarIFrame.frameBorder = 0 ; eToolbarIFrame.width = '100%' ; eToolbarIFrame.height = '10' ; eToolbarTarget.appendChild( eToolbarIFrame ) ; eToolbarIFrame.unselectable = 'on' ; // Write the basic HTML for the toolbar (copy from the editor main page). var eTargetDocument = eToolbarIFrame.contentWindow.document ; // Workaround for Safari 12256. Ticket #63 var sBase = '' ; if ( FCKBrowserInfo.IsSafari ) sBase = '<base href="' + window.document.location + '">' ; // Initialize the IFRAME document body. eTargetDocument.open() ; eTargetDocument.write( '<html><head>' + sBase + '<script type="text/javascript"> var adjust = function() { window.frameElement.height = document.body.scrollHeight ; }; ' + 'window.onresize = window.onload = ' + 'function(){' // poll scrollHeight until it no longer changes for 1 sec. + 'var timer = null;' + 'var lastHeight = -1;' + 'var lastChange = 0;' + 'var poller = function(){' + 'var currentHeight = document.body.scrollHeight || 0;' + 'var currentTime = (new Date()).getTime();' + 'if (currentHeight != lastHeight){' + 'lastChange = currentTime;' + 'adjust();' + 'lastHeight = document.body.scrollHeight;' + '}' + 'if (lastChange < currentTime - 1000) clearInterval(timer);' + '};' + 'timer = setInterval(poller, 100);' + '}' + '</script></head><body style="overflow: hidden">' + document.getElementById( 'xToolbarSpace' ).innerHTML + '</body></html>' ) ; eTargetDocument.close() ; if( FCKBrowserInfo.IsAIR ) FCKAdobeAIR.ToolbarSet_InitOutFrame( eTargetDocument ) ; FCKTools.AddEventListener( eTargetDocument, 'contextmenu', FCKTools.CancelEvent ) ; // Load external resources (must be done here, otherwise Firefox will not // have the document DOM ready to be used right away. FCKTools.AppendStyleSheet( eTargetDocument, FCKConfig.SkinEditorCSS ) ; oToolbarSet = eToolbarTarget.__FCKToolbarSet = new FCKToolbarSet( eTargetDocument ) ; oToolbarSet._IFrame = eToolbarIFrame ; if ( FCK.IECleanup ) FCK.IECleanup.AddItem( eToolbarTarget, FCKToolbarSet_Target_Cleanup ) ; } oToolbarSet.CurrentInstance = FCK ; if ( !oToolbarSet.ToolbarItems ) oToolbarSet.ToolbarItems = FCKToolbarItems ; FCK.AttachToOnSelectionChange( oToolbarSet.RefreshItemsState ) ; return oToolbarSet ; } function FCK_OnBlur( editorInstance ) { var eToolbarSet = editorInstance.ToolbarSet ; if ( eToolbarSet.CurrentInstance == editorInstance ) eToolbarSet.Disable() ; } function FCK_OnFocus( editorInstance ) { var oToolbarset = editorInstance.ToolbarSet ; var oInstance = editorInstance || FCK ; // Unregister the toolbar window from the current instance. oToolbarset.CurrentInstance.FocusManager.RemoveWindow( oToolbarset._IFrame.contentWindow ) ; // Set the new current instance. oToolbarset.CurrentInstance = oInstance ; // Register the toolbar window in the current instance. oInstance.FocusManager.AddWindow( oToolbarset._IFrame.contentWindow, true ) ; oToolbarset.Enable() ; } function FCKToolbarSet_Cleanup() { this._TargetElement = null ; this._IFrame = null ; } function FCKToolbarSet_Target_Cleanup() { this.__FCKToolbarSet = null ; } var FCKToolbarSet = function( targetDocument ) { this._Document = targetDocument ; // Get the element that will hold the elements structure. this._TargetElement = targetDocument.getElementById( 'xToolbar' ) ; // Setup the expand and collapse handlers. var eExpandHandle = targetDocument.getElementById( 'xExpandHandle' ) ; var eCollapseHandle = targetDocument.getElementById( 'xCollapseHandle' ) ; eExpandHandle.title = FCKLang.ToolbarExpand ; FCKTools.AddEventListener( eExpandHandle, 'click', FCKToolbarSet_Expand_OnClick ) ; eCollapseHandle.title = FCKLang.ToolbarCollapse ; FCKTools.AddEventListener( eCollapseHandle, 'click', FCKToolbarSet_Collapse_OnClick ) ; // Set the toolbar state at startup. if ( !FCKConfig.ToolbarCanCollapse || FCKConfig.ToolbarStartExpanded ) this.Expand() ; else this.Collapse() ; // Enable/disable the collapse handler eCollapseHandle.style.display = FCKConfig.ToolbarCanCollapse ? '' : 'none' ; if ( FCKConfig.ToolbarCanCollapse ) eCollapseHandle.style.display = '' ; else targetDocument.getElementById( 'xTBLeftBorder' ).style.display = '' ; // Set the default properties. this.Toolbars = new Array() ; this.IsLoaded = false ; if ( FCK.IECleanup ) FCK.IECleanup.AddItem( this, FCKToolbarSet_Cleanup ) ; } function FCKToolbarSet_Expand_OnClick() { FCK.ToolbarSet.Expand() ; } function FCKToolbarSet_Collapse_OnClick() { FCK.ToolbarSet.Collapse() ; } FCKToolbarSet.prototype.Expand = function() { this._ChangeVisibility( false ) ; } FCKToolbarSet.prototype.Collapse = function() { this._ChangeVisibility( true ) ; } FCKToolbarSet.prototype._ChangeVisibility = function( collapse ) { this._Document.getElementById( 'xCollapsed' ).style.display = collapse ? '' : 'none' ; this._Document.getElementById( 'xExpanded' ).style.display = collapse ? 'none' : '' ; if ( FCKBrowserInfo.IsGecko ) { // I had to use "setTimeout" because Gecko was not responding in a right // way when calling window.onresize() directly. FCKTools.RunFunction( window.onresize ) ; } } FCKToolbarSet.prototype.Load = function( toolbarSetName ) { this.Name = toolbarSetName ; this.Items = new Array() ; // Reset the array of toolbar items that are active only on WYSIWYG mode. this.ItemsWysiwygOnly = new Array() ; // Reset the array of toolbar items that are sensitive to the cursor position. this.ItemsContextSensitive = new Array() ; // Cleanup the target element. this._TargetElement.innerHTML = '' ; var ToolbarSet = FCKConfig.ToolbarSets[toolbarSetName] ; if ( !ToolbarSet ) { alert( FCKLang.UnknownToolbarSet.replace( /%1/g, toolbarSetName ) ) ; return ; } this.Toolbars = new Array() ; for ( var x = 0 ; x < ToolbarSet.length ; x++ ) { var oToolbarItems = ToolbarSet[x] ; // If the configuration for the toolbar is missing some element or has any extra comma // this item won't be valid, so skip it and keep on processing. if ( !oToolbarItems ) continue ; var oToolbar ; if ( typeof( oToolbarItems ) == 'string' ) { if ( oToolbarItems == '/' ) oToolbar = new FCKToolbarBreak() ; } else { oToolbar = new FCKToolbar() ; for ( var j = 0 ; j < oToolbarItems.length ; j++ ) { var sItem = oToolbarItems[j] ; if ( sItem == '-') oToolbar.AddSeparator() ; else { var oItem = FCKToolbarItems.GetItem( sItem ) ; if ( oItem ) { oToolbar.AddItem( oItem ) ; this.Items.push( oItem ) ; if ( !oItem.SourceView ) this.ItemsWysiwygOnly.push( oItem ) ; if ( oItem.ContextSensitive ) this.ItemsContextSensitive.push( oItem ) ; } } } // oToolbar.AddTerminator() ; } oToolbar.Create( this._TargetElement ) ; this.Toolbars[ this.Toolbars.length ] = oToolbar ; } FCKTools.DisableSelection( this._Document.getElementById( 'xCollapseHandle' ).parentNode ) ; if ( FCK.Status != FCK_STATUS_COMPLETE ) FCK.Events.AttachEvent( 'OnStatusChange', this.RefreshModeState ) ; else this.RefreshModeState() ; this.IsLoaded = true ; this.IsEnabled = true ; FCKTools.RunFunction( this.OnLoad ) ; } FCKToolbarSet.prototype.Enable = function() { if ( this.IsEnabled ) return ; this.IsEnabled = true ; var aItems = this.Items ; for ( var i = 0 ; i < aItems.length ; i++ ) aItems[i].RefreshState() ; } FCKToolbarSet.prototype.Disable = function() { if ( !this.IsEnabled ) return ; this.IsEnabled = false ; var aItems = this.Items ; for ( var i = 0 ; i < aItems.length ; i++ ) aItems[i].Disable() ; } FCKToolbarSet.prototype.RefreshModeState = function( editorInstance ) { if ( FCK.Status != FCK_STATUS_COMPLETE ) return ; var oToolbarSet = editorInstance ? editorInstance.ToolbarSet : this ; var aItems = oToolbarSet.ItemsWysiwygOnly ; if ( FCK.EditMode == FCK_EDITMODE_WYSIWYG ) { // Enable all buttons that are available on WYSIWYG mode only. for ( var i = 0 ; i < aItems.length ; i++ ) aItems[i].Enable() ; // Refresh the buttons state. oToolbarSet.RefreshItemsState( editorInstance ) ; } else { // Refresh the buttons state. oToolbarSet.RefreshItemsState( editorInstance ) ; // Disable all buttons that are available on WYSIWYG mode only. for ( var j = 0 ; j < aItems.length ; j++ ) aItems[j].Disable() ; } } FCKToolbarSet.prototype.RefreshItemsState = function( editorInstance ) { var aItems = ( editorInstance ? editorInstance.ToolbarSet : this ).ItemsContextSensitive ; for ( var i = 0 ; i < aItems.length ; i++ ) aItems[i].RefreshState() ; }
JavaScript
/* * 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 == * * Defines the FCK.ContextMenu object that is responsible for all * Context Menu operations in the editing area. */ FCK.ContextMenu = new Object() ; FCK.ContextMenu.Listeners = new Array() ; FCK.ContextMenu.RegisterListener = function( listener ) { if ( listener ) this.Listeners.push( listener ) ; } function FCK_ContextMenu_Init() { var oInnerContextMenu = FCK.ContextMenu._InnerContextMenu = new FCKContextMenu( FCKBrowserInfo.IsIE ? window : window.parent, FCKLang.Dir ) ; oInnerContextMenu.CtrlDisable = FCKConfig.BrowserContextMenuOnCtrl ; oInnerContextMenu.OnBeforeOpen = FCK_ContextMenu_OnBeforeOpen ; oInnerContextMenu.OnItemClick = FCK_ContextMenu_OnItemClick ; // Get the registering function. var oMenu = FCK.ContextMenu ; // Register all configured context menu listeners. for ( var i = 0 ; i < FCKConfig.ContextMenu.length ; i++ ) oMenu.RegisterListener( FCK_ContextMenu_GetListener( FCKConfig.ContextMenu[i] ) ) ; } function FCK_ContextMenu_GetListener( listenerName ) { switch ( listenerName ) { case 'Generic' : return { AddItems : function( menu, tag, tagName ) { menu.AddItem( 'Cut' , FCKLang.Cut , 7, FCKCommands.GetCommand( 'Cut' ).GetState() == FCK_TRISTATE_DISABLED ) ; menu.AddItem( 'Copy' , FCKLang.Copy , 8, FCKCommands.GetCommand( 'Copy' ).GetState() == FCK_TRISTATE_DISABLED ) ; menu.AddItem( 'Paste' , FCKLang.Paste , 9, FCKCommands.GetCommand( 'Paste' ).GetState() == FCK_TRISTATE_DISABLED ) ; }} ; case 'Table' : return { AddItems : function( menu, tag, tagName ) { var bIsTable = ( tagName == 'TABLE' ) ; var bIsCell = ( !bIsTable && FCKSelection.HasAncestorNode( 'TABLE' ) ) ; if ( bIsCell ) { menu.AddSeparator() ; var oItem = menu.AddItem( 'Cell' , FCKLang.CellCM ) ; oItem.AddItem( 'TableInsertCellBefore' , FCKLang.InsertCellBefore, 69 ) ; oItem.AddItem( 'TableInsertCellAfter' , FCKLang.InsertCellAfter, 58 ) ; oItem.AddItem( 'TableDeleteCells' , FCKLang.DeleteCells, 59 ) ; if ( FCKBrowserInfo.IsGecko ) oItem.AddItem( 'TableMergeCells' , FCKLang.MergeCells, 60, FCKCommands.GetCommand( 'TableMergeCells' ).GetState() == FCK_TRISTATE_DISABLED ) ; else { oItem.AddItem( 'TableMergeRight' , FCKLang.MergeRight, 60, FCKCommands.GetCommand( 'TableMergeRight' ).GetState() == FCK_TRISTATE_DISABLED ) ; oItem.AddItem( 'TableMergeDown' , FCKLang.MergeDown, 60, FCKCommands.GetCommand( 'TableMergeDown' ).GetState() == FCK_TRISTATE_DISABLED ) ; } oItem.AddItem( 'TableHorizontalSplitCell' , FCKLang.HorizontalSplitCell, 61, FCKCommands.GetCommand( 'TableHorizontalSplitCell' ).GetState() == FCK_TRISTATE_DISABLED ) ; oItem.AddItem( 'TableVerticalSplitCell' , FCKLang.VerticalSplitCell, 61, FCKCommands.GetCommand( 'TableVerticalSplitCell' ).GetState() == FCK_TRISTATE_DISABLED ) ; oItem.AddSeparator() ; oItem.AddItem( 'TableCellProp' , FCKLang.CellProperties, 57, FCKCommands.GetCommand( 'TableCellProp' ).GetState() == FCK_TRISTATE_DISABLED ) ; menu.AddSeparator() ; oItem = menu.AddItem( 'Row' , FCKLang.RowCM ) ; oItem.AddItem( 'TableInsertRowBefore' , FCKLang.InsertRowBefore, 70 ) ; oItem.AddItem( 'TableInsertRowAfter' , FCKLang.InsertRowAfter, 62 ) ; oItem.AddItem( 'TableDeleteRows' , FCKLang.DeleteRows, 63 ) ; menu.AddSeparator() ; oItem = menu.AddItem( 'Column' , FCKLang.ColumnCM ) ; oItem.AddItem( 'TableInsertColumnBefore', FCKLang.InsertColumnBefore, 71 ) ; oItem.AddItem( 'TableInsertColumnAfter' , FCKLang.InsertColumnAfter, 64 ) ; oItem.AddItem( 'TableDeleteColumns' , FCKLang.DeleteColumns, 65 ) ; } if ( bIsTable || bIsCell ) { menu.AddSeparator() ; menu.AddItem( 'TableDelete' , FCKLang.TableDelete ) ; menu.AddItem( 'TableProp' , FCKLang.TableProperties, 39 ) ; } }} ; case 'Link' : return { AddItems : function( menu, tag, tagName ) { var bInsideLink = ( tagName == 'A' || FCKSelection.HasAncestorNode( 'A' ) ) ; if ( bInsideLink || FCK.GetNamedCommandState( 'Unlink' ) != FCK_TRISTATE_DISABLED ) { // Go up to the anchor to test its properties var oLink = FCKSelection.MoveToAncestorNode( 'A' ) ; var bIsAnchor = ( oLink && oLink.name.length > 0 && oLink.href.length == 0 ) ; // If it isn't a link then don't add the Link context menu if ( bIsAnchor ) return ; menu.AddSeparator() ; menu.AddItem( 'VisitLink', FCKLang.VisitLink ) ; menu.AddSeparator() ; if ( bInsideLink ) menu.AddItem( 'Link', FCKLang.EditLink , 34 ) ; menu.AddItem( 'Unlink' , FCKLang.RemoveLink , 35 ) ; } }} ; case 'Image' : return { AddItems : function( menu, tag, tagName ) { if ( tagName == 'IMG' && !tag.getAttribute( '_fckfakelement' ) ) { menu.AddSeparator() ; menu.AddItem( 'Image', FCKLang.ImageProperties, 37 ) ; } }} ; case 'Anchor' : return { AddItems : function( menu, tag, tagName ) { // Go up to the anchor to test its properties var oLink = FCKSelection.MoveToAncestorNode( 'A' ) ; var bIsAnchor = ( oLink && oLink.name.length > 0 ) ; if ( bIsAnchor || ( tagName == 'IMG' && tag.getAttribute( '_fckanchor' ) ) ) { menu.AddSeparator() ; menu.AddItem( 'Anchor', FCKLang.AnchorProp, 36 ) ; menu.AddItem( 'AnchorDelete', FCKLang.AnchorDelete ) ; } }} ; case 'Flash' : return { AddItems : function( menu, tag, tagName ) { if ( tagName == 'IMG' && tag.getAttribute( '_fckflash' ) ) { menu.AddSeparator() ; menu.AddItem( 'Flash', FCKLang.FlashProperties, 38 ) ; } }} ; case 'Form' : return { AddItems : function( menu, tag, tagName ) { if ( FCKSelection.HasAncestorNode('FORM') ) { menu.AddSeparator() ; menu.AddItem( 'Form', FCKLang.FormProp, 48 ) ; } }} ; case 'Checkbox' : return { AddItems : function( menu, tag, tagName ) { if ( tagName == 'INPUT' && tag.type == 'checkbox' ) { menu.AddSeparator() ; menu.AddItem( 'Checkbox', FCKLang.CheckboxProp, 49 ) ; } }} ; case 'Radio' : return { AddItems : function( menu, tag, tagName ) { if ( tagName == 'INPUT' && tag.type == 'radio' ) { menu.AddSeparator() ; menu.AddItem( 'Radio', FCKLang.RadioButtonProp, 50 ) ; } }} ; case 'TextField' : return { AddItems : function( menu, tag, tagName ) { if ( tagName == 'INPUT' && ( tag.type == 'text' || tag.type == 'password' ) ) { menu.AddSeparator() ; menu.AddItem( 'TextField', FCKLang.TextFieldProp, 51 ) ; } }} ; case 'HiddenField' : return { AddItems : function( menu, tag, tagName ) { if ( tagName == 'IMG' && tag.getAttribute( '_fckinputhidden' ) ) { menu.AddSeparator() ; menu.AddItem( 'HiddenField', FCKLang.HiddenFieldProp, 56 ) ; } }} ; case 'ImageButton' : return { AddItems : function( menu, tag, tagName ) { if ( tagName == 'INPUT' && tag.type == 'image' ) { menu.AddSeparator() ; menu.AddItem( 'ImageButton', FCKLang.ImageButtonProp, 55 ) ; } }} ; case 'Button' : return { AddItems : function( menu, tag, tagName ) { if ( tagName == 'INPUT' && ( tag.type == 'button' || tag.type == 'submit' || tag.type == 'reset' ) ) { menu.AddSeparator() ; menu.AddItem( 'Button', FCKLang.ButtonProp, 54 ) ; } }} ; case 'Select' : return { AddItems : function( menu, tag, tagName ) { if ( tagName == 'SELECT' ) { menu.AddSeparator() ; menu.AddItem( 'Select', FCKLang.SelectionFieldProp, 53 ) ; } }} ; case 'Textarea' : return { AddItems : function( menu, tag, tagName ) { if ( tagName == 'TEXTAREA' ) { menu.AddSeparator() ; menu.AddItem( 'Textarea', FCKLang.TextareaProp, 52 ) ; } }} ; case 'BulletedList' : return { AddItems : function( menu, tag, tagName ) { if ( FCKSelection.HasAncestorNode('UL') ) { menu.AddSeparator() ; menu.AddItem( 'BulletedList', FCKLang.BulletedListProp, 27 ) ; } }} ; case 'NumberedList' : return { AddItems : function( menu, tag, tagName ) { if ( FCKSelection.HasAncestorNode('OL') ) { menu.AddSeparator() ; menu.AddItem( 'NumberedList', FCKLang.NumberedListProp, 26 ) ; } }} ; case 'DivContainer': return { AddItems : function( menu, tag, tagName ) { var currentBlocks = FCKDomTools.GetSelectedDivContainers() ; if ( currentBlocks.length > 0 ) { menu.AddSeparator() ; menu.AddItem( 'EditDiv', FCKLang.EditDiv, 75 ) ; menu.AddItem( 'DeleteDiv', FCKLang.DeleteDiv, 76 ) ; } }} ; } return null ; } function FCK_ContextMenu_OnBeforeOpen() { // Update the UI. FCK.Events.FireEvent( 'OnSelectionChange' ) ; // Get the actual selected tag (if any). var oTag, sTagName ; // The extra () is to avoid a warning with strict error checking. This is ok. if ( (oTag = FCKSelection.GetSelectedElement()) ) sTagName = oTag.tagName ; // Cleanup the current menu items. var oMenu = FCK.ContextMenu._InnerContextMenu ; oMenu.RemoveAllItems() ; // Loop through the listeners. var aListeners = FCK.ContextMenu.Listeners ; for ( var i = 0 ; i < aListeners.length ; i++ ) aListeners[i].AddItems( oMenu, oTag, sTagName ) ; } function FCK_ContextMenu_OnItemClick( item ) { // IE might work incorrectly if we refocus the editor #798 if ( !FCKBrowserInfo.IsIE ) FCK.Focus() ; FCKCommands.GetCommand( item.Name ).Execute( item.CustomData ) ; }
JavaScript
/* * 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 == * * Define all commands available in the editor. */ var FCKCommands = FCK.Commands = new Object() ; FCKCommands.LoadedCommands = new Object() ; FCKCommands.RegisterCommand = function( commandName, command ) { this.LoadedCommands[ commandName ] = command ; } FCKCommands.GetCommand = function( commandName ) { var oCommand = FCKCommands.LoadedCommands[ commandName ] ; if ( oCommand ) return oCommand ; switch ( commandName ) { case 'Bold' : case 'Italic' : case 'Underline' : case 'StrikeThrough': case 'Subscript' : case 'Superscript' : oCommand = new FCKCoreStyleCommand( commandName ) ; break ; case 'RemoveFormat' : oCommand = new FCKRemoveFormatCommand() ; break ; case 'DocProps' : oCommand = new FCKDialogCommand( 'DocProps' , FCKLang.DocProps , 'dialog/fck_docprops.html' , 400, 380, FCKCommands.GetFullPageState ) ; break ; case 'Templates' : oCommand = new FCKDialogCommand( 'Templates' , FCKLang.DlgTemplatesTitle , 'dialog/fck_template.html' , 380, 450 ) ; break ; case 'Link' : oCommand = new FCKDialogCommand( 'Link' , FCKLang.DlgLnkWindowTitle , 'dialog/fck_link.html' , 400, 300 ) ; break ; case 'Unlink' : oCommand = new FCKUnlinkCommand() ; break ; case 'VisitLink' : oCommand = new FCKVisitLinkCommand() ; break ; case 'Anchor' : oCommand = new FCKDialogCommand( 'Anchor' , FCKLang.DlgAnchorTitle , 'dialog/fck_anchor.html' , 370, 160 ) ; break ; case 'AnchorDelete' : oCommand = new FCKAnchorDeleteCommand() ; break ; case 'BulletedList' : oCommand = new FCKDialogCommand( 'BulletedList', FCKLang.BulletedListProp , 'dialog/fck_listprop.html?UL' , 370, 160 ) ; break ; case 'NumberedList' : oCommand = new FCKDialogCommand( 'NumberedList', FCKLang.NumberedListProp , 'dialog/fck_listprop.html?OL' , 370, 160 ) ; break ; case 'About' : oCommand = new FCKDialogCommand( 'About' , FCKLang.About , 'dialog/fck_about.html' , 420, 330, function(){ return FCK_TRISTATE_OFF ; } ) ; break ; case 'Find' : oCommand = new FCKDialogCommand( 'Find' , FCKLang.DlgFindAndReplaceTitle, 'dialog/fck_replace.html' , 340, 230, null, null, 'Find' ) ; break ; case 'Replace' : oCommand = new FCKDialogCommand( 'Replace' , FCKLang.DlgFindAndReplaceTitle, 'dialog/fck_replace.html' , 340, 230, null, null, 'Replace' ) ; break ; case 'Image' : oCommand = new FCKDialogCommand( 'Image' , FCKLang.DlgImgTitle , 'dialog/fck_image.html' , 450, 390 ) ; break ; case 'Flash' : oCommand = new FCKDialogCommand( 'Flash' , FCKLang.DlgFlashTitle , 'dialog/fck_flash.html' , 450, 390 ) ; break ; case 'SpecialChar' : oCommand = new FCKDialogCommand( 'SpecialChar', FCKLang.DlgSpecialCharTitle , 'dialog/fck_specialchar.html' , 400, 290 ) ; break ; case 'Smiley' : oCommand = new FCKDialogCommand( 'Smiley' , FCKLang.DlgSmileyTitle , 'dialog/fck_smiley.html' , FCKConfig.SmileyWindowWidth, FCKConfig.SmileyWindowHeight ) ; break ; case 'Table' : oCommand = new FCKDialogCommand( 'Table' , FCKLang.DlgTableTitle , 'dialog/fck_table.html' , 480, 250 ) ; break ; case 'TableProp' : oCommand = new FCKDialogCommand( 'Table' , FCKLang.DlgTableTitle , 'dialog/fck_table.html?Parent', 480, 250 ) ; break ; case 'TableCellProp': oCommand = new FCKDialogCommand( 'TableCell' , FCKLang.DlgCellTitle , 'dialog/fck_tablecell.html' , 550, 240 ) ; break ; case 'Style' : oCommand = new FCKStyleCommand() ; break ; case 'FontName' : oCommand = new FCKFontNameCommand() ; break ; case 'FontSize' : oCommand = new FCKFontSizeCommand() ; break ; case 'FontFormat' : oCommand = new FCKFormatBlockCommand() ; break ; case 'Source' : oCommand = new FCKSourceCommand() ; break ; case 'Preview' : oCommand = new FCKPreviewCommand() ; break ; case 'Save' : oCommand = new FCKSaveCommand() ; break ; case 'NewPage' : oCommand = new FCKNewPageCommand() ; break ; case 'PageBreak' : oCommand = new FCKPageBreakCommand() ; break ; case 'Rule' : oCommand = new FCKRuleCommand() ; break ; case 'Nbsp' : oCommand = new FCKNbsp() ; break ; case 'TextColor' : oCommand = new FCKTextColorCommand('ForeColor') ; break ; case 'BGColor' : oCommand = new FCKTextColorCommand('BackColor') ; break ; case 'Paste' : oCommand = new FCKPasteCommand() ; break ; case 'PasteText' : oCommand = new FCKPastePlainTextCommand() ; break ; case 'PasteWord' : oCommand = new FCKPasteWordCommand() ; break ; case 'JustifyLeft' : oCommand = new FCKJustifyCommand( 'left' ) ; break ; case 'JustifyCenter' : oCommand = new FCKJustifyCommand( 'center' ) ; break ; case 'JustifyRight' : oCommand = new FCKJustifyCommand( 'right' ) ; break ; case 'JustifyFull' : oCommand = new FCKJustifyCommand( 'justify' ) ; break ; case 'Indent' : oCommand = new FCKIndentCommand( 'indent', FCKConfig.IndentLength ) ; break ; case 'Outdent' : oCommand = new FCKIndentCommand( 'outdent', FCKConfig.IndentLength * -1 ) ; break ; case 'Blockquote' : oCommand = new FCKBlockQuoteCommand() ; break ; case 'CreateDiv' : oCommand = new FCKDialogCommand( 'CreateDiv', FCKLang.CreateDiv, 'dialog/fck_div.html', 380, 210, null, null, true ) ; break ; case 'EditDiv' : oCommand = new FCKDialogCommand( 'EditDiv', FCKLang.EditDiv, 'dialog/fck_div.html', 380, 210, null, null, false ) ; break ; case 'DeleteDiv' : oCommand = new FCKDeleteDivCommand() ; break ; case 'TableInsertRowAfter' : oCommand = new FCKTableCommand('TableInsertRowAfter') ; break ; case 'TableInsertRowBefore' : oCommand = new FCKTableCommand('TableInsertRowBefore') ; break ; case 'TableDeleteRows' : oCommand = new FCKTableCommand('TableDeleteRows') ; break ; case 'TableInsertColumnAfter' : oCommand = new FCKTableCommand('TableInsertColumnAfter') ; break ; case 'TableInsertColumnBefore' : oCommand = new FCKTableCommand('TableInsertColumnBefore') ; break ; case 'TableDeleteColumns' : oCommand = new FCKTableCommand('TableDeleteColumns') ; break ; case 'TableInsertCellAfter' : oCommand = new FCKTableCommand('TableInsertCellAfter') ; break ; case 'TableInsertCellBefore' : oCommand = new FCKTableCommand('TableInsertCellBefore') ; break ; case 'TableDeleteCells' : oCommand = new FCKTableCommand('TableDeleteCells') ; break ; case 'TableMergeCells' : oCommand = new FCKTableCommand('TableMergeCells') ; break ; case 'TableMergeRight' : oCommand = new FCKTableCommand('TableMergeRight') ; break ; case 'TableMergeDown' : oCommand = new FCKTableCommand('TableMergeDown') ; break ; case 'TableHorizontalSplitCell' : oCommand = new FCKTableCommand('TableHorizontalSplitCell') ; break ; case 'TableVerticalSplitCell' : oCommand = new FCKTableCommand('TableVerticalSplitCell') ; break ; case 'TableDelete' : oCommand = new FCKTableCommand('TableDelete') ; break ; case 'Form' : oCommand = new FCKDialogCommand( 'Form' , FCKLang.Form , 'dialog/fck_form.html' , 380, 210 ) ; break ; case 'Checkbox' : oCommand = new FCKDialogCommand( 'Checkbox' , FCKLang.Checkbox , 'dialog/fck_checkbox.html' , 380, 200 ) ; break ; case 'Radio' : oCommand = new FCKDialogCommand( 'Radio' , FCKLang.RadioButton , 'dialog/fck_radiobutton.html' , 380, 200 ) ; break ; case 'TextField' : oCommand = new FCKDialogCommand( 'TextField' , FCKLang.TextField , 'dialog/fck_textfield.html' , 380, 210 ) ; break ; case 'Textarea' : oCommand = new FCKDialogCommand( 'Textarea' , FCKLang.Textarea , 'dialog/fck_textarea.html' , 380, 210 ) ; break ; case 'HiddenField' : oCommand = new FCKDialogCommand( 'HiddenField', FCKLang.HiddenField , 'dialog/fck_hiddenfield.html' , 380, 190 ) ; break ; case 'Button' : oCommand = new FCKDialogCommand( 'Button' , FCKLang.Button , 'dialog/fck_button.html' , 380, 210 ) ; break ; case 'Select' : oCommand = new FCKDialogCommand( 'Select' , FCKLang.SelectionField, 'dialog/fck_select.html' , 400, 340 ) ; break ; case 'ImageButton' : oCommand = new FCKDialogCommand( 'ImageButton', FCKLang.ImageButton , 'dialog/fck_image.html?ImageButton', 450, 390 ) ; break ; case 'SpellCheck' : oCommand = new FCKSpellCheckCommand() ; break ; case 'FitWindow' : oCommand = new FCKFitWindow() ; break ; case 'Undo' : oCommand = new FCKUndoCommand() ; break ; case 'Redo' : oCommand = new FCKRedoCommand() ; break ; case 'Copy' : oCommand = new FCKCutCopyCommand( false ) ; break ; case 'Cut' : oCommand = new FCKCutCopyCommand( true ) ; break ; case 'SelectAll' : oCommand = new FCKSelectAllCommand() ; break ; case 'InsertOrderedList' : oCommand = new FCKListCommand( 'insertorderedlist', 'ol' ) ; break ; case 'InsertUnorderedList' : oCommand = new FCKListCommand( 'insertunorderedlist', 'ul' ) ; break ; case 'ShowBlocks' : oCommand = new FCKShowBlockCommand( 'ShowBlocks', FCKConfig.StartupShowBlocks ? FCK_TRISTATE_ON : FCK_TRISTATE_OFF ) ; break ; // Generic Undefined command (usually used when a command is under development). case 'Undefined' : oCommand = new FCKUndefinedCommand() ; break ; // By default we assume that it is a named command. default: if ( FCKRegexLib.NamedCommands.test( commandName ) ) oCommand = new FCKNamedCommand( commandName ) ; else { alert( FCKLang.UnknownCommand.replace( /%1/g, commandName ) ) ; return null ; } } FCKCommands.LoadedCommands[ commandName ] = oCommand ; return oCommand ; } // Gets the state of the "Document Properties" button. It must be enabled only // when "Full Page" editing is available. FCKCommands.GetFullPageState = function() { return FCKConfig.FullPage ? FCK_TRISTATE_OFF : FCK_TRISTATE_DISABLED ; } FCKCommands.GetBooleanState = function( isDisabled ) { return isDisabled ? FCK_TRISTATE_DISABLED : FCK_TRISTATE_OFF ; }
JavaScript
/* * 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 == * * Extensions to the JavaScript Core. * * All custom extensions functions are PascalCased to differ from the standard * camelCased ones. */ String.prototype.Contains = function( textToCheck ) { return ( this.indexOf( textToCheck ) > -1 ) ; } String.prototype.Equals = function() { 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 ( this == aArgs[i] ) return true ; } return false ; } 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 ; } String.prototype.ReplaceAll = function( searchArray, replaceArray ) { var replaced = this ; for ( var i = 0 ; i < searchArray.length ; i++ ) { replaced = replaced.replace( searchArray[i], replaceArray[i] ) ; } return replaced ; } String.prototype.StartsWith = function( value ) { return ( this.substr( 0, value.length ) == value ) ; } // Extends the String object, creating a "EndsWith" method on it. String.prototype.EndsWith = function( value, ignoreCase ) { var L1 = this.length ; var L2 = value.length ; if ( L2 > L1 ) return false ; if ( ignoreCase ) { var oRegex = new RegExp( value + '$' , 'i' ) ; return oRegex.test( this ) ; } else return ( L2 == 0 || this.substr( L1 - L2, L2 ) == value ) ; } String.prototype.Remove = function( start, length ) { var s = '' ; if ( start > 0 ) s = this.substring( 0, start ) ; if ( start + length < this.length ) s += this.substring( start + length , this.length ) ; return s ; } String.prototype.Trim = function() { // We are not using \s because we don't want "non-breaking spaces to be caught". return this.replace( /(^[ \t\n\r]*)|([ \t\n\r]*$)/g, '' ) ; } String.prototype.LTrim = function() { // We are not using \s because we don't want "non-breaking spaces to be caught". return this.replace( /^[ \t\n\r]*/g, '' ) ; } String.prototype.RTrim = function() { // We are not using \s because we don't want "non-breaking spaces to be caught". return this.replace( /[ \t\n\r]*$/g, '' ) ; } String.prototype.ReplaceNewLineChars = function( replacement ) { return this.replace( /\n/g, replacement ) ; } String.prototype.Replace = function( regExp, replacement, thisObj ) { if ( typeof replacement == 'function' ) { return this.replace( regExp, function() { return replacement.apply( thisObj || this, arguments ) ; } ) ; } else return this.replace( regExp, replacement ) ; } Array.prototype.IndexOf = function( value ) { for ( var i = 0 ; i < this.length ; i++ ) { if ( this[i] == value ) return i ; } return -1 ; }
JavaScript
/* * 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 == * * The Data Processor is responsible for transforming the input and output data * in the editor. For more info: * http://dev.fckeditor.net/wiki/Components/DataProcessor * * The default implementation offers the base XHTML compatibility features of * FCKeditor. Further Data Processors may be implemented for other purposes. * */ var FCKDataProcessor = function() {} FCKDataProcessor.prototype = { /* * Returns a string representing the HTML format of "data". The returned * value will be loaded in the editor. * The HTML must be from <html> to </html>, including <head>, <body> and * eventually the DOCTYPE. * Note: HTML comments may already be part of the data because of the * pre-processing made with ProtectedSource. * @param {String} data The data to be converted in the * DataProcessor specific format. */ ConvertToHtml : function( data ) { // The default data processor must handle two different cases depending // on the FullPage setting. Custom Data Processors will not be // compatible with FullPage, much probably. if ( FCKConfig.FullPage ) { // Save the DOCTYPE. FCK.DocTypeDeclaration = data.match( FCKRegexLib.DocTypeTag ) ; // Check if the <body> tag is available. if ( !FCKRegexLib.HasBodyTag.test( data ) ) data = '<body>' + data + '</body>' ; // Check if the <html> tag is available. if ( !FCKRegexLib.HtmlOpener.test( data ) ) data = '<html dir="' + FCKConfig.ContentLangDirection + '">' + data + '</html>' ; // Check if the <head> tag is available. if ( !FCKRegexLib.HeadOpener.test( data ) ) data = data.replace( FCKRegexLib.HtmlOpener, '$&<head><title></title></head>' ) ; return data ; } else { var html = FCKConfig.DocType + '<html dir="' + FCKConfig.ContentLangDirection + '"' ; // On IE, if you are using a DOCTYPE different of HTML 4 (like // XHTML), you must force the vertical scroll to show, otherwise // the horizontal one may appear when the page needs vertical scrolling. // TODO : Check it with IE7 and make it IE6- if it is the case. if ( FCKBrowserInfo.IsIE && FCKConfig.DocType.length > 0 && !FCKRegexLib.Html4DocType.test( FCKConfig.DocType ) ) html += ' style="overflow-y: scroll"' ; html += '><head><title></title></head>' + '<body' + FCKConfig.GetBodyAttributes() + '>' + data + '</body></html>' ; return html ; } }, /* * Converts a DOM (sub-)tree to a string in the data format. * @param {Object} rootNode The node that contains the DOM tree to be * converted to the data format. * @param {Boolean} excludeRoot Indicates that the root node must not * be included in the conversion, only its children. * @param {Boolean} format Indicates that the data must be formatted * for human reading. Not all Data Processors may provide it. */ ConvertToDataFormat : function( rootNode, excludeRoot, ignoreIfEmptyParagraph, format ) { var data = FCKXHtml.GetXHTML( rootNode, !excludeRoot, format ) ; if ( ignoreIfEmptyParagraph && FCKRegexLib.EmptyOutParagraph.test( data ) ) return '' ; return data ; }, /* * Makes any necessary changes to a piece of HTML for insertion in the * editor selection position. * @param {String} html The HTML to be fixed. */ FixHtml : function( html ) { return html ; } } ;
JavaScript
/* * 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 == * * Class for working with a selection range, much like the W3C DOM Range, but * it is not intended to be an implementation of the W3C interface. * (IE Implementation) */ FCKDomRange.prototype.MoveToSelection = function() { this.Release( true ) ; this._Range = new FCKW3CRange( this.Window.document ) ; var oSel = this.Window.document.selection ; if ( oSel.type != 'Control' ) { var eMarkerStart = this._GetSelectionMarkerTag( true ) ; var eMarkerEnd = this._GetSelectionMarkerTag( false ) ; if ( !eMarkerStart && !eMarkerEnd ) { this._Range.setStart( this.Window.document.body, 0 ) ; this._UpdateElementInfo() ; return ; } // Set the start boundary. this._Range.setStart( eMarkerStart.parentNode, FCKDomTools.GetIndexOf( eMarkerStart ) ) ; eMarkerStart.parentNode.removeChild( eMarkerStart ) ; // Set the end boundary. this._Range.setEnd( eMarkerEnd.parentNode, FCKDomTools.GetIndexOf( eMarkerEnd ) ) ; eMarkerEnd.parentNode.removeChild( eMarkerEnd ) ; this._UpdateElementInfo() ; } else { var oControl = oSel.createRange().item(0) ; if ( oControl ) { this._Range.setStartBefore( oControl ) ; this._Range.setEndAfter( oControl ) ; this._UpdateElementInfo() ; } } } FCKDomRange.prototype.Select = function( forceExpand ) { if ( this._Range ) this.SelectBookmark( this.CreateBookmark( true ), forceExpand ) ; } // Not compatible with bookmark created with CreateBookmark2. // The bookmark nodes will be deleted from the document. FCKDomRange.prototype.SelectBookmark = function( bookmark, forceExpand ) { var bIsCollapsed = this.CheckIsCollapsed() ; var bIsStartMakerAlone ; var dummySpan ; // Create marker tags for the start and end boundaries. var eStartMarker = this.GetBookmarkNode( bookmark, true ) ; if ( !eStartMarker ) return ; var eEndMarker ; if ( !bIsCollapsed ) eEndMarker = this.GetBookmarkNode( bookmark, false ) ; // Create the main range which will be used for the selection. var oIERange = this.Window.document.body.createTextRange() ; // Position the range at the start boundary. oIERange.moveToElementText( eStartMarker ) ; oIERange.moveStart( 'character', 1 ) ; if ( eEndMarker ) { // Create a tool range for the end. var oIERangeEnd = this.Window.document.body.createTextRange() ; // Position the tool range at the end. oIERangeEnd.moveToElementText( eEndMarker ) ; // Move the end boundary of the main range to match the tool range. oIERange.setEndPoint( 'EndToEnd', oIERangeEnd ) ; oIERange.moveEnd( 'character', -1 ) ; } else { bIsStartMakerAlone = ( forceExpand || !eStartMarker.previousSibling || eStartMarker.previousSibling.nodeName.toLowerCase() == 'br' ) && !eStartMarker.nextSibing ; // Append a temporary <span>&#65279;</span> before the selection. // This is needed to avoid IE destroying selections inside empty // inline elements, like <b></b> (#253). // It is also needed when placing the selection right after an inline // element to avoid the selection moving inside of it. dummySpan = this.Window.document.createElement( 'span' ) ; dummySpan.innerHTML = '&#65279;' ; // Zero Width No-Break Space (U+FEFF). See #1359. eStartMarker.parentNode.insertBefore( dummySpan, eStartMarker ) ; if ( bIsStartMakerAlone ) { // To expand empty blocks or line spaces after <br>, we need // instead to have any char, which will be later deleted using the // selection. // \ufeff = Zero Width No-Break Space (U+FEFF). See #1359. eStartMarker.parentNode.insertBefore( this.Window.document.createTextNode( '\ufeff' ), eStartMarker ) ; } } if ( !this._Range ) this._Range = this.CreateRange() ; // Remove the markers (reset the position, because of the changes in the DOM tree). this._Range.setStartBefore( eStartMarker ) ; eStartMarker.parentNode.removeChild( eStartMarker ) ; if ( bIsCollapsed ) { if ( bIsStartMakerAlone ) { // Move the selection start to include the temporary &#65279;. oIERange.moveStart( 'character', -1 ) ; oIERange.select() ; // Remove our temporary stuff. this.Window.document.selection.clear() ; } else oIERange.select() ; FCKDomTools.RemoveNode( dummySpan ) ; } else { this._Range.setEndBefore( eEndMarker ) ; eEndMarker.parentNode.removeChild( eEndMarker ) ; oIERange.select() ; } } FCKDomRange.prototype._GetSelectionMarkerTag = function( toStart ) { var doc = this.Window.document ; var selection = doc.selection ; // Get a range for the start boundary. var oRange ; // IE may throw an "unspecified error" on some cases (it happened when // loading _samples/default.html), so try/catch. try { oRange = selection.createRange() ; } catch (e) { return null ; } // IE might take the range object to the main window instead of inside the editor iframe window. // This is known to happen when the editor window has not been selected before (See #933). // We need to avoid that. if ( oRange.parentElement().document != doc ) return null ; oRange.collapse( toStart === true ) ; // Paste a marker element at the collapsed range and get it from the DOM. var sMarkerId = 'fck_dom_range_temp_' + (new Date()).valueOf() + '_' + Math.floor(Math.random()*1000) ; oRange.pasteHTML( '<span id="' + sMarkerId + '"></span>' ) ; return doc.getElementById( sMarkerId ) ; }
JavaScript
/* * 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 == * * FCKToolbarPanelButton Class: Handles the Fonts combo selector. */ var FCKToolbarFontsCombo = function( tooltip, style ) { this.CommandName = 'FontName' ; this.Label = this.GetLabel() ; this.Tooltip = tooltip ? tooltip : this.Label ; this.Style = style ? style : FCK_TOOLBARITEM_ICONTEXT ; this.DefaultLabel = FCKConfig.DefaultFontLabel || '' ; } // Inherit from FCKToolbarSpecialCombo. FCKToolbarFontsCombo.prototype = new FCKToolbarFontFormatCombo( false ) ; FCKToolbarFontsCombo.prototype.GetLabel = function() { return FCKLang.Font ; } FCKToolbarFontsCombo.prototype.GetStyles = function() { var baseStyle = FCKStyles.GetStyle( '_FCK_FontFace' ) ; if ( !baseStyle ) { alert( "The FCKConfig.CoreStyles['Size'] setting was not found. Please check the fckconfig.js file" ) ; return {} ; } var styles = {} ; var fonts = FCKConfig.FontNames.split(';') ; for ( var i = 0 ; i < fonts.length ; i++ ) { var fontParts = fonts[i].split('/') ; var font = fontParts[0] ; var caption = fontParts[1] || font ; var style = FCKTools.CloneObject( baseStyle ) ; style.SetVariable( 'Font', font ) ; style.Label = caption ; styles[ caption ] = style ; } return styles ; } FCKToolbarFontsCombo.prototype.RefreshActiveItems = FCKToolbarStyleCombo.prototype.RefreshActiveItems ; FCKToolbarFontsCombo.prototype.StyleCombo_OnBeforeClick = function( targetSpecialCombo ) { // Clear the current selection. targetSpecialCombo.DeselectAll() ; var startElement = FCKSelection.GetBoundaryParentElement( true ) ; if ( startElement ) { var path = new FCKElementPath( startElement ) ; for ( var i in targetSpecialCombo.Items ) { var item = targetSpecialCombo.Items[i] ; var style = item.Style ; if ( style.CheckActive( path ) ) { targetSpecialCombo.SelectItem( item ) ; return ; } } } }
JavaScript
/* * 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 == * * Controls the [Enter] keystroke behavior in a document. */ /* * Constructor. * @targetDocument : the target document. * @enterMode : the behavior for the <Enter> keystroke. * May be "p", "div", "br". Default is "p". * @shiftEnterMode : the behavior for the <Shift>+<Enter> keystroke. * May be "p", "div", "br". Defaults to "br". */ var FCKEnterKey = function( targetWindow, enterMode, shiftEnterMode, tabSpaces ) { this.Window = targetWindow ; this.EnterMode = enterMode || 'p' ; this.ShiftEnterMode = shiftEnterMode || 'br' ; // Setup the Keystroke Handler. var oKeystrokeHandler = new FCKKeystrokeHandler( false ) ; oKeystrokeHandler._EnterKey = this ; oKeystrokeHandler.OnKeystroke = FCKEnterKey_OnKeystroke ; oKeystrokeHandler.SetKeystrokes( [ [ 13 , 'Enter' ], [ SHIFT + 13, 'ShiftEnter' ], [ 8 , 'Backspace' ], [ CTRL + 8 , 'CtrlBackspace' ], [ 46 , 'Delete' ] ] ) ; this.TabText = '' ; // Safari by default inserts 4 spaces on TAB, while others make the editor // loose focus. So, we need to handle it here to not include those spaces. if ( tabSpaces > 0 || FCKBrowserInfo.IsSafari ) { while ( tabSpaces-- ) this.TabText += '\xa0' ; oKeystrokeHandler.SetKeystrokes( [ 9, 'Tab' ] ); } oKeystrokeHandler.AttachToElement( targetWindow.document ) ; } function FCKEnterKey_OnKeystroke( keyCombination, keystrokeValue ) { var oEnterKey = this._EnterKey ; try { switch ( keystrokeValue ) { case 'Enter' : return oEnterKey.DoEnter() ; break ; case 'ShiftEnter' : return oEnterKey.DoShiftEnter() ; break ; case 'Backspace' : return oEnterKey.DoBackspace() ; break ; case 'Delete' : return oEnterKey.DoDelete() ; break ; case 'Tab' : return oEnterKey.DoTab() ; break ; case 'CtrlBackspace' : return oEnterKey.DoCtrlBackspace() ; break ; } } catch (e) { // If for any reason we are not able to handle it, go // ahead with the browser default behavior. } return false ; } /* * Executes the <Enter> key behavior. */ FCKEnterKey.prototype.DoEnter = function( mode, hasShift ) { // Save an undo snapshot before doing anything FCKUndo.SaveUndoStep() ; this._HasShift = ( hasShift === true ) ; var parentElement = FCKSelection.GetParentElement() ; var parentPath = new FCKElementPath( parentElement ) ; var sMode = mode || this.EnterMode ; if ( sMode == 'br' || parentPath.Block && parentPath.Block.tagName.toLowerCase() == 'pre' ) return this._ExecuteEnterBr() ; else return this._ExecuteEnterBlock( sMode ) ; } /* * Executes the <Shift>+<Enter> key behavior. */ FCKEnterKey.prototype.DoShiftEnter = function() { return this.DoEnter( this.ShiftEnterMode, true ) ; } /* * Executes the <Backspace> key behavior. */ FCKEnterKey.prototype.DoBackspace = function() { var bCustom = false ; // Get the current selection. var oRange = new FCKDomRange( this.Window ) ; oRange.MoveToSelection() ; // Kludge for #247 if ( FCKBrowserInfo.IsIE && this._CheckIsAllContentsIncluded( oRange, this.Window.document.body ) ) { this._FixIESelectAllBug( oRange ) ; return true ; } var isCollapsed = oRange.CheckIsCollapsed() ; if ( !isCollapsed ) { // Bug #327, Backspace with an img selection would activate the default action in IE. // Let's override that with our logic here. if ( FCKBrowserInfo.IsIE && this.Window.document.selection.type.toLowerCase() == "control" ) { var controls = this.Window.document.selection.createRange() ; for ( var i = controls.length - 1 ; i >= 0 ; i-- ) { var el = controls.item( i ) ; el.parentNode.removeChild( el ) ; } return true ; } return false ; } // On IE, it is better for us handle the deletion if the caret is preceeded // by a <br> (#1383). if ( FCKBrowserInfo.IsIE ) { var previousElement = FCKDomTools.GetPreviousSourceElement( oRange.StartNode, true ) ; if ( previousElement && previousElement.nodeName.toLowerCase() == 'br' ) { // Create a range that starts after the <br> and ends at the // current range position. var testRange = oRange.Clone() ; testRange.SetStart( previousElement, 4 ) ; // If that range is empty, we can proceed cleaning that <br> manually. if ( testRange.CheckIsEmpty() ) { previousElement.parentNode.removeChild( previousElement ) ; return true ; } } } var oStartBlock = oRange.StartBlock ; var oEndBlock = oRange.EndBlock ; // The selection boundaries must be in the same "block limit" element if ( oRange.StartBlockLimit == oRange.EndBlockLimit && oStartBlock && oEndBlock ) { if ( !isCollapsed ) { var bEndOfBlock = oRange.CheckEndOfBlock() ; oRange.DeleteContents() ; if ( oStartBlock != oEndBlock ) { oRange.SetStart(oEndBlock,1) ; oRange.SetEnd(oEndBlock,1) ; // if ( bEndOfBlock ) // oEndBlock.parentNode.removeChild( oEndBlock ) ; } oRange.Select() ; bCustom = ( oStartBlock == oEndBlock ) ; } if ( oRange.CheckStartOfBlock() ) { var oCurrentBlock = oRange.StartBlock ; var ePrevious = FCKDomTools.GetPreviousSourceElement( oCurrentBlock, true, [ 'BODY', oRange.StartBlockLimit.nodeName ], ['UL','OL'] ) ; bCustom = this._ExecuteBackspace( oRange, ePrevious, oCurrentBlock ) ; } else if ( FCKBrowserInfo.IsGeckoLike ) { // Firefox and Opera (#1095) loose the selection when executing // CheckStartOfBlock, so we must reselect. oRange.Select() ; } } oRange.Release() ; return bCustom ; } FCKEnterKey.prototype.DoCtrlBackspace = function() { FCKUndo.SaveUndoStep() ; var oRange = new FCKDomRange( this.Window ) ; oRange.MoveToSelection() ; if ( FCKBrowserInfo.IsIE && this._CheckIsAllContentsIncluded( oRange, this.Window.document.body ) ) { this._FixIESelectAllBug( oRange ) ; return true ; } return false ; } FCKEnterKey.prototype._ExecuteBackspace = function( range, previous, currentBlock ) { var bCustom = false ; // We could be in a nested LI. if ( !previous && currentBlock && currentBlock.nodeName.IEquals( 'LI' ) && currentBlock.parentNode.parentNode.nodeName.IEquals( 'LI' ) ) { this._OutdentWithSelection( currentBlock, range ) ; return true ; } if ( previous && previous.nodeName.IEquals( 'LI' ) ) { var oNestedList = FCKDomTools.GetLastChild( previous, ['UL','OL'] ) ; while ( oNestedList ) { previous = FCKDomTools.GetLastChild( oNestedList, 'LI' ) ; oNestedList = FCKDomTools.GetLastChild( previous, ['UL','OL'] ) ; } } if ( previous && currentBlock ) { // If we are in a LI, and the previous block is not an LI, we must outdent it. if ( currentBlock.nodeName.IEquals( 'LI' ) && !previous.nodeName.IEquals( 'LI' ) ) { this._OutdentWithSelection( currentBlock, range ) ; return true ; } // Take a reference to the parent for post processing cleanup. var oCurrentParent = currentBlock.parentNode ; var sPreviousName = previous.nodeName.toLowerCase() ; if ( FCKListsLib.EmptyElements[ sPreviousName ] != null || sPreviousName == 'table' ) { FCKDomTools.RemoveNode( previous ) ; bCustom = true ; } else { // Remove the current block. FCKDomTools.RemoveNode( currentBlock ) ; // Remove any empty tag left by the block removal. while ( oCurrentParent.innerHTML.Trim().length == 0 ) { var oParent = oCurrentParent.parentNode ; oParent.removeChild( oCurrentParent ) ; oCurrentParent = oParent ; } // Cleanup the previous and the current elements. FCKDomTools.LTrimNode( currentBlock ) ; FCKDomTools.RTrimNode( previous ) ; // Append a space to the previous. // Maybe it is not always desirable... // previous.appendChild( this.Window.document.createTextNode( ' ' ) ) ; // Set the range to the end of the previous element and bookmark it. range.SetStart( previous, 2, true ) ; range.Collapse( true ) ; var oBookmark = range.CreateBookmark( true ) ; // Move the contents of the block to the previous element and delete it. // But for some block types (e.g. table), moving the children to the previous block makes no sense. // So a check is needed. (See #1081) if ( ! currentBlock.tagName.IEquals( [ 'TABLE' ] ) ) FCKDomTools.MoveChildren( currentBlock, previous ) ; // Place the selection at the bookmark. range.SelectBookmark( oBookmark ) ; bCustom = true ; } } return bCustom ; } /* * Executes the <Delete> key behavior. */ FCKEnterKey.prototype.DoDelete = function() { // Save an undo snapshot before doing anything // This is to conform with the behavior seen in MS Word FCKUndo.SaveUndoStep() ; // The <Delete> has the same effect as the <Backspace>, so we have the same // results if we just move to the next block and apply the same <Backspace> logic. var bCustom = false ; // Get the current selection. var oRange = new FCKDomRange( this.Window ) ; oRange.MoveToSelection() ; // Kludge for #247 if ( FCKBrowserInfo.IsIE && this._CheckIsAllContentsIncluded( oRange, this.Window.document.body ) ) { this._FixIESelectAllBug( oRange ) ; return true ; } // There is just one special case for collapsed selections at the end of a block. if ( oRange.CheckIsCollapsed() && oRange.CheckEndOfBlock( FCKBrowserInfo.IsGeckoLike ) ) { var oCurrentBlock = oRange.StartBlock ; var eCurrentCell = FCKTools.GetElementAscensor( oCurrentBlock, 'td' ); var eNext = FCKDomTools.GetNextSourceElement( oCurrentBlock, true, [ oRange.StartBlockLimit.nodeName ], ['UL','OL','TR'], true ) ; // Bug #1323 : if we're in a table cell, and the next node belongs to a different cell, then don't // delete anything. if ( eCurrentCell ) { var eNextCell = FCKTools.GetElementAscensor( eNext, 'td' ); if ( eNextCell != eCurrentCell ) return true ; } bCustom = this._ExecuteBackspace( oRange, oCurrentBlock, eNext ) ; } oRange.Release() ; return bCustom ; } /* * Executes the <Tab> key behavior. */ FCKEnterKey.prototype.DoTab = function() { var oRange = new FCKDomRange( this.Window ); oRange.MoveToSelection() ; // If the user pressed <tab> inside a table, we should give him the default behavior ( moving between cells ) // instead of giving him more non-breaking spaces. (Bug #973) var node = oRange._Range.startContainer ; while ( node ) { if ( node.nodeType == 1 ) { var tagName = node.tagName.toLowerCase() ; if ( tagName == "tr" || tagName == "td" || tagName == "th" || tagName == "tbody" || tagName == "table" ) return false ; else break ; } node = node.parentNode ; } if ( this.TabText ) { oRange.DeleteContents() ; oRange.InsertNode( this.Window.document.createTextNode( this.TabText ) ) ; oRange.Collapse( false ) ; oRange.Select() ; } return true ; } FCKEnterKey.prototype._ExecuteEnterBlock = function( blockTag, range ) { // Get the current selection. var oRange = range || new FCKDomRange( this.Window ) ; var oSplitInfo = oRange.SplitBlock( blockTag ) ; if ( oSplitInfo ) { // Get the current blocks. var ePreviousBlock = oSplitInfo.PreviousBlock ; var eNextBlock = oSplitInfo.NextBlock ; var bIsStartOfBlock = oSplitInfo.WasStartOfBlock ; var bIsEndOfBlock = oSplitInfo.WasEndOfBlock ; // If there is one block under a list item, modify the split so that the list item gets split as well. (Bug #1647) if ( eNextBlock ) { if ( eNextBlock.parentNode.nodeName.IEquals( 'li' ) ) { FCKDomTools.BreakParent( eNextBlock, eNextBlock.parentNode ) ; FCKDomTools.MoveNode( eNextBlock, eNextBlock.nextSibling, true ) ; } } else if ( ePreviousBlock && ePreviousBlock.parentNode.nodeName.IEquals( 'li' ) ) { FCKDomTools.BreakParent( ePreviousBlock, ePreviousBlock.parentNode ) ; oRange.MoveToElementEditStart( ePreviousBlock.nextSibling ); FCKDomTools.MoveNode( ePreviousBlock, ePreviousBlock.previousSibling ) ; } // If we have both the previous and next blocks, it means that the // boundaries were on separated blocks, or none of them where on the // block limits (start/end). if ( !bIsStartOfBlock && !bIsEndOfBlock ) { // If the next block is an <li> with another list tree as the first child // We'll need to append a placeholder or the list item wouldn't be editable. (Bug #1420) if ( eNextBlock.nodeName.IEquals( 'li' ) && eNextBlock.firstChild && eNextBlock.firstChild.nodeName.IEquals( ['ul', 'ol'] ) ) eNextBlock.insertBefore( FCKTools.GetElementDocument( eNextBlock ).createTextNode( '\xa0' ), eNextBlock.firstChild ) ; // Move the selection to the end block. if ( eNextBlock ) oRange.MoveToElementEditStart( eNextBlock ) ; } else { if ( bIsStartOfBlock && bIsEndOfBlock && ePreviousBlock.tagName.toUpperCase() == 'LI' ) { oRange.MoveToElementStart( ePreviousBlock ) ; this._OutdentWithSelection( ePreviousBlock, oRange ) ; oRange.Release() ; return true ; } var eNewBlock ; if ( ePreviousBlock ) { var sPreviousBlockTag = ePreviousBlock.tagName.toUpperCase() ; // If is a header tag, or we are in a Shift+Enter (#77), // create a new block element (later in the code). if ( !this._HasShift && !(/^H[1-6]$/).test( sPreviousBlockTag ) ) { // Otherwise, duplicate the previous block. eNewBlock = FCKDomTools.CloneElement( ePreviousBlock ) ; } } else if ( eNextBlock ) eNewBlock = FCKDomTools.CloneElement( eNextBlock ) ; if ( !eNewBlock ) eNewBlock = this.Window.document.createElement( blockTag ) ; // Recreate the inline elements tree, which was available // before the hitting enter, so the same styles will be // available in the new block. var elementPath = oSplitInfo.ElementPath ; if ( elementPath ) { for ( var i = 0, len = elementPath.Elements.length ; i < len ; i++ ) { var element = elementPath.Elements[i] ; if ( element == elementPath.Block || element == elementPath.BlockLimit ) break ; if ( FCKListsLib.InlineChildReqElements[ element.nodeName.toLowerCase() ] ) { element = FCKDomTools.CloneElement( element ) ; FCKDomTools.MoveChildren( eNewBlock, element ) ; eNewBlock.appendChild( element ) ; } } } if ( FCKBrowserInfo.IsGeckoLike ) FCKTools.AppendBogusBr( eNewBlock ) ; oRange.InsertNode( eNewBlock ) ; // This is tricky, but to make the new block visible correctly // we must select it. if ( FCKBrowserInfo.IsIE ) { // Move the selection to the new block. oRange.MoveToElementEditStart( eNewBlock ) ; oRange.Select() ; } // Move the selection to the new block. oRange.MoveToElementEditStart( bIsStartOfBlock && !bIsEndOfBlock ? eNextBlock : eNewBlock ) ; } if ( FCKBrowserInfo.IsGeckoLike ) { if ( eNextBlock ) { // If we have split the block, adds a temporary span at the // range position and scroll relatively to it. var tmpNode = this.Window.document.createElement( 'span' ) ; // We need some content for Safari. tmpNode.innerHTML = '&nbsp;'; oRange.InsertNode( tmpNode ) ; FCKDomTools.ScrollIntoView( tmpNode, false ) ; oRange.DeleteContents() ; } else { // We may use the above scroll logic for the new block case // too, but it gives some weird result with Opera. FCKDomTools.ScrollIntoView( eNextBlock || eNewBlock, false ) ; } } oRange.Select() ; } // Release the resources used by the range. oRange.Release() ; return true ; } FCKEnterKey.prototype._ExecuteEnterBr = function( blockTag ) { // Get the current selection. var oRange = new FCKDomRange( this.Window ) ; oRange.MoveToSelection() ; // The selection boundaries must be in the same "block limit" element. if ( oRange.StartBlockLimit == oRange.EndBlockLimit ) { oRange.DeleteContents() ; // Get the new selection (it is collapsed at this point). oRange.MoveToSelection() ; var bIsStartOfBlock = oRange.CheckStartOfBlock() ; var bIsEndOfBlock = oRange.CheckEndOfBlock() ; var sStartBlockTag = oRange.StartBlock ? oRange.StartBlock.tagName.toUpperCase() : '' ; var bHasShift = this._HasShift ; var bIsPre = false ; if ( !bHasShift && sStartBlockTag == 'LI' ) return this._ExecuteEnterBlock( null, oRange ) ; // If we are at the end of a header block. if ( !bHasShift && bIsEndOfBlock && (/^H[1-6]$/).test( sStartBlockTag ) ) { // Insert a BR after the current paragraph. FCKDomTools.InsertAfterNode( oRange.StartBlock, this.Window.document.createElement( 'br' ) ) ; // The space is required by Gecko only to make the cursor blink. if ( FCKBrowserInfo.IsGecko ) FCKDomTools.InsertAfterNode( oRange.StartBlock, this.Window.document.createTextNode( '' ) ) ; // IE and Gecko have different behaviors regarding the position. oRange.SetStart( oRange.StartBlock.nextSibling, FCKBrowserInfo.IsIE ? 3 : 1 ) ; } else { var eLineBreak ; bIsPre = sStartBlockTag.IEquals( 'pre' ) ; if ( bIsPre ) eLineBreak = this.Window.document.createTextNode( FCKBrowserInfo.IsIE ? '\r' : '\n' ) ; else eLineBreak = this.Window.document.createElement( 'br' ) ; oRange.InsertNode( eLineBreak ) ; // The space is required by Gecko only to make the cursor blink. if ( FCKBrowserInfo.IsGecko ) FCKDomTools.InsertAfterNode( eLineBreak, this.Window.document.createTextNode( '' ) ) ; // If we are at the end of a block, we must be sure the bogus node is available in that block. if ( bIsEndOfBlock && FCKBrowserInfo.IsGeckoLike ) FCKTools.AppendBogusBr( eLineBreak.parentNode ) ; if ( FCKBrowserInfo.IsIE ) oRange.SetStart( eLineBreak, 4 ) ; else oRange.SetStart( eLineBreak.nextSibling, 1 ) ; if ( ! FCKBrowserInfo.IsIE ) { var dummy = null ; if ( FCKBrowserInfo.IsOpera ) dummy = this.Window.document.createElement( 'span' ) ; else dummy = this.Window.document.createElement( 'br' ) ; eLineBreak.parentNode.insertBefore( dummy, eLineBreak.nextSibling ) ; FCKDomTools.ScrollIntoView( dummy, false ) ; dummy.parentNode.removeChild( dummy ) ; } } // This collapse guarantees the cursor will be blinking. oRange.Collapse( true ) ; oRange.Select( bIsPre ) ; } // Release the resources used by the range. oRange.Release() ; return true ; } // Outdents a LI, maintaining the selection defined on a range. FCKEnterKey.prototype._OutdentWithSelection = function( li, range ) { var oBookmark = range.CreateBookmark() ; FCKListHandler.OutdentListItem( li ) ; range.MoveToBookmark( oBookmark ) ; range.Select() ; } // Is all the contents under a node included by a range? FCKEnterKey.prototype._CheckIsAllContentsIncluded = function( range, node ) { var startOk = false ; var endOk = false ; /* FCKDebug.Output( 'sc='+range.StartContainer.nodeName+ ',so='+range._Range.startOffset+ ',ec='+range.EndContainer.nodeName+ ',eo='+range._Range.endOffset ) ; */ if ( range.StartContainer == node || range.StartContainer == node.firstChild ) startOk = ( range._Range.startOffset == 0 ) ; if ( range.EndContainer == node || range.EndContainer == node.lastChild ) { var nodeLength = range.EndContainer.nodeType == 3 ? range.EndContainer.length : range.EndContainer.childNodes.length ; endOk = ( range._Range.endOffset == nodeLength ) ; } return startOk && endOk ; } // Kludge for #247 FCKEnterKey.prototype._FixIESelectAllBug = function( range ) { var doc = this.Window.document ; doc.body.innerHTML = '' ; var editBlock ; if ( FCKConfig.EnterMode.IEquals( ['div', 'p'] ) ) { editBlock = doc.createElement( FCKConfig.EnterMode ) ; doc.body.appendChild( editBlock ) ; } else editBlock = doc.body ; range.MoveToNodeContents( editBlock ) ; range.Collapse( true ) ; range.Select() ; range.Release() ; }
JavaScript
/* * 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 == * * FCKToolbarButton Class: represents a button in the toolbar. */ var FCKToolbarButton = function( commandName, label, tooltip, style, sourceView, contextSensitive, icon ) { this.CommandName = commandName ; this.Label = label ; this.Tooltip = tooltip ; this.Style = style ; this.SourceView = sourceView ? true : false ; this.ContextSensitive = contextSensitive ? true : false ; if ( icon == null ) this.IconPath = FCKConfig.SkinPath + 'toolbar/' + commandName.toLowerCase() + '.gif' ; else if ( typeof( icon ) == 'number' ) this.IconPath = [ FCKConfig.SkinPath + 'fck_strip.gif', 16, icon ] ; else this.IconPath = icon ; } FCKToolbarButton.prototype.Create = function( targetElement ) { this._UIButton = new FCKToolbarButtonUI( this.CommandName, this.Label, this.Tooltip, this.IconPath, this.Style ) ; this._UIButton.OnClick = this.Click ; this._UIButton._ToolbarButton = this ; this._UIButton.Create( targetElement ) ; } FCKToolbarButton.prototype.RefreshState = function() { var uiButton = this._UIButton ; if ( !uiButton ) return ; // Gets the actual state. var eState = FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( this.CommandName ).GetState() ; // If there are no state changes than do nothing and return. if ( eState == uiButton.State ) return ; // Sets the actual state. uiButton.ChangeState( eState ) ; } FCKToolbarButton.prototype.Click = function() { var oToolbarButton = this._ToolbarButton || this ; FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( oToolbarButton.CommandName ).Execute() ; } FCKToolbarButton.prototype.Enable = function() { this.RefreshState() ; } FCKToolbarButton.prototype.Disable = function() { // Sets the actual state. this._UIButton.ChangeState( FCK_TRISTATE_DISABLED ) ; }
JavaScript
/* * 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 == * * FCKToolbarButtonUI Class: interface representation of a toolbar button. */ var FCKToolbarButtonUI = function( name, label, tooltip, iconPathOrStripInfoArray, style, state ) { this.Name = name ; this.Label = label || name ; this.Tooltip = tooltip || this.Label ; this.Style = style || FCK_TOOLBARITEM_ONLYICON ; this.State = state || FCK_TRISTATE_OFF ; this.Icon = new FCKIcon( iconPathOrStripInfoArray ) ; if ( FCK.IECleanup ) FCK.IECleanup.AddItem( this, FCKToolbarButtonUI_Cleanup ) ; } FCKToolbarButtonUI.prototype._CreatePaddingElement = function( document ) { var oImg = document.createElement( 'IMG' ) ; oImg.className = 'TB_Button_Padding' ; oImg.src = FCK_SPACER_PATH ; return oImg ; } FCKToolbarButtonUI.prototype.Create = function( parentElement ) { var oDoc = FCKTools.GetElementDocument( parentElement ) ; // Create the Main Element. var oMainElement = this.MainElement = oDoc.createElement( 'DIV' ) ; oMainElement.title = this.Tooltip ; // The following will prevent the button from catching the focus. if ( FCKBrowserInfo.IsGecko ) oMainElement.onmousedown = FCKTools.CancelEvent ; FCKTools.AddEventListenerEx( oMainElement, 'mouseover', FCKToolbarButtonUI_OnMouseOver, this ) ; FCKTools.AddEventListenerEx( oMainElement, 'mouseout', FCKToolbarButtonUI_OnMouseOut, this ) ; FCKTools.AddEventListenerEx( oMainElement, 'click', FCKToolbarButtonUI_OnClick, this ) ; this.ChangeState( this.State, true ) ; if ( this.Style == FCK_TOOLBARITEM_ONLYICON && !this.ShowArrow ) { // <td><div class="TB_Button_On" title="Smiley">{Image}</div></td> oMainElement.appendChild( this.Icon.CreateIconElement( oDoc ) ) ; } else { // <td><div class="TB_Button_On" title="Smiley"><table cellpadding="0" cellspacing="0"><tr><td>{Image}</td><td nowrap>Toolbar Button</td><td><img class="TB_Button_Padding"></td></tr></table></div></td> // <td><div class="TB_Button_On" title="Smiley"><table cellpadding="0" cellspacing="0"><tr><td><img class="TB_Button_Padding"></td><td nowrap>Toolbar Button</td><td><img class="TB_Button_Padding"></td></tr></table></div></td> var oTable = oMainElement.appendChild( oDoc.createElement( 'TABLE' ) ) ; oTable.cellPadding = 0 ; oTable.cellSpacing = 0 ; var oRow = oTable.insertRow(-1) ; // The Image cell (icon or padding). var oCell = oRow.insertCell(-1) ; if ( this.Style == FCK_TOOLBARITEM_ONLYICON || this.Style == FCK_TOOLBARITEM_ICONTEXT ) oCell.appendChild( this.Icon.CreateIconElement( oDoc ) ) ; else oCell.appendChild( this._CreatePaddingElement( oDoc ) ) ; if ( this.Style == FCK_TOOLBARITEM_ONLYTEXT || this.Style == FCK_TOOLBARITEM_ICONTEXT ) { // The Text cell. oCell = oRow.insertCell(-1) ; oCell.className = 'TB_Button_Text' ; oCell.noWrap = true ; oCell.appendChild( oDoc.createTextNode( this.Label ) ) ; } if ( this.ShowArrow ) { if ( this.Style != FCK_TOOLBARITEM_ONLYICON ) { // A padding cell. oRow.insertCell(-1).appendChild( this._CreatePaddingElement( oDoc ) ) ; } oCell = oRow.insertCell(-1) ; var eImg = oCell.appendChild( oDoc.createElement( 'IMG' ) ) ; eImg.src = FCKConfig.SkinPath + 'images/toolbar.buttonarrow.gif' ; eImg.width = 5 ; eImg.height = 3 ; } // The last padding cell. oCell = oRow.insertCell(-1) ; oCell.appendChild( this._CreatePaddingElement( oDoc ) ) ; } parentElement.appendChild( oMainElement ) ; } FCKToolbarButtonUI.prototype.ChangeState = function( newState, force ) { if ( !force && this.State == newState ) return ; var e = this.MainElement ; // In IE it can happen when the page is reloaded that MainElement is null, so exit here if ( !e ) return ; switch ( parseInt( newState, 10 ) ) { case FCK_TRISTATE_OFF : e.className = 'TB_Button_Off' ; break ; case FCK_TRISTATE_ON : e.className = 'TB_Button_On' ; break ; case FCK_TRISTATE_DISABLED : e.className = 'TB_Button_Disabled' ; break ; } this.State = newState ; } function FCKToolbarButtonUI_OnMouseOver( ev, button ) { if ( button.State == FCK_TRISTATE_OFF ) this.className = 'TB_Button_Off_Over' ; else if ( button.State == FCK_TRISTATE_ON ) this.className = 'TB_Button_On_Over' ; } function FCKToolbarButtonUI_OnMouseOut( ev, button ) { if ( button.State == FCK_TRISTATE_OFF ) this.className = 'TB_Button_Off' ; else if ( button.State == FCK_TRISTATE_ON ) this.className = 'TB_Button_On' ; } function FCKToolbarButtonUI_OnClick( ev, button ) { if ( button.OnClick && button.State != FCK_TRISTATE_DISABLED ) button.OnClick( button ) ; } function FCKToolbarButtonUI_Cleanup() { // This one should not cause memory leak, but just for safety, let's clean // it up. this.MainElement = null ; } /* Sample outputs: This is the base structure. The variation is the image that is marked as {Image}: <td><div class="TB_Button_On" title="Smiley">{Image}</div></td> <td><div class="TB_Button_On" title="Smiley"><table cellpadding="0" cellspacing="0"><tr><td>{Image}</td><td nowrap>Toolbar Button</td><td><img class="TB_Button_Padding"></td></tr></table></div></td> <td><div class="TB_Button_On" title="Smiley"><table cellpadding="0" cellspacing="0"><tr><td><img class="TB_Button_Padding"></td><td nowrap>Toolbar Button</td><td><img class="TB_Button_Padding"></td></tr></table></div></td> These are samples of possible {Image} values: Strip - IE version: <div class="TB_Button_Image"><img src="strip.gif" style="top:-16px"></div> Strip : Firefox, Safari and Opera version <img class="TB_Button_Image" style="background-position: 0px -16px;background-image: url(strip.gif);"> No-Strip : Browser independent: <img class="TB_Button_Image" src="smiley.gif"> */
JavaScript
/* * 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 == * * FCKSpecialCombo Class: represents a special combo. */ var FCKSpecialCombo = function( caption, fieldWidth, panelWidth, panelMaxHeight, parentWindow ) { // Default properties values. this.FieldWidth = fieldWidth || 100 ; this.PanelWidth = panelWidth || 150 ; this.PanelMaxHeight = panelMaxHeight || 150 ; this.Label = '&nbsp;' ; this.Caption = caption ; this.Tooltip = caption ; this.Style = FCK_TOOLBARITEM_ICONTEXT ; this.Enabled = true ; this.Items = new Object() ; this._Panel = new FCKPanel( parentWindow || window ) ; this._Panel.AppendStyleSheet( FCKConfig.SkinEditorCSS ) ; this._PanelBox = this._Panel.MainNode.appendChild( this._Panel.Document.createElement( 'DIV' ) ) ; this._PanelBox.className = 'SC_Panel' ; this._PanelBox.style.width = this.PanelWidth + 'px' ; this._PanelBox.innerHTML = '<table cellpadding="0" cellspacing="0" width="100%" style="TABLE-LAYOUT: fixed"><tr><td nowrap></td></tr></table>' ; this._ItemsHolderEl = this._PanelBox.getElementsByTagName('TD')[0] ; if ( FCK.IECleanup ) FCK.IECleanup.AddItem( this, FCKSpecialCombo_Cleanup ) ; // this._Panel.StyleSheet = FCKConfig.SkinPath + 'fck_contextmenu.css' ; // this._Panel.Create() ; // this._Panel.PanelDiv.className += ' SC_Panel' ; // this._Panel.PanelDiv.innerHTML = '<table cellpadding="0" cellspacing="0" width="100%" style="TABLE-LAYOUT: fixed"><tr><td nowrap></td></tr></table>' ; // this._ItemsHolderEl = this._Panel.PanelDiv.getElementsByTagName('TD')[0] ; } function FCKSpecialCombo_ItemOnMouseOver() { this.className += ' SC_ItemOver' ; } function FCKSpecialCombo_ItemOnMouseOut() { this.className = this.originalClass ; } function FCKSpecialCombo_ItemOnClick( ev, specialCombo, itemId ) { this.className = this.originalClass ; specialCombo._Panel.Hide() ; specialCombo.SetLabel( this.FCKItemLabel ) ; if ( typeof( specialCombo.OnSelect ) == 'function' ) specialCombo.OnSelect( itemId, this ) ; } FCKSpecialCombo.prototype.ClearItems = function () { if ( this.Items ) this.Items = {} ; var itemsholder = this._ItemsHolderEl ; while ( itemsholder.firstChild ) itemsholder.removeChild( itemsholder.firstChild ) ; } FCKSpecialCombo.prototype.AddItem = function( id, html, label, bgColor ) { // <div class="SC_Item" onmouseover="this.className='SC_Item SC_ItemOver';" onmouseout="this.className='SC_Item';"><b>Bold 1</b></div> var oDiv = this._ItemsHolderEl.appendChild( this._Panel.Document.createElement( 'DIV' ) ) ; oDiv.className = oDiv.originalClass = 'SC_Item' ; oDiv.innerHTML = html ; oDiv.FCKItemLabel = label || id ; oDiv.Selected = false ; // In IE, the width must be set so the borders are shown correctly when the content overflows. if ( FCKBrowserInfo.IsIE ) oDiv.style.width = '100%' ; if ( bgColor ) oDiv.style.backgroundColor = bgColor ; FCKTools.AddEventListenerEx( oDiv, 'mouseover', FCKSpecialCombo_ItemOnMouseOver ) ; FCKTools.AddEventListenerEx( oDiv, 'mouseout', FCKSpecialCombo_ItemOnMouseOut ) ; FCKTools.AddEventListenerEx( oDiv, 'click', FCKSpecialCombo_ItemOnClick, [ this, id ] ) ; this.Items[ id.toString().toLowerCase() ] = oDiv ; return oDiv ; } FCKSpecialCombo.prototype.SelectItem = function( item ) { if ( typeof item == 'string' ) item = this.Items[ item.toString().toLowerCase() ] ; if ( item ) { item.className = item.originalClass = 'SC_ItemSelected' ; item.Selected = true ; } } FCKSpecialCombo.prototype.SelectItemByLabel = function( itemLabel, setLabel ) { for ( var id in this.Items ) { var oDiv = this.Items[id] ; if ( oDiv.FCKItemLabel == itemLabel ) { oDiv.className = oDiv.originalClass = 'SC_ItemSelected' ; oDiv.Selected = true ; if ( setLabel ) this.SetLabel( itemLabel ) ; } } } FCKSpecialCombo.prototype.DeselectAll = function( clearLabel ) { for ( var i in this.Items ) { if ( !this.Items[i] ) continue; this.Items[i].className = this.Items[i].originalClass = 'SC_Item' ; this.Items[i].Selected = false ; } if ( clearLabel ) this.SetLabel( '' ) ; } FCKSpecialCombo.prototype.SetLabelById = function( id ) { id = id ? id.toString().toLowerCase() : '' ; var oDiv = this.Items[ id ] ; this.SetLabel( oDiv ? oDiv.FCKItemLabel : '' ) ; } FCKSpecialCombo.prototype.SetLabel = function( text ) { text = ( !text || text.length == 0 ) ? '&nbsp;' : text ; if ( text == this.Label ) return ; this.Label = text ; var labelEl = this._LabelEl ; if ( labelEl ) { labelEl.innerHTML = text ; // It may happen that the label is some HTML, including tags. This // would be a problem because when the user click on those tags, the // combo will get the selection from the editing area. So we must // disable any kind of selection here. FCKTools.DisableSelection( labelEl ) ; } } FCKSpecialCombo.prototype.SetEnabled = function( isEnabled ) { this.Enabled = isEnabled ; // In IE it can happen when the page is reloaded that _OuterTable is null, so check its existence if ( this._OuterTable ) this._OuterTable.className = isEnabled ? '' : 'SC_FieldDisabled' ; } FCKSpecialCombo.prototype.Create = function( targetElement ) { var oDoc = FCKTools.GetElementDocument( targetElement ) ; var eOuterTable = this._OuterTable = targetElement.appendChild( oDoc.createElement( 'TABLE' ) ) ; eOuterTable.cellPadding = 0 ; eOuterTable.cellSpacing = 0 ; eOuterTable.insertRow(-1) ; var sClass ; var bShowLabel ; switch ( this.Style ) { case FCK_TOOLBARITEM_ONLYICON : sClass = 'TB_ButtonType_Icon' ; bShowLabel = false; break ; case FCK_TOOLBARITEM_ONLYTEXT : sClass = 'TB_ButtonType_Text' ; bShowLabel = false; break ; case FCK_TOOLBARITEM_ICONTEXT : bShowLabel = true; break ; } if ( this.Caption && this.Caption.length > 0 && bShowLabel ) { var oCaptionCell = eOuterTable.rows[0].insertCell(-1) ; oCaptionCell.innerHTML = this.Caption ; oCaptionCell.className = 'SC_FieldCaption' ; } // Create the main DIV element. var oField = FCKTools.AppendElement( eOuterTable.rows[0].insertCell(-1), 'div' ) ; if ( bShowLabel ) { oField.className = 'SC_Field' ; oField.style.width = this.FieldWidth + 'px' ; oField.innerHTML = '<table width="100%" cellpadding="0" cellspacing="0" style="TABLE-LAYOUT: fixed;"><tbody><tr><td class="SC_FieldLabel"><label>&nbsp;</label></td><td class="SC_FieldButton">&nbsp;</td></tr></tbody></table>' ; this._LabelEl = oField.getElementsByTagName('label')[0] ; // Memory Leak this._LabelEl.innerHTML = this.Label ; } else { oField.className = 'TB_Button_Off' ; //oField.innerHTML = '<span className="SC_FieldCaption">' + this.Caption + '<table cellpadding="0" cellspacing="0" style="TABLE-LAYOUT: fixed;"><tbody><tr><td class="SC_FieldButton" style="border-left: none;">&nbsp;</td></tr></tbody></table>' ; //oField.innerHTML = '<table cellpadding="0" cellspacing="0" style="TABLE-LAYOUT: fixed;"><tbody><tr><td class="SC_FieldButton" style="border-left: none;">&nbsp;</td></tr></tbody></table>' ; // Gets the correct CSS class to use for the specified style (param). oField.innerHTML = '<table title="' + this.Tooltip + '" class="' + sClass + '" cellspacing="0" cellpadding="0" border="0">' + '<tr>' + //'<td class="TB_Icon"><img src="' + FCKConfig.SkinPath + 'toolbar/' + this.Command.Name.toLowerCase() + '.gif" width="21" height="21"></td>' + '<td><img class="TB_Button_Padding" src="' + FCK_SPACER_PATH + '" /></td>' + '<td class="TB_Text">' + this.Caption + '</td>' + '<td><img class="TB_Button_Padding" src="' + FCK_SPACER_PATH + '" /></td>' + '<td class="TB_ButtonArrow"><img src="' + FCKConfig.SkinPath + 'images/toolbar.buttonarrow.gif" width="5" height="3"></td>' + '<td><img class="TB_Button_Padding" src="' + FCK_SPACER_PATH + '" /></td>' + '</tr>' + '</table>' ; } // Events Handlers FCKTools.AddEventListenerEx( oField, 'mouseover', FCKSpecialCombo_OnMouseOver, this ) ; FCKTools.AddEventListenerEx( oField, 'mouseout', FCKSpecialCombo_OnMouseOut, this ) ; FCKTools.AddEventListenerEx( oField, 'click', FCKSpecialCombo_OnClick, this ) ; FCKTools.DisableSelection( this._Panel.Document.body ) ; } function FCKSpecialCombo_Cleanup() { this._LabelEl = null ; this._OuterTable = null ; this._ItemsHolderEl = null ; this._PanelBox = null ; if ( this.Items ) { for ( var key in this.Items ) this.Items[key] = null ; } } function FCKSpecialCombo_OnMouseOver( ev, specialCombo ) { if ( specialCombo.Enabled ) { switch ( specialCombo.Style ) { case FCK_TOOLBARITEM_ONLYICON : this.className = 'TB_Button_On_Over'; break ; case FCK_TOOLBARITEM_ONLYTEXT : this.className = 'TB_Button_On_Over'; break ; case FCK_TOOLBARITEM_ICONTEXT : this.className = 'SC_Field SC_FieldOver' ; break ; } } } function FCKSpecialCombo_OnMouseOut( ev, specialCombo ) { switch ( specialCombo.Style ) { case FCK_TOOLBARITEM_ONLYICON : this.className = 'TB_Button_Off'; break ; case FCK_TOOLBARITEM_ONLYTEXT : this.className = 'TB_Button_Off'; break ; case FCK_TOOLBARITEM_ICONTEXT : this.className='SC_Field' ; break ; } } function FCKSpecialCombo_OnClick( e, specialCombo ) { // For Mozilla we must stop the event propagation to avoid it hiding // the panel because of a click outside of it. // if ( e ) // { // e.stopPropagation() ; // FCKPanelEventHandlers.OnDocumentClick( e ) ; // } if ( specialCombo.Enabled ) { var oPanel = specialCombo._Panel ; var oPanelBox = specialCombo._PanelBox ; var oItemsHolder = specialCombo._ItemsHolderEl ; var iMaxHeight = specialCombo.PanelMaxHeight ; if ( specialCombo.OnBeforeClick ) specialCombo.OnBeforeClick( specialCombo ) ; // This is a tricky thing. We must call the "Load" function, otherwise // it will not be possible to retrieve "oItemsHolder.offsetHeight" (IE only). if ( FCKBrowserInfo.IsIE ) oPanel.Preload( 0, this.offsetHeight, this ) ; if ( oItemsHolder.offsetHeight > iMaxHeight ) // { oPanelBox.style.height = iMaxHeight + 'px' ; // if ( FCKBrowserInfo.IsGecko ) // oPanelBox.style.overflow = '-moz-scrollbars-vertical' ; // } else oPanelBox.style.height = '' ; // oPanel.PanelDiv.style.width = specialCombo.PanelWidth + 'px' ; oPanel.Show( 0, this.offsetHeight, this ) ; } // return false ; } /* Sample Combo Field HTML output: <div class="SC_Field" style="width: 80px;"> <table width="100%" cellpadding="0" cellspacing="0" style="table-layout: fixed;"> <tbody> <tr> <td class="SC_FieldLabel"><label>&nbsp;</label></td> <td class="SC_FieldButton">&nbsp;</td> </tr> </tbody> </table> </div> */
JavaScript
/* * 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 == * * FCKToolbarPanelButton Class: Handles the Fonts combo selector. */ var FCKToolbarFontFormatCombo = function( tooltip, style ) { if ( tooltip === false ) return ; this.CommandName = 'FontFormat' ; this.Label = this.GetLabel() ; this.Tooltip = tooltip ? tooltip : this.Label ; this.Style = style ? style : FCK_TOOLBARITEM_ICONTEXT ; this.NormalLabel = 'Normal' ; this.PanelWidth = 190 ; this.DefaultLabel = FCKConfig.DefaultFontFormatLabel || '' ; } // Inherit from FCKToolbarSpecialCombo. FCKToolbarFontFormatCombo.prototype = new FCKToolbarStyleCombo( false ) ; FCKToolbarFontFormatCombo.prototype.GetLabel = function() { return FCKLang.FontFormat ; } FCKToolbarFontFormatCombo.prototype.GetStyles = function() { var styles = {} ; // Get the format names from the language file. var aNames = FCKLang['FontFormats'].split(';') ; var oNames = { p : aNames[0], pre : aNames[1], address : aNames[2], h1 : aNames[3], h2 : aNames[4], h3 : aNames[5], h4 : aNames[6], h5 : aNames[7], h6 : aNames[8], div : aNames[9] || ( aNames[0] + ' (DIV)') } ; // Get the available formats from the configuration file. var elements = FCKConfig.FontFormats.split(';') ; for ( var i = 0 ; i < elements.length ; i++ ) { var elementName = elements[ i ] ; var style = FCKStyles.GetStyle( '_FCK_' + elementName ) ; if ( style ) { style.Label = oNames[ elementName ] ; styles[ '_FCK_' + elementName ] = style ; } else alert( "The FCKConfig.CoreStyles['" + elementName + "'] setting was not found. Please check the fckconfig.js file" ) ; } return styles ; } FCKToolbarFontFormatCombo.prototype.RefreshActiveItems = function( targetSpecialCombo ) { var startElement = FCK.ToolbarSet.CurrentInstance.Selection.GetBoundaryParentElement( true ) ; if ( startElement ) { var path = new FCKElementPath( startElement ) ; var blockElement = path.Block ; if ( blockElement ) { for ( var i in targetSpecialCombo.Items ) { var item = targetSpecialCombo.Items[i] ; var style = item.Style ; if ( style.CheckElementRemovable( blockElement ) ) { targetSpecialCombo.SetLabel( style.Label ) ; return ; } } } } targetSpecialCombo.SetLabel( this.DefaultLabel ) ; } FCKToolbarFontFormatCombo.prototype.StyleCombo_OnBeforeClick = function( targetSpecialCombo ) { // Clear the current selection. targetSpecialCombo.DeselectAll() ; var startElement = FCK.ToolbarSet.CurrentInstance.Selection.GetBoundaryParentElement( true ) ; if ( startElement ) { var path = new FCKElementPath( startElement ) ; var blockElement = path.Block ; for ( var i in targetSpecialCombo.Items ) { var item = targetSpecialCombo.Items[i] ; var style = item.Style ; if ( style.CheckElementRemovable( blockElement ) ) { targetSpecialCombo.SelectItem( item ) ; return ; } } } }
JavaScript
/* * 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 == * * FCKStyle Class: contains a style definition, and all methods to work with * the style in a document. */ /** * @param {Object} styleDesc A "style descriptor" object, containing the raw * style definition in the following format: * '<style name>' : { * Element : '<element name>', * Attributes : { * '<att name>' : '<att value>', * ... * }, * Styles : { * '<style name>' : '<style value>', * ... * }, * Overrides : '<element name>'|{ * Element : '<element name>', * Attributes : { * '<att name>' : '<att value>'|/<att regex>/ * }, * Styles : { * '<style name>' : '<style value>'|/<style regex>/ * }, * } * } */ var FCKStyle = function( styleDesc ) { this.Element = ( styleDesc.Element || 'span' ).toLowerCase() ; this._StyleDesc = styleDesc ; } FCKStyle.prototype = { /** * Get the style type, based on its element name: * - FCK_STYLE_BLOCK (0): Block Style * - FCK_STYLE_INLINE (1): Inline Style * - FCK_STYLE_OBJECT (2): Object Style */ GetType : function() { var type = this.GetType_$ ; if ( type != undefined ) return type ; var elementName = this.Element ; if ( elementName == '#' || FCKListsLib.StyleBlockElements[ elementName ] ) type = FCK_STYLE_BLOCK ; else if ( FCKListsLib.StyleObjectElements[ elementName ] ) type = FCK_STYLE_OBJECT ; else type = FCK_STYLE_INLINE ; return ( this.GetType_$ = type ) ; }, /** * Apply the style to the current selection. */ ApplyToSelection : function( targetWindow ) { // Create a range for the current selection. var range = new FCKDomRange( targetWindow ) ; range.MoveToSelection() ; this.ApplyToRange( range, true ) ; }, /** * Apply the style to a FCKDomRange. */ ApplyToRange : function( range, selectIt, updateRange ) { // ApplyToRange is not valid for FCK_STYLE_OBJECT types. // Use ApplyToObject instead. switch ( this.GetType() ) { case FCK_STYLE_BLOCK : this.ApplyToRange = this._ApplyBlockStyle ; break ; case FCK_STYLE_INLINE : this.ApplyToRange = this._ApplyInlineStyle ; break ; default : return ; } this.ApplyToRange( range, selectIt, updateRange ) ; }, /** * Apply the style to an object. Valid for FCK_STYLE_BLOCK types only. */ ApplyToObject : function( objectElement ) { if ( !objectElement ) return ; this.BuildElement( null, objectElement ) ; }, /** * Remove the style from the current selection. */ RemoveFromSelection : function( targetWindow ) { // Create a range for the current selection. var range = new FCKDomRange( targetWindow ) ; range.MoveToSelection() ; this.RemoveFromRange( range, true ) ; }, /** * Remove the style from a FCKDomRange. Block type styles will have no * effect. */ RemoveFromRange : function( range, selectIt, updateRange ) { var bookmark ; // Create the attribute list to be used later for element comparisons. var styleAttribs = this._GetAttribsForComparison() ; var styleOverrides = this._GetOverridesForComparison() ; // If collapsed, we are removing all conflicting styles from the range // parent tree. if ( range.CheckIsCollapsed() ) { // Bookmark the range so we can re-select it after processing. var bookmark = range.CreateBookmark( true ) ; // Let's start from the bookmark <span> parent. var bookmarkStart = range.GetBookmarkNode( bookmark, true ) ; var path = new FCKElementPath( bookmarkStart.parentNode ) ; // While looping through the path, we'll be saving references to // parent elements if the range is in one of their boundaries. In // this way, we are able to create a copy of those elements when // removing a style if the range is in a boundary limit (see #1270). var boundaryElements = [] ; // Check if the range is in the boundary limits of an element // (related to #1270). var isBoundaryRight = !FCKDomTools.GetNextSibling( bookmarkStart ) ; var isBoundary = isBoundaryRight || !FCKDomTools.GetPreviousSibling( bookmarkStart ) ; // This is the last element to be removed in the boundary situation // described at #1270. var lastBoundaryElement ; var boundaryLimitIndex = -1 ; for ( var i = 0 ; i < path.Elements.length ; i++ ) { var pathElement = path.Elements[i] ; if ( this.CheckElementRemovable( pathElement ) ) { if ( isBoundary && !FCKDomTools.CheckIsEmptyElement( pathElement, function( el ) { return ( el != bookmarkStart ) ; } ) ) { lastBoundaryElement = pathElement ; // We'll be continuously including elements in the // boundaryElements array, but only those added before // setting lastBoundaryElement must be used later, so // let's mark the current index here. boundaryLimitIndex = boundaryElements.length - 1 ; } else { var pathElementName = pathElement.nodeName.toLowerCase() ; if ( pathElementName == this.Element ) { // Remove any attribute that conflict with this style, no // matter their values. for ( var att in styleAttribs ) { if ( FCKDomTools.HasAttribute( pathElement, att ) ) { switch ( att ) { case 'style' : this._RemoveStylesFromElement( pathElement ) ; break ; case 'class' : // The 'class' element value must match (#1318). if ( FCKDomTools.GetAttributeValue( pathElement, att ) != this.GetFinalAttributeValue( att ) ) continue ; /*jsl:fallthru*/ default : FCKDomTools.RemoveAttribute( pathElement, att ) ; } } } } // Remove overrides defined to the same element name. this._RemoveOverrides( pathElement, styleOverrides[ pathElementName ] ) ; // Remove the element if no more attributes are available and it's an inline style element if ( this.GetType() == FCK_STYLE_INLINE) this._RemoveNoAttribElement( pathElement ) ; } } else if ( isBoundary ) boundaryElements.push( pathElement ) ; // Check if we are still in a boundary (at the same side). isBoundary = isBoundary && ( ( isBoundaryRight && !FCKDomTools.GetNextSibling( pathElement ) ) || ( !isBoundaryRight && !FCKDomTools.GetPreviousSibling( pathElement ) ) ) ; // If we are in an element that is not anymore a boundary, or // we are at the last element, let's move things outside the // boundary (if available). if ( lastBoundaryElement && ( !isBoundary || ( i == path.Elements.length - 1 ) ) ) { // Remove the bookmark node from the DOM. var currentElement = FCKDomTools.RemoveNode( bookmarkStart ) ; // Build the collapsed group of elements that are not // removed by this style, but share the boundary. // (see comment 1 and 2 at #1270) for ( var j = 0 ; j <= boundaryLimitIndex ; j++ ) { var newElement = FCKDomTools.CloneElement( boundaryElements[j] ) ; newElement.appendChild( currentElement ) ; currentElement = newElement ; } // Re-insert the bookmark node (and the collapsed elements) // in the DOM, in the new position next to the styled element. if ( isBoundaryRight ) FCKDomTools.InsertAfterNode( lastBoundaryElement, currentElement ) ; else lastBoundaryElement.parentNode.insertBefore( currentElement, lastBoundaryElement ) ; isBoundary = false ; lastBoundaryElement = null ; } } // Re-select the original range. if ( selectIt ) range.SelectBookmark( bookmark ) ; if ( updateRange ) range.MoveToBookmark( bookmark ) ; return ; } // Expand the range, if inside inline element boundaries. range.Expand( 'inline_elements' ) ; // Bookmark the range so we can re-select it after processing. bookmark = range.CreateBookmark( true ) ; // The style will be applied within the bookmark boundaries. var startNode = range.GetBookmarkNode( bookmark, true ) ; var endNode = range.GetBookmarkNode( bookmark, false ) ; range.Release( true ) ; // We need to check the selection boundaries (bookmark spans) to break // the code in a way that we can properly remove partially selected nodes. // For example, removing a <b> style from // <b>This is [some text</b> to show <b>the] problem</b> // ... where [ and ] represent the selection, must result: // <b>This is </b>[some text to show the]<b> problem</b> // The strategy is simple, we just break the partial nodes before the // removal logic, having something that could be represented this way: // <b>This is </b>[<b>some text</b> to show <b>the</b>]<b> problem</b> // Let's start checking the start boundary. var path = new FCKElementPath( startNode ) ; var pathElements = path.Elements ; var pathElement ; for ( var i = 1 ; i < pathElements.length ; i++ ) { pathElement = pathElements[i] ; if ( pathElement == path.Block || pathElement == path.BlockLimit ) break ; // If this element can be removed (even partially). if ( this.CheckElementRemovable( pathElement ) ) FCKDomTools.BreakParent( startNode, pathElement, range ) ; } // Now the end boundary. path = new FCKElementPath( endNode ) ; pathElements = path.Elements ; for ( var i = 1 ; i < pathElements.length ; i++ ) { pathElement = pathElements[i] ; if ( pathElement == path.Block || pathElement == path.BlockLimit ) break ; elementName = pathElement.nodeName.toLowerCase() ; // If this element can be removed (even partially). if ( this.CheckElementRemovable( pathElement ) ) FCKDomTools.BreakParent( endNode, pathElement, range ) ; } // Navigate through all nodes between the bookmarks. var currentNode = FCKDomTools.GetNextSourceNode( startNode, true ) ; while ( currentNode ) { // Cache the next node to be processed. Do it now, because // currentNode may be removed. var nextNode = FCKDomTools.GetNextSourceNode( currentNode ) ; // Remove elements nodes that match with this style rules. if ( currentNode.nodeType == 1 ) { var elementName = currentNode.nodeName.toLowerCase() ; var mayRemove = ( elementName == this.Element ) ; if ( mayRemove ) { // Remove any attribute that conflict with this style, no matter // their values. for ( var att in styleAttribs ) { if ( FCKDomTools.HasAttribute( currentNode, att ) ) { switch ( att ) { case 'style' : this._RemoveStylesFromElement( currentNode ) ; break ; case 'class' : // The 'class' element value must match (#1318). if ( FCKDomTools.GetAttributeValue( currentNode, att ) != this.GetFinalAttributeValue( att ) ) continue ; /*jsl:fallthru*/ default : FCKDomTools.RemoveAttribute( currentNode, att ) ; } } } } else mayRemove = !!styleOverrides[ elementName ] ; if ( mayRemove ) { // Remove overrides defined to the same element name. this._RemoveOverrides( currentNode, styleOverrides[ elementName ] ) ; // Remove the element if no more attributes are available. this._RemoveNoAttribElement( currentNode ) ; } } // If we have reached the end of the selection, stop looping. if ( nextNode == endNode ) break ; currentNode = nextNode ; } this._FixBookmarkStart( startNode ) ; // Re-select the original range. if ( selectIt ) range.SelectBookmark( bookmark ) ; if ( updateRange ) range.MoveToBookmark( bookmark ) ; }, /** * Checks if an element, or any of its attributes, is removable by the * current style definition. */ CheckElementRemovable : function( element, fullMatch ) { if ( !element ) return false ; var elementName = element.nodeName.toLowerCase() ; // If the element name is the same as the style name. if ( elementName == this.Element ) { // If no attributes are defined in the element. if ( !fullMatch && !FCKDomTools.HasAttributes( element ) ) return true ; // If any attribute conflicts with the style attributes. var attribs = this._GetAttribsForComparison() ; var allMatched = ( attribs._length == 0 ) ; for ( var att in attribs ) { if ( att == '_length' ) continue ; if ( this._CompareAttributeValues( att, FCKDomTools.GetAttributeValue( element, att ), ( this.GetFinalAttributeValue( att ) || '' ) ) ) { allMatched = true ; if ( !fullMatch ) break ; } else { allMatched = false ; if ( fullMatch ) return false ; } } if ( allMatched ) return true ; } // Check if the element can be somehow overriden. var override = this._GetOverridesForComparison()[ elementName ] ; if ( override ) { // If no attributes have been defined, remove the element. if ( !( attribs = override.Attributes ) ) // Only one "=" return true ; for ( var i = 0 ; i < attribs.length ; i++ ) { var attName = attribs[i][0] ; if ( FCKDomTools.HasAttribute( element, attName ) ) { var attValue = attribs[i][1] ; // Remove the attribute if: // - The override definition value is null ; // - The override definition valie is a string that // matches the attribute value exactly. // - The override definition value is a regex that // has matches in the attribute value. if ( attValue == null || ( typeof attValue == 'string' && FCKDomTools.GetAttributeValue( element, attName ) == attValue ) || attValue.test( FCKDomTools.GetAttributeValue( element, attName ) ) ) return true ; } } } return false ; }, /** * Get the style state for an element path. Returns "true" if the element * is active in the path. */ CheckActive : function( elementPath ) { switch ( this.GetType() ) { case FCK_STYLE_BLOCK : return this.CheckElementRemovable( elementPath.Block || elementPath.BlockLimit, true ) ; case FCK_STYLE_INLINE : var elements = elementPath.Elements ; for ( var i = 0 ; i < elements.length ; i++ ) { var element = elements[i] ; if ( element == elementPath.Block || element == elementPath.BlockLimit ) continue ; if ( this.CheckElementRemovable( element, true ) ) return true ; } } return false ; }, /** * Removes an inline style from inside an element tree. The element node * itself is not checked or removed, only the child tree inside of it. */ RemoveFromElement : function( element ) { var attribs = this._GetAttribsForComparison() ; var overrides = this._GetOverridesForComparison() ; // Get all elements with the same name. var innerElements = element.getElementsByTagName( this.Element ) ; for ( var i = innerElements.length - 1 ; i >= 0 ; i-- ) { var innerElement = innerElements[i] ; // Remove any attribute that conflict with this style, no matter // their values. for ( var att in attribs ) { if ( FCKDomTools.HasAttribute( innerElement, att ) ) { switch ( att ) { case 'style' : this._RemoveStylesFromElement( innerElement ) ; break ; case 'class' : // The 'class' element value must match (#1318). if ( FCKDomTools.GetAttributeValue( innerElement, att ) != this.GetFinalAttributeValue( att ) ) continue ; /*jsl:fallthru*/ default : FCKDomTools.RemoveAttribute( innerElement, att ) ; } } } // Remove overrides defined to the same element name. this._RemoveOverrides( innerElement, overrides[ this.Element ] ) ; // Remove the element if no more attributes are available. this._RemoveNoAttribElement( innerElement ) ; } // Now remove any other element with different name that is // defined to be overriden. for ( var overrideElement in overrides ) { if ( overrideElement != this.Element ) { // Get all elements. innerElements = element.getElementsByTagName( overrideElement ) ; for ( var i = innerElements.length - 1 ; i >= 0 ; i-- ) { var innerElement = innerElements[i] ; this._RemoveOverrides( innerElement, overrides[ overrideElement ] ) ; this._RemoveNoAttribElement( innerElement ) ; } } } }, _RemoveStylesFromElement : function( element ) { var elementStyle = element.style.cssText ; var pattern = this.GetFinalStyleValue() ; if ( elementStyle.length > 0 && pattern.length == 0 ) return ; pattern = '(^|;)\\s*(' + pattern.replace( /\s*([^ ]+):.*?(;|$)/g, '$1|' ).replace( /\|$/, '' ) + '):[^;]+' ; var regex = new RegExp( pattern, 'gi' ) ; elementStyle = elementStyle.replace( regex, '' ).Trim() ; if ( elementStyle.length == 0 || elementStyle == ';' ) FCKDomTools.RemoveAttribute( element, 'style' ) ; else element.style.cssText = elementStyle.replace( regex, '' ) ; }, /** * Remove all attributes that are defined to be overriden, */ _RemoveOverrides : function( element, override ) { var attributes = override && override.Attributes ; if ( attributes ) { for ( var i = 0 ; i < attributes.length ; i++ ) { var attName = attributes[i][0] ; if ( FCKDomTools.HasAttribute( element, attName ) ) { var attValue = attributes[i][1] ; // Remove the attribute if: // - The override definition value is null ; // - The override definition valie is a string that // matches the attribute value exactly. // - The override definition value is a regex that // has matches in the attribute value. if ( attValue == null || ( attValue.test && attValue.test( FCKDomTools.GetAttributeValue( element, attName ) ) ) || ( typeof attValue == 'string' && FCKDomTools.GetAttributeValue( element, attName ) == attValue ) ) FCKDomTools.RemoveAttribute( element, attName ) ; } } } }, /** * If the element has no more attributes, remove it. */ _RemoveNoAttribElement : function( element ) { // If no more attributes remained in the element, remove it, // leaving its children. if ( !FCKDomTools.HasAttributes( element ) ) { // Removing elements may open points where merging is possible, // so let's cache the first and last nodes for later checking. var firstChild = element.firstChild ; var lastChild = element.lastChild ; FCKDomTools.RemoveNode( element, true ) ; // Check the cached nodes for merging. this._MergeSiblings( firstChild ) ; if ( firstChild != lastChild ) this._MergeSiblings( lastChild ) ; } }, /** * Creates a DOM element for this style object. */ BuildElement : function( targetDoc, element ) { // Create the element. var el = element || targetDoc.createElement( this.Element ) ; // Assign all defined attributes. var attribs = this._StyleDesc.Attributes ; var attValue ; if ( attribs ) { for ( var att in attribs ) { attValue = this.GetFinalAttributeValue( att ) ; if ( att.toLowerCase() == 'class' ) el.className = attValue ; else el.setAttribute( att, attValue ) ; } } // Assign the style attribute. if ( this._GetStyleText().length > 0 ) el.style.cssText = this.GetFinalStyleValue() ; return el ; }, _CompareAttributeValues : function( attName, valueA, valueB ) { if ( attName == 'style' && valueA && valueB ) { valueA = valueA.replace( /;$/, '' ).toLowerCase() ; valueB = valueB.replace( /;$/, '' ).toLowerCase() ; } // Return true if they match or if valueA is null and valueB is an empty string return ( valueA == valueB || ( ( valueA === null || valueA === '' ) && ( valueB === null || valueB === '' ) ) ) }, GetFinalAttributeValue : function( attName ) { var attValue = this._StyleDesc.Attributes ; var attValue = attValue ? attValue[ attName ] : null ; if ( !attValue && attName == 'style' ) return this.GetFinalStyleValue() ; if ( attValue && this._Variables ) // Using custom Replace() to guarantee the correct scope. attValue = attValue.Replace( FCKRegexLib.StyleVariableAttName, this._GetVariableReplace, this ) ; return attValue ; }, GetFinalStyleValue : function() { var attValue = this._GetStyleText() ; if ( attValue.length > 0 && this._Variables ) { // Using custom Replace() to guarantee the correct scope. attValue = attValue.Replace( FCKRegexLib.StyleVariableAttName, this._GetVariableReplace, this ) ; attValue = FCKTools.NormalizeCssText( attValue ) ; } return attValue ; }, _GetVariableReplace : function() { // The second group in the regex is the variable name. return this._Variables[ arguments[2] ] || arguments[0] ; }, /** * Set the value of a variable attribute or style, to be used when * appliying the style. */ SetVariable : function( name, value ) { var variables = this._Variables ; if ( !variables ) variables = this._Variables = {} ; this._Variables[ name ] = value ; }, /** * Converting from a PRE block to a non-PRE block in formatting operations. */ _FromPre : function( doc, block, newBlock ) { var innerHTML = block.innerHTML ; // Trim the first and last linebreaks immediately after and before <pre>, </pre>, // if they exist. // This is done because the linebreaks are not rendered. innerHTML = innerHTML.replace( /(\r\n|\r)/g, '\n' ) ; innerHTML = innerHTML.replace( /^[ \t]*\n/, '' ) ; innerHTML = innerHTML.replace( /\n$/, '' ) ; // 1. Convert spaces or tabs at the beginning or at the end to &nbsp; innerHTML = innerHTML.replace( /^[ \t]+|[ \t]+$/g, function( match, offset, s ) { if ( match.length == 1 ) // one space, preserve it return '&nbsp;' ; else if ( offset == 0 ) // beginning of block return new Array( match.length ).join( '&nbsp;' ) + ' ' ; else // end of block return ' ' + new Array( match.length ).join( '&nbsp;' ) ; } ) ; // 2. Convert \n to <BR>. // 3. Convert contiguous (i.e. non-singular) spaces or tabs to &nbsp; var htmlIterator = new FCKHtmlIterator( innerHTML ) ; var results = [] ; htmlIterator.Each( function( isTag, value ) { if ( !isTag ) { value = value.replace( /\n/g, '<br>' ) ; value = value.replace( /[ \t]{2,}/g, function ( match ) { return new Array( match.length ).join( '&nbsp;' ) + ' ' ; } ) ; } results.push( value ) ; } ) ; newBlock.innerHTML = results.join( '' ) ; return newBlock ; }, /** * Converting from a non-PRE block to a PRE block in formatting operations. */ _ToPre : function( doc, block, newBlock ) { // Handle converting from a regular block to a <pre> block. var innerHTML = block.innerHTML.Trim() ; // 1. Delete ANSI whitespaces immediately before and after <BR> because // they are not visible. // 2. Mark down any <BR /> nodes here so they can be turned into \n in // the next step and avoid being compressed. innerHTML = innerHTML.replace( /[ \t\r\n]*(<br[^>]*>)[ \t\r\n]*/gi, '<br />' ) ; // 3. Compress other ANSI whitespaces since they're only visible as one // single space previously. // 4. Convert &nbsp; to spaces since &nbsp; is no longer needed in <PRE>. // 5. Convert any <BR /> to \n. This must not be done earlier because // the \n would then get compressed. var htmlIterator = new FCKHtmlIterator( innerHTML ) ; var results = [] ; htmlIterator.Each( function( isTag, value ) { if ( !isTag ) value = value.replace( /([ \t\n\r]+|&nbsp;)/g, ' ' ) ; else if ( isTag && value == '<br />' ) value = '\n' ; results.push( value ) ; } ) ; // Assigning innerHTML to <PRE> in IE causes all linebreaks to be // reduced to spaces. // Assigning outerHTML to <PRE> in IE doesn't work if the <PRE> isn't // contained in another node since the node reference is changed after // outerHTML assignment. // So, we need some hacks to workaround IE bugs here. if ( FCKBrowserInfo.IsIE ) { var temp = doc.createElement( 'div' ) ; temp.appendChild( newBlock ) ; newBlock.outerHTML = '<pre>\n' + results.join( '' ) + '</pre>' ; newBlock = temp.removeChild( temp.firstChild ) ; } else newBlock.innerHTML = results.join( '' ) ; return newBlock ; }, /** * Merge a <pre> block with a previous <pre> block, if available. */ _CheckAndMergePre : function( previousBlock, preBlock ) { // Check if the previous block and the current block are next // to each other. if ( previousBlock != FCKDomTools.GetPreviousSourceElement( preBlock, true ) ) return ; // Merge the previous <pre> block contents into the current <pre> // block. // // Another thing to be careful here is that currentBlock might contain // a '\n' at the beginning, and previousBlock might contain a '\n' // towards the end. These new lines are not normally displayed but they // become visible after merging. var innerHTML = previousBlock.innerHTML.replace( /\n$/, '' ) + '\n\n' + preBlock.innerHTML.replace( /^\n/, '' ) ; // Buggy IE normalizes innerHTML from <pre>, breaking whitespaces. if ( FCKBrowserInfo.IsIE ) preBlock.outerHTML = '<pre>' + innerHTML + '</pre>' ; else preBlock.innerHTML = innerHTML ; // Remove the previous <pre> block. // // The preBlock must not be moved or deleted from the DOM tree. This // guarantees the FCKDomRangeIterator in _ApplyBlockStyle would not // get lost at the next iteration. FCKDomTools.RemoveNode( previousBlock ) ; }, _CheckAndSplitPre : function( newBlock ) { var lastNewBlock ; var cursor = newBlock.firstChild ; // We are not splitting <br><br> at the beginning of the block, so // we'll start from the second child. cursor = cursor && cursor.nextSibling ; while ( cursor ) { var next = cursor.nextSibling ; // If we have two <BR>s, and they're not at the beginning or the end, // then we'll split up the contents following them into another block. // Stop processing if we are at the last child couple. if ( next && next.nextSibling && cursor.nodeName.IEquals( 'br' ) && next.nodeName.IEquals( 'br' ) ) { // Remove the first <br>. FCKDomTools.RemoveNode( cursor ) ; // Move to the node after the second <br>. cursor = next.nextSibling ; // Remove the second <br>. FCKDomTools.RemoveNode( next ) ; // Create the block that will hold the child nodes from now on. lastNewBlock = FCKDomTools.InsertAfterNode( lastNewBlock || newBlock, FCKDomTools.CloneElement( newBlock ) ) ; continue ; } // If we split it, then start moving the nodes to the new block. if ( lastNewBlock ) { cursor = cursor.previousSibling ; FCKDomTools.MoveNode(cursor.nextSibling, lastNewBlock ) ; } cursor = cursor.nextSibling ; } }, /** * Apply an inline style to a FCKDomRange. * * TODO * - Implement the "#" style handling. * - Properly handle block containers like <div> and <blockquote>. */ _ApplyBlockStyle : function( range, selectIt, updateRange ) { // Bookmark the range so we can re-select it after processing. var bookmark ; if ( selectIt ) bookmark = range.CreateBookmark() ; var iterator = new FCKDomRangeIterator( range ) ; iterator.EnforceRealBlocks = true ; var block ; var doc = range.Window.document ; var previousPreBlock ; while( ( block = iterator.GetNextParagraph() ) ) // Only one = { // Create the new node right before the current one. var newBlock = this.BuildElement( doc ) ; // Check if we are changing from/to <pre>. var newBlockIsPre = newBlock.nodeName.IEquals( 'pre' ) ; var blockIsPre = block.nodeName.IEquals( 'pre' ) ; var toPre = newBlockIsPre && !blockIsPre ; var fromPre = !newBlockIsPre && blockIsPre ; // Move everything from the current node to the new one. if ( toPre ) newBlock = this._ToPre( doc, block, newBlock ) ; else if ( fromPre ) newBlock = this._FromPre( doc, block, newBlock ) ; else // Convering from a regular block to another regular block. FCKDomTools.MoveChildren( block, newBlock ) ; // Replace the current block. block.parentNode.insertBefore( newBlock, block ) ; FCKDomTools.RemoveNode( block ) ; // Complete other tasks after inserting the node in the DOM. if ( newBlockIsPre ) { if ( previousPreBlock ) this._CheckAndMergePre( previousPreBlock, newBlock ) ; // Merge successive <pre> blocks. previousPreBlock = newBlock ; } else if ( fromPre ) this._CheckAndSplitPre( newBlock ) ; // Split <br><br> in successive <pre>s. } // Re-select the original range. if ( selectIt ) range.SelectBookmark( bookmark ) ; if ( updateRange ) range.MoveToBookmark( bookmark ) ; }, /** * Apply an inline style to a FCKDomRange. * * TODO * - Merge elements, when applying styles to similar elements that enclose * the entire selection, outputing: * <span style="color: #ff0000; background-color: #ffffff">XYZ</span> * instead of: * <span style="color: #ff0000;"><span style="background-color: #ffffff">XYZ</span></span> */ _ApplyInlineStyle : function( range, selectIt, updateRange ) { var doc = range.Window.document ; if ( range.CheckIsCollapsed() ) { // Create the element to be inserted in the DOM. var collapsedElement = this.BuildElement( doc ) ; range.InsertNode( collapsedElement ) ; range.MoveToPosition( collapsedElement, 2 ) ; range.Select() ; return ; } // The general idea here is navigating through all nodes inside the // current selection, working on distinct range blocks, defined by the // DTD compatibility between the style element and the nodes inside the // ranges. // // For example, suppose we have the following selection (where [ and ] // are the boundaries), and we apply a <b> style there: // // <p>Here we [have <b>some</b> text.<p> // <p>And some here] here.</p> // // Two different ranges will be detected: // // "have <b>some</b> text." // "And some here" // // Both ranges will be extracted, moved to a <b> element, and // re-inserted, resulting in the following output: // // <p>Here we [<b>have some text.</b><p> // <p><b>And some here</b>] here.</p> // // Note that the <b> element at <b>some</b> is also removed because it // is not needed anymore. var elementName = this.Element ; // Get the DTD definition for the element. Defaults to "span". var elementDTD = FCK.DTD[ elementName ] || FCK.DTD.span ; // Create the attribute list to be used later for element comparisons. var styleAttribs = this._GetAttribsForComparison() ; var styleNode ; // Expand the range, if inside inline element boundaries. range.Expand( 'inline_elements' ) ; // Bookmark the range so we can re-select it after processing. var bookmark = range.CreateBookmark( true ) ; // The style will be applied within the bookmark boundaries. var startNode = range.GetBookmarkNode( bookmark, true ) ; var endNode = range.GetBookmarkNode( bookmark, false ) ; // We'll be reusing the range to apply the styles. So, release it here // to indicate that it has not been initialized. range.Release( true ) ; // Let's start the nodes lookup from the node right after the bookmark // span. var currentNode = FCKDomTools.GetNextSourceNode( startNode, true ) ; while ( currentNode ) { var applyStyle = false ; var nodeType = currentNode.nodeType ; var nodeName = nodeType == 1 ? currentNode.nodeName.toLowerCase() : null ; // Check if the current node can be a child of the style element. if ( !nodeName || elementDTD[ nodeName ] ) { // Check if the style element can be a child of the current // node parent or if the element is not defined in the DTD. if ( ( FCK.DTD[ currentNode.parentNode.nodeName.toLowerCase() ] || FCK.DTD.span )[ elementName ] || !FCK.DTD[ elementName ] ) { // This node will be part of our range, so if it has not // been started, place its start right before the node. if ( !range.CheckHasRange() ) range.SetStart( currentNode, 3 ) ; // Non element nodes, or empty elements can be added // completely to the range. if ( nodeType != 1 || currentNode.childNodes.length == 0 ) { var includedNode = currentNode ; var parentNode = includedNode.parentNode ; // This node is about to be included completelly, but, // if this is the last node in its parent, we must also // check if the parent itself can be added completelly // to the range. while ( includedNode == parentNode.lastChild && elementDTD[ parentNode.nodeName.toLowerCase() ] ) { includedNode = parentNode ; } range.SetEnd( includedNode, 4 ) ; // If the included node is the last node in its parent // and its parent can't be inside the style node, apply // the style immediately. if ( includedNode == includedNode.parentNode.lastChild && !elementDTD[ includedNode.parentNode.nodeName.toLowerCase() ] ) applyStyle = true ; } else { // Element nodes will not be added directly. We need to // check their children because the selection could end // inside the node, so let's place the range end right // before the element. range.SetEnd( currentNode, 3 ) ; } } else applyStyle = true ; } else applyStyle = true ; // Get the next node to be processed. currentNode = FCKDomTools.GetNextSourceNode( currentNode ) ; // If we have reached the end of the selection, just apply the // style ot the range, and stop looping. if ( currentNode == endNode ) { currentNode = null ; applyStyle = true ; } // Apply the style if we have something to which apply it. if ( applyStyle && range.CheckHasRange() && !range.CheckIsCollapsed() ) { // Build the style element, based on the style object definition. styleNode = this.BuildElement( doc ) ; // Move the contents of the range to the style element. range.ExtractContents().AppendTo( styleNode ) ; // If it is not empty. if ( styleNode.innerHTML.RTrim().length > 0 ) { // Insert it in the range position (it is collapsed after // ExtractContents. range.InsertNode( styleNode ) ; // Here we do some cleanup, removing all duplicated // elements from the style element. this.RemoveFromElement( styleNode ) ; // Let's merge our new style with its neighbors, if possible. this._MergeSiblings( styleNode, this._GetAttribsForComparison() ) ; // As the style system breaks text nodes constantly, let's normalize // things for performance. // With IE, some paragraphs get broken when calling normalize() // repeatedly. Also, for IE, we must normalize body, not documentElement. // IE is also known for having a "crash effect" with normalize(). // We should try to normalize with IE too in some way, somewhere. if ( !FCKBrowserInfo.IsIE ) styleNode.normalize() ; } // Style applied, let's release the range, so it gets marked to // re-initialization in the next loop. range.Release( true ) ; } } this._FixBookmarkStart( startNode ) ; // Re-select the original range. if ( selectIt ) range.SelectBookmark( bookmark ) ; if ( updateRange ) range.MoveToBookmark( bookmark ) ; }, _FixBookmarkStart : function( startNode ) { // After appliying or removing an inline style, the start boundary of // the selection must be placed inside all inline elements it is // bordering. var startSibling ; while ( ( startSibling = startNode.nextSibling ) ) // Only one "=". { if ( startSibling.nodeType == 1 && FCKListsLib.InlineNonEmptyElements[ startSibling.nodeName.toLowerCase() ] ) { // If it is an empty inline element, we can safely remove it. if ( !startSibling.firstChild ) FCKDomTools.RemoveNode( startSibling ) ; else FCKDomTools.MoveNode( startNode, startSibling, true ) ; continue ; } // Empty text nodes can be safely removed to not disturb. if ( startSibling.nodeType == 3 && startSibling.length == 0 ) { FCKDomTools.RemoveNode( startSibling ) ; continue ; } break ; } }, /** * Merge an element with its similar siblings. * "attribs" is and object computed with _CreateAttribsForComparison. */ _MergeSiblings : function( element, attribs ) { if ( !element || element.nodeType != 1 || !FCKListsLib.InlineNonEmptyElements[ element.nodeName.toLowerCase() ] ) return ; this._MergeNextSibling( element, attribs ) ; this._MergePreviousSibling( element, attribs ) ; }, /** * Merge an element with its similar siblings after it. * "attribs" is and object computed with _CreateAttribsForComparison. */ _MergeNextSibling : function( element, attribs ) { // Check the next sibling. var sibling = element.nextSibling ; // Check if the next sibling is a bookmark element. In this case, jump it. var hasBookmark = ( sibling && sibling.nodeType == 1 && sibling.getAttribute( '_fck_bookmark' ) ) ; if ( hasBookmark ) sibling = sibling.nextSibling ; if ( sibling && sibling.nodeType == 1 && sibling.nodeName == element.nodeName ) { if ( !attribs ) attribs = this._CreateElementAttribsForComparison( element ) ; if ( this._CheckAttributesMatch( sibling, attribs ) ) { // Save the last child to be checked too (to merge things like <b><i></i></b><b><i></i></b>). var innerSibling = element.lastChild ; if ( hasBookmark ) FCKDomTools.MoveNode( element.nextSibling, element ) ; // Move contents from the sibling. FCKDomTools.MoveChildren( sibling, element ) ; FCKDomTools.RemoveNode( sibling ) ; // Now check the last inner child (see two comments above). if ( innerSibling ) this._MergeNextSibling( innerSibling ) ; } } }, /** * Merge an element with its similar siblings before it. * "attribs" is and object computed with _CreateAttribsForComparison. */ _MergePreviousSibling : function( element, attribs ) { // Check the previous sibling. var sibling = element.previousSibling ; // Check if the previous sibling is a bookmark element. In this case, jump it. var hasBookmark = ( sibling && sibling.nodeType == 1 && sibling.getAttribute( '_fck_bookmark' ) ) ; if ( hasBookmark ) sibling = sibling.previousSibling ; if ( sibling && sibling.nodeType == 1 && sibling.nodeName == element.nodeName ) { if ( !attribs ) attribs = this._CreateElementAttribsForComparison( element ) ; if ( this._CheckAttributesMatch( sibling, attribs ) ) { // Save the first child to be checked too (to merge things like <b><i></i></b><b><i></i></b>). var innerSibling = element.firstChild ; if ( hasBookmark ) FCKDomTools.MoveNode( element.previousSibling, element, true ) ; // Move contents to the sibling. FCKDomTools.MoveChildren( sibling, element, true ) ; FCKDomTools.RemoveNode( sibling ) ; // Now check the first inner child (see two comments above). if ( innerSibling ) this._MergePreviousSibling( innerSibling ) ; } } }, /** * Build the cssText based on the styles definition. */ _GetStyleText : function() { var stylesDef = this._StyleDesc.Styles ; // Builds the StyleText. var stylesText = ( this._StyleDesc.Attributes ? this._StyleDesc.Attributes['style'] || '' : '' ) ; if ( stylesText.length > 0 ) stylesText += ';' ; for ( var style in stylesDef ) stylesText += style + ':' + stylesDef[style] + ';' ; // Browsers make some changes to the style when applying them. So, here // we normalize it to the browser format. We'll not do that if there // are variables inside the style. if ( stylesText.length > 0 && !( /#\(/.test( stylesText ) ) ) { stylesText = FCKTools.NormalizeCssText( stylesText ) ; } return (this._GetStyleText = function() { return stylesText ; })() ; }, /** * Get the the collection used to compare the attributes defined in this * style with attributes in an element. All information in it is lowercased. */ _GetAttribsForComparison : function() { // If we have already computed it, just return it. var attribs = this._GetAttribsForComparison_$ ; if ( attribs ) return attribs ; attribs = new Object() ; // Loop through all defined attributes. var styleAttribs = this._StyleDesc.Attributes ; if ( styleAttribs ) { for ( var styleAtt in styleAttribs ) { attribs[ styleAtt.toLowerCase() ] = styleAttribs[ styleAtt ].toLowerCase() ; } } // Includes the style definitions. if ( this._GetStyleText().length > 0 ) { attribs['style'] = this._GetStyleText().toLowerCase() ; } // Appends the "length" information to the object. FCKTools.AppendLengthProperty( attribs, '_length' ) ; // Return it, saving it to the next request. return ( this._GetAttribsForComparison_$ = attribs ) ; }, /** * Get the the collection used to compare the elements and attributes, * defined in this style overrides, with other element. All information in * it is lowercased. */ _GetOverridesForComparison : function() { // If we have already computed it, just return it. var overrides = this._GetOverridesForComparison_$ ; if ( overrides ) return overrides ; overrides = new Object() ; var overridesDesc = this._StyleDesc.Overrides ; if ( overridesDesc ) { // The override description can be a string, object or array. // Internally, well handle arrays only, so transform it if needed. if ( !FCKTools.IsArray( overridesDesc ) ) overridesDesc = [ overridesDesc ] ; // Loop through all override definitions. for ( var i = 0 ; i < overridesDesc.length ; i++ ) { var override = overridesDesc[i] ; var elementName ; var overrideEl ; var attrs ; // If can be a string with the element name. if ( typeof override == 'string' ) elementName = override.toLowerCase() ; // Or an object. else { elementName = override.Element ? override.Element.toLowerCase() : this.Element ; attrs = override.Attributes ; } // We can have more than one override definition for the same // element name, so we attempt to simply append information to // it if it already exists. overrideEl = overrides[ elementName ] || ( overrides[ elementName ] = {} ) ; if ( attrs ) { // The returning attributes list is an array, because we // could have different override definitions for the same // attribute name. var overrideAttrs = ( overrideEl.Attributes = overrideEl.Attributes || new Array() ) ; for ( var attName in attrs ) { // Each item in the attributes array is also an array, // where [0] is the attribute name and [1] is the // override value. overrideAttrs.push( [ attName.toLowerCase(), attrs[ attName ] ] ) ; } } } } return ( this._GetOverridesForComparison_$ = overrides ) ; }, /* * Create and object containing all attributes specified in an element, * added by a "_length" property. All values are lowercased. */ _CreateElementAttribsForComparison : function( element ) { var attribs = new Object() ; var attribsCount = 0 ; for ( var i = 0 ; i < element.attributes.length ; i++ ) { var att = element.attributes[i] ; if ( att.specified ) { attribs[ att.nodeName.toLowerCase() ] = FCKDomTools.GetAttributeValue( element, att ).toLowerCase() ; attribsCount++ ; } } attribs._length = attribsCount ; return attribs ; }, /** * Checks is the element attributes have a perfect match with the style * attributes. */ _CheckAttributesMatch : function( element, styleAttribs ) { // Loop through all specified attributes. The same number of // attributes must be found and their values must match to // declare them as equal. var elementAttrbs = element.attributes ; var matchCount = 0 ; for ( var i = 0 ; i < elementAttrbs.length ; i++ ) { var att = elementAttrbs[i] ; if ( att.specified ) { var attName = att.nodeName.toLowerCase() ; var styleAtt = styleAttribs[ attName ] ; // The attribute is not defined in the style. if ( !styleAtt ) break ; // The values are different. if ( styleAtt != FCKDomTools.GetAttributeValue( element, att ).toLowerCase() ) break ; matchCount++ ; } } return ( matchCount == styleAttribs._length ) ; } } ;
JavaScript
/* * 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 == * * FCKPlugin Class: Represents a single plugin. */ var FCKPlugin = function( name, availableLangs, basePath ) { this.Name = name ; this.BasePath = basePath ? basePath : FCKConfig.PluginsPath ; this.Path = this.BasePath + name + '/' ; if ( !availableLangs || availableLangs.length == 0 ) this.AvailableLangs = new Array() ; else this.AvailableLangs = availableLangs.split(',') ; } FCKPlugin.prototype.Load = function() { // Load the language file, if defined. if ( this.AvailableLangs.length > 0 ) { var sLang ; // Check if the plugin has the language file for the active language. if ( this.AvailableLangs.IndexOf( FCKLanguageManager.ActiveLanguage.Code ) >= 0 ) sLang = FCKLanguageManager.ActiveLanguage.Code ; else // Load the default language file (first one) if the current one is not available. sLang = this.AvailableLangs[0] ; // Add the main plugin script. LoadScript( this.Path + 'lang/' + sLang + '.js' ) ; } // Add the main plugin script. LoadScript( this.Path + 'fckplugin.js' ) ; }
JavaScript
/* * 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 == * * Component that creates floating panels. It is used by many * other components, like the toolbar items, context menu, etc... */ var FCKPanel = function( parentWindow ) { this.IsRTL = ( FCKLang.Dir == 'rtl' ) ; this.IsContextMenu = false ; this._LockCounter = 0 ; this._Window = parentWindow || window ; var oDocument ; if ( FCKBrowserInfo.IsIE ) { // Create the Popup that will hold the panel. // The popup has to be created before playing with domain hacks, see #1666. this._Popup = this._Window.createPopup() ; // this._Window cannot be accessed while playing with domain hacks, but local variable is ok. // See #1666. var pDoc = this._Window.document ; // This is a trick to IE6 (not IE7). The original domain must be set // before creating the popup, so we are able to take a refence to the // document inside of it, and the set the proper domain for it. (#123) if ( FCK_IS_CUSTOM_DOMAIN && !FCKBrowserInfo.IsIE7 ) { pDoc.domain = FCK_ORIGINAL_DOMAIN ; document.domain = FCK_ORIGINAL_DOMAIN ; } oDocument = this.Document = this._Popup.document ; // Set the proper domain inside the popup. if ( FCK_IS_CUSTOM_DOMAIN ) { oDocument.domain = FCK_RUNTIME_DOMAIN ; pDoc.domain = FCK_RUNTIME_DOMAIN ; document.domain = FCK_RUNTIME_DOMAIN ; } FCK.IECleanup.AddItem( this, FCKPanel_Cleanup ) ; } else { var oIFrame = this._IFrame = this._Window.document.createElement('iframe') ; FCKTools.ResetStyles( oIFrame ); oIFrame.src = 'javascript:void(0)' ; oIFrame.allowTransparency = true ; oIFrame.frameBorder = '0' ; oIFrame.scrolling = 'no' ; oIFrame.style.width = oIFrame.style.height = '0px' ; FCKDomTools.SetElementStyles( oIFrame, { position : 'absolute', zIndex : FCKConfig.FloatingPanelsZIndex } ) ; this._Window.document.body.appendChild( oIFrame ) ; var oIFrameWindow = oIFrame.contentWindow ; oDocument = this.Document = oIFrameWindow.document ; // Workaround for Safari 12256. Ticket #63 var sBase = '' ; if ( FCKBrowserInfo.IsSafari ) sBase = '<base href="' + window.document.location + '">' ; // Initialize the IFRAME document body. oDocument.open() ; oDocument.write( '<html><head>' + sBase + '<\/head><body style="margin:0px;padding:0px;"><\/body><\/html>' ) ; oDocument.close() ; if( FCKBrowserInfo.IsAIR ) FCKAdobeAIR.Panel_Contructor( oDocument, window.document.location ) ; FCKTools.AddEventListenerEx( oIFrameWindow, 'focus', FCKPanel_Window_OnFocus, this ) ; FCKTools.AddEventListenerEx( oIFrameWindow, 'blur', FCKPanel_Window_OnBlur, this ) ; } oDocument.dir = FCKLang.Dir ; FCKTools.AddEventListener( oDocument, 'contextmenu', FCKTools.CancelEvent ) ; // Create the main DIV that is used as the panel base. this.MainNode = oDocument.body.appendChild( oDocument.createElement('DIV') ) ; // The "float" property must be set so Firefox calculates the size correctly. this.MainNode.style.cssFloat = this.IsRTL ? 'right' : 'left' ; } FCKPanel.prototype.AppendStyleSheet = function( styleSheet ) { FCKTools.AppendStyleSheet( this.Document, styleSheet ) ; } FCKPanel.prototype.Preload = function( x, y, relElement ) { // The offsetWidth and offsetHeight properties are not available if the // element is not visible. So we must "show" the popup with no size to // be able to use that values in the second call (IE only). if ( this._Popup ) this._Popup.show( x, y, 0, 0, relElement ) ; } // Workaround for IE7 problem. See #1982 // Submenus are restricted to the size of its parent, so we increase it as needed. // Returns true if the panel has been repositioned FCKPanel.prototype.ResizeForSubpanel = function( panel, width, height ) { if ( !FCKBrowserInfo.IsIE7 ) return false ; if ( !this._Popup.isOpen ) { this.Subpanel = null ; return false ; } // If we are resetting the extra space if ( width == 0 && height == 0 ) { // Another subpanel is being shown, so we must not shrink back if (this.Subpanel !== panel) return false ; // Reset values. // We leave the IncreasedY untouched to avoid vertical movement of the // menu if the submenu is higher than the main menu. this.Subpanel = null ; this.IncreasedX = 0 ; } else { this.Subpanel = panel ; // If the panel has already been increased enough, get out if ( ( this.IncreasedX >= width ) && ( this.IncreasedY >= height ) ) return false ; this.IncreasedX = Math.max( this.IncreasedX, width ) ; this.IncreasedY = Math.max( this.IncreasedY, height ) ; } var x = this.ShowRect.x ; var w = this.IncreasedX ; if ( this.IsRTL ) x = x - w ; // Horizontally increase as needed (sum of widths). // Vertically, use only the maximum of this menu or the submenu var finalWidth = this.ShowRect.w + w ; var finalHeight = Math.max( this.ShowRect.h, this.IncreasedY ) ; if ( this.ParentPanel ) this.ParentPanel.ResizeForSubpanel( this, finalWidth, finalHeight ) ; this._Popup.show( x, this.ShowRect.y, finalWidth, finalHeight, this.RelativeElement ) ; return this.IsRTL ; } FCKPanel.prototype.Show = function( x, y, relElement, width, height ) { var iMainWidth ; var eMainNode = this.MainNode ; if ( this._Popup ) { // The offsetWidth and offsetHeight properties are not available if the // element is not visible. So we must "show" the popup with no size to // be able to use that values in the second call. this._Popup.show( x, y, 0, 0, relElement ) ; // The following lines must be place after the above "show", otherwise it // doesn't has the desired effect. FCKDomTools.SetElementStyles( eMainNode, { width : width ? width + 'px' : '', height : height ? height + 'px' : '' } ) ; iMainWidth = eMainNode.offsetWidth ; if ( FCKBrowserInfo.IsIE7 ) { if (this.ParentPanel && this.ParentPanel.ResizeForSubpanel(this, iMainWidth, eMainNode.offsetHeight) ) { // As the parent has moved, allow the browser to update its internal data, so the new position is correct. FCKTools.RunFunction( this.Show, this, [x, y, relElement] ) ; return ; } } if ( this.IsRTL ) { if ( this.IsContextMenu ) x = x - iMainWidth + 1 ; else if ( relElement ) x = ( x * -1 ) + relElement.offsetWidth - iMainWidth ; } if ( FCKBrowserInfo.IsIE7 ) { // Store the values that will be used by the ResizeForSubpanel function this.ShowRect = {x:x, y:y, w:iMainWidth, h:eMainNode.offsetHeight} ; this.IncreasedX = 0 ; this.IncreasedY = 0 ; this.RelativeElement = relElement ; } // Second call: Show the Popup at the specified location, with the correct size. this._Popup.show( x, y, iMainWidth, eMainNode.offsetHeight, relElement ) ; if ( this.OnHide ) { if ( this._Timer ) CheckPopupOnHide.call( this, true ) ; this._Timer = FCKTools.SetInterval( CheckPopupOnHide, 100, this ) ; } } else { // Do not fire OnBlur while the panel is opened. if ( typeof( FCK.ToolbarSet.CurrentInstance.FocusManager ) != 'undefined' ) FCK.ToolbarSet.CurrentInstance.FocusManager.Lock() ; if ( this.ParentPanel ) { this.ParentPanel.Lock() ; // Due to a bug on FF3, we must ensure that the parent panel will // blur (#1584). FCKPanel_Window_OnBlur( null, this.ParentPanel ) ; } // Toggle the iframe scrolling attribute to prevent the panel // scrollbars from disappearing in FF Mac. (#191) if ( FCKBrowserInfo.IsGecko && FCKBrowserInfo.IsMac ) { this._IFrame.scrolling = '' ; FCKTools.RunFunction( function(){ this._IFrame.scrolling = 'no'; }, this ) ; } // Be sure we'll not have more than one Panel opened at the same time. // Do not unlock focus manager here because we're displaying another floating panel // instead of returning the editor to a "no panel" state (Bug #1514). if ( FCK.ToolbarSet.CurrentInstance.GetInstanceObject( 'FCKPanel' )._OpenedPanel && FCK.ToolbarSet.CurrentInstance.GetInstanceObject( 'FCKPanel' )._OpenedPanel != this ) FCK.ToolbarSet.CurrentInstance.GetInstanceObject( 'FCKPanel' )._OpenedPanel.Hide( false, true ) ; FCKDomTools.SetElementStyles( eMainNode, { width : width ? width + 'px' : '', height : height ? height + 'px' : '' } ) ; iMainWidth = eMainNode.offsetWidth ; if ( !width ) this._IFrame.width = 1 ; if ( !height ) this._IFrame.height = 1 ; // This is weird... but with Firefox, we must get the offsetWidth before // setting the _IFrame size (which returns "0"), and then after that, // to return the correct width. Remove the first step and it will not // work when the editor is in RTL. // // The "|| eMainNode.firstChild.offsetWidth" part has been added // for Opera compatibility (see #570). iMainWidth = eMainNode.offsetWidth || eMainNode.firstChild.offsetWidth ; // Base the popup coordinates upon the coordinates of relElement. var oPos = FCKTools.GetDocumentPosition( this._Window, relElement.nodeType == 9 ? ( FCKTools.IsStrictMode( relElement ) ? relElement.documentElement : relElement.body ) : relElement ) ; // Minus the offsets provided by any positioned parent element of the panel iframe. var positionedAncestor = FCKDomTools.GetPositionedAncestor( this._IFrame.parentNode ) ; if ( positionedAncestor ) { var nPos = FCKTools.GetDocumentPosition( FCKTools.GetElementWindow( positionedAncestor ), positionedAncestor ) ; oPos.x -= nPos.x ; oPos.y -= nPos.y ; } if ( this.IsRTL && !this.IsContextMenu ) x = ( x * -1 ) ; x += oPos.x ; y += oPos.y ; if ( this.IsRTL ) { if ( this.IsContextMenu ) x = x - iMainWidth + 1 ; else if ( relElement ) x = x + relElement.offsetWidth - iMainWidth ; } else { var oViewPaneSize = FCKTools.GetViewPaneSize( this._Window ) ; var oScrollPosition = FCKTools.GetScrollPosition( this._Window ) ; var iViewPaneHeight = oViewPaneSize.Height + oScrollPosition.Y ; var iViewPaneWidth = oViewPaneSize.Width + oScrollPosition.X ; if ( ( x + iMainWidth ) > iViewPaneWidth ) x -= x + iMainWidth - iViewPaneWidth ; if ( ( y + eMainNode.offsetHeight ) > iViewPaneHeight ) y -= y + eMainNode.offsetHeight - iViewPaneHeight ; } // Set the context menu DIV in the specified location. FCKDomTools.SetElementStyles( this._IFrame, { left : x + 'px', top : y + 'px' } ) ; // Move the focus to the IFRAME so we catch the "onblur". this._IFrame.contentWindow.focus() ; this._IsOpened = true ; var me = this ; this._resizeTimer = setTimeout( function() { var iWidth = eMainNode.offsetWidth || eMainNode.firstChild.offsetWidth ; var iHeight = eMainNode.offsetHeight ; me._IFrame.style.width = iWidth + 'px' ; me._IFrame.style.height = iHeight + 'px' ; }, 0 ) ; FCK.ToolbarSet.CurrentInstance.GetInstanceObject( 'FCKPanel' )._OpenedPanel = this ; } FCKTools.RunFunction( this.OnShow, this ) ; } FCKPanel.prototype.Hide = function( ignoreOnHide, ignoreFocusManagerUnlock ) { if ( this._Popup ) this._Popup.hide() ; else { if ( !this._IsOpened || this._LockCounter > 0 ) return ; // Enable the editor to fire the "OnBlur". if ( typeof( FCKFocusManager ) != 'undefined' && !ignoreFocusManagerUnlock ) FCKFocusManager.Unlock() ; // It is better to set the sizes to 0, otherwise Firefox would have // rendering problems. this._IFrame.style.width = this._IFrame.style.height = '0px' ; this._IsOpened = false ; if ( this._resizeTimer ) { clearTimeout( this._resizeTimer ) ; this._resizeTimer = null ; } if ( this.ParentPanel ) this.ParentPanel.Unlock() ; if ( !ignoreOnHide ) FCKTools.RunFunction( this.OnHide, this ) ; } } FCKPanel.prototype.CheckIsOpened = function() { if ( this._Popup ) return this._Popup.isOpen ; else return this._IsOpened ; } FCKPanel.prototype.CreateChildPanel = function() { var oWindow = this._Popup ? FCKTools.GetDocumentWindow( this.Document ) : this._Window ; var oChildPanel = new FCKPanel( oWindow ) ; oChildPanel.ParentPanel = this ; return oChildPanel ; } FCKPanel.prototype.Lock = function() { this._LockCounter++ ; } FCKPanel.prototype.Unlock = function() { if ( --this._LockCounter == 0 && !this.HasFocus ) this.Hide() ; } /* Events */ function FCKPanel_Window_OnFocus( e, panel ) { panel.HasFocus = true ; } function FCKPanel_Window_OnBlur( e, panel ) { panel.HasFocus = false ; if ( panel._LockCounter == 0 ) FCKTools.RunFunction( panel.Hide, panel ) ; } function CheckPopupOnHide( forceHide ) { if ( forceHide || !this._Popup.isOpen ) { window.clearInterval( this._Timer ) ; this._Timer = null ; if (this._Popup && this.ParentPanel && !forceHide) this.ParentPanel.ResizeForSubpanel(this, 0, 0) ; FCKTools.RunFunction( this.OnHide, this ) ; } } function FCKPanel_Cleanup() { this._Popup = null ; this._Window = null ; this.Document = null ; this.MainNode = null ; this.RelativeElement = null ; }
JavaScript
/* * 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 == * * FCKToolbarPanelButton Class: represents a special button in the toolbar * that shows a panel when pressed. */ var FCKToolbarPanelButton = function( commandName, label, tooltip, style, icon ) { this.CommandName = commandName ; var oIcon ; if ( icon == null ) oIcon = FCKConfig.SkinPath + 'toolbar/' + commandName.toLowerCase() + '.gif' ; else if ( typeof( icon ) == 'number' ) oIcon = [ FCKConfig.SkinPath + 'fck_strip.gif', 16, icon ] ; var oUIButton = this._UIButton = new FCKToolbarButtonUI( commandName, label, tooltip, oIcon, style ) ; oUIButton._FCKToolbarPanelButton = this ; oUIButton.ShowArrow = true ; oUIButton.OnClick = FCKToolbarPanelButton_OnButtonClick ; } FCKToolbarPanelButton.prototype.TypeName = 'FCKToolbarPanelButton' ; FCKToolbarPanelButton.prototype.Create = function( parentElement ) { parentElement.className += 'Menu' ; this._UIButton.Create( parentElement ) ; var oPanel = FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( this.CommandName )._Panel ; this.RegisterPanel( oPanel ) ; } FCKToolbarPanelButton.prototype.RegisterPanel = function( oPanel ) { if ( oPanel._FCKToolbarPanelButton ) return ; oPanel._FCKToolbarPanelButton = this ; var eLineDiv = oPanel.Document.body.appendChild( oPanel.Document.createElement( 'div' ) ) ; eLineDiv.style.position = 'absolute' ; eLineDiv.style.top = '0px' ; var eLine = oPanel._FCKToolbarPanelButtonLineDiv = eLineDiv.appendChild( oPanel.Document.createElement( 'IMG' ) ) ; eLine.className = 'TB_ConnectionLine' ; eLine.style.position = 'absolute' ; // eLine.style.backgroundColor = 'Red' ; eLine.src = FCK_SPACER_PATH ; oPanel.OnHide = FCKToolbarPanelButton_OnPanelHide ; } /* Events */ function FCKToolbarPanelButton_OnButtonClick( toolbarButton ) { var oButton = this._FCKToolbarPanelButton ; var e = oButton._UIButton.MainElement ; oButton._UIButton.ChangeState( FCK_TRISTATE_ON ) ; // oButton.LineImg.style.width = ( e.offsetWidth - 2 ) + 'px' ; var oCommand = FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( oButton.CommandName ) ; var oPanel = oCommand._Panel ; oPanel._FCKToolbarPanelButtonLineDiv.style.width = ( e.offsetWidth - 2 ) + 'px' ; oCommand.Execute( 0, e.offsetHeight - 1, e ) ; // -1 to be over the border } function FCKToolbarPanelButton_OnPanelHide() { var oMenuButton = this._FCKToolbarPanelButton ; oMenuButton._UIButton.ChangeState( FCK_TRISTATE_OFF ) ; } // The Panel Button works like a normal button so the refresh state functions // defined for the normal button can be reused here. FCKToolbarPanelButton.prototype.RefreshState = FCKToolbarButton.prototype.RefreshState ; FCKToolbarPanelButton.prototype.Enable = FCKToolbarButton.prototype.Enable ; FCKToolbarPanelButton.prototype.Disable = FCKToolbarButton.prototype.Disable ;
JavaScript
/* * 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 == * * FCKToolbarPanelButton Class: Handles the Fonts combo selector. */ var FCKToolbarStyleCombo = function( tooltip, style ) { if ( tooltip === false ) return ; this.CommandName = 'Style' ; this.Label = this.GetLabel() ; this.Tooltip = tooltip ? tooltip : this.Label ; this.Style = style ? style : FCK_TOOLBARITEM_ICONTEXT ; this.DefaultLabel = FCKConfig.DefaultStyleLabel || '' ; } // Inherit from FCKToolbarSpecialCombo. FCKToolbarStyleCombo.prototype = new FCKToolbarSpecialCombo ; FCKToolbarStyleCombo.prototype.GetLabel = function() { return FCKLang.Style ; } FCKToolbarStyleCombo.prototype.GetStyles = function() { var styles = {} ; var allStyles = FCK.ToolbarSet.CurrentInstance.Styles.GetStyles() ; for ( var styleName in allStyles ) { var style = allStyles[ styleName ] ; if ( !style.IsCore ) styles[ styleName ] = style ; } return styles ; } FCKToolbarStyleCombo.prototype.CreateItems = function( targetSpecialCombo ) { var targetDoc = targetSpecialCombo._Panel.Document ; // Add the Editor Area CSS to the panel so the style classes are previewed correctly. FCKTools.AppendStyleSheet( targetDoc, FCKConfig.ToolbarComboPreviewCSS ) ; FCKTools.AppendStyleString( targetDoc, FCKConfig.EditorAreaStyles ) ; targetDoc.body.className += ' ForceBaseFont' ; // Add ID and Class to the body. FCKConfig.ApplyBodyAttributes( targetDoc.body ) ; // Get the styles list. var styles = this.GetStyles() ; for ( var styleName in styles ) { var style = styles[ styleName ] ; // Object type styles have no preview. var caption = style.GetType() == FCK_STYLE_OBJECT ? styleName : FCKToolbarStyleCombo_BuildPreview( style, style.Label || styleName ) ; var item = targetSpecialCombo.AddItem( styleName, caption ) ; item.Style = style ; } // We must prepare the list before showing it. targetSpecialCombo.OnBeforeClick = this.StyleCombo_OnBeforeClick ; } FCKToolbarStyleCombo.prototype.RefreshActiveItems = function( targetSpecialCombo ) { var startElement = FCK.ToolbarSet.CurrentInstance.Selection.GetBoundaryParentElement( true ) ; if ( startElement ) { var path = new FCKElementPath( startElement ) ; var elements = path.Elements ; for ( var e = 0 ; e < elements.length ; e++ ) { for ( var i in targetSpecialCombo.Items ) { var item = targetSpecialCombo.Items[i] ; var style = item.Style ; if ( style.CheckElementRemovable( elements[ e ], true ) ) { targetSpecialCombo.SetLabel( style.Label || style.Name ) ; return ; } } } } targetSpecialCombo.SetLabel( this.DefaultLabel ) ; } FCKToolbarStyleCombo.prototype.StyleCombo_OnBeforeClick = function( targetSpecialCombo ) { // Two things are done here: // - In a control selection, get the element name, so we'll display styles // for that element only. // - Select the styles that are active for the current selection. // Clear the current selection. targetSpecialCombo.DeselectAll() ; var startElement ; var path ; var tagName ; var selection = FCK.ToolbarSet.CurrentInstance.Selection ; if ( selection.GetType() == 'Control' ) { startElement = selection.GetSelectedElement() ; tagName = startElement.nodeName.toLowerCase() ; } else { startElement = selection.GetBoundaryParentElement( true ) ; path = new FCKElementPath( startElement ) ; } for ( var i in targetSpecialCombo.Items ) { var item = targetSpecialCombo.Items[i] ; var style = item.Style ; if ( ( tagName && style.Element == tagName ) || ( !tagName && style.GetType() != FCK_STYLE_OBJECT ) ) { item.style.display = '' ; if ( ( path && style.CheckActive( path ) ) || ( !path && style.CheckElementRemovable( startElement, true ) ) ) targetSpecialCombo.SelectItem( style.Name ) ; } else item.style.display = 'none' ; } } function FCKToolbarStyleCombo_BuildPreview( style, caption ) { var styleType = style.GetType() ; var html = [] ; if ( styleType == FCK_STYLE_BLOCK ) html.push( '<div class="BaseFont">' ) ; var elementName = style.Element ; // Avoid <bdo> in the preview. if ( elementName == 'bdo' ) elementName = 'span' ; html = [ '<', elementName ] ; // Assign all defined attributes. var attribs = style._StyleDesc.Attributes ; if ( attribs ) { for ( var att in attribs ) { html.push( ' ', att, '="', style.GetFinalAttributeValue( att ), '"' ) ; } } // Assign the style attribute. if ( style._GetStyleText().length > 0 ) html.push( ' style="', style.GetFinalStyleValue(), '"' ) ; html.push( '>', caption, '</', elementName, '>' ) ; if ( styleType == FCK_STYLE_BLOCK ) html.push( '</div>' ) ; return html.join( '' ) ; }
JavaScript
/* * 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 == * * This is a generic Document Fragment object. It is not intended to provide * the W3C implementation, but is a way to fix the missing of a real Document * Fragment in IE (where document.createDocumentFragment() returns a normal * document instead), giving a standard interface for it. * (IE Implementation) */ var FCKDocumentFragment = function( parentDocument ) { this._Document = parentDocument ; this.RootNode = parentDocument.createElement( 'div' ) ; } // Append the contents of this Document Fragment to another node. FCKDocumentFragment.prototype = { AppendTo : function( targetNode ) { FCKDomTools.MoveChildren( this.RootNode, targetNode ) ; }, AppendHtml : function( html ) { var eTmpDiv = this._Document.createElement( 'div' ) ; eTmpDiv.innerHTML = html ; FCKDomTools.MoveChildren( eTmpDiv, this.RootNode ) ; }, InsertAfterNode : function( existingNode ) { var eRoot = this.RootNode ; var eLast ; while( ( eLast = eRoot.lastChild ) ) FCKDomTools.InsertAfterNode( existingNode, eRoot.removeChild( eLast ) ) ; } } ;
JavaScript
/* * 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 == * * FCKIECleanup Class: a generic class used as a tool to remove IE leaks. */ var FCKIECleanup = function( attachWindow ) { // If the attachWindow already have a cleanup object, just use that one. if ( attachWindow._FCKCleanupObj ) this.Items = attachWindow._FCKCleanupObj.Items ; else { this.Items = new Array() ; attachWindow._FCKCleanupObj = this ; FCKTools.AddEventListenerEx( attachWindow, 'unload', FCKIECleanup_Cleanup ) ; // attachWindow.attachEvent( 'onunload', FCKIECleanup_Cleanup ) ; } } FCKIECleanup.prototype.AddItem = function( dirtyItem, cleanupFunction ) { this.Items.push( [ dirtyItem, cleanupFunction ] ) ; } function FCKIECleanup_Cleanup() { if ( !this._FCKCleanupObj || ( FCKConfig.MsWebBrowserControlCompat && !window.FCKUnloadFlag ) ) return ; var aItems = this._FCKCleanupObj.Items ; while ( aItems.length > 0 ) { // It is important to remove from the end to the beginning (pop()), // because of the order things get created in the editor. In the code, // elements in deeper position in the DOM are placed at the end of the // cleanup function, so we must cleanup then first, otherwise IE could // throw some crazy memory errors (IE bug). var oItem = aItems.pop() ; if ( oItem ) oItem[1].call( oItem[0] ) ; } this._FCKCleanupObj = null ; if ( CollectGarbage ) CollectGarbage() ; }
JavaScript
/* * 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 == * * Class for working with a selection range, much like the W3C DOM Range, but * it is not intended to be an implementation of the W3C interface. * (Gecko Implementation) */ FCKDomRange.prototype.MoveToSelection = function() { this.Release( true ) ; var oSel = this.Window.getSelection() ; if ( oSel && oSel.rangeCount > 0 ) { this._Range = FCKW3CRange.CreateFromRange( this.Window.document, oSel.getRangeAt(0) ) ; this._UpdateElementInfo() ; } else if ( this.Window.document ) this.MoveToElementStart( this.Window.document.body ) ; } FCKDomRange.prototype.Select = function() { var oRange = this._Range ; if ( oRange ) { var startContainer = oRange.startContainer ; // If we have a collapsed range, inside an empty element, we must add // something to it, otherwise the caret will not be visible. if ( oRange.collapsed && startContainer.nodeType == 1 && startContainer.childNodes.length == 0 ) startContainer.appendChild( oRange._Document.createTextNode('') ) ; var oDocRange = this.Window.document.createRange() ; oDocRange.setStart( startContainer, oRange.startOffset ) ; try { oDocRange.setEnd( oRange.endContainer, oRange.endOffset ) ; } catch ( e ) { // There is a bug in Firefox implementation (it would be too easy // otherwise). The new start can't be after the end (W3C says it can). // So, let's create a new range and collapse it to the desired point. if ( e.toString().Contains( 'NS_ERROR_ILLEGAL_VALUE' ) ) { oRange.collapse( true ) ; oDocRange.setEnd( oRange.endContainer, oRange.endOffset ) ; } else throw( e ) ; } var oSel = this.Window.getSelection() ; oSel.removeAllRanges() ; // We must add a clone otherwise Firefox will have rendering issues. oSel.addRange( oDocRange ) ; } } // Not compatible with bookmark created with CreateBookmark2. // The bookmark nodes will be deleted from the document. FCKDomRange.prototype.SelectBookmark = function( bookmark ) { var domRange = this.Window.document.createRange() ; var startNode = this.GetBookmarkNode( bookmark, true ) ; var endNode = this.GetBookmarkNode( bookmark, false ) ; domRange.setStart( startNode.parentNode, FCKDomTools.GetIndexOf( startNode ) ) ; FCKDomTools.RemoveNode( startNode ) ; if ( endNode ) { domRange.setEnd( endNode.parentNode, FCKDomTools.GetIndexOf( endNode ) ) ; FCKDomTools.RemoveNode( endNode ) ; } var selection = this.Window.getSelection() ; selection.removeAllRanges() ; selection.addRange( domRange ) ; }
JavaScript
/* * 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 == * * FCKToolbarBreak Class: breaks the toolbars. * It makes it possible to force the toolbar to break to a new line. * This is the Gecko specific implementation. */ var FCKToolbarBreak = function() {} FCKToolbarBreak.prototype.Create = function( targetElement ) { var oBreakDiv = targetElement.ownerDocument.createElement( 'div' ) ; oBreakDiv.style.clear = oBreakDiv.style.cssFloat = FCKLang.Dir == 'rtl' ? 'right' : 'left' ; targetElement.appendChild( oBreakDiv ) ; }
JavaScript
/* * 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 == * * This is a generic Document Fragment object. It is not intended to provide * the W3C implementation, but is a way to fix the missing of a real Document * Fragment in IE (where document.createDocumentFragment() returns a normal * document instead), giving a standard interface for it. * (IE Implementation) */ var FCKDocumentFragment = function( parentDocument, baseDocFrag ) { this.RootNode = baseDocFrag || parentDocument.createDocumentFragment() ; } FCKDocumentFragment.prototype = { // Append the contents of this Document Fragment to another element. AppendTo : function( targetNode ) { targetNode.appendChild( this.RootNode ) ; }, AppendHtml : function( html ) { var eTmpDiv = this.RootNode.ownerDocument.createElement( 'div' ) ; eTmpDiv.innerHTML = html ; FCKDomTools.MoveChildren( eTmpDiv, this.RootNode ) ; }, InsertAfterNode : function( existingNode ) { FCKDomTools.InsertAfterNode( existingNode, this.RootNode ) ; } }
JavaScript
/* * 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 == * * FCKIcon Class: renders an icon from a single image, a strip or even a * spacer. */ var FCKIcon = function( iconPathOrStripInfoArray ) { var sTypeOf = iconPathOrStripInfoArray ? typeof( iconPathOrStripInfoArray ) : 'undefined' ; switch ( sTypeOf ) { case 'number' : this.Path = FCKConfig.SkinPath + 'fck_strip.gif' ; this.Size = 16 ; this.Position = iconPathOrStripInfoArray ; break ; case 'undefined' : this.Path = FCK_SPACER_PATH ; break ; case 'string' : this.Path = iconPathOrStripInfoArray ; break ; default : // It is an array in the format [ StripFilePath, IconSize, IconPosition ] this.Path = iconPathOrStripInfoArray[0] ; this.Size = iconPathOrStripInfoArray[1] ; this.Position = iconPathOrStripInfoArray[2] ; } } FCKIcon.prototype.CreateIconElement = function( document ) { var eIcon, eIconImage ; if ( this.Position ) // It is using an icons strip image. { var sPos = '-' + ( ( this.Position - 1 ) * this.Size ) + 'px' ; if ( FCKBrowserInfo.IsIE ) { // <div class="TB_Button_Image"><img src="strip.gif" style="top:-16px"></div> eIcon = document.createElement( 'DIV' ) ; eIconImage = eIcon.appendChild( document.createElement( 'IMG' ) ) ; eIconImage.src = this.Path ; eIconImage.style.top = sPos ; } else { // <img class="TB_Button_Image" src="spacer.gif" style="background-position: 0px -16px;background-image: url(strip.gif);"> eIcon = document.createElement( 'IMG' ) ; eIcon.src = FCK_SPACER_PATH ; eIcon.style.backgroundPosition = '0px ' + sPos ; eIcon.style.backgroundImage = 'url("' + this.Path + '")' ; } } else // It is using a single icon image. { if ( FCKBrowserInfo.IsIE ) { // IE makes the button 1px higher if using the <img> directly, so we // are changing to the <div> system to clip the image correctly. eIcon = document.createElement( 'DIV' ) ; eIconImage = eIcon.appendChild( document.createElement( 'IMG' ) ) ; eIconImage.src = this.Path ? this.Path : FCK_SPACER_PATH ; } else { // This is not working well with IE. See notes above. // <img class="TB_Button_Image" src="smiley.gif"> eIcon = document.createElement( 'IMG' ) ; eIcon.src = this.Path ? this.Path : FCK_SPACER_PATH ; } } eIcon.className = 'TB_Button_Image' ; return eIcon ; }
JavaScript
/* * 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 == * * FCKXml Class: class to load and manipulate XML files. */ FCKXml.prototype = { LoadUrl : function( urlToCall ) { this.Error = false ; var oXml ; var oXmlHttp = FCKTools.CreateXmlObject( 'XmlHttp' ) ; oXmlHttp.open( 'GET', urlToCall, false ) ; oXmlHttp.send( null ) ; if ( oXmlHttp.status == 200 || oXmlHttp.status == 304 || ( oXmlHttp.status == 0 && oXmlHttp.readyState == 4 ) ) { oXml = oXmlHttp.responseXML ; // #1426: Fallback if responseXML isn't set for some // reason (e.g. improperly configured web server) if ( !oXml ) oXml = (new DOMParser()).parseFromString( oXmlHttp.responseText, 'text/xml' ) ; } else oXml = null ; if ( oXml ) { // Try to access something on it. try { var test = oXml.firstChild ; } catch (e) { // If document.domain has been changed (#123), we'll have a security // error at this point. The workaround here is parsing the responseText: // http://alexander.kirk.at/2006/07/27/firefox-15-xmlhttprequest-reqresponsexml-and-documentdomain/ oXml = (new DOMParser()).parseFromString( oXmlHttp.responseText, 'text/xml' ) ; } } if ( !oXml || !oXml.firstChild ) { this.Error = true ; if ( window.confirm( 'Error loading "' + urlToCall + '" (HTTP Status: ' + oXmlHttp.status + ').\r\nDo you want to see the server response dump?' ) ) alert( oXmlHttp.responseText ) ; } this.DOMDocument = oXml ; }, SelectNodes : function( xpath, contextNode ) { if ( this.Error ) return new Array() ; var aNodeArray = new Array(); var xPathResult = this.DOMDocument.evaluate( xpath, contextNode ? contextNode : this.DOMDocument, this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), XPathResult.ORDERED_NODE_ITERATOR_TYPE, null) ; if ( xPathResult ) { var oNode = xPathResult.iterateNext() ; while( oNode ) { aNodeArray[aNodeArray.length] = oNode ; oNode = xPathResult.iterateNext(); } } return aNodeArray ; }, SelectSingleNode : function( xpath, contextNode ) { if ( this.Error ) return null ; var xPathResult = this.DOMDocument.evaluate( xpath, contextNode ? contextNode : this.DOMDocument, this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), 9, null); if ( xPathResult && xPathResult.singleNodeValue ) return xPathResult.singleNodeValue ; else return null ; } } ;
JavaScript
/* * 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 == * * Control keyboard keystroke combinations. */ var FCKKeystrokeHandler = function( cancelCtrlDefaults ) { this.Keystrokes = new Object() ; this.CancelCtrlDefaults = ( cancelCtrlDefaults !== false ) ; } /* * Listen to keystroke events in an element or DOM document object. * @target: The element or document to listen to keystroke events. */ FCKKeystrokeHandler.prototype.AttachToElement = function( target ) { // For newer browsers, it is enough to listen to the keydown event only. // Some browsers instead, don't cancel key events in the keydown, but in the // keypress. So we must do a longer trip in those cases. FCKTools.AddEventListenerEx( target, 'keydown', _FCKKeystrokeHandler_OnKeyDown, this ) ; if ( FCKBrowserInfo.IsGecko10 || FCKBrowserInfo.IsOpera || ( FCKBrowserInfo.IsGecko && FCKBrowserInfo.IsMac ) ) FCKTools.AddEventListenerEx( target, 'keypress', _FCKKeystrokeHandler_OnKeyPress, this ) ; } /* * Sets a list of keystrokes. It can receive either a single array or "n" * arguments, each one being an array of 1 or 2 elemenst. The first element * is the keystroke combination, and the second is the value to assign to it. * If the second element is missing, the keystroke definition is removed. */ FCKKeystrokeHandler.prototype.SetKeystrokes = function() { // Look through the arguments. for ( var i = 0 ; i < arguments.length ; i++ ) { var keyDef = arguments[i] ; // If the configuration for the keystrokes is missing some element or has any extra comma // this item won't be valid, so skip it and keep on processing. if ( !keyDef ) continue ; if ( typeof( keyDef[0] ) == 'object' ) // It is an array with arrays defining the keystrokes. this.SetKeystrokes.apply( this, keyDef ) ; else { if ( keyDef.length == 1 ) // If it has only one element, remove the keystroke. delete this.Keystrokes[ keyDef[0] ] ; else // Otherwise add it. this.Keystrokes[ keyDef[0] ] = keyDef[1] === true ? true : keyDef ; } } } function _FCKKeystrokeHandler_OnKeyDown( ev, keystrokeHandler ) { // Get the key code. var keystroke = ev.keyCode || ev.which ; // Combine it with the CTRL, SHIFT and ALT states. var keyModifiers = 0 ; if ( ev.ctrlKey || ev.metaKey ) keyModifiers += CTRL ; if ( ev.shiftKey ) keyModifiers += SHIFT ; if ( ev.altKey ) keyModifiers += ALT ; var keyCombination = keystroke + keyModifiers ; var cancelIt = keystrokeHandler._CancelIt = false ; // Look for its definition availability. var keystrokeValue = keystrokeHandler.Keystrokes[ keyCombination ] ; // FCKDebug.Output( 'KeyDown: ' + keyCombination + ' - Value: ' + keystrokeValue ) ; // If the keystroke is defined if ( keystrokeValue ) { // If the keystroke has been explicitly set to "true" OR calling the // "OnKeystroke" event, it doesn't return "true", the default behavior // must be preserved. if ( keystrokeValue === true || !( keystrokeHandler.OnKeystroke && keystrokeHandler.OnKeystroke.apply( keystrokeHandler, keystrokeValue ) ) ) return true ; cancelIt = true ; } // By default, it will cancel all combinations with the CTRL key only (except positioning keys). if ( cancelIt || ( keystrokeHandler.CancelCtrlDefaults && keyModifiers == CTRL && ( keystroke < 33 || keystroke > 40 ) ) ) { keystrokeHandler._CancelIt = true ; if ( ev.preventDefault ) return ev.preventDefault() ; ev.returnValue = false ; ev.cancelBubble = true ; return false ; } return true ; } function _FCKKeystrokeHandler_OnKeyPress( ev, keystrokeHandler ) { if ( keystrokeHandler._CancelIt ) { // FCKDebug.Output( 'KeyPress Cancel', 'Red') ; if ( ev.preventDefault ) return ev.preventDefault() ; return false ; } return true ; }
JavaScript
/* * 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 == * * FCKEditingArea Class: renders an editable area. */ /** * @constructor * @param {String} targetElement The element that will hold the editing area. Any child element present in the target will be deleted. */ var FCKEditingArea = function( targetElement ) { this.TargetElement = targetElement ; this.Mode = FCK_EDITMODE_WYSIWYG ; if ( FCK.IECleanup ) FCK.IECleanup.AddItem( this, FCKEditingArea_Cleanup ) ; } /** * @param {String} html The complete HTML for the page, including DOCTYPE and the <html> tag. */ FCKEditingArea.prototype.Start = function( html, secondCall ) { var eTargetElement = this.TargetElement ; var oTargetDocument = FCKTools.GetElementDocument( eTargetElement ) ; // Remove all child nodes from the target. while( eTargetElement.firstChild ) eTargetElement.removeChild( eTargetElement.firstChild ) ; if ( this.Mode == FCK_EDITMODE_WYSIWYG ) { // For FF, document.domain must be set only when different, otherwhise // we'll strangely have "Permission denied" issues. if ( FCK_IS_CUSTOM_DOMAIN ) html = '<script>document.domain="' + FCK_RUNTIME_DOMAIN + '";</script>' + html ; // IE has a bug with the <base> tag... it must have a </base> closer, // otherwise the all successive tags will be set as children nodes of the <base>. if ( FCKBrowserInfo.IsIE ) html = html.replace( /(<base[^>]*?)\s*\/?>(?!\s*<\/base>)/gi, '$1></base>' ) ; else if ( !secondCall ) { // Gecko moves some tags out of the body to the head, so we must use // innerHTML to set the body contents (SF BUG 1526154). // Extract the BODY contents from the html. var oMatchBefore = html.match( FCKRegexLib.BeforeBody ) ; var oMatchAfter = html.match( FCKRegexLib.AfterBody ) ; if ( oMatchBefore && oMatchAfter ) { var sBody = html.substr( oMatchBefore[1].length, html.length - oMatchBefore[1].length - oMatchAfter[1].length ) ; // This is the BODY tag contents. html = oMatchBefore[1] + // This is the HTML until the <body...> tag, inclusive. '&nbsp;' + oMatchAfter[1] ; // This is the HTML from the </body> tag, inclusive. // If nothing in the body, place a BOGUS tag so the cursor will appear. if ( FCKBrowserInfo.IsGecko && ( sBody.length == 0 || FCKRegexLib.EmptyParagraph.test( sBody ) ) ) sBody = '<br type="_moz">' ; this._BodyHTML = sBody ; } else this._BodyHTML = html ; // Invalid HTML input. } // Create the editing area IFRAME. var oIFrame = this.IFrame = oTargetDocument.createElement( 'iframe' ) ; // IE: Avoid JavaScript errors thrown by the editing are source (like tags events). // See #1055. var sOverrideError = '<script type="text/javascript" _fcktemp="true">window.onerror=function(){return true;};</script>' ; oIFrame.frameBorder = 0 ; oIFrame.style.width = oIFrame.style.height = '100%' ; if ( FCK_IS_CUSTOM_DOMAIN && FCKBrowserInfo.IsIE ) { window._FCKHtmlToLoad = html.replace( /<head>/i, '<head>' + sOverrideError ) ; oIFrame.src = 'javascript:void( (function(){' + 'document.open() ;' + 'document.domain="' + document.domain + '" ;' + 'document.write( window.parent._FCKHtmlToLoad );' + 'document.close() ;' + 'window.parent._FCKHtmlToLoad = null ;' + '})() )' ; } else if ( !FCKBrowserInfo.IsGecko ) { // Firefox will render the tables inside the body in Quirks mode if the // source of the iframe is set to javascript. see #515 oIFrame.src = 'javascript:void(0)' ; } // Append the new IFRAME to the target. For IE, it must be done after // setting the "src", to avoid the "secure/unsecure" message under HTTPS. eTargetElement.appendChild( oIFrame ) ; // Get the window and document objects used to interact with the newly created IFRAME. this.Window = oIFrame.contentWindow ; // IE: Avoid JavaScript errors thrown by the editing are source (like tags events). // TODO: This error handler is not being fired. // this.Window.onerror = function() { alert( 'Error!' ) ; return true ; } if ( !FCK_IS_CUSTOM_DOMAIN || !FCKBrowserInfo.IsIE ) { var oDoc = this.Window.document ; oDoc.open() ; oDoc.write( html.replace( /<head>/i, '<head>' + sOverrideError ) ) ; oDoc.close() ; } if ( FCKBrowserInfo.IsAIR ) FCKAdobeAIR.EditingArea_Start( oDoc, html ) ; // Firefox 1.0.x is buggy... ohh yes... so let's do it two times and it // will magically work. if ( FCKBrowserInfo.IsGecko10 && !secondCall ) { this.Start( html, true ) ; return ; } if ( oIFrame.readyState && oIFrame.readyState != 'completed' ) { var editArea = this ; // Using a IE alternative for DOMContentLoaded, similar to the // solution proposed at http://javascript.nwbox.com/IEContentLoaded/ setTimeout( function() { try { editArea.Window.document.documentElement.doScroll("left") ; } catch(e) { setTimeout( arguments.callee, 0 ) ; return ; } editArea.Window._FCKEditingArea = editArea ; FCKEditingArea_CompleteStart.call( editArea.Window ) ; }, 0 ) ; } else { this.Window._FCKEditingArea = this ; // FF 1.0.x is buggy... we must wait a lot to enable editing because // sometimes the content simply disappears, for example when pasting // "bla1!<img src='some_url'>!bla2" in the source and then switching // back to design. if ( FCKBrowserInfo.IsGecko10 ) this.Window.setTimeout( FCKEditingArea_CompleteStart, 500 ) ; else FCKEditingArea_CompleteStart.call( this.Window ) ; } } else { var eTextarea = this.Textarea = oTargetDocument.createElement( 'textarea' ) ; eTextarea.className = 'SourceField' ; eTextarea.dir = 'ltr' ; FCKDomTools.SetElementStyles( eTextarea, { width : '100%', height : '100%', border : 'none', resize : 'none', outline : 'none' } ) ; eTargetElement.appendChild( eTextarea ) ; eTextarea.value = html ; // Fire the "OnLoad" event. FCKTools.RunFunction( this.OnLoad ) ; } } // "this" here is FCKEditingArea.Window function FCKEditingArea_CompleteStart() { // On Firefox, the DOM takes a little to become available. So we must wait for it in a loop. if ( !this.document.body ) { this.setTimeout( FCKEditingArea_CompleteStart, 50 ) ; return ; } var oEditorArea = this._FCKEditingArea ; // Save this reference to be re-used later. oEditorArea.Document = oEditorArea.Window.document ; oEditorArea.MakeEditable() ; // Fire the "OnLoad" event. FCKTools.RunFunction( oEditorArea.OnLoad ) ; } FCKEditingArea.prototype.MakeEditable = function() { var oDoc = this.Document ; if ( FCKBrowserInfo.IsIE ) { // Kludge for #141 and #523 oDoc.body.disabled = true ; oDoc.body.contentEditable = true ; oDoc.body.removeAttribute( "disabled" ) ; /* The following commands don't throw errors, but have no effect. oDoc.execCommand( 'AutoDetect', false, false ) ; oDoc.execCommand( 'KeepSelection', false, true ) ; */ } else { try { // Disable Firefox 2 Spell Checker. oDoc.body.spellcheck = ( this.FFSpellChecker !== false ) ; if ( this._BodyHTML ) { oDoc.body.innerHTML = this._BodyHTML ; oDoc.body.offsetLeft ; // Don't remove, this is a hack to fix Opera 9.50, see #2264. this._BodyHTML = null ; } oDoc.designMode = 'on' ; // Tell Gecko (Firefox 1.5+) to enable or not live resizing of objects (by Alfonso Martinez) oDoc.execCommand( 'enableObjectResizing', false, !FCKConfig.DisableObjectResizing ) ; // Disable the standard table editing features of Firefox. oDoc.execCommand( 'enableInlineTableEditing', false, !FCKConfig.DisableFFTableHandles ) ; } catch (e) { // In Firefox if the iframe is initially hidden it can't be set to designMode and it raises an exception // So we set up a DOM Mutation event Listener on the HTML, as it will raise several events when the document is visible again FCKTools.AddEventListener( this.Window.frameElement, 'DOMAttrModified', FCKEditingArea_Document_AttributeNodeModified ) ; } } } // This function processes the notifications of the DOM Mutation event on the document // We use it to know that the document will be ready to be editable again (or we hope so) function FCKEditingArea_Document_AttributeNodeModified( evt ) { var editingArea = evt.currentTarget.contentWindow._FCKEditingArea ; // We want to run our function after the events no longer fire, so we can know that it's a stable situation if ( editingArea._timer ) window.clearTimeout( editingArea._timer ) ; editingArea._timer = FCKTools.SetTimeout( FCKEditingArea_MakeEditableByMutation, 1000, editingArea ) ; } // This function ideally should be called after the document is visible, it does clean up of the // mutation tracking and tries again to make the area editable. function FCKEditingArea_MakeEditableByMutation() { // Clean up delete this._timer ; // Now we don't want to keep on getting this event FCKTools.RemoveEventListener( this.Window.frameElement, 'DOMAttrModified', FCKEditingArea_Document_AttributeNodeModified ) ; // Let's try now to set the editing area editable // If it fails it will set up the Mutation Listener again automatically this.MakeEditable() ; } FCKEditingArea.prototype.Focus = function() { try { if ( this.Mode == FCK_EDITMODE_WYSIWYG ) { if ( FCKBrowserInfo.IsIE ) this._FocusIE() ; else this.Window.focus() ; } else { var oDoc = FCKTools.GetElementDocument( this.Textarea ) ; if ( (!oDoc.hasFocus || oDoc.hasFocus() ) && oDoc.activeElement == this.Textarea ) return ; this.Textarea.focus() ; } } catch(e) {} } FCKEditingArea.prototype._FocusIE = function() { // In IE it can happen that the document is in theory focused but the // active element is outside of it. this.Document.body.setActive() ; this.Window.focus() ; // Kludge for #141... yet more code to workaround IE bugs var range = this.Document.selection.createRange() ; var parentNode = range.parentElement() ; var parentTag = parentNode.nodeName.toLowerCase() ; // Only apply the fix when in a block, and the block is empty. if ( parentNode.childNodes.length > 0 || !( FCKListsLib.BlockElements[parentTag] || FCKListsLib.NonEmptyBlockElements[parentTag] ) ) { return ; } // Force the selection to happen, in this way we guarantee the focus will // be there. range = new FCKDomRange( this.Window ) ; range.MoveToElementEditStart( parentNode ) ; range.Select() ; } function FCKEditingArea_Cleanup() { if ( this.Document ) this.Document.body.innerHTML = "" ; this.TargetElement = null ; this.IFrame = null ; this.Document = null ; this.Textarea = null ; if ( this.Window ) { this.Window._FCKEditingArea = null ; this.Window = null ; } }
JavaScript
/* * 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 == * * Class for working with a selection range, much like the W3C DOM Range, but * it is not intended to be an implementation of the W3C interface. */ var FCKDomRange = function( sourceWindow ) { this.Window = sourceWindow ; this._Cache = {} ; } FCKDomRange.prototype = { _UpdateElementInfo : function() { var innerRange = this._Range ; if ( !innerRange ) this.Release( true ) ; else { // For text nodes, the node itself is the StartNode. var eStart = innerRange.startContainer ; var oElementPath = new FCKElementPath( eStart ) ; this.StartNode = eStart.nodeType == 3 ? eStart : eStart.childNodes[ innerRange.startOffset ] ; this.StartContainer = eStart ; this.StartBlock = oElementPath.Block ; this.StartBlockLimit = oElementPath.BlockLimit ; if ( innerRange.collapsed ) { this.EndNode = this.StartNode ; this.EndContainer = this.StartContainer ; this.EndBlock = this.StartBlock ; this.EndBlockLimit = this.StartBlockLimit ; } else { var eEnd = innerRange.endContainer ; if ( eStart != eEnd ) oElementPath = new FCKElementPath( eEnd ) ; // The innerRange.endContainer[ innerRange.endOffset ] is not // usually part of the range, but the marker for the range end. So, // let's get the previous available node as the real end. var eEndNode = eEnd ; if ( innerRange.endOffset == 0 ) { while ( eEndNode && !eEndNode.previousSibling ) eEndNode = eEndNode.parentNode ; if ( eEndNode ) eEndNode = eEndNode.previousSibling ; } else if ( eEndNode.nodeType == 1 ) eEndNode = eEndNode.childNodes[ innerRange.endOffset - 1 ] ; this.EndNode = eEndNode ; this.EndContainer = eEnd ; this.EndBlock = oElementPath.Block ; this.EndBlockLimit = oElementPath.BlockLimit ; } } this._Cache = {} ; }, CreateRange : function() { return new FCKW3CRange( this.Window.document ) ; }, DeleteContents : function() { if ( this._Range ) { this._Range.deleteContents() ; this._UpdateElementInfo() ; } }, ExtractContents : function() { if ( this._Range ) { var docFrag = this._Range.extractContents() ; this._UpdateElementInfo() ; return docFrag ; } return null ; }, CheckIsCollapsed : function() { if ( this._Range ) return this._Range.collapsed ; return false ; }, Collapse : function( toStart ) { if ( this._Range ) this._Range.collapse( toStart ) ; this._UpdateElementInfo() ; }, Clone : function() { var oClone = FCKTools.CloneObject( this ) ; if ( this._Range ) oClone._Range = this._Range.cloneRange() ; return oClone ; }, MoveToNodeContents : function( targetNode ) { if ( !this._Range ) this._Range = this.CreateRange() ; this._Range.selectNodeContents( targetNode ) ; this._UpdateElementInfo() ; }, MoveToElementStart : function( targetElement ) { this.SetStart(targetElement,1) ; this.SetEnd(targetElement,1) ; }, // Moves to the first editing point inside a element. For example, in a // element tree like "<p><b><i></i></b> Text</p>", the start editing point // is "<p><b><i>^</i></b> Text</p>" (inside <i>). MoveToElementEditStart : function( targetElement ) { var editableElement ; while ( targetElement && targetElement.nodeType == 1 ) { if ( FCKDomTools.CheckIsEditable( targetElement ) ) editableElement = targetElement ; else if ( editableElement ) break ; // If we already found an editable element, stop the loop. targetElement = targetElement.firstChild ; } if ( editableElement ) this.MoveToElementStart( editableElement ) ; }, InsertNode : function( node ) { if ( this._Range ) this._Range.insertNode( node ) ; }, CheckIsEmpty : function() { if ( this.CheckIsCollapsed() ) return true ; // Inserts the contents of the range in a div tag. var eToolDiv = this.Window.document.createElement( 'div' ) ; this._Range.cloneContents().AppendTo( eToolDiv ) ; FCKDomTools.TrimNode( eToolDiv ) ; return ( eToolDiv.innerHTML.length == 0 ) ; }, /** * Checks if the start boundary of the current range is "visually" (like a * selection caret) at the beginning of the block. It means that some * things could be brefore the range, like spaces or empty inline elements, * but it would still be considered at the beginning of the block. */ CheckStartOfBlock : function() { var cache = this._Cache ; var bIsStartOfBlock = cache.IsStartOfBlock ; if ( bIsStartOfBlock != undefined ) return bIsStartOfBlock ; // Take the block reference. var block = this.StartBlock || this.StartBlockLimit ; var container = this._Range.startContainer ; var offset = this._Range.startOffset ; var currentNode ; if ( offset > 0 ) { // First, check the start container. If it is a text node, get the // substring of the node value before the range offset. if ( container.nodeType == 3 ) { var textValue = container.nodeValue.substr( 0, offset ).Trim() ; // If we have some text left in the container, we are not at // the end for the block. if ( textValue.length != 0 ) return cache.IsStartOfBlock = false ; } else currentNode = container.childNodes[ offset - 1 ] ; } // We'll not have a currentNode if the container was a text node, or // the offset is zero. if ( !currentNode ) currentNode = FCKDomTools.GetPreviousSourceNode( container, true, null, block ) ; while ( currentNode ) { switch ( currentNode.nodeType ) { case 1 : // It's not an inline element. if ( !FCKListsLib.InlineChildReqElements[ currentNode.nodeName.toLowerCase() ] ) return cache.IsStartOfBlock = false ; break ; case 3 : // It's a text node with real text. if ( currentNode.nodeValue.Trim().length > 0 ) return cache.IsStartOfBlock = false ; } currentNode = FCKDomTools.GetPreviousSourceNode( currentNode, false, null, block ) ; } return cache.IsStartOfBlock = true ; }, /** * Checks if the end boundary of the current range is "visually" (like a * selection caret) at the end of the block. It means that some things * could be after the range, like spaces, empty inline elements, or a * single <br>, but it would still be considered at the end of the block. */ CheckEndOfBlock : function( refreshSelection ) { var isEndOfBlock = this._Cache.IsEndOfBlock ; if ( isEndOfBlock != undefined ) return isEndOfBlock ; // Take the block reference. var block = this.EndBlock || this.EndBlockLimit ; var container = this._Range.endContainer ; var offset = this._Range.endOffset ; var currentNode ; // First, check the end container. If it is a text node, get the // substring of the node value after the range offset. if ( container.nodeType == 3 ) { var textValue = container.nodeValue ; if ( offset < textValue.length ) { textValue = textValue.substr( offset ) ; // If we have some text left in the container, we are not at // the end for the block. if ( textValue.Trim().length != 0 ) return this._Cache.IsEndOfBlock = false ; } } else currentNode = container.childNodes[ offset ] ; // We'll not have a currentNode if the container was a text node, of // the offset is out the container children limits (after it probably). if ( !currentNode ) currentNode = FCKDomTools.GetNextSourceNode( container, true, null, block ) ; var hadBr = false ; while ( currentNode ) { switch ( currentNode.nodeType ) { case 1 : var nodeName = currentNode.nodeName.toLowerCase() ; // It's an inline element. if ( FCKListsLib.InlineChildReqElements[ nodeName ] ) break ; // It is the first <br> found. if ( nodeName == 'br' && !hadBr ) { hadBr = true ; break ; } return this._Cache.IsEndOfBlock = false ; case 3 : // It's a text node with real text. if ( currentNode.nodeValue.Trim().length > 0 ) return this._Cache.IsEndOfBlock = false ; } currentNode = FCKDomTools.GetNextSourceNode( currentNode, false, null, block ) ; } if ( refreshSelection ) this.Select() ; return this._Cache.IsEndOfBlock = true ; }, // This is an "intrusive" way to create a bookmark. It includes <span> tags // in the range boundaries. The advantage of it is that it is possible to // handle DOM mutations when moving back to the bookmark. // Attention: the inclusion of nodes in the DOM is a design choice and // should not be changed as there are other points in the code that may be // using those nodes to perform operations. See GetBookmarkNode. // For performance, includeNodes=true if intended to SelectBookmark. CreateBookmark : function( includeNodes ) { // Create the bookmark info (random IDs). var oBookmark = { StartId : (new Date()).valueOf() + Math.floor(Math.random()*1000) + 'S', EndId : (new Date()).valueOf() + Math.floor(Math.random()*1000) + 'E' } ; var oDoc = this.Window.document ; var eStartSpan ; var eEndSpan ; var oClone ; // For collapsed ranges, add just the start marker. if ( !this.CheckIsCollapsed() ) { eEndSpan = oDoc.createElement( 'span' ) ; eEndSpan.style.display = 'none' ; eEndSpan.id = oBookmark.EndId ; eEndSpan.setAttribute( '_fck_bookmark', true ) ; // For IE, it must have something inside, otherwise it may be // removed during DOM operations. // if ( FCKBrowserInfo.IsIE ) eEndSpan.innerHTML = '&nbsp;' ; oClone = this.Clone() ; oClone.Collapse( false ) ; oClone.InsertNode( eEndSpan ) ; } eStartSpan = oDoc.createElement( 'span' ) ; eStartSpan.style.display = 'none' ; eStartSpan.id = oBookmark.StartId ; eStartSpan.setAttribute( '_fck_bookmark', true ) ; // For IE, it must have something inside, otherwise it may be removed // during DOM operations. // if ( FCKBrowserInfo.IsIE ) eStartSpan.innerHTML = '&nbsp;' ; oClone = this.Clone() ; oClone.Collapse( true ) ; oClone.InsertNode( eStartSpan ) ; if ( includeNodes ) { oBookmark.StartNode = eStartSpan ; oBookmark.EndNode = eEndSpan ; } // Update the range position. if ( eEndSpan ) { this.SetStart( eStartSpan, 4 ) ; this.SetEnd( eEndSpan, 3 ) ; } else this.MoveToPosition( eStartSpan, 4 ) ; return oBookmark ; }, // This one should be a part of a hypothetic "bookmark" object. GetBookmarkNode : function( bookmark, start ) { var doc = this.Window.document ; if ( start ) return bookmark.StartNode || doc.getElementById( bookmark.StartId ) ; else return bookmark.EndNode || doc.getElementById( bookmark.EndId ) ; }, MoveToBookmark : function( bookmark, preserveBookmark ) { var eStartSpan = this.GetBookmarkNode( bookmark, true ) ; var eEndSpan = this.GetBookmarkNode( bookmark, false ) ; this.SetStart( eStartSpan, 3 ) ; if ( !preserveBookmark ) FCKDomTools.RemoveNode( eStartSpan ) ; // If collapsed, the end span will not be available. if ( eEndSpan ) { this.SetEnd( eEndSpan, 3 ) ; if ( !preserveBookmark ) FCKDomTools.RemoveNode( eEndSpan ) ; } else this.Collapse( true ) ; this._UpdateElementInfo() ; }, // Non-intrusive bookmark algorithm CreateBookmark2 : function() { // If there is no range then get out of here. // It happens on initial load in Safari #962 and if the editor it's hidden also in Firefox if ( ! this._Range ) return { "Start" : 0, "End" : 0 } ; // First, we record down the offset values var bookmark = { "Start" : [ this._Range.startOffset ], "End" : [ this._Range.endOffset ] } ; // Since we're treating the document tree as normalized, we need to backtrack the text lengths // of previous text nodes into the offset value. var curStart = this._Range.startContainer.previousSibling ; var curEnd = this._Range.endContainer.previousSibling ; // Also note that the node that we use for "address base" would change during backtracking. var addrStart = this._Range.startContainer ; var addrEnd = this._Range.endContainer ; while ( curStart && curStart.nodeType == 3 && addrStart.nodeType == 3 ) { bookmark.Start[0] += curStart.length ; addrStart = curStart ; curStart = curStart.previousSibling ; } while ( curEnd && curEnd.nodeType == 3 && addrEnd.nodeType == 3 ) { bookmark.End[0] += curEnd.length ; addrEnd = curEnd ; curEnd = curEnd.previousSibling ; } // If the object pointed to by the startOffset and endOffset are text nodes, we need // to backtrack and add in the text offset to the bookmark addresses. if ( addrStart.nodeType == 1 && addrStart.childNodes[bookmark.Start[0]] && addrStart.childNodes[bookmark.Start[0]].nodeType == 3 ) { var curNode = addrStart.childNodes[bookmark.Start[0]] ; var offset = 0 ; while ( curNode.previousSibling && curNode.previousSibling.nodeType == 3 ) { curNode = curNode.previousSibling ; offset += curNode.length ; } addrStart = curNode ; bookmark.Start[0] = offset ; } if ( addrEnd.nodeType == 1 && addrEnd.childNodes[bookmark.End[0]] && addrEnd.childNodes[bookmark.End[0]].nodeType == 3 ) { var curNode = addrEnd.childNodes[bookmark.End[0]] ; var offset = 0 ; while ( curNode.previousSibling && curNode.previousSibling.nodeType == 3 ) { curNode = curNode.previousSibling ; offset += curNode.length ; } addrEnd = curNode ; bookmark.End[0] = offset ; } // Then, we record down the precise position of the container nodes // by walking up the DOM tree and counting their childNode index bookmark.Start = FCKDomTools.GetNodeAddress( addrStart, true ).concat( bookmark.Start ) ; bookmark.End = FCKDomTools.GetNodeAddress( addrEnd, true ).concat( bookmark.End ) ; return bookmark; }, MoveToBookmark2 : function( bookmark ) { // Reverse the childNode counting algorithm in CreateBookmark2() var curStart = FCKDomTools.GetNodeFromAddress( this.Window.document, bookmark.Start.slice( 0, -1 ), true ) ; var curEnd = FCKDomTools.GetNodeFromAddress( this.Window.document, bookmark.End.slice( 0, -1 ), true ) ; // Generate the W3C Range object and update relevant data this.Release( true ) ; this._Range = new FCKW3CRange( this.Window.document ) ; var startOffset = bookmark.Start[ bookmark.Start.length - 1 ] ; var endOffset = bookmark.End[ bookmark.End.length - 1 ] ; while ( curStart.nodeType == 3 && startOffset > curStart.length ) { if ( ! curStart.nextSibling || curStart.nextSibling.nodeType != 3 ) break ; startOffset -= curStart.length ; curStart = curStart.nextSibling ; } while ( curEnd.nodeType == 3 && endOffset > curEnd.length ) { if ( ! curEnd.nextSibling || curEnd.nextSibling.nodeType != 3 ) break ; endOffset -= curEnd.length ; curEnd = curEnd.nextSibling ; } this._Range.setStart( curStart, startOffset ) ; this._Range.setEnd( curEnd, endOffset ) ; this._UpdateElementInfo() ; }, MoveToPosition : function( targetElement, position ) { this.SetStart( targetElement, position ) ; this.Collapse( true ) ; }, /* * Moves the position of the start boundary of the range to a specific position * relatively to a element. * @position: * 1 = After Start <target>^contents</target> * 2 = Before End <target>contents^</target> * 3 = Before Start ^<target>contents</target> * 4 = After End <target>contents</target>^ */ SetStart : function( targetElement, position, noInfoUpdate ) { var oRange = this._Range ; if ( !oRange ) oRange = this._Range = this.CreateRange() ; switch( position ) { case 1 : // After Start <target>^contents</target> oRange.setStart( targetElement, 0 ) ; break ; case 2 : // Before End <target>contents^</target> oRange.setStart( targetElement, targetElement.childNodes.length ) ; break ; case 3 : // Before Start ^<target>contents</target> oRange.setStartBefore( targetElement ) ; break ; case 4 : // After End <target>contents</target>^ oRange.setStartAfter( targetElement ) ; } if ( !noInfoUpdate ) this._UpdateElementInfo() ; }, /* * Moves the position of the start boundary of the range to a specific position * relatively to a element. * @position: * 1 = After Start <target>^contents</target> * 2 = Before End <target>contents^</target> * 3 = Before Start ^<target>contents</target> * 4 = After End <target>contents</target>^ */ SetEnd : function( targetElement, position, noInfoUpdate ) { var oRange = this._Range ; if ( !oRange ) oRange = this._Range = this.CreateRange() ; switch( position ) { case 1 : // After Start <target>^contents</target> oRange.setEnd( targetElement, 0 ) ; break ; case 2 : // Before End <target>contents^</target> oRange.setEnd( targetElement, targetElement.childNodes.length ) ; break ; case 3 : // Before Start ^<target>contents</target> oRange.setEndBefore( targetElement ) ; break ; case 4 : // After End <target>contents</target>^ oRange.setEndAfter( targetElement ) ; } if ( !noInfoUpdate ) this._UpdateElementInfo() ; }, Expand : function( unit ) { var oNode, oSibling ; switch ( unit ) { // Expand the range to include all inline parent elements if we are // are in their boundary limits. // For example (where [ ] are the range limits): // Before => Some <b>[<i>Some sample text]</i></b>. // After => Some [<b><i>Some sample text</i></b>]. case 'inline_elements' : // Expand the start boundary. if ( this._Range.startOffset == 0 ) { oNode = this._Range.startContainer ; if ( oNode.nodeType != 1 ) oNode = oNode.previousSibling ? null : oNode.parentNode ; if ( oNode ) { while ( FCKListsLib.InlineNonEmptyElements[ oNode.nodeName.toLowerCase() ] ) { this._Range.setStartBefore( oNode ) ; if ( oNode != oNode.parentNode.firstChild ) break ; oNode = oNode.parentNode ; } } } // Expand the end boundary. oNode = this._Range.endContainer ; var offset = this._Range.endOffset ; if ( ( oNode.nodeType == 3 && offset >= oNode.nodeValue.length ) || ( oNode.nodeType == 1 && offset >= oNode.childNodes.length ) || ( oNode.nodeType != 1 && oNode.nodeType != 3 ) ) { if ( oNode.nodeType != 1 ) oNode = oNode.nextSibling ? null : oNode.parentNode ; if ( oNode ) { while ( FCKListsLib.InlineNonEmptyElements[ oNode.nodeName.toLowerCase() ] ) { this._Range.setEndAfter( oNode ) ; if ( oNode != oNode.parentNode.lastChild ) break ; oNode = oNode.parentNode ; } } } break ; case 'block_contents' : case 'list_contents' : var boundarySet = FCKListsLib.BlockBoundaries ; if ( unit == 'list_contents' || FCKConfig.EnterMode == 'br' ) boundarySet = FCKListsLib.ListBoundaries ; if ( this.StartBlock && FCKConfig.EnterMode != 'br' && unit == 'block_contents' ) this.SetStart( this.StartBlock, 1 ) ; else { // Get the start node for the current range. oNode = this._Range.startContainer ; // If it is an element, get the node right before of it (in source order). if ( oNode.nodeType == 1 ) { var lastNode = oNode.childNodes[ this._Range.startOffset ] ; if ( lastNode ) oNode = FCKDomTools.GetPreviousSourceNode( lastNode, true ) ; else oNode = oNode.lastChild || oNode ; } // We must look for the left boundary, relative to the range // start, which is limited by a block element. while ( oNode && ( oNode.nodeType != 1 || ( oNode != this.StartBlockLimit && !boundarySet[ oNode.nodeName.toLowerCase() ] ) ) ) { this._Range.setStartBefore( oNode ) ; oNode = oNode.previousSibling || oNode.parentNode ; } } if ( this.EndBlock && FCKConfig.EnterMode != 'br' && unit == 'block_contents' && this.EndBlock.nodeName.toLowerCase() != 'li' ) this.SetEnd( this.EndBlock, 2 ) ; else { oNode = this._Range.endContainer ; if ( oNode.nodeType == 1 ) oNode = oNode.childNodes[ this._Range.endOffset ] || oNode.lastChild ; // We must look for the right boundary, relative to the range // end, which is limited by a block element. while ( oNode && ( oNode.nodeType != 1 || ( oNode != this.StartBlockLimit && !boundarySet[ oNode.nodeName.toLowerCase() ] ) ) ) { this._Range.setEndAfter( oNode ) ; oNode = oNode.nextSibling || oNode.parentNode ; } // In EnterMode='br', the end <br> boundary element must // be included in the expanded range. if ( oNode && oNode.nodeName.toLowerCase() == 'br' ) this._Range.setEndAfter( oNode ) ; } this._UpdateElementInfo() ; } }, /** * Split the block element for the current range. It deletes the contents * of the range and splits the block in the collapsed position, resulting * in two sucessive blocks. The range is then positioned in the middle of * them. * * It returns and object with the following properties: * - PreviousBlock : a reference to the block element that preceeds * the range after the split. * - NextBlock : a reference to the block element that follows the * range after the split. * - WasStartOfBlock : a boolean indicating that the range was * originaly at the start of the block. * - WasEndOfBlock : a boolean indicating that the range was originaly * at the end of the block. * * If the range was originaly at the start of the block, no split will happen * and the PreviousBlock value will be null. The same is valid for the * NextBlock value if the range was at the end of the block. */ SplitBlock : function( forceBlockTag ) { var blockTag = forceBlockTag || FCKConfig.EnterMode ; if ( !this._Range ) this.MoveToSelection() ; // The range boundaries must be in the same "block limit" element. if ( this.StartBlockLimit == this.EndBlockLimit ) { // Get the current blocks. var eStartBlock = this.StartBlock ; var eEndBlock = this.EndBlock ; var oElementPath = null ; if ( blockTag != 'br' ) { if ( !eStartBlock ) { eStartBlock = this.FixBlock( true, blockTag ) ; eEndBlock = this.EndBlock ; // FixBlock may have fixed the EndBlock too. } if ( !eEndBlock ) eEndBlock = this.FixBlock( false, blockTag ) ; } // Get the range position. var bIsStartOfBlock = ( eStartBlock != null && this.CheckStartOfBlock() ) ; var bIsEndOfBlock = ( eEndBlock != null && this.CheckEndOfBlock() ) ; // Delete the current contents. if ( !this.CheckIsEmpty() ) this.DeleteContents() ; if ( eStartBlock && eEndBlock && eStartBlock == eEndBlock ) { if ( bIsEndOfBlock ) { oElementPath = new FCKElementPath( this.StartContainer ) ; this.MoveToPosition( eEndBlock, 4 ) ; eEndBlock = null ; } else if ( bIsStartOfBlock ) { oElementPath = new FCKElementPath( this.StartContainer ) ; this.MoveToPosition( eStartBlock, 3 ) ; eStartBlock = null ; } else { // Extract the contents of the block from the selection point to the end of its contents. this.SetEnd( eStartBlock, 2 ) ; var eDocFrag = this.ExtractContents() ; // Duplicate the block element after it. eEndBlock = eStartBlock.cloneNode( false ) ; eEndBlock.removeAttribute( 'id', false ) ; // Place the extracted contents in the duplicated block. eDocFrag.AppendTo( eEndBlock ) ; FCKDomTools.InsertAfterNode( eStartBlock, eEndBlock ) ; this.MoveToPosition( eStartBlock, 4 ) ; // In Gecko, the last child node must be a bogus <br>. // Note: bogus <br> added under <ul> or <ol> would cause lists to be incorrectly rendered. if ( FCKBrowserInfo.IsGecko && ! eStartBlock.nodeName.IEquals( ['ul', 'ol'] ) ) FCKTools.AppendBogusBr( eStartBlock ) ; } } return { PreviousBlock : eStartBlock, NextBlock : eEndBlock, WasStartOfBlock : bIsStartOfBlock, WasEndOfBlock : bIsEndOfBlock, ElementPath : oElementPath } ; } return null ; }, // Transform a block without a block tag in a valid block (orphan text in the body or td, usually). FixBlock : function( isStart, blockTag ) { // Bookmark the range so we can restore it later. var oBookmark = this.CreateBookmark() ; // Collapse the range to the requested ending boundary. this.Collapse( isStart ) ; // Expands it to the block contents. this.Expand( 'block_contents' ) ; // Create the fixed block. var oFixedBlock = this.Window.document.createElement( blockTag ) ; // Move the contents of the temporary range to the fixed block. this.ExtractContents().AppendTo( oFixedBlock ) ; FCKDomTools.TrimNode( oFixedBlock ) ; // If the fixed block is empty (not counting bookmark nodes) // Add a <br /> inside to expand it. if ( FCKDomTools.CheckIsEmptyElement(oFixedBlock, function( element ) { return element.getAttribute('_fck_bookmark') != 'true' ; } ) && FCKBrowserInfo.IsGeckoLike ) FCKTools.AppendBogusBr( oFixedBlock ) ; // Insert the fixed block into the DOM. this.InsertNode( oFixedBlock ) ; // Move the range back to the bookmarked place. this.MoveToBookmark( oBookmark ) ; return oFixedBlock ; }, Release : function( preserveWindow ) { if ( !preserveWindow ) this.Window = null ; this.StartNode = null ; this.StartContainer = null ; this.StartBlock = null ; this.StartBlockLimit = null ; this.EndNode = null ; this.EndContainer = null ; this.EndBlock = null ; this.EndBlockLimit = null ; this._Range = null ; this._Cache = null ; }, CheckHasRange : function() { return !!this._Range ; }, GetTouchedStartNode : function() { var range = this._Range ; var container = range.startContainer ; if ( range.collapsed || container.nodeType != 1 ) return container ; return container.childNodes[ range.startOffset ] || container ; }, GetTouchedEndNode : function() { var range = this._Range ; var container = range.endContainer ; if ( range.collapsed || container.nodeType != 1 ) return container ; return container.childNodes[ range.endOffset - 1 ] || container ; } } ;
JavaScript
/* * 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 == * * This class can be used to interate through nodes inside a range. * * During interation, the provided range can become invalid, due to document * mutations, so CreateBookmark() used to restore it after processing, if * needed. */ var FCKDomRangeIterator = function( range ) { /** * The FCKDomRange object that marks the interation boundaries. */ this.Range = range ; /** * Indicates that <br> elements must be used as paragraph boundaries. */ this.ForceBrBreak = false ; /** * Guarantees that the iterator will always return "real" block elements. * If "false", elements like <li>, <th> and <td> are returned. If "true", a * dedicated block element block element will be created inside those * elements to hold the selected content. */ this.EnforceRealBlocks = false ; } FCKDomRangeIterator.CreateFromSelection = function( targetWindow ) { var range = new FCKDomRange( targetWindow ) ; range.MoveToSelection() ; return new FCKDomRangeIterator( range ) ; } FCKDomRangeIterator.prototype = { /** * Get the next paragraph element. It automatically breaks the document * when necessary to generate block elements for the paragraphs. */ GetNextParagraph : function() { // The block element to be returned. var block ; // The range object used to identify the paragraph contents. var range ; // Indicated that the current element in the loop is the last one. var isLast ; // Instructs to cleanup remaining BRs. var removePreviousBr ; var removeLastBr ; var boundarySet = this.ForceBrBreak ? FCKListsLib.ListBoundaries : FCKListsLib.BlockBoundaries ; // This is the first iteration. Let's initialize it. if ( !this._LastNode ) { var range = this.Range.Clone() ; range.Expand( this.ForceBrBreak ? 'list_contents' : 'block_contents' ) ; this._NextNode = range.GetTouchedStartNode() ; this._LastNode = range.GetTouchedEndNode() ; // Let's reuse this variable. range = null ; } var currentNode = this._NextNode ; var lastNode = this._LastNode ; this._NextNode = null ; while ( currentNode ) { // closeRange indicates that a paragraph boundary has been found, // so the range can be closed. var closeRange = false ; // includeNode indicates that the current node is good to be part // of the range. By default, any non-element node is ok for it. var includeNode = ( currentNode.nodeType != 1 ) ; var continueFromSibling = false ; // If it is an element node, let's check if it can be part of the // range. if ( !includeNode ) { var nodeName = currentNode.nodeName.toLowerCase() ; if ( boundarySet[ nodeName ] && ( !FCKBrowserInfo.IsIE || currentNode.scopeName == 'HTML' ) ) { // <br> boundaries must be part of the range. It will // happen only if ForceBrBreak. if ( nodeName == 'br' ) includeNode = true ; else if ( !range && currentNode.childNodes.length == 0 && nodeName != 'hr' ) { // If we have found an empty block, and haven't started // the range yet, it means we must return this block. block = currentNode ; isLast = currentNode == lastNode ; break ; } // The range must finish right before the boundary, // including possibly skipped empty spaces. (#1603) if ( range ) { range.SetEnd( currentNode, 3, true ) ; // The found boundary must be set as the next one at this // point. (#1717) if ( nodeName != 'br' ) this._NextNode = FCKDomTools.GetNextSourceNode( currentNode, true, null, lastNode ) || currentNode ; } closeRange = true ; } else { // If we have child nodes, let's check them. if ( currentNode.firstChild ) { // If we don't have a range yet, let's start it. if ( !range ) { range = new FCKDomRange( this.Range.Window ) ; range.SetStart( currentNode, 3, true ) ; } currentNode = currentNode.firstChild ; continue ; } includeNode = true ; } } else if ( currentNode.nodeType == 3 ) { // Ignore normal whitespaces (i.e. not including &nbsp; or // other unicode whitespaces) before/after a block node. if ( /^[\r\n\t ]+$/.test( currentNode.nodeValue ) ) includeNode = false ; } // The current node is good to be part of the range and we are // starting a new range, initialize it first. if ( includeNode && !range ) { range = new FCKDomRange( this.Range.Window ) ; range.SetStart( currentNode, 3, true ) ; } // The last node has been found. isLast = ( ( !closeRange || includeNode ) && currentNode == lastNode ) ; // isLast = ( currentNode == lastNode && ( currentNode.nodeType != 1 || currentNode.childNodes.length == 0 ) ) ; // If we are in an element boundary, let's check if it is time // to close the range, otherwise we include the parent within it. if ( range && !closeRange ) { while ( !currentNode.nextSibling && !isLast ) { var parentNode = currentNode.parentNode ; if ( boundarySet[ parentNode.nodeName.toLowerCase() ] ) { closeRange = true ; isLast = isLast || ( parentNode == lastNode ) ; break ; } currentNode = parentNode ; includeNode = true ; isLast = ( currentNode == lastNode ) ; continueFromSibling = true ; } } // Now finally include the node. if ( includeNode ) range.SetEnd( currentNode, 4, true ) ; // We have found a block boundary. Let's close the range and move out of the // loop. if ( ( closeRange || isLast ) && range ) { range._UpdateElementInfo() ; if ( range.StartNode == range.EndNode && range.StartNode.parentNode == range.StartBlockLimit && range.StartNode.getAttribute && range.StartNode.getAttribute( '_fck_bookmark' ) ) range = null ; else break ; } if ( isLast ) break ; currentNode = FCKDomTools.GetNextSourceNode( currentNode, continueFromSibling, null, lastNode ) ; } // Now, based on the processed range, look for (or create) the block to be returned. if ( !block ) { // If no range has been found, this is the end. if ( !range ) { this._NextNode = null ; return null ; } block = range.StartBlock ; if ( !block && !this.EnforceRealBlocks && range.StartBlockLimit.nodeName.IEquals( 'DIV', 'TH', 'TD' ) && range.CheckStartOfBlock() && range.CheckEndOfBlock() ) { block = range.StartBlockLimit ; } else if ( !block || ( this.EnforceRealBlocks && block.nodeName.toLowerCase() == 'li' ) ) { // Create the fixed block. block = this.Range.Window.document.createElement( FCKConfig.EnterMode == 'p' ? 'p' : 'div' ) ; // Move the contents of the temporary range to the fixed block. range.ExtractContents().AppendTo( block ) ; FCKDomTools.TrimNode( block ) ; // Insert the fixed block into the DOM. range.InsertNode( block ) ; removePreviousBr = true ; removeLastBr = true ; } else if ( block.nodeName.toLowerCase() != 'li' ) { // If the range doesn't includes the entire contents of the // block, we must split it, isolating the range in a dedicated // block. if ( !range.CheckStartOfBlock() || !range.CheckEndOfBlock() ) { // The resulting block will be a clone of the current one. block = block.cloneNode( false ) ; // Extract the range contents, moving it to the new block. range.ExtractContents().AppendTo( block ) ; FCKDomTools.TrimNode( block ) ; // Split the block. At this point, the range will be in the // right position for our intents. var splitInfo = range.SplitBlock() ; removePreviousBr = !splitInfo.WasStartOfBlock ; removeLastBr = !splitInfo.WasEndOfBlock ; // Insert the new block into the DOM. range.InsertNode( block ) ; } } else if ( !isLast ) { // LIs are returned as is, with all their children (due to the // nested lists). But, the next node is the node right after // the current range, which could be an <li> child (nested // lists) or the next sibling <li>. this._NextNode = block == lastNode ? null : FCKDomTools.GetNextSourceNode( range.EndNode, true, null, lastNode ) ; return block ; } } if ( removePreviousBr ) { var previousSibling = block.previousSibling ; if ( previousSibling && previousSibling.nodeType == 1 ) { if ( previousSibling.nodeName.toLowerCase() == 'br' ) previousSibling.parentNode.removeChild( previousSibling ) ; else if ( previousSibling.lastChild && previousSibling.lastChild.nodeName.IEquals( 'br' ) ) previousSibling.removeChild( previousSibling.lastChild ) ; } } if ( removeLastBr ) { var lastChild = block.lastChild ; if ( lastChild && lastChild.nodeType == 1 && lastChild.nodeName.toLowerCase() == 'br' ) block.removeChild( lastChild ) ; } // Get a reference for the next element. This is important because the // above block can be removed or changed, so we can rely on it for the // next interation. if ( !this._NextNode ) this._NextNode = ( isLast || block == lastNode ) ? null : FCKDomTools.GetNextSourceNode( block, true, null, lastNode ) ; return block ; } } ;
JavaScript
/* * 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 == * * This class can be used to interate through nodes inside a range. * * During interation, the provided range can become invalid, due to document * mutations, so CreateBookmark() used to restore it after processing, if * needed. */ var FCKHtmlIterator = function( source ) { this._sourceHtml = source ; } FCKHtmlIterator.prototype = { Next : function() { var sourceHtml = this._sourceHtml ; if ( sourceHtml == null ) return null ; var match = FCKRegexLib.HtmlTag.exec( sourceHtml ) ; var isTag = false ; var value = "" ; if ( match ) { if ( match.index > 0 ) { value = sourceHtml.substr( 0, match.index ) ; this._sourceHtml = sourceHtml.substr( match.index ) ; } else { isTag = true ; value = match[0] ; this._sourceHtml = sourceHtml.substr( match[0].length ) ; } } else { value = sourceHtml ; this._sourceHtml = null ; } return { 'isTag' : isTag, 'value' : value } ; }, Each : function( func ) { var chunk ; while ( ( chunk = this.Next() ) ) func( chunk.isTag, chunk.value ) ; } } ; /* * 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 == * * This class can be used to interate through nodes inside a range. * * During interation, the provided range can become invalid, due to document * mutations, so CreateBookmark() used to restore it after processing, if * needed. */ var FCKHtmlIterator = function( source ) { this._sourceHtml = source ; } FCKHtmlIterator.prototype = { Next : function() { var sourceHtml = this._sourceHtml ; if ( sourceHtml == null ) return null ; var match = FCKRegexLib.HtmlTag.exec( sourceHtml ) ; var isTag = false ; var value = "" ; if ( match ) { if ( match.index > 0 ) { value = sourceHtml.substr( 0, match.index ) ; this._sourceHtml = sourceHtml.substr( match.index ) ; } else { isTag = true ; value = match[0] ; this._sourceHtml = sourceHtml.substr( match[0].length ) ; } } else { value = sourceHtml ; this._sourceHtml = null ; } return { 'isTag' : isTag, 'value' : value } ; }, Each : function( func ) { var chunk ; while ( ( chunk = this.Next() ) ) func( chunk.isTag, chunk.value ) ; } } ;
JavaScript
/* * 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 == * * FCKEvents Class: used to handle events is a advanced way. */ var FCKEvents = function( eventsOwner ) { this.Owner = eventsOwner ; this._RegisteredEvents = new Object() ; } FCKEvents.prototype.AttachEvent = function( eventName, functionPointer ) { var aTargets ; if ( !( aTargets = this._RegisteredEvents[ eventName ] ) ) this._RegisteredEvents[ eventName ] = [ functionPointer ] ; else { // Check that the event handler isn't already registered with the same listener // It doesn't detect function pointers belonging to an object (at least in Gecko) if ( aTargets.IndexOf( functionPointer ) == -1 ) aTargets.push( functionPointer ) ; } } FCKEvents.prototype.FireEvent = function( eventName, params ) { var bReturnValue = true ; var oCalls = this._RegisteredEvents[ eventName ] ; if ( oCalls ) { for ( var i = 0 ; i < oCalls.length ; i++ ) { try { bReturnValue = ( oCalls[ i ]( this.Owner, params ) && bReturnValue ) ; } catch(e) { // Ignore the following error. It may happen if pointing to a // script not anymore available (#934): // -2146823277 = Can't execute code from a freed script if ( e.number != -2146823277 ) throw e ; } } } return bReturnValue ; }
JavaScript
/* * 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 == * * FCKXml Class: class to load and manipulate XML files. * (IE specific implementation) */ FCKXml.prototype = { LoadUrl : function( urlToCall ) { this.Error = false ; var oXmlHttp = FCKTools.CreateXmlObject( 'XmlHttp' ) ; if ( !oXmlHttp ) { this.Error = true ; return ; } oXmlHttp.open( "GET", urlToCall, false ) ; oXmlHttp.send( null ) ; if ( oXmlHttp.status == 200 || oXmlHttp.status == 304 || ( oXmlHttp.status == 0 && oXmlHttp.readyState == 4 ) ) { this.DOMDocument = oXmlHttp.responseXML ; // #1426: Fallback if responseXML isn't set for some // reason (e.g. improperly configured web server) if ( !this.DOMDocument || this.DOMDocument.firstChild == null ) { this.DOMDocument = FCKTools.CreateXmlObject( 'DOMDocument' ) ; this.DOMDocument.async = false ; this.DOMDocument.resolveExternals = false ; this.DOMDocument.loadXML( oXmlHttp.responseText ) ; } } else { this.DOMDocument = null ; } if ( this.DOMDocument == null || this.DOMDocument.firstChild == null ) { this.Error = true ; if (window.confirm( 'Error loading "' + urlToCall + '"\r\nDo you want to see more info?' ) ) alert( 'URL requested: "' + urlToCall + '"\r\n' + 'Server response:\r\nStatus: ' + oXmlHttp.status + '\r\n' + 'Response text:\r\n' + oXmlHttp.responseText ) ; } }, SelectNodes : function( xpath, contextNode ) { if ( this.Error ) return new Array() ; if ( contextNode ) return contextNode.selectNodes( xpath ) ; else return this.DOMDocument.selectNodes( xpath ) ; }, SelectSingleNode : function( xpath, contextNode ) { if ( this.Error ) return null ; if ( contextNode ) return contextNode.selectSingleNode( xpath ) ; else return this.DOMDocument.selectSingleNode( xpath ) ; } } ;
JavaScript
/* * 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 == * * Preload a list of images, firing an event when complete. */ var FCKImagePreloader = function() { this._Images = new Array() ; } FCKImagePreloader.prototype = { AddImages : function( images ) { if ( typeof( images ) == 'string' ) images = images.split( ';' ) ; this._Images = this._Images.concat( images ) ; }, Start : function() { var aImages = this._Images ; this._PreloadCount = aImages.length ; for ( var i = 0 ; i < aImages.length ; i++ ) { var eImg = document.createElement( 'img' ) ; FCKTools.AddEventListenerEx( eImg, 'load', _FCKImagePreloader_OnImage, this ) ; FCKTools.AddEventListenerEx( eImg, 'error', _FCKImagePreloader_OnImage, this ) ; eImg.src = aImages[i] ; _FCKImagePreloader_ImageCache.push( eImg ) ; } } }; // All preloaded images must be placed in a global array, otherwise the preload // magic will not happen. var _FCKImagePreloader_ImageCache = new Array() ; function _FCKImagePreloader_OnImage( ev, imagePreloader ) { if ( (--imagePreloader._PreloadCount) == 0 && imagePreloader.OnComplete ) imagePreloader.OnComplete() ; }
JavaScript
/* * 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 == * * FCKXml Class: class to load and manipulate XML files. * (IE specific implementation) */ var FCKXml = function() { this.Error = false ; } FCKXml.GetAttribute = function( node, attName, defaultValue ) { var attNode = node.attributes.getNamedItem( attName ) ; return attNode ? attNode.value : defaultValue ; } /** * Transforms a XML element node in a JavaScript object. Attributes defined for * the element will be available as properties, as long as child element * nodes, but the later will generate arrays with property names prefixed with "$". * * For example, the following XML element: * * <SomeNode name="Test" key="2"> * <MyChild id="10"> * <OtherLevel name="Level 3" /> * </MyChild> * <MyChild id="25" /> * <AnotherChild price="499" /> * </SomeNode> * * ... results in the following object: * * { * name : "Test", * key : "2", * $MyChild : * [ * { * id : "10", * $OtherLevel : * { * name : "Level 3" * } * }, * { * id : "25" * } * ], * $AnotherChild : * [ * { * price : "499" * } * ] * } */ FCKXml.TransformToObject = function( element ) { if ( !element ) return null ; var obj = {} ; var attributes = element.attributes ; for ( var i = 0 ; i < attributes.length ; i++ ) { var att = attributes[i] ; obj[ att.name ] = att.value ; } var childNodes = element.childNodes ; for ( i = 0 ; i < childNodes.length ; i++ ) { var child = childNodes[i] ; if ( child.nodeType == 1 ) { var childName = '$' + child.nodeName ; var childList = obj[ childName ] ; if ( !childList ) childList = obj[ childName ] = [] ; childList.push( this.TransformToObject( child ) ) ; } } return obj ; }
JavaScript
/* * 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 == * * Renders a list of menu items. */ var FCKMenuBlock = function() { this._Items = new Array() ; } FCKMenuBlock.prototype.Count = function() { return this._Items.length ; } FCKMenuBlock.prototype.AddItem = function( name, label, iconPathOrStripInfoArrayOrIndex, isDisabled, customData ) { var oItem = new FCKMenuItem( this, name, label, iconPathOrStripInfoArrayOrIndex, isDisabled, customData ) ; oItem.OnClick = FCKTools.CreateEventListener( FCKMenuBlock_Item_OnClick, this ) ; oItem.OnActivate = FCKTools.CreateEventListener( FCKMenuBlock_Item_OnActivate, this ) ; this._Items.push( oItem ) ; return oItem ; } FCKMenuBlock.prototype.AddSeparator = function() { this._Items.push( new FCKMenuSeparator() ) ; } FCKMenuBlock.prototype.RemoveAllItems = function() { this._Items = new Array() ; var eItemsTable = this._ItemsTable ; if ( eItemsTable ) { while ( eItemsTable.rows.length > 0 ) eItemsTable.deleteRow( 0 ) ; } } FCKMenuBlock.prototype.Create = function( parentElement ) { if ( !this._ItemsTable ) { if ( FCK.IECleanup ) FCK.IECleanup.AddItem( this, FCKMenuBlock_Cleanup ) ; this._Window = FCKTools.GetElementWindow( parentElement ) ; var oDoc = FCKTools.GetElementDocument( parentElement ) ; var eTable = parentElement.appendChild( oDoc.createElement( 'table' ) ) ; eTable.cellPadding = 0 ; eTable.cellSpacing = 0 ; FCKTools.DisableSelection( eTable ) ; var oMainElement = eTable.insertRow(-1).insertCell(-1) ; oMainElement.className = 'MN_Menu' ; var eItemsTable = this._ItemsTable = oMainElement.appendChild( oDoc.createElement( 'table' ) ) ; eItemsTable.cellPadding = 0 ; eItemsTable.cellSpacing = 0 ; } for ( var i = 0 ; i < this._Items.length ; i++ ) this._Items[i].Create( this._ItemsTable ) ; } /* Events */ function FCKMenuBlock_Item_OnClick( clickedItem, menuBlock ) { if ( menuBlock.Hide ) menuBlock.Hide() ; FCKTools.RunFunction( menuBlock.OnClick, menuBlock, [ clickedItem ] ) ; } function FCKMenuBlock_Item_OnActivate( menuBlock ) { var oActiveItem = menuBlock._ActiveItem ; if ( oActiveItem && oActiveItem != this ) { // Set the focus to this menu block window (to fire OnBlur on opened panels). if ( !FCKBrowserInfo.IsIE && oActiveItem.HasSubMenu && !this.HasSubMenu ) { menuBlock._Window.focus() ; // Due to the event model provided by Opera, we need to set // HasFocus here as the above focus() call will not fire the focus // event in the panel immediately (#1200). menuBlock.Panel.HasFocus = true ; } oActiveItem.Deactivate() ; } menuBlock._ActiveItem = this ; } function FCKMenuBlock_Cleanup() { this._Window = null ; this._ItemsTable = null ; } // ################# // var FCKMenuSeparator = function() {} FCKMenuSeparator.prototype.Create = function( parentTable ) { var oDoc = FCKTools.GetElementDocument( parentTable ) ; var r = parentTable.insertRow(-1) ; var eCell = r.insertCell(-1) ; eCell.className = 'MN_Separator MN_Icon' ; eCell = r.insertCell(-1) ; eCell.className = 'MN_Separator' ; eCell.appendChild( oDoc.createElement( 'DIV' ) ).className = 'MN_Separator_Line' ; eCell = r.insertCell(-1) ; eCell.className = 'MN_Separator' ; eCell.appendChild( oDoc.createElement( 'DIV' ) ).className = 'MN_Separator_Line' ; }
JavaScript
/* * 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 == * * Defines and renders a menu items in a menu block. */ var FCKMenuItem = function( parentMenuBlock, name, label, iconPathOrStripInfoArray, isDisabled, customData ) { this.Name = name ; this.Label = label || name ; this.IsDisabled = isDisabled ; this.Icon = new FCKIcon( iconPathOrStripInfoArray ) ; this.SubMenu = new FCKMenuBlockPanel() ; this.SubMenu.Parent = parentMenuBlock ; this.SubMenu.OnClick = FCKTools.CreateEventListener( FCKMenuItem_SubMenu_OnClick, this ) ; this.CustomData = customData ; if ( FCK.IECleanup ) FCK.IECleanup.AddItem( this, FCKMenuItem_Cleanup ) ; } FCKMenuItem.prototype.AddItem = function( name, label, iconPathOrStripInfoArrayOrIndex, isDisabled, customData ) { this.HasSubMenu = true ; return this.SubMenu.AddItem( name, label, iconPathOrStripInfoArrayOrIndex, isDisabled, customData ) ; } FCKMenuItem.prototype.AddSeparator = function() { this.SubMenu.AddSeparator() ; } FCKMenuItem.prototype.Create = function( parentTable ) { var bHasSubMenu = this.HasSubMenu ; var oDoc = FCKTools.GetElementDocument( parentTable ) ; // Add a row in the table to hold the menu item. var r = this.MainElement = parentTable.insertRow(-1) ; r.className = this.IsDisabled ? 'MN_Item_Disabled' : 'MN_Item' ; // Set the row behavior. if ( !this.IsDisabled ) { FCKTools.AddEventListenerEx( r, 'mouseover', FCKMenuItem_OnMouseOver, [ this ] ) ; FCKTools.AddEventListenerEx( r, 'click', FCKMenuItem_OnClick, [ this ] ) ; if ( !bHasSubMenu ) FCKTools.AddEventListenerEx( r, 'mouseout', FCKMenuItem_OnMouseOut, [ this ] ) ; } // Create the icon cell. var eCell = r.insertCell(-1) ; eCell.className = 'MN_Icon' ; eCell.appendChild( this.Icon.CreateIconElement( oDoc ) ) ; // Create the label cell. eCell = r.insertCell(-1) ; eCell.className = 'MN_Label' ; eCell.noWrap = true ; eCell.appendChild( oDoc.createTextNode( this.Label ) ) ; // Create the arrow cell and setup the sub menu panel (if needed). eCell = r.insertCell(-1) ; if ( bHasSubMenu ) { eCell.className = 'MN_Arrow' ; // The arrow is a fixed size image. var eArrowImg = eCell.appendChild( oDoc.createElement( 'IMG' ) ) ; eArrowImg.src = FCK_IMAGES_PATH + 'arrow_' + FCKLang.Dir + '.gif' ; eArrowImg.width = 4 ; eArrowImg.height = 7 ; this.SubMenu.Create() ; this.SubMenu.Panel.OnHide = FCKTools.CreateEventListener( FCKMenuItem_SubMenu_OnHide, this ) ; } } FCKMenuItem.prototype.Activate = function() { this.MainElement.className = 'MN_Item_Over' ; if ( this.HasSubMenu ) { // Show the child menu block. The ( +2, -2 ) correction is done because // of the padding in the skin. It is not a good solution because one // could change the skin and so the final result would not be accurate. // For now it is ok because we are controlling the skin. this.SubMenu.Show( this.MainElement.offsetWidth + 2, -2, this.MainElement ) ; } FCKTools.RunFunction( this.OnActivate, this ) ; } FCKMenuItem.prototype.Deactivate = function() { this.MainElement.className = 'MN_Item' ; if ( this.HasSubMenu ) this.SubMenu.Hide() ; } /* Events */ function FCKMenuItem_SubMenu_OnClick( clickedItem, listeningItem ) { FCKTools.RunFunction( listeningItem.OnClick, listeningItem, [ clickedItem ] ) ; } function FCKMenuItem_SubMenu_OnHide( menuItem ) { menuItem.Deactivate() ; } function FCKMenuItem_OnClick( ev, menuItem ) { if ( menuItem.HasSubMenu ) menuItem.Activate() ; else { menuItem.Deactivate() ; FCKTools.RunFunction( menuItem.OnClick, menuItem, [ menuItem ] ) ; } } function FCKMenuItem_OnMouseOver( ev, menuItem ) { menuItem.Activate() ; } function FCKMenuItem_OnMouseOut( ev, menuItem ) { menuItem.Deactivate() ; } function FCKMenuItem_Cleanup() { this.MainElement = null ; }
JavaScript
/* * 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 == * * FCKContextMenu Class: renders an control a context menu. */ var FCKContextMenu = function( parentWindow, langDir ) { this.CtrlDisable = false ; var oPanel = this._Panel = new FCKPanel( parentWindow ) ; oPanel.AppendStyleSheet( FCKConfig.SkinEditorCSS ) ; oPanel.IsContextMenu = true ; // The FCKTools.DisableSelection doesn't seems to work to avoid dragging of the icons in Mozilla // so we stop the start of the dragging if ( FCKBrowserInfo.IsGecko ) oPanel.Document.addEventListener( 'draggesture', function(e) {e.preventDefault(); return false;}, true ) ; var oMenuBlock = this._MenuBlock = new FCKMenuBlock() ; oMenuBlock.Panel = oPanel ; oMenuBlock.OnClick = FCKTools.CreateEventListener( FCKContextMenu_MenuBlock_OnClick, this ) ; this._Redraw = true ; } FCKContextMenu.prototype.SetMouseClickWindow = function( mouseClickWindow ) { if ( !FCKBrowserInfo.IsIE ) { this._Document = mouseClickWindow.document ; if ( FCKBrowserInfo.IsOpera && !( 'oncontextmenu' in document.createElement('foo') ) ) { this._Document.addEventListener( 'mousedown', FCKContextMenu_Document_OnMouseDown, false ) ; this._Document.addEventListener( 'mouseup', FCKContextMenu_Document_OnMouseUp, false ) ; } this._Document.addEventListener( 'contextmenu', FCKContextMenu_Document_OnContextMenu, false ) ; } } /** The customData parameter is just a value that will be send to the command that is executed, so it's possible to reuse the same command for several items just by assigning different data for each one. */ FCKContextMenu.prototype.AddItem = function( name, label, iconPathOrStripInfoArrayOrIndex, isDisabled, customData ) { var oItem = this._MenuBlock.AddItem( name, label, iconPathOrStripInfoArrayOrIndex, isDisabled, customData ) ; this._Redraw = true ; return oItem ; } FCKContextMenu.prototype.AddSeparator = function() { this._MenuBlock.AddSeparator() ; this._Redraw = true ; } FCKContextMenu.prototype.RemoveAllItems = function() { this._MenuBlock.RemoveAllItems() ; this._Redraw = true ; } FCKContextMenu.prototype.AttachToElement = function( element ) { if ( FCKBrowserInfo.IsIE ) FCKTools.AddEventListenerEx( element, 'contextmenu', FCKContextMenu_AttachedElement_OnContextMenu, this ) ; else element._FCKContextMenu = this ; } function FCKContextMenu_Document_OnContextMenu( e ) { if ( FCKConfig.BrowserContextMenu ) return true ; var el = e.target ; while ( el ) { if ( el._FCKContextMenu ) { if ( el._FCKContextMenu.CtrlDisable && ( e.ctrlKey || e.metaKey ) ) return true ; FCKTools.CancelEvent( e ) ; FCKContextMenu_AttachedElement_OnContextMenu( e, el._FCKContextMenu, el ) ; return false ; } el = el.parentNode ; } return true ; } var FCKContextMenu_OverrideButton ; function FCKContextMenu_Document_OnMouseDown( e ) { if( !e || e.button != 2 ) return false ; if ( FCKConfig.BrowserContextMenu ) return true ; var el = e.target ; while ( el ) { if ( el._FCKContextMenu ) { if ( el._FCKContextMenu.CtrlDisable && ( e.ctrlKey || e.metaKey ) ) return true ; var overrideButton = FCKContextMenu_OverrideButton ; if( !overrideButton ) { var doc = FCKTools.GetElementDocument( e.target ) ; overrideButton = FCKContextMenu_OverrideButton = doc.createElement('input') ; overrideButton.type = 'button' ; var buttonHolder = doc.createElement('p') ; doc.body.appendChild( buttonHolder ) ; buttonHolder.appendChild( overrideButton ) ; } overrideButton.style.cssText = 'position:absolute;top:' + ( e.clientY - 2 ) + 'px;left:' + ( e.clientX - 2 ) + 'px;width:5px;height:5px;opacity:0.01' ; } el = el.parentNode ; } return false ; } function FCKContextMenu_Document_OnMouseUp( e ) { if ( FCKConfig.BrowserContextMenu ) return true ; var overrideButton = FCKContextMenu_OverrideButton ; if ( overrideButton ) { var parent = overrideButton.parentNode ; parent.parentNode.removeChild( parent ) ; FCKContextMenu_OverrideButton = undefined ; if( e && e.button == 2 ) { FCKContextMenu_Document_OnContextMenu( e ) ; return false ; } } return true ; } function FCKContextMenu_AttachedElement_OnContextMenu( ev, fckContextMenu, el ) { if ( ( fckContextMenu.CtrlDisable && ( ev.ctrlKey || ev.metaKey ) ) || FCKConfig.BrowserContextMenu ) return true ; var eTarget = el || this ; if ( fckContextMenu.OnBeforeOpen ) fckContextMenu.OnBeforeOpen.call( fckContextMenu, eTarget ) ; if ( fckContextMenu._MenuBlock.Count() == 0 ) return false ; if ( fckContextMenu._Redraw ) { fckContextMenu._MenuBlock.Create( fckContextMenu._Panel.MainNode ) ; fckContextMenu._Redraw = false ; } // This will avoid that the content of the context menu can be dragged in IE // as the content of the panel is recreated we need to do it every time FCKTools.DisableSelection( fckContextMenu._Panel.Document.body ) ; var x = 0 ; var y = 0 ; if ( FCKBrowserInfo.IsIE ) { x = ev.screenX ; y = ev.screenY ; } else if ( FCKBrowserInfo.IsSafari ) { x = ev.clientX ; y = ev.clientY ; } else { x = ev.pageX ; y = ev.pageY ; } fckContextMenu._Panel.Show( x, y, ev.currentTarget || null ) ; return false ; } function FCKContextMenu_MenuBlock_OnClick( menuItem, contextMenu ) { contextMenu._Panel.Hide() ; FCKTools.RunFunction( contextMenu.OnItemClick, contextMenu, menuItem ) ; }
JavaScript
/* * 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 == * * FCKToolbar Class: represents a toolbar in the toolbarset. It is a group of * toolbar items. */ var FCKToolbar = function() { this.Items = new Array() ; } FCKToolbar.prototype.AddItem = function( item ) { return this.Items[ this.Items.length ] = item ; } FCKToolbar.prototype.AddButton = function( name, label, tooltip, iconPathOrStripInfoArrayOrIndex, style, state ) { if ( typeof( iconPathOrStripInfoArrayOrIndex ) == 'number' ) iconPathOrStripInfoArrayOrIndex = [ this.DefaultIconsStrip, this.DefaultIconSize, iconPathOrStripInfoArrayOrIndex ] ; var oButton = new FCKToolbarButtonUI( name, label, tooltip, iconPathOrStripInfoArrayOrIndex, style, state ) ; oButton._FCKToolbar = this ; oButton.OnClick = FCKToolbar_OnItemClick ; return this.AddItem( oButton ) ; } function FCKToolbar_OnItemClick( item ) { var oToolbar = item._FCKToolbar ; if ( oToolbar.OnItemClick ) oToolbar.OnItemClick( oToolbar, item ) ; } FCKToolbar.prototype.AddSeparator = function() { this.AddItem( new FCKToolbarSeparator() ) ; } FCKToolbar.prototype.Create = function( parentElement ) { var oDoc = FCKTools.GetElementDocument( parentElement ) ; var e = oDoc.createElement( 'table' ) ; e.className = 'TB_Toolbar' ; e.style.styleFloat = e.style.cssFloat = ( FCKLang.Dir == 'ltr' ? 'left' : 'right' ) ; e.dir = FCKLang.Dir ; e.cellPadding = 0 ; e.cellSpacing = 0 ; var targetRow = e.insertRow(-1) ; // Insert the start cell. var eCell ; if ( !this.HideStart ) { eCell = targetRow.insertCell(-1) ; eCell.appendChild( oDoc.createElement( 'div' ) ).className = 'TB_Start' ; } for ( var i = 0 ; i < this.Items.length ; i++ ) { this.Items[i].Create( targetRow.insertCell(-1) ) ; } // Insert the ending cell. if ( !this.HideEnd ) { eCell = targetRow.insertCell(-1) ; eCell.appendChild( oDoc.createElement( 'div' ) ).className = 'TB_End' ; } parentElement.appendChild( e ) ; } var FCKToolbarSeparator = function() {} FCKToolbarSeparator.prototype.Create = function( parentElement ) { FCKTools.AppendElement( parentElement, 'div' ).className = 'TB_Separator' ; }
JavaScript
/* * 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 == * * This class is a menu block that behaves like a panel. It's a mix of the * FCKMenuBlock and FCKPanel classes. */ var FCKMenuBlockPanel = function() { // Call the "base" constructor. FCKMenuBlock.call( this ) ; } FCKMenuBlockPanel.prototype = new FCKMenuBlock() ; // Override the create method. FCKMenuBlockPanel.prototype.Create = function() { var oPanel = this.Panel = ( this.Parent && this.Parent.Panel ? this.Parent.Panel.CreateChildPanel() : new FCKPanel() ) ; oPanel.AppendStyleSheet( FCKConfig.SkinEditorCSS ) ; // Call the "base" implementation. FCKMenuBlock.prototype.Create.call( this, oPanel.MainNode ) ; } FCKMenuBlockPanel.prototype.Show = function( x, y, relElement ) { if ( !this.Panel.CheckIsOpened() ) this.Panel.Show( x, y, relElement ) ; } FCKMenuBlockPanel.prototype.Hide = function() { if ( this.Panel.CheckIsOpened() ) this.Panel.Hide() ; }
JavaScript
/* * 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 == * * FCKToolbarPanelButton Class: Handles the Fonts combo selector. */ var FCKToolbarFontSizeCombo = function( tooltip, style ) { this.CommandName = 'FontSize' ; this.Label = this.GetLabel() ; this.Tooltip = tooltip ? tooltip : this.Label ; this.Style = style ? style : FCK_TOOLBARITEM_ICONTEXT ; this.DefaultLabel = FCKConfig.DefaultFontSizeLabel || '' ; this.FieldWidth = 70 ; } // Inherit from FCKToolbarSpecialCombo. FCKToolbarFontSizeCombo.prototype = new FCKToolbarFontFormatCombo( false ) ; FCKToolbarFontSizeCombo.prototype.GetLabel = function() { return FCKLang.FontSize ; } FCKToolbarFontSizeCombo.prototype.GetStyles = function() { var baseStyle = FCKStyles.GetStyle( '_FCK_Size' ) ; if ( !baseStyle ) { alert( "The FCKConfig.CoreStyles['FontFace'] setting was not found. Please check the fckconfig.js file" ) ; return {} ; } var styles = {} ; var fonts = FCKConfig.FontSizes.split(';') ; for ( var i = 0 ; i < fonts.length ; i++ ) { var fontParts = fonts[i].split('/') ; var font = fontParts[0] ; var caption = fontParts[1] || font ; var style = FCKTools.CloneObject( baseStyle ) ; style.SetVariable( 'Size', font ) ; style.Label = caption ; styles[ caption ] = style ; } return styles ; } FCKToolbarFontSizeCombo.prototype.RefreshActiveItems = FCKToolbarStyleCombo.prototype.RefreshActiveItems ; FCKToolbarFontSizeCombo.prototype.StyleCombo_OnBeforeClick = FCKToolbarFontsCombo.prototype.StyleCombo_OnBeforeClick ;
JavaScript
/* * 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 == * * FCKToolbarBreak Class: breaks the toolbars. * It makes it possible to force the toolbar to break to a new line. * This is the IE specific implementation. */ var FCKToolbarBreak = function() {} FCKToolbarBreak.prototype.Create = function( targetElement ) { var oBreakDiv = FCKTools.GetElementDocument( targetElement ).createElement( 'div' ) ; oBreakDiv.className = 'TB_Break' ; oBreakDiv.style.clear = FCKLang.Dir == 'rtl' ? 'left' : 'right' ; targetElement.appendChild( oBreakDiv ) ; }
JavaScript
/* * 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 == * * FCKToolbarSpecialCombo Class: This is a "abstract" base class to be used * by the special combo toolbar elements like font name, font size, paragraph format, etc... * * The following properties and methods must be implemented when inheriting from * this class: * - Property: CommandName [ The command name to be executed ] * - Method: GetLabel() [ Returns the label ] * - CreateItems( targetSpecialCombo ) [ Add all items in the special combo ] */ var FCKToolbarSpecialCombo = function() { this.SourceView = false ; this.ContextSensitive = true ; this.FieldWidth = null ; this.PanelWidth = null ; this.PanelMaxHeight = null ; //this._LastValue = null ; } FCKToolbarSpecialCombo.prototype.DefaultLabel = '' ; function FCKToolbarSpecialCombo_OnSelect( itemId, item ) { FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( this.CommandName ).Execute( itemId, item ) ; } FCKToolbarSpecialCombo.prototype.Create = function( targetElement ) { this._Combo = new FCKSpecialCombo( this.GetLabel(), this.FieldWidth, this.PanelWidth, this.PanelMaxHeight, FCKBrowserInfo.IsIE ? window : FCKTools.GetElementWindow( targetElement ).parent ) ; /* this._Combo.FieldWidth = this.FieldWidth != null ? this.FieldWidth : 100 ; this._Combo.PanelWidth = this.PanelWidth != null ? this.PanelWidth : 150 ; this._Combo.PanelMaxHeight = this.PanelMaxHeight != null ? this.PanelMaxHeight : 150 ; */ //this._Combo.Command.Name = this.Command.Name; // this._Combo.Label = this.Label ; this._Combo.Tooltip = this.Tooltip ; this._Combo.Style = this.Style ; this.CreateItems( this._Combo ) ; this._Combo.Create( targetElement ) ; this._Combo.CommandName = this.CommandName ; this._Combo.OnSelect = FCKToolbarSpecialCombo_OnSelect ; } function FCKToolbarSpecialCombo_RefreshActiveItems( combo, value ) { combo.DeselectAll() ; combo.SelectItem( value ) ; combo.SetLabelById( value ) ; } FCKToolbarSpecialCombo.prototype.RefreshState = function() { // Gets the actual state. var eState ; // if ( FCK.EditMode == FCK_EDITMODE_SOURCE && ! this.SourceView ) // eState = FCK_TRISTATE_DISABLED ; // else // { var sValue = FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( this.CommandName ).GetState() ; // FCKDebug.Output( 'RefreshState of Special Combo "' + this.TypeOf + '" - State: ' + sValue ) ; if ( sValue != FCK_TRISTATE_DISABLED ) { eState = FCK_TRISTATE_ON ; if ( this.RefreshActiveItems ) this.RefreshActiveItems( this._Combo, sValue ) ; else { if ( this._LastValue !== sValue) { this._LastValue = sValue ; if ( !sValue || sValue.length == 0 ) { this._Combo.DeselectAll() ; this._Combo.SetLabel( this.DefaultLabel ) ; } else FCKToolbarSpecialCombo_RefreshActiveItems( this._Combo, sValue ) ; } } } else eState = FCK_TRISTATE_DISABLED ; // } // If there are no state changes then do nothing and return. if ( eState == this.State ) return ; if ( eState == FCK_TRISTATE_DISABLED ) { this._Combo.DeselectAll() ; this._Combo.SetLabel( '' ) ; } // Sets the actual state. this.State = eState ; // Updates the graphical state. this._Combo.SetEnabled( eState != FCK_TRISTATE_DISABLED ) ; } FCKToolbarSpecialCombo.prototype.Enable = function() { this.RefreshState() ; } FCKToolbarSpecialCombo.prototype.Disable = function() { this.State = FCK_TRISTATE_DISABLED ; this._Combo.DeselectAll() ; this._Combo.SetLabel( '' ) ; this._Combo.SetEnabled( false ) ; }
JavaScript
/* * 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 == * * This class partially implements the W3C DOM Range for browser that don't * support the standards (like IE): * http://www.w3.org/TR/DOM-Level-2-Traversal-Range/ranges.html */ var FCKW3CRange = function( parentDocument ) { this._Document = parentDocument ; this.startContainer = null ; this.startOffset = null ; this.endContainer = null ; this.endOffset = null ; this.collapsed = true ; } FCKW3CRange.CreateRange = function( parentDocument ) { // We could opt to use the Range implementation of the browsers. The problem // is that every browser have different bugs on their implementations, // mostly related to different interpretations of the W3C specifications. // So, for now, let's use our implementation and pray for browsers fixings // soon. Otherwise will go crazy on trying to find out workarounds. /* // Get the browser implementation of the range, if available. if ( parentDocument.createRange ) { var range = parentDocument.createRange() ; if ( typeof( range.startContainer ) != 'undefined' ) return range ; } */ return new FCKW3CRange( parentDocument ) ; } FCKW3CRange.CreateFromRange = function( parentDocument, sourceRange ) { var range = FCKW3CRange.CreateRange( parentDocument ) ; range.setStart( sourceRange.startContainer, sourceRange.startOffset ) ; range.setEnd( sourceRange.endContainer, sourceRange.endOffset ) ; return range ; } FCKW3CRange.prototype = { _UpdateCollapsed : function() { this.collapsed = ( this.startContainer == this.endContainer && this.startOffset == this.endOffset ) ; }, // W3C requires a check for the new position. If it is after the end // boundary, the range should be collapsed to the new start. It seams we // will not need this check for our use of this class so we can ignore it for now. setStart : function( refNode, offset ) { this.startContainer = refNode ; this.startOffset = offset ; if ( !this.endContainer ) { this.endContainer = refNode ; this.endOffset = offset ; } this._UpdateCollapsed() ; }, // W3C requires a check for the new position. If it is before the start // boundary, the range should be collapsed to the new end. It seams we // will not need this check for our use of this class so we can ignore it for now. setEnd : function( refNode, offset ) { this.endContainer = refNode ; this.endOffset = offset ; if ( !this.startContainer ) { this.startContainer = refNode ; this.startOffset = offset ; } this._UpdateCollapsed() ; }, setStartAfter : function( refNode ) { this.setStart( refNode.parentNode, FCKDomTools.GetIndexOf( refNode ) + 1 ) ; }, setStartBefore : function( refNode ) { this.setStart( refNode.parentNode, FCKDomTools.GetIndexOf( refNode ) ) ; }, setEndAfter : function( refNode ) { this.setEnd( refNode.parentNode, FCKDomTools.GetIndexOf( refNode ) + 1 ) ; }, setEndBefore : function( refNode ) { this.setEnd( refNode.parentNode, FCKDomTools.GetIndexOf( refNode ) ) ; }, collapse : function( toStart ) { if ( toStart ) { this.endContainer = this.startContainer ; this.endOffset = this.startOffset ; } else { this.startContainer = this.endContainer ; this.startOffset = this.endOffset ; } this.collapsed = true ; }, selectNodeContents : function( refNode ) { this.setStart( refNode, 0 ) ; this.setEnd( refNode, refNode.nodeType == 3 ? refNode.data.length : refNode.childNodes.length ) ; }, insertNode : function( newNode ) { var startContainer = this.startContainer ; var startOffset = this.startOffset ; // If we are in a text node. if ( startContainer.nodeType == 3 ) { startContainer.splitText( startOffset ) ; // Check if it is necessary to update the end boundary. if ( startContainer == this.endContainer ) this.setEnd( startContainer.nextSibling, this.endOffset - this.startOffset ) ; // Insert the new node it after the text node. FCKDomTools.InsertAfterNode( startContainer, newNode ) ; return ; } else { // Simply insert the new node before the current start node. startContainer.insertBefore( newNode, startContainer.childNodes[ startOffset ] || null ) ; // Check if it is necessary to update the end boundary. if ( startContainer == this.endContainer ) { this.endOffset++ ; this.collapsed = false ; } } }, deleteContents : function() { if ( this.collapsed ) return ; this._ExecContentsAction( 0 ) ; }, extractContents : function() { var docFrag = new FCKDocumentFragment( this._Document ) ; if ( !this.collapsed ) this._ExecContentsAction( 1, docFrag ) ; return docFrag ; }, // The selection may be lost when cloning (due to the splitText() call). cloneContents : function() { var docFrag = new FCKDocumentFragment( this._Document ) ; if ( !this.collapsed ) this._ExecContentsAction( 2, docFrag ) ; return docFrag ; }, _ExecContentsAction : function( action, docFrag ) { var startNode = this.startContainer ; var endNode = this.endContainer ; var startOffset = this.startOffset ; var endOffset = this.endOffset ; var removeStartNode = false ; var removeEndNode = false ; // Check the start and end nodes and make the necessary removals or changes. // Start from the end, otherwise DOM mutations (splitText) made in the // start boundary may interfere on the results here. // For text containers, we must simply split the node and point to the // second part. The removal will be handled by the rest of the code . if ( endNode.nodeType == 3 ) endNode = endNode.splitText( endOffset ) ; else { // If the end container has children and the offset is pointing // to a child, then we should start from it. if ( endNode.childNodes.length > 0 ) { // If the offset points after the last node. if ( endOffset > endNode.childNodes.length - 1 ) { // Let's create a temporary node and mark it for removal. endNode = FCKDomTools.InsertAfterNode( endNode.lastChild, this._Document.createTextNode('') ) ; removeEndNode = true ; } else endNode = endNode.childNodes[ endOffset ] ; } } // For text containers, we must simply split the node. The removal will // be handled by the rest of the code . if ( startNode.nodeType == 3 ) { startNode.splitText( startOffset ) ; // In cases the end node is the same as the start node, the above // splitting will also split the end, so me must move the end to // the second part of the split. if ( startNode == endNode ) endNode = startNode.nextSibling ; } else { // If the start container has children and the offset is pointing // to a child, then we should start from its previous sibling. // If the offset points to the first node, we don't have a // sibling, so let's use the first one, but mark it for removal. if ( startOffset == 0 ) { // Let's create a temporary node and mark it for removal. startNode = startNode.insertBefore( this._Document.createTextNode(''), startNode.firstChild ) ; removeStartNode = true ; } else if ( startOffset > startNode.childNodes.length - 1 ) { // Let's create a temporary node and mark it for removal. startNode = startNode.appendChild( this._Document.createTextNode('') ) ; removeStartNode = true ; } else startNode = startNode.childNodes[ startOffset ].previousSibling ; } // Get the parent nodes tree for the start and end boundaries. var startParents = FCKDomTools.GetParents( startNode ) ; var endParents = FCKDomTools.GetParents( endNode ) ; // Compare them, to find the top most siblings. var i, topStart, topEnd ; for ( i = 0 ; i < startParents.length ; i++ ) { topStart = startParents[i] ; topEnd = endParents[i] ; // The compared nodes will match until we find the top most // siblings (different nodes that have the same parent). // "i" will hold the index in the parents array for the top // most element. if ( topStart != topEnd ) break ; } var clone, levelStartNode, levelClone, currentNode, currentSibling ; if ( docFrag ) clone = docFrag.RootNode ; // Remove all successive sibling nodes for every node in the // startParents tree. for ( var j = i ; j < startParents.length ; j++ ) { levelStartNode = startParents[j] ; // For Extract and Clone, we must clone this level. if ( clone && levelStartNode != startNode ) // action = 0 = Delete levelClone = clone.appendChild( levelStartNode.cloneNode( levelStartNode == startNode ) ) ; currentNode = levelStartNode.nextSibling ; while( currentNode ) { // Stop processing when the current node matches a node in the // endParents tree or if it is the endNode. if ( currentNode == endParents[j] || currentNode == endNode ) break ; // Cache the next sibling. currentSibling = currentNode.nextSibling ; // If cloning, just clone it. if ( action == 2 ) // 2 = Clone clone.appendChild( currentNode.cloneNode( true ) ) ; else { // Both Delete and Extract will remove the node. currentNode.parentNode.removeChild( currentNode ) ; // When Extracting, move the removed node to the docFrag. if ( action == 1 ) // 1 = Extract clone.appendChild( currentNode ) ; } currentNode = currentSibling ; } if ( clone ) clone = levelClone ; } if ( docFrag ) clone = docFrag.RootNode ; // Remove all previous sibling nodes for every node in the // endParents tree. for ( var k = i ; k < endParents.length ; k++ ) { levelStartNode = endParents[k] ; // For Extract and Clone, we must clone this level. if ( action > 0 && levelStartNode != endNode ) // action = 0 = Delete levelClone = clone.appendChild( levelStartNode.cloneNode( levelStartNode == endNode ) ) ; // The processing of siblings may have already been done by the parent. if ( !startParents[k] || levelStartNode.parentNode != startParents[k].parentNode ) { currentNode = levelStartNode.previousSibling ; while( currentNode ) { // Stop processing when the current node matches a node in the // startParents tree or if it is the startNode. if ( currentNode == startParents[k] || currentNode == startNode ) break ; // Cache the next sibling. currentSibling = currentNode.previousSibling ; // If cloning, just clone it. if ( action == 2 ) // 2 = Clone clone.insertBefore( currentNode.cloneNode( true ), clone.firstChild ) ; else { // Both Delete and Extract will remove the node. currentNode.parentNode.removeChild( currentNode ) ; // When Extracting, mode the removed node to the docFrag. if ( action == 1 ) // 1 = Extract clone.insertBefore( currentNode, clone.firstChild ) ; } currentNode = currentSibling ; } } if ( clone ) clone = levelClone ; } if ( action == 2 ) // 2 = Clone. { // No changes in the DOM should be done, so fix the split text (if any). var startTextNode = this.startContainer ; if ( startTextNode.nodeType == 3 ) { startTextNode.data += startTextNode.nextSibling.data ; startTextNode.parentNode.removeChild( startTextNode.nextSibling ) ; } var endTextNode = this.endContainer ; if ( endTextNode.nodeType == 3 && endTextNode.nextSibling ) { endTextNode.data += endTextNode.nextSibling.data ; endTextNode.parentNode.removeChild( endTextNode.nextSibling ) ; } } else { // Collapse the range. // If a node has been partially selected, collapse the range between // topStart and topEnd. Otherwise, simply collapse it to the start. (W3C specs). if ( topStart && topEnd && ( startNode.parentNode != topStart.parentNode || endNode.parentNode != topEnd.parentNode ) ) { var endIndex = FCKDomTools.GetIndexOf( topEnd ) ; // If the start node is to be removed, we must correct the // index to reflect the removal. if ( removeStartNode && topEnd.parentNode == startNode.parentNode ) endIndex-- ; this.setStart( topEnd.parentNode, endIndex ) ; } // Collapse it to the start. this.collapse( true ) ; } // Cleanup any marked node. if( removeStartNode ) startNode.parentNode.removeChild( startNode ) ; if( removeEndNode && endNode.parentNode ) endNode.parentNode.removeChild( endNode ) ; }, cloneRange : function() { return FCKW3CRange.CreateFromRange( this._Document, this ) ; } } ;
JavaScript
/* * 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 == * * Manages the DOM ascensors element list of a specific DOM node * (limited to body, inclusive). */ var FCKElementPath = function( lastNode ) { var eBlock = null ; var eBlockLimit = null ; var aElements = new Array() ; var e = lastNode ; while ( e ) { if ( e.nodeType == 1 ) { if ( !this.LastElement ) this.LastElement = e ; var sElementName = e.nodeName.toLowerCase() ; if ( FCKBrowserInfo.IsIE && e.scopeName != 'HTML' ) sElementName = e.scopeName.toLowerCase() + ':' + sElementName ; if ( !eBlockLimit ) { if ( !eBlock && FCKListsLib.PathBlockElements[ sElementName ] != null ) eBlock = e ; if ( FCKListsLib.PathBlockLimitElements[ sElementName ] != null ) { // DIV is considered the Block, if no block is available (#525) // and if it doesn't contain other blocks. if ( !eBlock && sElementName == 'div' && !FCKElementPath._CheckHasBlock( e ) ) eBlock = e ; else eBlockLimit = e ; } } aElements.push( e ) ; if ( sElementName == 'body' ) break ; } e = e.parentNode ; } this.Block = eBlock ; this.BlockLimit = eBlockLimit ; this.Elements = aElements ; } /** * Check if an element contains any block element. */ FCKElementPath._CheckHasBlock = function( element ) { var childNodes = element.childNodes ; for ( var i = 0, count = childNodes.length ; i < count ; i++ ) { var child = childNodes[i] ; if ( child.nodeType == 1 && FCKListsLib.BlockElements[ child.nodeName.toLowerCase() ] ) return true ; } return false ; }
JavaScript
/* * 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 == * * Create the FCKeditorAPI object that is available as a global object in * the page where the editor is placed in. */ var FCKeditorAPI ; function InitializeAPI() { var oParentWindow = window.parent ; if ( !( FCKeditorAPI = oParentWindow.FCKeditorAPI ) ) { // Make the FCKeditorAPI object available in the parent window. Use // eval so this core runs in the parent's scope and so it will still be // available if the editor instance is removed ("Can't execute code // from a freed script" error). // Note: we check the existence of oEditor.GetParentForm because some external // code (like JSON) can extend the Object prototype and we get then extra oEditor // objects that aren't really FCKeditor instances. var sScript = 'window.FCKeditorAPI = {' + 'Version : "2.6.4",' + 'VersionBuild : "21629",' + 'Instances : window.FCKeditorAPI && window.FCKeditorAPI.Instances || {},' + 'GetInstance : function( name )' + '{' + 'return this.Instances[ name ];' + '},' + '_FormSubmit : function()' + '{' + 'for ( var name in FCKeditorAPI.Instances )' + '{' + 'var oEditor = FCKeditorAPI.Instances[ name ] ;' + 'if ( oEditor.GetParentForm && oEditor.GetParentForm() == this )' + 'oEditor.UpdateLinkedField() ;' + '}' + 'this._FCKOriginalSubmit() ;' + '},' + '_FunctionQueue : window.FCKeditorAPI && window.FCKeditorAPI._FunctionQueue || {' + 'Functions : new Array(),' + 'IsRunning : false,' + 'Add : function( f )' + '{' + 'this.Functions.push( f );' + 'if ( !this.IsRunning )' + 'this.StartNext();' + '},' + 'StartNext : function()' + '{' + 'var aQueue = this.Functions ;' + 'if ( aQueue.length > 0 )' + '{' + 'this.IsRunning = true;' + 'aQueue[0].call();' + '}' + 'else ' + 'this.IsRunning = false;' + '},' + 'Remove : function( f )' + '{' + 'var aQueue = this.Functions;' + 'var i = 0, fFunc;' + 'while( (fFunc = aQueue[ i ]) )' + '{' + 'if ( fFunc == f )' + 'aQueue.splice( i,1 );' + 'i++ ;' + '}' + 'this.StartNext();' + '}' + '}' + '}' ; // In IE, the "eval" function is not always available (it works with // the JavaScript samples, but not with the ASP ones, for example). // So, let's use the execScript instead. if ( oParentWindow.execScript ) oParentWindow.execScript( sScript, 'JavaScript' ) ; else { if ( FCKBrowserInfo.IsGecko10 ) { // FF 1.0.4 gives an error with the request bellow. The // following seams to work well. eval.call( oParentWindow, sScript ) ; } else if( FCKBrowserInfo.IsAIR ) { FCKAdobeAIR.FCKeditorAPI_Evaluate( oParentWindow, sScript ) ; } else if ( FCKBrowserInfo.IsSafari ) { // oParentWindow.eval in Safari executes in the calling window // environment, instead of the parent one. The following should // make it work. var oParentDocument = oParentWindow.document ; var eScript = oParentDocument.createElement('script') ; eScript.appendChild( oParentDocument.createTextNode( sScript ) ) ; oParentDocument.documentElement.appendChild( eScript ) ; } else oParentWindow.eval( sScript ) ; } FCKeditorAPI = oParentWindow.FCKeditorAPI ; // The __Instances properly has been changed to the public Instances, // but we should still have the "deprecated" version of it. FCKeditorAPI.__Instances = FCKeditorAPI.Instances ; } // Add the current instance to the FCKeditorAPI's instances collection. FCKeditorAPI.Instances[ FCK.Name ] = FCK ; } // Attach to the form onsubmit event and to the form.submit(). function _AttachFormSubmitToAPI() { // Get the linked field form. var oForm = FCK.GetParentForm() ; if ( oForm ) { // Attach to the onsubmit event. FCKTools.AddEventListener( oForm, 'submit', FCK.UpdateLinkedField ) ; // IE sees oForm.submit function as an 'object'. if ( !oForm._FCKOriginalSubmit && ( typeof( oForm.submit ) == 'function' || ( !oForm.submit.tagName && !oForm.submit.length ) ) ) { // Save the original submit. oForm._FCKOriginalSubmit = oForm.submit ; // Create our replacement for the submit. oForm.submit = FCKeditorAPI._FormSubmit ; } } } function FCKeditorAPI_Cleanup() { if ( window.FCKConfig && FCKConfig.MsWebBrowserControlCompat && !window.FCKUnloadFlag ) return ; delete FCKeditorAPI.Instances[ FCK.Name ] ; } function FCKeditorAPI_ConfirmCleanup() { if ( window.FCKConfig && FCKConfig.MsWebBrowserControlCompat ) window.FCKUnloadFlag = true ; } FCKTools.AddEventListener( window, 'unload', FCKeditorAPI_Cleanup ) ; FCKTools.AddEventListener( window, 'beforeunload', FCKeditorAPI_ConfirmCleanup) ;
JavaScript
/* * 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 == * * FCKTextColorCommand Class: represents the text color comand. It shows the * color selection panel. */ // FCKTextColorCommand Constructor // type: can be 'ForeColor' or 'BackColor'. var FCKTextColorCommand = function( type ) { this.Name = type == 'ForeColor' ? 'TextColor' : 'BGColor' ; this.Type = type ; var oWindow ; if ( FCKBrowserInfo.IsIE ) oWindow = window ; else if ( FCK.ToolbarSet._IFrame ) oWindow = FCKTools.GetElementWindow( FCK.ToolbarSet._IFrame ) ; else oWindow = window.parent ; this._Panel = new FCKPanel( oWindow ) ; this._Panel.AppendStyleSheet( FCKConfig.SkinEditorCSS ) ; this._Panel.MainNode.className = 'FCK_Panel' ; this._CreatePanelBody( this._Panel.Document, this._Panel.MainNode ) ; FCK.ToolbarSet.ToolbarItems.GetItem( this.Name ).RegisterPanel( this._Panel ) ; FCKTools.DisableSelection( this._Panel.Document.body ) ; } FCKTextColorCommand.prototype.Execute = function( panelX, panelY, relElement ) { // Show the Color Panel at the desired position. this._Panel.Show( panelX, panelY, relElement ) ; } FCKTextColorCommand.prototype.SetColor = function( color ) { FCKUndo.SaveUndoStep() ; var style = FCKStyles.GetStyle( '_FCK_' + ( this.Type == 'ForeColor' ? 'Color' : 'BackColor' ) ) ; if ( !color || color.length == 0 ) FCK.Styles.RemoveStyle( style ) ; else { style.SetVariable( 'Color', color ) ; FCKStyles.ApplyStyle( style ) ; } FCKUndo.SaveUndoStep() ; FCK.Focus() ; FCK.Events.FireEvent( 'OnSelectionChange' ) ; } FCKTextColorCommand.prototype.GetState = function() { if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG ) return FCK_TRISTATE_DISABLED ; return FCK_TRISTATE_OFF ; } function FCKTextColorCommand_OnMouseOver() { this.className = 'ColorSelected' ; } function FCKTextColorCommand_OnMouseOut() { this.className = 'ColorDeselected' ; } function FCKTextColorCommand_OnClick( ev, command, color ) { this.className = 'ColorDeselected' ; command.SetColor( color ) ; command._Panel.Hide() ; } function FCKTextColorCommand_AutoOnClick( ev, command ) { this.className = 'ColorDeselected' ; command.SetColor( '' ) ; command._Panel.Hide() ; } function FCKTextColorCommand_MoreOnClick( ev, command ) { this.className = 'ColorDeselected' ; command._Panel.Hide() ; FCKDialog.OpenDialog( 'FCKDialog_Color', FCKLang.DlgColorTitle, 'dialog/fck_colorselector.html', 410, 320, FCKTools.Bind( command, command.SetColor ) ) ; } FCKTextColorCommand.prototype._CreatePanelBody = function( targetDocument, targetDiv ) { function CreateSelectionDiv() { var oDiv = targetDocument.createElement( "DIV" ) ; oDiv.className = 'ColorDeselected' ; FCKTools.AddEventListenerEx( oDiv, 'mouseover', FCKTextColorCommand_OnMouseOver ) ; FCKTools.AddEventListenerEx( oDiv, 'mouseout', FCKTextColorCommand_OnMouseOut ) ; return oDiv ; } // Create the Table that will hold all colors. var oTable = targetDiv.appendChild( targetDocument.createElement( "TABLE" ) ) ; oTable.className = 'ForceBaseFont' ; // Firefox 1.5 Bug. oTable.style.tableLayout = 'fixed' ; oTable.cellPadding = 0 ; oTable.cellSpacing = 0 ; oTable.border = 0 ; oTable.width = 150 ; var oCell = oTable.insertRow(-1).insertCell(-1) ; oCell.colSpan = 8 ; // Create the Button for the "Automatic" color selection. var oDiv = oCell.appendChild( CreateSelectionDiv() ) ; oDiv.innerHTML = '<table cellspacing="0" cellpadding="0" width="100%" border="0">\ <tr>\ <td><div class="ColorBoxBorder"><div class="ColorBox" style="background-color: #000000"></div></div></td>\ <td nowrap width="100%" align="center">' + FCKLang.ColorAutomatic + '</td>\ </tr>\ </table>' ; FCKTools.AddEventListenerEx( oDiv, 'click', FCKTextColorCommand_AutoOnClick, this ) ; // Dirty hack for Opera, Safari and Firefox 3. if ( !FCKBrowserInfo.IsIE ) oDiv.style.width = '96%' ; // Create an array of colors based on the configuration file. var aColors = FCKConfig.FontColors.toString().split(',') ; // Create the colors table based on the array. var iCounter = 0 ; while ( iCounter < aColors.length ) { var oRow = oTable.insertRow(-1) ; for ( var i = 0 ; i < 8 ; i++, iCounter++ ) { // The div will be created even if no more colors are available. // Extra divs will be hidden later in the code. (#1597) if ( iCounter < aColors.length ) { var colorParts = aColors[iCounter].split('/') ; var colorValue = '#' + colorParts[0] ; var colorName = colorParts[1] || colorValue ; } oDiv = oRow.insertCell(-1).appendChild( CreateSelectionDiv() ) ; oDiv.innerHTML = '<div class="ColorBoxBorder"><div class="ColorBox" style="background-color: ' + colorValue + '"></div></div>' ; if ( iCounter >= aColors.length ) oDiv.style.visibility = 'hidden' ; else FCKTools.AddEventListenerEx( oDiv, 'click', FCKTextColorCommand_OnClick, [ this, colorName ] ) ; } } // Create the Row and the Cell for the "More Colors..." button. if ( FCKConfig.EnableMoreFontColors ) { oCell = oTable.insertRow(-1).insertCell(-1) ; oCell.colSpan = 8 ; oDiv = oCell.appendChild( CreateSelectionDiv() ) ; oDiv.innerHTML = '<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td nowrap align="center">' + FCKLang.ColorMoreColors + '</td></tr></table>' ; FCKTools.AddEventListenerEx( oDiv, 'click', FCKTextColorCommand_MoreOnClick, this ) ; } // Dirty hack for Opera, Safari and Firefox 3. if ( !FCKBrowserInfo.IsIE ) oDiv.style.width = '96%' ; }
JavaScript
/* * 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 == * * FCKNamedCommand Class: represents an internal browser command. */ var FCKNamedCommand = function( commandName ) { this.Name = commandName ; } FCKNamedCommand.prototype.Execute = function() { FCK.ExecuteNamedCommand( this.Name ) ; } FCKNamedCommand.prototype.GetState = function() { if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG ) return FCK_TRISTATE_DISABLED ; return FCK.GetNamedCommandState( this.Name ) ; }
JavaScript
/* * 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 == * * Implementation for the "Insert/Remove Ordered/Unordered List" commands. */ var FCKListCommand = function( name, tagName ) { this.Name = name ; this.TagName = tagName ; } FCKListCommand.prototype = { GetState : function() { // Disabled if not WYSIWYG. if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG || ! FCK.EditorWindow ) return FCK_TRISTATE_DISABLED ; // We'll use the style system's convention to determine list state here... // If the starting block is a descendant of an <ol> or <ul> node, then we're in a list. var startContainer = FCKSelection.GetBoundaryParentElement( true ) ; var listNode = startContainer ; while ( listNode ) { if ( listNode.nodeName.IEquals( [ 'ul', 'ol' ] ) ) break ; listNode = listNode.parentNode ; } if ( listNode && listNode.nodeName.IEquals( this.TagName ) ) return FCK_TRISTATE_ON ; else return FCK_TRISTATE_OFF ; }, Execute : function() { FCKUndo.SaveUndoStep() ; var doc = FCK.EditorDocument ; var range = new FCKDomRange( FCK.EditorWindow ) ; range.MoveToSelection() ; var state = this.GetState() ; // Midas lists rule #1 says we can create a list even in an empty document. // But FCKDomRangeIterator wouldn't run if the document is really empty. // So create a paragraph if the document is empty and we're going to create a list. if ( state == FCK_TRISTATE_OFF ) { FCKDomTools.TrimNode( doc.body ) ; if ( ! doc.body.firstChild ) { var paragraph = doc.createElement( 'p' ) ; doc.body.appendChild( paragraph ) ; range.MoveToNodeContents( paragraph ) ; } } var bookmark = range.CreateBookmark() ; // Group the blocks up because there are many cases where multiple lists have to be created, // or multiple lists have to be cancelled. var listGroups = [] ; var markerObj = {} ; var iterator = new FCKDomRangeIterator( range ) ; var block ; iterator.ForceBrBreak = ( state == FCK_TRISTATE_OFF ) ; var nextRangeExists = true ; var rangeQueue = null ; while ( nextRangeExists ) { while ( ( block = iterator.GetNextParagraph() ) ) { var path = new FCKElementPath( block ) ; var listNode = null ; var processedFlag = false ; var blockLimit = path.BlockLimit ; // First, try to group by a list ancestor. for ( var i = path.Elements.length - 1 ; i >= 0 ; i-- ) { var el = path.Elements[i] ; if ( el.nodeName.IEquals( ['ol', 'ul'] ) ) { // If we've encountered a list inside a block limit // The last group object of the block limit element should // no longer be valid. Since paragraphs after the list // should belong to a different group of paragraphs before // the list. (Bug #1309) if ( blockLimit._FCK_ListGroupObject ) blockLimit._FCK_ListGroupObject = null ; var groupObj = el._FCK_ListGroupObject ; if ( groupObj ) groupObj.contents.push( block ) ; else { groupObj = { 'root' : el, 'contents' : [ block ] } ; listGroups.push( groupObj ) ; FCKDomTools.SetElementMarker( markerObj, el, '_FCK_ListGroupObject', groupObj ) ; } processedFlag = true ; break ; } } if ( processedFlag ) continue ; // No list ancestor? Group by block limit. var root = blockLimit ; if ( root._FCK_ListGroupObject ) root._FCK_ListGroupObject.contents.push( block ) ; else { var groupObj = { 'root' : root, 'contents' : [ block ] } ; FCKDomTools.SetElementMarker( markerObj, root, '_FCK_ListGroupObject', groupObj ) ; listGroups.push( groupObj ) ; } } if ( FCKBrowserInfo.IsIE ) nextRangeExists = false ; else { if ( rangeQueue == null ) { rangeQueue = [] ; var selectionObject = FCKSelection.GetSelection() ; if ( selectionObject && listGroups.length == 0 ) rangeQueue.push( selectionObject.getRangeAt( 0 ) ) ; for ( var i = 1 ; selectionObject && i < selectionObject.rangeCount ; i++ ) rangeQueue.push( selectionObject.getRangeAt( i ) ) ; } if ( rangeQueue.length < 1 ) nextRangeExists = false ; else { var internalRange = FCKW3CRange.CreateFromRange( doc, rangeQueue.shift() ) ; range._Range = internalRange ; range._UpdateElementInfo() ; if ( range.StartNode.nodeName.IEquals( 'td' ) ) range.SetStart( range.StartNode, 1 ) ; if ( range.EndNode.nodeName.IEquals( 'td' ) ) range.SetEnd( range.EndNode, 2 ) ; iterator = new FCKDomRangeIterator( range ) ; iterator.ForceBrBreak = ( state == FCK_TRISTATE_OFF ) ; } } } // Now we have two kinds of list groups, groups rooted at a list, and groups rooted at a block limit element. // We either have to build lists or remove lists, for removing a list does not makes sense when we are looking // at the group that's not rooted at lists. So we have three cases to handle. var listsCreated = [] ; while ( listGroups.length > 0 ) { var groupObj = listGroups.shift() ; if ( state == FCK_TRISTATE_OFF ) { if ( groupObj.root.nodeName.IEquals( ['ul', 'ol'] ) ) this._ChangeListType( groupObj, markerObj, listsCreated ) ; else this._CreateList( groupObj, listsCreated ) ; } else if ( state == FCK_TRISTATE_ON && groupObj.root.nodeName.IEquals( ['ul', 'ol'] ) ) this._RemoveList( groupObj, markerObj ) ; } // For all new lists created, merge adjacent, same type lists. for ( var i = 0 ; i < listsCreated.length ; i++ ) { var listNode = listsCreated[i] ; var stopFlag = false ; var currentNode = listNode ; while ( ! stopFlag ) { currentNode = currentNode.nextSibling ; if ( currentNode && currentNode.nodeType == 3 && currentNode.nodeValue.search( /^[\n\r\t ]*$/ ) == 0 ) continue ; stopFlag = true ; } if ( currentNode && currentNode.nodeName.IEquals( this.TagName ) ) { currentNode.parentNode.removeChild( currentNode ) ; while ( currentNode.firstChild ) listNode.appendChild( currentNode.removeChild( currentNode.firstChild ) ) ; } stopFlag = false ; currentNode = listNode ; while ( ! stopFlag ) { currentNode = currentNode.previousSibling ; if ( currentNode && currentNode.nodeType == 3 && currentNode.nodeValue.search( /^[\n\r\t ]*$/ ) == 0 ) continue ; stopFlag = true ; } if ( currentNode && currentNode.nodeName.IEquals( this.TagName ) ) { currentNode.parentNode.removeChild( currentNode ) ; while ( currentNode.lastChild ) listNode.insertBefore( currentNode.removeChild( currentNode.lastChild ), listNode.firstChild ) ; } } // Clean up, restore selection and update toolbar button states. FCKDomTools.ClearAllMarkers( markerObj ) ; range.MoveToBookmark( bookmark ) ; range.Select() ; FCK.Focus() ; FCK.Events.FireEvent( 'OnSelectionChange' ) ; }, _ChangeListType : function( groupObj, markerObj, listsCreated ) { // This case is easy... // 1. Convert the whole list into a one-dimensional array. // 2. Change the list type by modifying the array. // 3. Recreate the whole list by converting the array to a list. // 4. Replace the original list with the recreated list. var listArray = FCKDomTools.ListToArray( groupObj.root, markerObj ) ; var selectedListItems = [] ; for ( var i = 0 ; i < groupObj.contents.length ; i++ ) { var itemNode = groupObj.contents[i] ; itemNode = FCKTools.GetElementAscensor( itemNode, 'li' ) ; if ( ! itemNode || itemNode._FCK_ListItem_Processed ) continue ; selectedListItems.push( itemNode ) ; FCKDomTools.SetElementMarker( markerObj, itemNode, '_FCK_ListItem_Processed', true ) ; } var fakeParent = FCKTools.GetElementDocument( groupObj.root ).createElement( this.TagName ) ; for ( var i = 0 ; i < selectedListItems.length ; i++ ) { var listIndex = selectedListItems[i]._FCK_ListArray_Index ; listArray[listIndex].parent = fakeParent ; } var newList = FCKDomTools.ArrayToList( listArray, markerObj ) ; for ( var i = 0 ; i < newList.listNode.childNodes.length ; i++ ) { if ( newList.listNode.childNodes[i].nodeName.IEquals( this.TagName ) ) listsCreated.push( newList.listNode.childNodes[i] ) ; } groupObj.root.parentNode.replaceChild( newList.listNode, groupObj.root ) ; }, _CreateList : function( groupObj, listsCreated ) { var contents = groupObj.contents ; var doc = FCKTools.GetElementDocument( groupObj.root ) ; var listContents = [] ; // It is possible to have the contents returned by DomRangeIterator to be the same as the root. // e.g. when we're running into table cells. // In such a case, enclose the childNodes of contents[0] into a <div>. if ( contents.length == 1 && contents[0] == groupObj.root ) { var divBlock = doc.createElement( 'div' ); while ( contents[0].firstChild ) divBlock.appendChild( contents[0].removeChild( contents[0].firstChild ) ) ; contents[0].appendChild( divBlock ) ; contents[0] = divBlock ; } // Calculate the common parent node of all content blocks. var commonParent = groupObj.contents[0].parentNode ; for ( var i = 0 ; i < contents.length ; i++ ) commonParent = FCKDomTools.GetCommonParents( commonParent, contents[i].parentNode ).pop() ; // We want to insert things that are in the same tree level only, so calculate the contents again // by expanding the selected blocks to the same tree level. for ( var i = 0 ; i < contents.length ; i++ ) { var contentNode = contents[i] ; while ( contentNode.parentNode ) { if ( contentNode.parentNode == commonParent ) { listContents.push( contentNode ) ; break ; } contentNode = contentNode.parentNode ; } } if ( listContents.length < 1 ) return ; // Insert the list to the DOM tree. var insertAnchor = listContents[listContents.length - 1].nextSibling ; var listNode = doc.createElement( this.TagName ) ; listsCreated.push( listNode ) ; while ( listContents.length ) { var contentBlock = listContents.shift() ; var docFrag = doc.createDocumentFragment() ; while ( contentBlock.firstChild ) docFrag.appendChild( contentBlock.removeChild( contentBlock.firstChild ) ) ; contentBlock.parentNode.removeChild( contentBlock ) ; var listItem = doc.createElement( 'li' ) ; listItem.appendChild( docFrag ) ; listNode.appendChild( listItem ) ; } commonParent.insertBefore( listNode, insertAnchor ) ; }, _RemoveList : function( groupObj, markerObj ) { // This is very much like the change list type operation. // Except that we're changing the selected items' indent to -1 in the list array. var listArray = FCKDomTools.ListToArray( groupObj.root, markerObj ) ; var selectedListItems = [] ; for ( var i = 0 ; i < groupObj.contents.length ; i++ ) { var itemNode = groupObj.contents[i] ; itemNode = FCKTools.GetElementAscensor( itemNode, 'li' ) ; if ( ! itemNode || itemNode._FCK_ListItem_Processed ) continue ; selectedListItems.push( itemNode ) ; FCKDomTools.SetElementMarker( markerObj, itemNode, '_FCK_ListItem_Processed', true ) ; } var lastListIndex = null ; for ( var i = 0 ; i < selectedListItems.length ; i++ ) { var listIndex = selectedListItems[i]._FCK_ListArray_Index ; listArray[listIndex].indent = -1 ; lastListIndex = listIndex ; } // After cutting parts of the list out with indent=-1, we still have to maintain the array list // model's nextItem.indent <= currentItem.indent + 1 invariant. Otherwise the array model of the // list cannot be converted back to a real DOM list. for ( var i = lastListIndex + 1; i < listArray.length ; i++ ) { if ( listArray[i].indent > listArray[i-1].indent + 1 ) { var indentOffset = listArray[i-1].indent + 1 - listArray[i].indent ; var oldIndent = listArray[i].indent ; while ( listArray[i] && listArray[i].indent >= oldIndent) { listArray[i].indent += indentOffset ; i++ ; } i-- ; } } var newList = FCKDomTools.ArrayToList( listArray, markerObj ) ; // If groupObj.root is the last element in its parent, or its nextSibling is a <br>, then we should // not add a <br> after the final item. So, check for the cases and trim the <br>. if ( groupObj.root.nextSibling == null || groupObj.root.nextSibling.nodeName.IEquals( 'br' ) ) { if ( newList.listNode.lastChild.nodeName.IEquals( 'br' ) ) newList.listNode.removeChild( newList.listNode.lastChild ) ; } groupObj.root.parentNode.replaceChild( newList.listNode, groupObj.root ) ; } };
JavaScript
/* * 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 == * * FCKStyleCommand Class: represents the "Spell Check" command. * (Gecko specific implementation) */ var FCKSpellCheckCommand = function() { this.Name = 'SpellCheck' ; this.IsEnabled = ( FCKConfig.SpellChecker != 'ieSpell' ) ; } FCKSpellCheckCommand.prototype.Execute = function() { switch ( FCKConfig.SpellChecker ) { case 'SpellerPages' : FCKDialog.OpenDialog( 'FCKDialog_SpellCheck', 'Spell Check', 'dialog/fck_spellerpages.html', 440, 480 ) ; break; case 'WSC' : FCKDialog.OpenDialog( 'FCKDialog_SpellCheck', 'Spell Check', 'wsc/w.html', 530, 480 ) ; } } FCKSpellCheckCommand.prototype.GetState = function() { if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG ) return FCK_TRISTATE_DISABLED ; return this.IsEnabled ? FCK_TRISTATE_OFF : FCK_TRISTATE_DISABLED ; }
JavaScript
/* * 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 == * * FCKPastePlainTextCommand Class: represents the * "Paste as Plain Text" command. */ var FCKPastePlainTextCommand = function() { this.Name = 'PasteText' ; } FCKPastePlainTextCommand.prototype.Execute = function() { FCK.PasteAsPlainText() ; } FCKPastePlainTextCommand.prototype.GetState = function() { if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG ) return FCK_TRISTATE_DISABLED ; return FCK.GetNamedCommandState( 'Paste' ) ; }
JavaScript
/* * 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 == * * FCKBlockQuoteCommand Class: adds or removes blockquote tags. */ var FCKBlockQuoteCommand = function() { } FCKBlockQuoteCommand.prototype = { Execute : function() { FCKUndo.SaveUndoStep() ; var state = this.GetState() ; var range = new FCKDomRange( FCK.EditorWindow ) ; range.MoveToSelection() ; var bookmark = range.CreateBookmark() ; // Kludge for #1592: if the bookmark nodes are in the beginning of // blockquote, then move them to the nearest block element in the // blockquote. if ( FCKBrowserInfo.IsIE ) { var bStart = range.GetBookmarkNode( bookmark, true ) ; var bEnd = range.GetBookmarkNode( bookmark, false ) ; var cursor ; if ( bStart && bStart.parentNode.nodeName.IEquals( 'blockquote' ) && !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( 'blockquote' ) && !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 ; if ( state == FCK_TRISTATE_OFF ) { var paragraphs = [] ; while ( ( block = iterator.GetNextParagraph() ) ) paragraphs.push( block ) ; // If no paragraphs, create one from the current selection position. if ( paragraphs.length < 1 ) { para = range.Window.document.createElement( FCKConfig.EnterMode.IEquals( 'p' ) ? 'p' : 'div' ) ; range.InsertNode( para ) ; para.appendChild( range.Window.document.createTextNode( '\ufeff' ) ) ; range.MoveToBookmark( bookmark ) ; range.MoveToNodeContents( para ) ; range.Collapse( true ) ; bookmark = range.CreateBookmark() ; paragraphs.push( para ) ; } // 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 ; } // If any of the selected blocks is a blockquote, remove it to prevent nested blockquotes. while ( tmp.length > 0 ) { block = tmp.shift() ; if ( block.nodeName.IEquals( 'blockquote' ) ) { var docFrag = FCKTools.GetElementDocument( block ).createDocumentFragment() ; while ( block.firstChild ) { docFrag.appendChild( block.removeChild( block.firstChild ) ) ; paragraphs.push( docFrag.lastChild ) ; } block.parentNode.replaceChild( docFrag, block ) ; } else paragraphs.push( block ) ; } // Now we have all the blocks to be included in a new blockquote node. var bqBlock = range.Window.document.createElement( 'blockquote' ) ; commonParent.insertBefore( bqBlock, paragraphs[0] ) ; while ( paragraphs.length > 0 ) { block = paragraphs.shift() ; bqBlock.appendChild( block ) ; } } else if ( state == FCK_TRISTATE_ON ) { var moveOutNodes = [] ; var elementMarkers = {} ; while ( ( block = iterator.GetNextParagraph() ) ) { var bqParent = null ; var bqChild = null ; while ( block.parentNode ) { if ( block.parentNode.nodeName.IEquals( 'blockquote' ) ) { bqParent = block.parentNode ; bqChild = block ; break ; } block = block.parentNode ; } // Remember the blocks that were recorded down in the moveOutNodes array // to prevent duplicates. if ( bqParent && bqChild && !bqChild._fckblockquotemoveout ) { moveOutNodes.push( bqChild ) ; FCKDomTools.SetElementMarker( elementMarkers, bqChild, '_fckblockquotemoveout', true ) ; } } FCKDomTools.ClearAllMarkers( elementMarkers ) ; var movedNodes = [] ; var processedBlockquoteBlocks = [], elementMarkers = {} ; var noBlockLeft = function( bqBlock ) { for ( var i = 0 ; i < bqBlock.childNodes.length ; i++ ) { if ( FCKListsLib.BlockElements[ bqBlock.childNodes[i].nodeName.toLowerCase() ] ) return false ; } return true ; } ; while ( moveOutNodes.length > 0 ) { var node = moveOutNodes.shift() ; var bqBlock = node.parentNode ; // If the node is located at the beginning or the end, just take it out without splitting. // Otherwise, split the blockquote node and move the paragraph in between the two blockquote nodes. if ( node == node.parentNode.firstChild ) bqBlock.parentNode.insertBefore( bqBlock.removeChild( node ), bqBlock ) ; else if ( node == node.parentNode.lastChild ) bqBlock.parentNode.insertBefore( bqBlock.removeChild( node ), bqBlock.nextSibling ) ; else FCKDomTools.BreakParent( node, node.parentNode, range ) ; // Remember the blockquote node so we can clear it later (if it becomes empty). if ( !bqBlock._fckbqprocessed ) { processedBlockquoteBlocks.push( bqBlock ) ; FCKDomTools.SetElementMarker( elementMarkers, bqBlock, '_fckbqprocessed', true ); } movedNodes.push( node ) ; } // Clear blockquote nodes that have become empty. for ( var i = processedBlockquoteBlocks.length - 1 ; i >= 0 ; i-- ) { var bqBlock = processedBlockquoteBlocks[i] ; if ( noBlockLeft( bqBlock ) ) FCKDomTools.RemoveNode( bqBlock ) ; } FCKDomTools.ClearAllMarkers( elementMarkers ) ; if ( FCKConfig.EnterMode.IEquals( 'br' ) ) { while ( movedNodes.length ) { var node = movedNodes.shift() ; var firstTime = true ; if ( node.nodeName.IEquals( 'div' ) ) { var docFrag = FCKTools.GetElementDocument( node ).createDocumentFragment() ; var needBeginBr = firstTime && node.previousSibling && !FCKListsLib.BlockBoundaries[node.previousSibling.nodeName.toLowerCase()] ; if ( firstTime && needBeginBr ) docFrag.appendChild( FCKTools.GetElementDocument( node ).createElement( 'br' ) ) ; var needEndBr = node.nextSibling && !FCKListsLib.BlockBoundaries[node.nextSibling.nodeName.toLowerCase()] ; while ( node.firstChild ) docFrag.appendChild( node.removeChild( node.firstChild ) ) ; if ( needEndBr ) docFrag.appendChild( FCKTools.GetElementDocument( node ).createElement( 'br' ) ) ; node.parentNode.replaceChild( docFrag, node ) ; firstTime = false ; } } } } range.MoveToBookmark( bookmark ) ; range.Select() ; FCK.Focus() ; FCK.Events.FireEvent( 'OnSelectionChange' ) ; }, GetState : function() { // Disabled if not WYSIWYG. if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG || ! FCK.EditorWindow ) return FCK_TRISTATE_DISABLED ; var path = new FCKElementPath( FCKSelection.GetBoundaryParentElement( true ) ) ; var firstBlock = path.Block || path.BlockLimit ; if ( !firstBlock || firstBlock.nodeName.toLowerCase() == 'body' ) return FCK_TRISTATE_OFF ; // See if the first block has a blockquote parent. for ( var i = 0 ; i < path.Elements.length ; i++ ) { if ( path.Elements[i].nodeName.IEquals( 'blockquote' ) ) return FCK_TRISTATE_ON ; } return FCK_TRISTATE_OFF ; } } ;
JavaScript
/* * 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 == * * FCKPastePlainTextCommand Class: represents the * "Paste as Plain Text" command. */ var FCKTableCommand = function( command ) { this.Name = command ; } FCKTableCommand.prototype.Execute = function() { FCKUndo.SaveUndoStep() ; if ( ! FCKBrowserInfo.IsGecko ) { switch ( this.Name ) { case 'TableMergeRight' : return FCKTableHandler.MergeRight() ; case 'TableMergeDown' : return FCKTableHandler.MergeDown() ; } } switch ( this.Name ) { case 'TableInsertRowAfter' : return FCKTableHandler.InsertRow( false ) ; case 'TableInsertRowBefore' : return FCKTableHandler.InsertRow( true ) ; case 'TableDeleteRows' : return FCKTableHandler.DeleteRows() ; case 'TableInsertColumnAfter' : return FCKTableHandler.InsertColumn( false ) ; case 'TableInsertColumnBefore' : return FCKTableHandler.InsertColumn( true ) ; case 'TableDeleteColumns' : return FCKTableHandler.DeleteColumns() ; case 'TableInsertCellAfter' : return FCKTableHandler.InsertCell( null, false ) ; case 'TableInsertCellBefore' : return FCKTableHandler.InsertCell( null, true ) ; case 'TableDeleteCells' : return FCKTableHandler.DeleteCells() ; case 'TableMergeCells' : return FCKTableHandler.MergeCells() ; case 'TableHorizontalSplitCell' : return FCKTableHandler.HorizontalSplitCell() ; case 'TableVerticalSplitCell' : return FCKTableHandler.VerticalSplitCell() ; case 'TableDelete' : return FCKTableHandler.DeleteTable() ; default : return alert( FCKLang.UnknownCommand.replace( /%1/g, this.Name ) ) ; } } FCKTableCommand.prototype.GetState = function() { if ( FCK.EditorDocument != null && FCKSelection.HasAncestorNode( 'TABLE' ) ) { switch ( this.Name ) { case 'TableHorizontalSplitCell' : case 'TableVerticalSplitCell' : if ( FCKTableHandler.GetSelectedCells().length == 1 ) return FCK_TRISTATE_OFF ; else return FCK_TRISTATE_DISABLED ; case 'TableMergeCells' : if ( FCKTableHandler.CheckIsSelectionRectangular() && FCKTableHandler.GetSelectedCells().length > 1 ) return FCK_TRISTATE_OFF ; else return FCK_TRISTATE_DISABLED ; case 'TableMergeRight' : return FCKTableHandler.GetMergeRightTarget() ? FCK_TRISTATE_OFF : FCK_TRISTATE_DISABLED ; case 'TableMergeDown' : return FCKTableHandler.GetMergeDownTarget() ? FCK_TRISTATE_OFF : FCK_TRISTATE_DISABLED ; default : return FCK_TRISTATE_OFF ; } } else return FCK_TRISTATE_DISABLED; }
JavaScript
/* * 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 == * * FCKShowBlockCommand Class: the "Show Blocks" command. */ var FCKShowBlockCommand = function( name, defaultState ) { this.Name = name ; if ( defaultState != undefined ) this._SavedState = defaultState ; else this._SavedState = null ; } FCKShowBlockCommand.prototype.Execute = function() { var state = this.GetState() ; if ( state == FCK_TRISTATE_DISABLED ) return ; var body = FCK.EditorDocument.body ; if ( state == FCK_TRISTATE_ON ) body.className = body.className.replace( /(^| )FCK__ShowBlocks/g, '' ) ; else body.className += ' FCK__ShowBlocks' ; if ( FCKBrowserInfo.IsIE ) { try { FCK.EditorDocument.selection.createRange().select() ; } catch ( e ) {} } else { var focus = FCK.EditorWindow.getSelection().focusNode ; if ( focus ) { if ( focus.nodeType != 1 ) focus = focus.parentNode ; FCKDomTools.ScrollIntoView( focus, false ) ; } } FCK.Events.FireEvent( 'OnSelectionChange' ) ; } FCKShowBlockCommand.prototype.GetState = function() { if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG ) return FCK_TRISTATE_DISABLED ; // On some cases FCK.EditorDocument.body is not yet available if ( !FCK.EditorDocument ) return FCK_TRISTATE_OFF ; if ( /FCK__ShowBlocks(?:\s|$)/.test( FCK.EditorDocument.body.className ) ) return FCK_TRISTATE_ON ; return FCK_TRISTATE_OFF ; } FCKShowBlockCommand.prototype.SaveState = function() { this._SavedState = this.GetState() ; } FCKShowBlockCommand.prototype.RestoreState = function() { if ( this._SavedState != null && this.GetState() != this._SavedState ) this.Execute() ; }
JavaScript
/* * 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 == * * FCKStyleCommand Class: represents the "Spell Check" command. * (IE specific implementation) */ var FCKSpellCheckCommand = function() { this.Name = 'SpellCheck' ; this.IsEnabled = true ; } FCKSpellCheckCommand.prototype.Execute = function() { switch ( FCKConfig.SpellChecker ) { case 'ieSpell' : this._RunIeSpell() ; break ; case 'SpellerPages' : FCKDialog.OpenDialog( 'FCKDialog_SpellCheck', 'Spell Check', 'dialog/fck_spellerpages.html', 440, 480 ) ; break ; case 'WSC' : FCKDialog.OpenDialog( 'FCKDialog_SpellCheck', 'Spell Check', 'wsc/w.html', 530, 480 ) ; } } FCKSpellCheckCommand.prototype._RunIeSpell = function() { try { var oIeSpell = new ActiveXObject( "ieSpell.ieSpellExtension" ) ; oIeSpell.CheckAllLinkedDocuments( FCK.EditorDocument ) ; } catch( e ) { if( e.number == -2146827859 ) { if ( confirm( FCKLang.IeSpellDownload ) ) window.open( FCKConfig.IeSpellDownloadUrl , 'IeSpellDownload' ) ; } else alert( 'Error Loading ieSpell: ' + e.message + ' (' + e.number + ')' ) ; } } FCKSpellCheckCommand.prototype.GetState = function() { if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG ) return FCK_TRISTATE_DISABLED ; return this.IsEnabled ? FCK_TRISTATE_OFF : FCK_TRISTATE_DISABLED ; }
JavaScript
/* * 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 == * * Definition of other commands that are not available internaly in the * browser (see FCKNamedCommand). */ // ### General Dialog Box Commands. var FCKDialogCommand = function( name, title, url, width, height, getStateFunction, getStateParam, customValue ) { this.Name = name ; this.Title = title ; this.Url = url ; this.Width = width ; this.Height = height ; this.CustomValue = customValue ; this.GetStateFunction = getStateFunction ; this.GetStateParam = getStateParam ; this.Resizable = false ; } FCKDialogCommand.prototype.Execute = function() { FCKDialog.OpenDialog( 'FCKDialog_' + this.Name , this.Title, this.Url, this.Width, this.Height, this.CustomValue, null, this.Resizable ) ; } FCKDialogCommand.prototype.GetState = function() { if ( this.GetStateFunction ) return this.GetStateFunction( this.GetStateParam ) ; else return FCK.EditMode == FCK_EDITMODE_WYSIWYG ? FCK_TRISTATE_OFF : FCK_TRISTATE_DISABLED ; } // Generic Undefined command (usually used when a command is under development). var FCKUndefinedCommand = function() { this.Name = 'Undefined' ; } FCKUndefinedCommand.prototype.Execute = function() { alert( FCKLang.NotImplemented ) ; } FCKUndefinedCommand.prototype.GetState = function() { return FCK_TRISTATE_OFF ; } // ### FormatBlock var FCKFormatBlockCommand = function() {} FCKFormatBlockCommand.prototype = { Name : 'FormatBlock', Execute : FCKStyleCommand.prototype.Execute, GetState : function() { return FCK.EditorDocument ? FCK_TRISTATE_OFF : FCK_TRISTATE_DISABLED ; } }; // ### FontName var FCKFontNameCommand = function() {} FCKFontNameCommand.prototype = { Name : 'FontName', Execute : FCKStyleCommand.prototype.Execute, GetState : FCKFormatBlockCommand.prototype.GetState }; // ### FontSize var FCKFontSizeCommand = function() {} FCKFontSizeCommand.prototype = { Name : 'FontSize', Execute : FCKStyleCommand.prototype.Execute, GetState : FCKFormatBlockCommand.prototype.GetState }; // ### Preview var FCKPreviewCommand = function() { this.Name = 'Preview' ; } FCKPreviewCommand.prototype.Execute = function() { FCK.Preview() ; } FCKPreviewCommand.prototype.GetState = function() { return FCK_TRISTATE_OFF ; } // ### Save var FCKSaveCommand = function() { this.Name = 'Save' ; } FCKSaveCommand.prototype.Execute = function() { // Get the linked field form. var oForm = FCK.GetParentForm() ; if ( typeof( oForm.onsubmit ) == 'function' ) { var bRet = oForm.onsubmit() ; if ( bRet != null && bRet === false ) return ; } // Submit the form. // If there's a button named "submit" then the form.submit() function is masked and // can't be called in Mozilla, so we call the click() method of that button. if ( typeof( oForm.submit ) == 'function' ) oForm.submit() ; else oForm.submit.click() ; } FCKSaveCommand.prototype.GetState = function() { return FCK_TRISTATE_OFF ; } // ### NewPage var FCKNewPageCommand = function() { this.Name = 'NewPage' ; } FCKNewPageCommand.prototype.Execute = function() { FCKUndo.SaveUndoStep() ; FCK.SetData( '' ) ; FCKUndo.Typing = true ; FCK.Focus() ; } FCKNewPageCommand.prototype.GetState = function() { return FCK_TRISTATE_OFF ; } // ### Source button var FCKSourceCommand = function() { this.Name = 'Source' ; } FCKSourceCommand.prototype.Execute = function() { if ( FCKConfig.SourcePopup ) // Until v2.2, it was mandatory for FCKBrowserInfo.IsGecko. { var iWidth = FCKConfig.ScreenWidth * 0.65 ; var iHeight = FCKConfig.ScreenHeight * 0.65 ; FCKDialog.OpenDialog( 'FCKDialog_Source', FCKLang.Source, 'dialog/fck_source.html', iWidth, iHeight, null, null, true ) ; } else FCK.SwitchEditMode() ; } FCKSourceCommand.prototype.GetState = function() { return ( FCK.EditMode == FCK_EDITMODE_WYSIWYG ? FCK_TRISTATE_OFF : FCK_TRISTATE_ON ) ; } // ### Undo var FCKUndoCommand = function() { this.Name = 'Undo' ; } FCKUndoCommand.prototype.Execute = function() { FCKUndo.Undo() ; } FCKUndoCommand.prototype.GetState = function() { if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG ) return FCK_TRISTATE_DISABLED ; return ( FCKUndo.CheckUndoState() ? FCK_TRISTATE_OFF : FCK_TRISTATE_DISABLED ) ; } // ### Redo var FCKRedoCommand = function() { this.Name = 'Redo' ; } FCKRedoCommand.prototype.Execute = function() { FCKUndo.Redo() ; } FCKRedoCommand.prototype.GetState = function() { if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG ) return FCK_TRISTATE_DISABLED ; return ( FCKUndo.CheckRedoState() ? FCK_TRISTATE_OFF : FCK_TRISTATE_DISABLED ) ; } // ### Page Break var FCKPageBreakCommand = function() { this.Name = 'PageBreak' ; } FCKPageBreakCommand.prototype.Execute = function() { // Take an undo snapshot before changing the document FCKUndo.SaveUndoStep() ; // var e = FCK.EditorDocument.createElement( 'CENTER' ) ; // e.style.pageBreakAfter = 'always' ; // Tidy was removing the empty CENTER tags, so the following solution has // been found. It also validates correctly as XHTML 1.0 Strict. var e = FCK.EditorDocument.createElement( 'DIV' ) ; e.style.pageBreakAfter = 'always' ; e.innerHTML = '' ;//<span style="DISPLAY:none"></span> var oFakeImage = FCKDocumentProcessor_CreateFakeImage( 'FCK__PageBreak', e ) ; var oRange = new FCKDomRange( FCK.EditorWindow ) ; oRange.MoveToSelection() ; var oSplitInfo = oRange.SplitBlock() ; oRange.InsertNode( oFakeImage ) ; FCK.Events.FireEvent( 'OnSelectionChange' ) ; } FCKPageBreakCommand.prototype.GetState = function() { if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG ) return FCK_TRISTATE_DISABLED ; return 0 ; // FCK_TRISTATE_OFF } // FCKUnlinkCommand - by Johnny Egeland (johnny@coretrek.com) var FCKUnlinkCommand = function() { this.Name = 'Unlink' ; } FCKUnlinkCommand.prototype.Execute = function() { // Take an undo snapshot before changing the document FCKUndo.SaveUndoStep() ; if ( FCKBrowserInfo.IsGeckoLike ) { var oLink = FCK.Selection.MoveToAncestorNode( 'A' ) ; // The unlink command can generate a span in Firefox, so let's do it our way. See #430 if ( oLink ) FCKTools.RemoveOuterTags( oLink ) ; return ; } FCK.ExecuteNamedCommand( this.Name ) ; } FCKUnlinkCommand.prototype.GetState = function() { if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG ) return FCK_TRISTATE_DISABLED ; var state = FCK.GetNamedCommandState( this.Name ) ; // Check that it isn't an anchor if ( state == FCK_TRISTATE_OFF && FCK.EditMode == FCK_EDITMODE_WYSIWYG ) { var oLink = FCKSelection.MoveToAncestorNode( 'A' ) ; var bIsAnchor = ( oLink && oLink.name.length > 0 && oLink.href.length == 0 ) ; if ( bIsAnchor ) state = FCK_TRISTATE_DISABLED ; } return state ; } var FCKVisitLinkCommand = function() { this.Name = 'VisitLink'; } FCKVisitLinkCommand.prototype = { GetState : function() { if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG ) return FCK_TRISTATE_DISABLED ; var state = FCK.GetNamedCommandState( 'Unlink' ) ; if ( state == FCK_TRISTATE_OFF ) { var el = FCKSelection.MoveToAncestorNode( 'A' ) ; if ( !el.href ) state = FCK_TRISTATE_DISABLED ; } return state ; }, Execute : function() { var el = FCKSelection.MoveToAncestorNode( 'A' ) ; var url = el.getAttribute( '_fcksavedurl' ) || el.getAttribute( 'href', 2 ) ; // Check if it's a full URL. // If not full URL, we'll need to apply the BaseHref setting. if ( ! /:\/\//.test( url ) ) { var baseHref = FCKConfig.BaseHref ; var parentWindow = FCK.GetInstanceObject( 'parent' ) ; if ( !baseHref ) { baseHref = parentWindow.document.location.href ; baseHref = baseHref.substring( 0, baseHref.lastIndexOf( '/' ) + 1 ) ; } if ( /^\//.test( url ) ) { try { baseHref = baseHref.match( /^.*:\/\/+[^\/]+/ )[0] ; } catch ( e ) { baseHref = parentWindow.document.location.protocol + '://' + parentWindow.parent.document.location.host ; } } url = baseHref + url ; } if ( !window.open( url, '_blank' ) ) alert( FCKLang.VisitLinkBlocked ) ; } } ; // FCKSelectAllCommand var FCKSelectAllCommand = function() { this.Name = 'SelectAll' ; } FCKSelectAllCommand.prototype.Execute = function() { if ( FCK.EditMode == FCK_EDITMODE_WYSIWYG ) { FCK.ExecuteNamedCommand( 'SelectAll' ) ; } else { // Select the contents of the textarea var textarea = FCK.EditingArea.Textarea ; if ( FCKBrowserInfo.IsIE ) { textarea.createTextRange().execCommand( 'SelectAll' ) ; } else { textarea.selectionStart = 0 ; textarea.selectionEnd = textarea.value.length ; } textarea.focus() ; } } FCKSelectAllCommand.prototype.GetState = function() { if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG ) return FCK_TRISTATE_DISABLED ; return FCK_TRISTATE_OFF ; } // FCKPasteCommand var FCKPasteCommand = function() { this.Name = 'Paste' ; } FCKPasteCommand.prototype = { Execute : function() { if ( FCKBrowserInfo.IsIE ) FCK.Paste() ; else FCK.ExecuteNamedCommand( 'Paste' ) ; }, GetState : function() { if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG ) return FCK_TRISTATE_DISABLED ; return FCK.GetNamedCommandState( 'Paste' ) ; } } ; // FCKRuleCommand var FCKRuleCommand = function() { this.Name = 'Rule' ; } FCKRuleCommand.prototype = { Execute : function() { FCKUndo.SaveUndoStep() ; FCK.InsertElement( 'hr' ) ; }, GetState : function() { if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG ) return FCK_TRISTATE_DISABLED ; return FCK.GetNamedCommandState( 'InsertHorizontalRule' ) ; } } ; // FCKCutCopyCommand var FCKCutCopyCommand = function( isCut ) { this.Name = isCut ? 'Cut' : 'Copy' ; } FCKCutCopyCommand.prototype = { Execute : function() { var enabled = false ; if ( FCKBrowserInfo.IsIE ) { // The following seems to be the only reliable way to detect that // cut/copy is enabled in IE. It will fire the oncut/oncopy event // only if the security settings enabled the command to execute. var onEvent = function() { enabled = true ; } ; var eventName = 'on' + this.Name.toLowerCase() ; FCK.EditorDocument.body.attachEvent( eventName, onEvent ) ; FCK.ExecuteNamedCommand( this.Name ) ; FCK.EditorDocument.body.detachEvent( eventName, onEvent ) ; } else { try { // Other browsers throw an error if the command is disabled. FCK.ExecuteNamedCommand( this.Name ) ; enabled = true ; } catch(e){} } if ( !enabled ) alert( FCKLang[ 'PasteError' + this.Name ] ) ; }, GetState : function() { // Strangely, the Cut command happens to have the correct states for // both Copy and Cut in all browsers. return FCK.EditMode != FCK_EDITMODE_WYSIWYG ? FCK_TRISTATE_DISABLED : FCK.GetNamedCommandState( 'Cut' ) ; } }; var FCKAnchorDeleteCommand = function() { this.Name = 'AnchorDelete' ; } FCKAnchorDeleteCommand.prototype = { Execute : function() { if (FCK.Selection.GetType() == 'Control') { FCK.Selection.Delete(); } else { var oFakeImage = FCK.Selection.GetSelectedElement() ; if ( oFakeImage ) { if ( oFakeImage.tagName == 'IMG' && oFakeImage.getAttribute('_fckanchor') ) oAnchor = FCK.GetRealElement( oFakeImage ) ; else oFakeImage = null ; } //Search for a real anchor if ( !oFakeImage ) { oAnchor = FCK.Selection.MoveToAncestorNode( 'A' ) ; if ( oAnchor ) FCK.Selection.SelectNode( oAnchor ) ; } // If it's also a link, then just remove the name and exit if ( oAnchor.href.length != 0 ) { oAnchor.removeAttribute( 'name' ) ; // Remove temporary class for IE if ( FCKBrowserInfo.IsIE ) oAnchor.className = oAnchor.className.replace( FCKRegexLib.FCK_Class, '' ) ; return ; } // We need to remove the anchor // If we got a fake image, then just remove it and we're done if ( oFakeImage ) { oFakeImage.parentNode.removeChild( oFakeImage ) ; return ; } // Empty anchor, so just remove it if ( oAnchor.innerHTML.length == 0 ) { oAnchor.parentNode.removeChild( oAnchor ) ; return ; } // Anchor with content, leave the content FCKTools.RemoveOuterTags( oAnchor ) ; } if ( FCKBrowserInfo.IsGecko ) FCK.Selection.Collapse( true ) ; }, GetState : function() { if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG ) return FCK_TRISTATE_DISABLED ; return FCK.GetNamedCommandState( 'Unlink') ; } }; var FCKDeleteDivCommand = function() { } FCKDeleteDivCommand.prototype = { GetState : function() { if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG ) return FCK_TRISTATE_DISABLED ; var node = FCKSelection.GetParentElement() ; var path = new FCKElementPath( node ) ; return path.BlockLimit && path.BlockLimit.nodeName.IEquals( 'div' ) ? FCK_TRISTATE_OFF : FCK_TRISTATE_DISABLED ; }, Execute : function() { // Create an undo snapshot before doing anything. FCKUndo.SaveUndoStep() ; // Find out the nodes to delete. var nodes = FCKDomTools.GetSelectedDivContainers() ; // Remember the current selection position. var range = new FCKDomRange( FCK.EditorWindow ) ; range.MoveToSelection() ; var bookmark = range.CreateBookmark() ; // Delete the container DIV node. for ( var i = 0 ; i < nodes.length ; i++) FCKDomTools.RemoveNode( nodes[i], true ) ; // Restore selection. range.MoveToBookmark( bookmark ) ; range.Select() ; } } ; // FCKRuleCommand var FCKNbsp = function() { this.Name = 'Non Breaking Space' ; } FCKNbsp.prototype = { Execute : function() { FCK.InsertHtml( '&nbsp;' ) ; }, GetState : function() { return ( FCK.EditMode != FCK_EDITMODE_WYSIWYG ? FCK_TRISTATE_DISABLED : FCK_TRISTATE_OFF ) ; } } ;
JavaScript
/* * 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 == * * Stretch the editor to full window size and back. */ var FCKFitWindow = function() { this.Name = 'FitWindow' ; } FCKFitWindow.prototype.Execute = function() { var eEditorFrame = window.frameElement ; var eEditorFrameStyle = eEditorFrame.style ; var eMainWindow = parent ; var eDocEl = eMainWindow.document.documentElement ; var eBody = eMainWindow.document.body ; var eBodyStyle = eBody.style ; var eParent ; // Save the current selection and scroll position. var oRange, oEditorScrollPos ; if ( FCK.EditMode == FCK_EDITMODE_WYSIWYG ) { oRange = new FCKDomRange( FCK.EditorWindow ) ; oRange.MoveToSelection() ; oEditorScrollPos = FCKTools.GetScrollPosition( FCK.EditorWindow ) ; } else { var eTextarea = FCK.EditingArea.Textarea ; oRange = !FCKBrowserInfo.IsIE && [ eTextarea.selectionStart, eTextarea.selectionEnd ] ; oEditorScrollPos = [ eTextarea.scrollLeft, eTextarea.scrollTop ] ; } // No original style properties known? Go fullscreen. if ( !this.IsMaximized ) { // Registering an event handler when the window gets resized. if( FCKBrowserInfo.IsIE ) eMainWindow.attachEvent( 'onresize', FCKFitWindow_Resize ) ; else eMainWindow.addEventListener( 'resize', FCKFitWindow_Resize, true ) ; // Save the scrollbars position. this._ScrollPos = FCKTools.GetScrollPosition( eMainWindow ) ; // Save and reset the styles for the entire node tree. They could interfere in the result. eParent = eEditorFrame ; // The extra () is to avoid a warning with strict error checking. This is ok. while( (eParent = eParent.parentNode) ) { if ( eParent.nodeType == 1 ) { eParent._fckSavedStyles = FCKTools.SaveStyles( eParent ) ; eParent.style.zIndex = FCKConfig.FloatingPanelsZIndex - 1 ; } } // Hide IE scrollbars (in strict mode). if ( FCKBrowserInfo.IsIE ) { this.documentElementOverflow = eDocEl.style.overflow ; eDocEl.style.overflow = 'hidden' ; eBodyStyle.overflow = 'hidden' ; } else { // Hide the scroolbars in Firefox. eBodyStyle.overflow = 'hidden' ; eBodyStyle.width = '0px' ; eBodyStyle.height = '0px' ; } // Save the IFRAME styles. this._EditorFrameStyles = FCKTools.SaveStyles( eEditorFrame ) ; // Resize. var oViewPaneSize = FCKTools.GetViewPaneSize( eMainWindow ) ; eEditorFrameStyle.position = "absolute"; eEditorFrame.offsetLeft ; // Kludge for Safari 3.1 browser bug, do not remove. See #2066. eEditorFrameStyle.zIndex = FCKConfig.FloatingPanelsZIndex - 1; eEditorFrameStyle.left = "0px"; eEditorFrameStyle.top = "0px"; eEditorFrameStyle.width = oViewPaneSize.Width + "px"; eEditorFrameStyle.height = oViewPaneSize.Height + "px"; // Giving the frame some (huge) borders on his right and bottom // side to hide the background that would otherwise show when the // editor is in fullsize mode and the window is increased in size // not for IE, because IE immediately adapts the editor on resize, // without showing any of the background oddly in firefox, the // editor seems not to fill the whole frame, so just setting the // background of it to white to cover the page laying behind it anyway. if ( !FCKBrowserInfo.IsIE ) { eEditorFrameStyle.borderRight = eEditorFrameStyle.borderBottom = "9999px solid white" ; eEditorFrameStyle.backgroundColor = "white"; } // Scroll to top left. eMainWindow.scrollTo(0, 0); // Is the editor still not on the top left? Let's find out and fix that as well. (Bug #174) var editorPos = FCKTools.GetWindowPosition( eMainWindow, eEditorFrame ) ; if ( editorPos.x != 0 ) eEditorFrameStyle.left = ( -1 * editorPos.x ) + "px" ; if ( editorPos.y != 0 ) eEditorFrameStyle.top = ( -1 * editorPos.y ) + "px" ; this.IsMaximized = true ; } else // Resize to original size. { // Remove the event handler of window resizing. if( FCKBrowserInfo.IsIE ) eMainWindow.detachEvent( "onresize", FCKFitWindow_Resize ) ; else eMainWindow.removeEventListener( "resize", FCKFitWindow_Resize, true ) ; // Restore the CSS position for the entire node tree. eParent = eEditorFrame ; // The extra () is to avoid a warning with strict error checking. This is ok. while( (eParent = eParent.parentNode) ) { if ( eParent._fckSavedStyles ) { FCKTools.RestoreStyles( eParent, eParent._fckSavedStyles ) ; eParent._fckSavedStyles = null ; } } // Restore IE scrollbars if ( FCKBrowserInfo.IsIE ) eDocEl.style.overflow = this.documentElementOverflow ; // Restore original size FCKTools.RestoreStyles( eEditorFrame, this._EditorFrameStyles ) ; // Restore the window scroll position. eMainWindow.scrollTo( this._ScrollPos.X, this._ScrollPos.Y ) ; this.IsMaximized = false ; } FCKToolbarItems.GetItem('FitWindow').RefreshState() ; // It seams that Firefox restarts the editing area when making this changes. // On FF 1.0.x, the area is not anymore editable. On FF 1.5+, the special //configuration, like DisableFFTableHandles and DisableObjectResizing get //lost, so we must reset it. Also, the cursor position and selection are //also lost, even if you comment the following line (MakeEditable). // if ( FCKBrowserInfo.IsGecko10 ) // Initially I thought it was a FF 1.0 only problem. if ( FCK.EditMode == FCK_EDITMODE_WYSIWYG ) FCK.EditingArea.MakeEditable() ; FCK.Focus() ; // Restore the selection and scroll position of inside the document. if ( FCK.EditMode == FCK_EDITMODE_WYSIWYG ) { oRange.Select() ; FCK.EditorWindow.scrollTo( oEditorScrollPos.X, oEditorScrollPos.Y ) ; } else { if ( !FCKBrowserInfo.IsIE ) { eTextarea.selectionStart = oRange[0] ; eTextarea.selectionEnd = oRange[1] ; } eTextarea.scrollLeft = oEditorScrollPos[0] ; eTextarea.scrollTop = oEditorScrollPos[1] ; } } FCKFitWindow.prototype.GetState = function() { if ( FCKConfig.ToolbarLocation != 'In' ) return FCK_TRISTATE_DISABLED ; else return ( this.IsMaximized ? FCK_TRISTATE_ON : FCK_TRISTATE_OFF ); } function FCKFitWindow_Resize() { var oViewPaneSize = FCKTools.GetViewPaneSize( parent ) ; var eEditorFrameStyle = window.frameElement.style ; eEditorFrameStyle.width = oViewPaneSize.Width + 'px' ; eEditorFrameStyle.height = oViewPaneSize.Height + 'px' ; }
JavaScript
/* * 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 == * * FCKCoreStyleCommand Class: controls the execution of a core style. Core * styles are usually represented as buttons in the toolbar., like Bold and * Italic. */ var FCKCoreStyleCommand = function( coreStyleName ) { this.Name = 'CoreStyle' ; this.StyleName = '_FCK_' + coreStyleName ; this.IsActive = false ; FCKStyles.AttachStyleStateChange( this.StyleName, this._OnStyleStateChange, this ) ; } FCKCoreStyleCommand.prototype = { Execute : function() { FCKUndo.SaveUndoStep() ; if ( this.IsActive ) FCKStyles.RemoveStyle( this.StyleName ) ; else FCKStyles.ApplyStyle( this.StyleName ) ; FCK.Focus() ; FCK.Events.FireEvent( 'OnSelectionChange' ) ; }, GetState : function() { if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG ) return FCK_TRISTATE_DISABLED ; return this.IsActive ? FCK_TRISTATE_ON : FCK_TRISTATE_OFF ; }, _OnStyleStateChange : function( styleName, isActive ) { this.IsActive = isActive ; } };
JavaScript
/* * 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 == * * FCKRemoveFormatCommand Class: controls the execution of a core style. Core * styles are usually represented as buttons in the toolbar., like Bold and * Italic. */ var FCKRemoveFormatCommand = function() { this.Name = 'RemoveFormat' ; } FCKRemoveFormatCommand.prototype = { Execute : function() { FCKStyles.RemoveAll() ; FCK.Focus() ; FCK.Events.FireEvent( 'OnSelectionChange' ) ; }, GetState : function() { return FCK.EditorWindow ? FCK_TRISTATE_OFF : FCK_TRISTATE_DISABLED ; } };
JavaScript
/* * 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 == * * FCKJustifyCommand Class: controls block justification. */ var FCKJustifyCommand = function( alignValue ) { this.AlignValue = alignValue ; // Detect whether this is the instance for the default alignment. var contentDir = FCKConfig.ContentLangDirection.toLowerCase() ; this.IsDefaultAlign = ( alignValue == 'left' && contentDir == 'ltr' ) || ( alignValue == 'right' && contentDir == 'rtl' ) ; // Get the class name to be used by this instance. var cssClassName = this._CssClassName = ( function() { var classes = FCKConfig.JustifyClasses ; if ( classes ) { switch ( alignValue ) { case 'left' : return classes[0] || null ; case 'center' : return classes[1] || null ; case 'right' : return classes[2] || null ; case 'justify' : return classes[3] || null ; } } return null ; } )() ; if ( cssClassName && cssClassName.length > 0 ) this._CssClassRegex = new RegExp( '(?:^|\\s+)' + cssClassName + '(?=$|\\s)' ) ; } FCKJustifyCommand._GetClassNameRegex = function() { var regex = FCKJustifyCommand._ClassRegex ; if ( regex != undefined ) return regex ; var names = [] ; var classes = FCKConfig.JustifyClasses ; if ( classes ) { for ( var i = 0 ; i < 4 ; i++ ) { var className = classes[i] ; if ( className && className.length > 0 ) names.push( className ) ; } } if ( names.length > 0 ) regex = new RegExp( '(?:^|\\s+)(?:' + names.join( '|' ) + ')(?=$|\\s)' ) ; else regex = null ; return FCKJustifyCommand._ClassRegex = regex ; } FCKJustifyCommand.prototype = { Execute : function() { // Save an undo snapshot before doing anything. FCKUndo.SaveUndoStep() ; var range = new FCKDomRange( FCK.EditorWindow ) ; range.MoveToSelection() ; var currentState = this.GetState() ; if ( currentState == FCK_TRISTATE_DISABLED ) return ; // Store a bookmark of the selection since the paragraph iterator might // change the DOM tree and break selections. var bookmark = range.CreateBookmark() ; var cssClassName = this._CssClassName ; // Apply alignment setting for each paragraph. var iterator = new FCKDomRangeIterator( range ) ; var block ; while ( ( block = iterator.GetNextParagraph() ) ) { block.removeAttribute( 'align' ) ; if ( cssClassName ) { // Remove the any of the alignment classes from the className. var className = block.className.replace( FCKJustifyCommand._GetClassNameRegex(), '' ) ; // Append the desired class name. if ( currentState == FCK_TRISTATE_OFF ) { if ( className.length > 0 ) className += ' ' ; block.className = className + cssClassName ; } else if ( className.length == 0 ) FCKDomTools.RemoveAttribute( block, 'class' ) ; } else { var style = block.style ; if ( currentState == FCK_TRISTATE_OFF ) style.textAlign = this.AlignValue ; else { style.textAlign = '' ; if ( style.cssText.length == 0 ) block.removeAttribute( 'style' ) ; } } } // Restore previous selection. range.MoveToBookmark( bookmark ) ; range.Select() ; FCK.Focus() ; FCK.Events.FireEvent( 'OnSelectionChange' ) ; }, GetState : function() { // Disabled if not WYSIWYG. if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG || ! FCK.EditorWindow ) return FCK_TRISTATE_DISABLED ; // Retrieve the first selected block. var path = new FCKElementPath( FCKSelection.GetBoundaryParentElement( true ) ) ; var firstBlock = path.Block || path.BlockLimit ; if ( !firstBlock || firstBlock.nodeName.toLowerCase() == 'body' ) return FCK_TRISTATE_OFF ; // Check if the desired style is already applied to the block. var currentAlign ; if ( FCKBrowserInfo.IsIE ) currentAlign = firstBlock.currentStyle.textAlign ; else currentAlign = FCK.EditorWindow.getComputedStyle( firstBlock, '' ).getPropertyValue( 'text-align' ); currentAlign = currentAlign.replace( /(-moz-|-webkit-|start|auto)/i, '' ); if ( ( !currentAlign && this.IsDefaultAlign ) || currentAlign == this.AlignValue ) return FCK_TRISTATE_ON ; return FCK_TRISTATE_OFF ; } } ;
JavaScript
/* * 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 == * * FCKPasteWordCommand Class: represents the "Paste from Word" command. */ var FCKPasteWordCommand = function() { this.Name = 'PasteWord' ; } FCKPasteWordCommand.prototype.Execute = function() { FCK.PasteFromWord() ; } FCKPasteWordCommand.prototype.GetState = function() { if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG || FCKConfig.ForcePasteAsPlainText ) return FCK_TRISTATE_DISABLED ; else return FCK.GetNamedCommandState( 'Paste' ) ; }
JavaScript
/* * 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 == * * FCKStyleCommand Class: represents the "Style" command. */ var FCKStyleCommand = function() {} FCKStyleCommand.prototype = { Name : 'Style', Execute : function( styleName, styleComboItem ) { FCKUndo.SaveUndoStep() ; if ( styleComboItem.Selected ) FCK.Styles.RemoveStyle( styleComboItem.Style ) ; else FCK.Styles.ApplyStyle( styleComboItem.Style ) ; FCKUndo.SaveUndoStep() ; FCK.Focus() ; FCK.Events.FireEvent( 'OnSelectionChange' ) ; }, GetState : function() { if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG || !FCK.EditorDocument ) return FCK_TRISTATE_DISABLED ; if ( FCKSelection.GetType() == 'Control' ) { var el = FCKSelection.GetSelectedElement() ; if ( !el || !FCKStyles.CheckHasObjectStyle( el.nodeName.toLowerCase() ) ) return FCK_TRISTATE_DISABLED ; } return FCK_TRISTATE_OFF ; } };
JavaScript
/* * 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 == * * FCKIndentCommand Class: controls block indentation. */ var FCKIndentCommand = function( name, offset ) { this.Name = name ; this.Offset = offset ; this.IndentCSSProperty = FCKConfig.ContentLangDirection.IEquals( 'ltr' ) ? 'marginLeft' : 'marginRight' ; } FCKIndentCommand._InitIndentModeParameters = function() { if ( FCKConfig.IndentClasses && FCKConfig.IndentClasses.length > 0 ) { this._UseIndentClasses = true ; this._IndentClassMap = {} ; for ( var i = 0 ; i < FCKConfig.IndentClasses.length ;i++ ) this._IndentClassMap[FCKConfig.IndentClasses[i]] = i + 1 ; this._ClassNameRegex = new RegExp( '(?:^|\\s+)(' + FCKConfig.IndentClasses.join( '|' ) + ')(?=$|\\s)' ) ; } else this._UseIndentClasses = false ; } FCKIndentCommand.prototype = { Execute : function() { // Save an undo snapshot before doing anything. FCKUndo.SaveUndoStep() ; var range = new FCKDomRange( FCK.EditorWindow ) ; range.MoveToSelection() ; var bookmark = range.CreateBookmark() ; // Two cases to handle here: either we're in a list, or not. // If we're in a list, then the indent/outdent operations would be done on the list nodes. // Otherwise, apply the operation on the nearest block nodes. var nearestListBlock = FCKDomTools.GetCommonParentNode( range.StartNode || range.StartContainer , range.EndNode || range.EndContainer, ['ul', 'ol'] ) ; if ( nearestListBlock ) this._IndentList( range, nearestListBlock ) ; else this._IndentBlock( range ) ; range.MoveToBookmark( bookmark ) ; range.Select() ; FCK.Focus() ; FCK.Events.FireEvent( 'OnSelectionChange' ) ; }, GetState : function() { // Disabled if not WYSIWYG. if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG || ! FCK.EditorWindow ) return FCK_TRISTATE_DISABLED ; // Initialize parameters if not already initialzed. if ( FCKIndentCommand._UseIndentClasses == undefined ) FCKIndentCommand._InitIndentModeParameters() ; // If we're not in a list, and the starting block's indentation is zero, and the current // command is the outdent command, then we should return FCK_TRISTATE_DISABLED. var startContainer = FCKSelection.GetBoundaryParentElement( true ) ; var endContainer = FCKSelection.GetBoundaryParentElement( false ) ; var listNode = FCKDomTools.GetCommonParentNode( startContainer, endContainer, ['ul','ol'] ) ; if ( listNode ) { if ( this.Name.IEquals( 'outdent' ) ) return FCK_TRISTATE_OFF ; var firstItem = FCKTools.GetElementAscensor( startContainer, 'li' ) ; if ( !firstItem || !firstItem.previousSibling ) return FCK_TRISTATE_DISABLED ; return FCK_TRISTATE_OFF ; } if ( ! FCKIndentCommand._UseIndentClasses && this.Name.IEquals( 'indent' ) ) return FCK_TRISTATE_OFF; var path = new FCKElementPath( startContainer ) ; var firstBlock = path.Block || path.BlockLimit ; if ( !firstBlock ) return FCK_TRISTATE_DISABLED ; if ( FCKIndentCommand._UseIndentClasses ) { var indentClass = firstBlock.className.match( FCKIndentCommand._ClassNameRegex ) ; var indentStep = 0 ; if ( indentClass != null ) { indentClass = indentClass[1] ; indentStep = FCKIndentCommand._IndentClassMap[indentClass] ; } if ( ( this.Name == 'outdent' && indentStep == 0 ) || ( this.Name == 'indent' && indentStep == FCKConfig.IndentClasses.length ) ) return FCK_TRISTATE_DISABLED ; return FCK_TRISTATE_OFF ; } else { var indent = parseInt( firstBlock.style[this.IndentCSSProperty], 10 ) ; if ( isNaN( indent ) ) indent = 0 ; if ( indent <= 0 ) return FCK_TRISTATE_DISABLED ; return FCK_TRISTATE_OFF ; } }, _IndentBlock : function( range ) { var iterator = new FCKDomRangeIterator( range ) ; iterator.EnforceRealBlocks = true ; range.Expand( 'block_contents' ) ; var commonParents = FCKDomTools.GetCommonParents( range.StartContainer, range.EndContainer ) ; var nearestParent = commonParents[commonParents.length - 1] ; var block ; while ( ( block = iterator.GetNextParagraph() ) ) { // We don't want to indent subtrees recursively, so only perform the indent operation // if the block itself is the nearestParent, or the block's parent is the nearestParent. if ( ! ( block == nearestParent || block.parentNode == nearestParent ) ) continue ; if ( FCKIndentCommand._UseIndentClasses ) { // Transform current class name to indent step index. var indentClass = block.className.match( FCKIndentCommand._ClassNameRegex ) ; var indentStep = 0 ; if ( indentClass != null ) { indentClass = indentClass[1] ; indentStep = FCKIndentCommand._IndentClassMap[indentClass] ; } // Operate on indent step index, transform indent step index back to class name. if ( this.Name.IEquals( 'outdent' ) ) indentStep-- ; else if ( this.Name.IEquals( 'indent' ) ) indentStep++ ; indentStep = Math.min( indentStep, FCKConfig.IndentClasses.length ) ; indentStep = Math.max( indentStep, 0 ) ; var className = block.className.replace( FCKIndentCommand._ClassNameRegex, '' ) ; if ( indentStep < 1 ) block.className = className ; else block.className = ( className.length > 0 ? className + ' ' : '' ) + FCKConfig.IndentClasses[indentStep - 1] ; } else { // Offset distance is assumed to be in pixels for now. var currentOffset = parseInt( block.style[this.IndentCSSProperty], 10 ) ; if ( isNaN( currentOffset ) ) currentOffset = 0 ; currentOffset += this.Offset ; currentOffset = Math.max( currentOffset, 0 ) ; currentOffset = Math.ceil( currentOffset / this.Offset ) * this.Offset ; block.style[this.IndentCSSProperty] = currentOffset ? currentOffset + FCKConfig.IndentUnit : '' ; if ( block.getAttribute( 'style' ) == '' ) block.removeAttribute( 'style' ) ; } } }, _IndentList : function( range, listNode ) { // Our starting and ending points of the range might be inside some blocks under a list item... // So before playing with the iterator, we need to expand the block to include the list items. var startContainer = range.StartContainer ; var endContainer = range.EndContainer ; while ( startContainer && startContainer.parentNode != listNode ) startContainer = startContainer.parentNode ; while ( endContainer && endContainer.parentNode != listNode ) endContainer = endContainer.parentNode ; if ( ! startContainer || ! endContainer ) return ; // Now we can iterate over the individual items on the same tree depth. var block = startContainer ; var itemsToMove = [] ; var stopFlag = false ; while ( stopFlag == false ) { if ( block == endContainer ) stopFlag = true ; itemsToMove.push( block ) ; block = block.nextSibling ; } if ( itemsToMove.length < 1 ) return ; // Do indent or outdent operations on the array model of the list, not the list's DOM tree itself. // The array model demands that it knows as much as possible about the surrounding lists, we need // to feed it the further ancestor node that is still a list. var listParents = FCKDomTools.GetParents( listNode ) ; for ( var i = 0 ; i < listParents.length ; i++ ) { if ( listParents[i].nodeName.IEquals( ['ul', 'ol'] ) ) { listNode = listParents[i] ; break ; } } var indentOffset = this.Name.IEquals( 'indent' ) ? 1 : -1 ; var startItem = itemsToMove[0] ; var lastItem = itemsToMove[ itemsToMove.length - 1 ] ; var markerObj = {} ; // Convert the list DOM tree into a one dimensional array. var listArray = FCKDomTools.ListToArray( listNode, markerObj ) ; // Apply indenting or outdenting on the array. var baseIndent = listArray[lastItem._FCK_ListArray_Index].indent ; for ( var i = startItem._FCK_ListArray_Index ; i <= lastItem._FCK_ListArray_Index ; i++ ) listArray[i].indent += indentOffset ; for ( var i = lastItem._FCK_ListArray_Index + 1 ; i < listArray.length && listArray[i].indent > baseIndent ; i++ ) listArray[i].indent += indentOffset ; /* For debug use only var PrintArray = function( listArray, doc ) { var s = [] ; for ( var i = 0 ; i < listArray.length ; i++ ) { for ( var j in listArray[i] ) { if ( j != 'contents' ) s.push( j + ":" + listArray[i][j] + "; " ) ; else { var docFrag = doc.createDocumentFragment() ; var tmpNode = doc.createElement( 'span' ) ; for ( var k = 0 ; k < listArray[i][j].length ; k++ ) docFrag.appendChild( listArray[i][j][k].cloneNode( true ) ) ; tmpNode.appendChild( docFrag ) ; s.push( j + ":" + tmpNode.innerHTML + "; ") ; } } s.push( '\n' ) ; } alert( s.join('') ) ; } PrintArray( listArray, FCK.EditorDocument ) ; */ // Convert the array back to a DOM forest (yes we might have a few subtrees now). // And replace the old list with the new forest. var newList = FCKDomTools.ArrayToList( listArray ) ; if ( newList ) listNode.parentNode.replaceChild( newList.listNode, listNode ) ; // Clean up the markers. FCKDomTools.ClearAllMarkers( markerObj ) ; } } ;
JavaScript
/* * 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 == * * This is a utility object which can be used to load specific components of * FCKeditor, including all dependencies. */ var FCK_GENERIC = 1 ; var FCK_GENERIC_SPECIFIC = 2 ; var FCK_SPECIFIC = 3 ; var FCKScriptLoader = new Object() ; FCKScriptLoader.FCKeditorPath = '/fckeditor/' ; FCKScriptLoader._Scripts = new Object() ; FCKScriptLoader._LoadedScripts = new Object() ; FCKScriptLoader._IsIE = (/msie/).test( navigator.userAgent.toLowerCase() ) ; FCKScriptLoader.Load = function( scriptName ) { // Check if the script has already been loaded. if ( scriptName in FCKScriptLoader._LoadedScripts ) return ; FCKScriptLoader._LoadedScripts[ scriptName ] = true ; var oScriptInfo = this._Scripts[ scriptName ] ; if ( !oScriptInfo ) { alert( 'FCKScriptLoader: The script "' + scriptName + '" could not be loaded' ) ; return ; } for ( var i = 0 ; i < oScriptInfo.Dependency.length ; i++ ) { this.Load( oScriptInfo.Dependency[i] ) ; } var sBaseScriptName = oScriptInfo.BasePath + scriptName.toLowerCase() ; if ( oScriptInfo.Compatibility == FCK_GENERIC || oScriptInfo.Compatibility == FCK_GENERIC_SPECIFIC ) this._LoadScript( sBaseScriptName + '.js' ) ; if ( oScriptInfo.Compatibility == FCK_SPECIFIC || oScriptInfo.Compatibility == FCK_GENERIC_SPECIFIC ) { if ( this._IsIE ) this._LoadScript( sBaseScriptName + '_ie.js' ) ; else this._LoadScript( sBaseScriptName + '_gecko.js' ) ; } } FCKScriptLoader._LoadScript = function( scriptPathFromSource ) { document.write( '<script type="text/javascript" src="' + this.FCKeditorPath + 'editor/_source/' + scriptPathFromSource + '"><\/script>' ) ; } FCKScriptLoader.AddScript = function( scriptName, scriptBasePath, dependency, compatibility ) { this._Scripts[ scriptName ] = { BasePath : scriptBasePath || '', Dependency : dependency || [], Compatibility : compatibility || FCK_GENERIC } ; } /* * #################################### * ### Scripts Definition List */ FCKScriptLoader.AddScript( 'FCKConstants' ) ; FCKScriptLoader.AddScript( 'FCKJSCoreExtensions' ) ; FCKScriptLoader.AddScript( 'FCK_Xhtml10Transitional', '../dtd/' ) ; FCKScriptLoader.AddScript( 'FCKDataProcessor' , 'classes/' , ['FCKConfig','FCKBrowserInfo','FCKRegexLib','FCKXHtml'] ) ; FCKScriptLoader.AddScript( 'FCKDocumentFragment', 'classes/' , ['FCKDomTools'], FCK_SPECIFIC ) ; FCKScriptLoader.AddScript( 'FCKDomRange' , 'classes/' , ['FCKBrowserInfo','FCKJSCoreExtensions','FCKW3CRange','FCKElementPath','FCKDomTools','FCKTools','FCKDocumentFragment'], FCK_GENERIC_SPECIFIC ) ; FCKScriptLoader.AddScript( 'FCKDomRangeIterator', 'classes/' , ['FCKDomRange','FCKListsLib'], FCK_GENERIC ) ; FCKScriptLoader.AddScript( 'FCKElementPath' , 'classes/' , ['FCKListsLib'], FCK_GENERIC ) ; FCKScriptLoader.AddScript( 'FCKEnterKey' , 'classes/' , ['FCKDomRange','FCKDomTools','FCKTools','FCKKeystrokeHandler','FCKListHandler'], FCK_GENERIC ) ; FCKScriptLoader.AddScript( 'FCKPanel' , 'classes/' , ['FCKBrowserInfo','FCKConfig','FCKTools'], FCK_GENERIC ) ; FCKScriptLoader.AddScript( 'FCKImagePreloader' , 'classes/' ) ; FCKScriptLoader.AddScript( 'FCKKeystrokeHandler', 'classes/' , ['FCKConstants','FCKBrowserInfo','FCKTools'], FCK_GENERIC ) ; FCKScriptLoader.AddScript( 'FCKStyle' , 'classes/' , ['FCKConstants','FCKDomRange','FCKDomRangeIterator','FCKDomTools','FCKListsLib','FCK_Xhtml10Transitional'], FCK_GENERIC ) ; FCKScriptLoader.AddScript( 'FCKW3CRange' , 'classes/' , ['FCKDomTools','FCKTools','FCKDocumentFragment'], FCK_GENERIC ) ; FCKScriptLoader.AddScript( 'FCKBrowserInfo' , 'internals/' , ['FCKJSCoreExtensions'] ) ; FCKScriptLoader.AddScript( 'FCKCodeFormatter' , 'internals/' ) ; FCKScriptLoader.AddScript( 'FCKConfig' , 'internals/' , ['FCKBrowserInfo','FCKConstants'] ) ; FCKScriptLoader.AddScript( 'FCKDebug' , 'internals/' , ['FCKConfig'] ) ; FCKScriptLoader.AddScript( 'FCKDomTools' , 'internals/' , ['FCKJSCoreExtensions','FCKBrowserInfo','FCKTools','FCKDomRange'], FCK_GENERIC ) ; FCKScriptLoader.AddScript( 'FCKListsLib' , 'internals/' ) ; FCKScriptLoader.AddScript( 'FCKListHandler' , 'internals/' , ['FCKConfig', 'FCKDocumentFragment', 'FCKJSCoreExtensions','FCKDomTools'], FCK_GENERIC ) ; FCKScriptLoader.AddScript( 'FCKRegexLib' , 'internals/' ) ; FCKScriptLoader.AddScript( 'FCKStyles' , 'internals/' , ['FCKConfig', 'FCKDocumentFragment', 'FCKDomRange','FCKDomTools','FCKElementPath','FCKTools'], FCK_GENERIC ) ; FCKScriptLoader.AddScript( 'FCKTools' , 'internals/' , ['FCKJSCoreExtensions','FCKBrowserInfo'], FCK_GENERIC_SPECIFIC ) ; FCKScriptLoader.AddScript( 'FCKXHtml' , 'internals/' , ['FCKBrowserInfo','FCKCodeFormatter','FCKConfig','FCKDomTools','FCKListsLib','FCKRegexLib','FCKTools','FCKXHtmlEntities'], FCK_GENERIC_SPECIFIC ) ; FCKScriptLoader.AddScript( 'FCKXHtmlEntities' , 'internals/' , ['FCKConfig'] ) ; // ####################################
JavaScript
/* * 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 == */ (function() { // IE6 doens't handle absolute positioning properly (it is always in quirks // mode). This function fixes the sizes and positions of many elements that // compose the skin (this is skin specific). var fixSizes = window.DoResizeFixes = function() { var fckDlg = window.document.body ; for ( var i = 0 ; i < fckDlg.childNodes.length ; i++ ) { var child = fckDlg.childNodes[i] ; switch ( child.className ) { case 'contents' : child.style.width = Math.max( 0, fckDlg.offsetWidth - 16 - 16 ) ; // -left -right child.style.height = Math.max( 0, fckDlg.clientHeight - 20 - 2 ) ; // -bottom -top break ; case 'blocker' : case 'cover' : child.style.width = Math.max( 0, fckDlg.offsetWidth - 16 - 16 + 4 ) ; // -left -right + 4 child.style.height = Math.max( 0, fckDlg.clientHeight - 20 - 2 + 4 ) ; // -bottom -top + 4 break ; case 'tr' : child.style.left = Math.max( 0, fckDlg.clientWidth - 16 ) ; break ; case 'tc' : child.style.width = Math.max( 0, fckDlg.clientWidth - 16 - 16 ) ; break ; case 'ml' : child.style.height = Math.max( 0, fckDlg.clientHeight - 16 - 51 ) ; break ; case 'mr' : child.style.left = Math.max( 0, fckDlg.clientWidth - 16 ) ; child.style.height = Math.max( 0, fckDlg.clientHeight - 16 - 51 ) ; break ; case 'bl' : child.style.top = Math.max( 0, fckDlg.clientHeight - 51 ) ; break ; case 'br' : child.style.left = Math.max( 0, fckDlg.clientWidth - 30 ) ; child.style.top = Math.max( 0, fckDlg.clientHeight - 51 ) ; break ; case 'bc' : child.style.width = Math.max( 0, fckDlg.clientWidth - 30 - 30 ) ; child.style.top = Math.max( 0, fckDlg.clientHeight - 51 ) ; break ; } } } var closeButtonOver = function() { this.style.backgroundPosition = '-16px -687px' ; } ; var closeButtonOut = function() { this.style.backgroundPosition = '-16px -651px' ; } ; var fixCloseButton = function() { var closeButton = document.getElementById ( 'closeButton' ) ; closeButton.onmouseover = closeButtonOver ; closeButton.onmouseout = closeButtonOut ; } var onLoad = function() { fixSizes() ; fixCloseButton() ; window.attachEvent( 'onresize', fixSizes ) ; window.detachEvent( 'onload', onLoad ) ; } window.attachEvent( 'onload', onLoad ) ; })() ;
JavaScript
/* * 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 == */ (function() { // IE6 doens't handle absolute positioning properly (it is always in quirks // mode). This function fixes the sizes and positions of many elements that // compose the skin (this is skin specific). var fixSizes = window.DoResizeFixes = function() { var fckDlg = window.document.body ; for ( var i = 0 ; i < fckDlg.childNodes.length ; i++ ) { var child = fckDlg.childNodes[i] ; switch ( child.className ) { case 'contents' : child.style.width = Math.max( 0, fckDlg.offsetWidth - 16 - 16 ) ; // -left -right child.style.height = Math.max( 0, fckDlg.clientHeight - 20 - 2 ) ; // -bottom -top break ; case 'blocker' : case 'cover' : child.style.width = Math.max( 0, fckDlg.offsetWidth - 16 - 16 + 4 ) ; // -left -right + 4 child.style.height = Math.max( 0, fckDlg.clientHeight - 20 - 2 + 4 ) ; // -bottom -top + 4 break ; case 'tr' : child.style.left = Math.max( 0, fckDlg.clientWidth - 16 ) ; break ; case 'tc' : child.style.width = Math.max( 0, fckDlg.clientWidth - 16 - 16 ) ; break ; case 'ml' : child.style.height = Math.max( 0, fckDlg.clientHeight - 16 - 51 ) ; break ; case 'mr' : child.style.left = Math.max( 0, fckDlg.clientWidth - 16 ) ; child.style.height = Math.max( 0, fckDlg.clientHeight - 16 - 51 ) ; break ; case 'bl' : child.style.top = Math.max( 0, fckDlg.clientHeight - 51 ) ; break ; case 'br' : child.style.left = Math.max( 0, fckDlg.clientWidth - 30 ) ; child.style.top = Math.max( 0, fckDlg.clientHeight - 51 ) ; break ; case 'bc' : child.style.width = Math.max( 0, fckDlg.clientWidth - 30 - 30 ) ; child.style.top = Math.max( 0, fckDlg.clientHeight - 51 ) ; break ; } } } var closeButtonOver = function() { this.style.backgroundPosition = '-16px -687px' ; } ; var closeButtonOut = function() { this.style.backgroundPosition = '-16px -651px' ; } ; var fixCloseButton = function() { var closeButton = document.getElementById ( 'closeButton' ) ; closeButton.onmouseover = closeButtonOver ; closeButton.onmouseout = closeButtonOut ; } var onLoad = function() { fixSizes() ; fixCloseButton() ; window.attachEvent( 'onresize', fixSizes ) ; window.detachEvent( 'onload', onLoad ) ; } window.attachEvent( 'onload', onLoad ) ; })() ;
JavaScript
/* * 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 == * * Compatibility code for Adobe AIR. */ if ( FCKBrowserInfo.IsAIR ) { var FCKAdobeAIR = (function() { /* * ### Private functions. */ var getDocumentHead = function( doc ) { var head ; var heads = doc.getElementsByTagName( 'head' ) ; if( heads && heads[0] ) head = heads[0] ; else { head = doc.createElement( 'head' ) ; doc.documentElement.insertBefore( head, doc.documentElement.firstChild ) ; } return head ; } ; /* * ### Public interface. */ return { FCKeditorAPI_Evaluate : function( parentWindow, script ) { // TODO : This one doesn't work always. The parent window will // point to an anonymous function in this window. If this // window is destroyied the parent window will be pointing to // an invalid reference. // Evaluate the script in this window. eval( script ) ; // Point the FCKeditorAPI property of the parent window to the // local reference. parentWindow.FCKeditorAPI = window.FCKeditorAPI ; }, EditingArea_Start : function( doc, html ) { // Get the HTML for the <head>. var headInnerHtml = html.match( /<head>([\s\S]*)<\/head>/i )[1] ; if ( headInnerHtml && headInnerHtml.length > 0 ) { // Inject the <head> HTML inside a <div>. // Do that before getDocumentHead because WebKit moves // <link css> elements to the <head> at this point. var div = doc.createElement( 'div' ) ; div.innerHTML = headInnerHtml ; // Move the <div> nodes to <head>. FCKDomTools.MoveChildren( div, getDocumentHead( doc ) ) ; } doc.body.innerHTML = html.match( /<body>([\s\S]*)<\/body>/i )[1] ; //prevent clicking on hyperlinks and navigating away doc.addEventListener('click', function( ev ) { ev.preventDefault() ; ev.stopPropagation() ; }, true ) ; }, Panel_Contructor : function( doc, baseLocation ) { var head = getDocumentHead( doc ) ; // Set the <base> href. head.appendChild( doc.createElement('base') ).href = baseLocation ; doc.body.style.margin = '0px' ; doc.body.style.padding = '0px' ; }, ToolbarSet_GetOutElement : function( win, outMatch ) { var toolbarTarget = win.parent ; var targetWindowParts = outMatch[1].split( '.' ) ; while ( targetWindowParts.length > 0 ) { var part = targetWindowParts.shift() ; if ( part.length > 0 ) toolbarTarget = toolbarTarget[ part ] ; } toolbarTarget = toolbarTarget.document.getElementById( outMatch[2] ) ; }, ToolbarSet_InitOutFrame : function( doc ) { var head = getDocumentHead( doc ) ; head.appendChild( doc.createElement('base') ).href = window.document.location ; var targetWindow = doc.defaultView; targetWindow.adjust = function() { targetWindow.frameElement.height = doc.body.scrollHeight; } ; targetWindow.onresize = targetWindow.adjust ; targetWindow.setTimeout( targetWindow.adjust, 0 ) ; doc.body.style.overflow = 'hidden'; doc.body.innerHTML = document.getElementById( 'xToolbarSpace' ).innerHTML ; } } ; })(); /* * ### Overrides */ ( function() { // Save references for override reuse. var _Original_FCKPanel_Window_OnFocus = FCKPanel_Window_OnFocus ; var _Original_FCKPanel_Window_OnBlur = FCKPanel_Window_OnBlur ; var _Original_FCK_StartEditor = FCK.StartEditor ; FCKPanel_Window_OnFocus = function( e, panel ) { // Call the original implementation. _Original_FCKPanel_Window_OnFocus.call( this, e, panel ) ; if ( panel._focusTimer ) clearTimeout( panel._focusTimer ) ; } FCKPanel_Window_OnBlur = function( e, panel ) { // Delay the execution of the original function. panel._focusTimer = FCKTools.SetTimeout( _Original_FCKPanel_Window_OnBlur, 100, this, [ e, panel ] ) ; } FCK.StartEditor = function() { // Force pointing to the CSS files instead of using the inline CSS cached styles. window.FCK_InternalCSS = FCKConfig.BasePath + 'css/fck_internal.css' ; window.FCK_ShowTableBordersCSS = FCKConfig.BasePath + 'css/fck_showtableborders_gecko.css' ; _Original_FCK_StartEditor.apply( this, arguments ) ; } })(); }
JavaScript
/* * 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 == * * Contains the DTD mapping for XHTML 1.0 Strict. * This file was automatically generated from the file: xhtml10-strict.dtd */ FCK.DTD = (function() { var X = FCKTools.Merge ; var H,I,J,K,C,L,M,A,B,D,E,G,N,F ; A = {ins:1, del:1, script:1} ; B = {hr:1, ul:1, div:1, blockquote:1, noscript:1, table:1, address:1, pre:1, p:1, h5:1, dl:1, h4:1, ol:1, h6:1, h1:1, h3:1, h2:1} ; C = X({fieldset:1}, B) ; D = X({sub:1, bdo:1, 'var':1, sup:1, br:1, kbd:1, map:1, samp:1, b:1, acronym:1, '#':1, abbr:1, code:1, i:1, cite:1, tt:1, strong:1, q:1, em:1, big:1, small:1, span:1, dfn:1}, A) ; E = X({img:1, object:1}, D) ; F = {input:1, button:1, textarea:1, select:1, label:1} ; G = X({a:1}, F) ; H = {img:1, noscript:1, br:1, kbd:1, button:1, h5:1, h4:1, samp:1, h6:1, ol:1, h1:1, h3:1, h2:1, form:1, select:1, '#':1, ins:1, abbr:1, label:1, code:1, table:1, script:1, cite:1, input:1, strong:1, textarea:1, big:1, small:1, span:1, hr:1, sub:1, bdo:1, 'var':1, div:1, object:1, sup:1, map:1, dl:1, del:1, fieldset:1, ul:1, b:1, acronym:1, a:1, blockquote:1, i:1, address:1, tt:1, q:1, pre:1, p:1, em:1, dfn:1} ; I = X({form:1, fieldset:1}, B, E, G) ; J = {tr:1} ; K = {'#':1} ; L = X(E, G) ; M = {li:1} ; N = X({form:1}, A, C) ; return { col: {}, tr: {td:1, th:1}, img: {}, colgroup: {col:1}, noscript: N, td: I, br: {}, th: I, kbd: L, button: X(B, E), h5: L, h4: L, samp: L, h6: L, ol: M, h1: L, h3: L, option: K, h2: L, form: X(A, C), select: {optgroup:1, option:1}, ins: I, abbr: L, label: L, code: L, table: {thead:1, col:1, tbody:1, tr:1, colgroup:1, caption:1, tfoot:1}, script: K, tfoot: J, cite: L, li: I, input: {}, strong: L, textarea: K, big: L, small: L, span: L, dt: L, hr: {}, sub: L, optgroup: {option:1}, bdo: L, param: {}, 'var': L, div: I, object: X({param:1}, H), sup: L, dd: I, area: {}, map: X({form:1, area:1}, A, C), dl: {dt:1, dd:1}, del: I, fieldset: X({legend:1}, H), thead: J, ul: M, acronym: L, b: L, a: X({img:1, object:1}, D, F), blockquote: N, caption: L, i: L, tbody: J, address: L, tt: L, legend: L, q: L, pre: X({a:1}, D, F), p: L, em: L, dfn: L } ; })() ;
JavaScript
/* * 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 == * * Contains the DTD mapping for XHTML 1.0 Transitional. * This file was automatically generated from the file: xhtml10-transitional.dtd */ FCK.DTD = (function() { var X = FCKTools.Merge ; var A,L,J,M,N,O,D,H,P,K,Q,F,G,C,B,E,I ; A = {isindex:1, fieldset:1} ; B = {input:1, button:1, select:1, textarea:1, label:1} ; C = X({a:1}, B) ; D = X({iframe:1}, C) ; E = {hr:1, ul:1, menu:1, div:1, blockquote:1, noscript:1, table:1, center:1, address:1, dir:1, pre:1, h5:1, dl:1, h4:1, noframes:1, h6:1, ol:1, h1:1, h3:1, h2:1} ; F = {ins:1, del:1, script:1} ; G = X({b:1, acronym:1, bdo:1, 'var':1, '#':1, abbr:1, code:1, br:1, i:1, cite:1, kbd:1, u:1, strike:1, s:1, tt:1, strong:1, q:1, samp:1, em:1, dfn:1, span:1}, F) ; H = X({sub:1, img:1, object:1, sup:1, basefont:1, map:1, applet:1, font:1, big:1, small:1}, G) ; I = X({p:1}, H) ; J = X({iframe:1}, H, B) ; K = {img:1, noscript:1, br:1, kbd:1, center:1, button:1, basefont:1, h5:1, h4:1, samp:1, h6:1, ol:1, h1:1, h3:1, h2:1, form:1, font:1, '#':1, select:1, menu:1, ins:1, abbr:1, label:1, code:1, table:1, script:1, cite:1, input:1, iframe:1, strong:1, textarea:1, noframes:1, big:1, small:1, span:1, hr:1, sub:1, bdo:1, 'var':1, div:1, object:1, sup:1, strike:1, dir:1, map:1, dl:1, applet:1, del:1, isindex:1, fieldset:1, ul:1, b:1, acronym:1, a:1, blockquote:1, i:1, u:1, s:1, tt:1, address:1, q:1, pre:1, p:1, em:1, dfn:1} ; L = X({a:1}, J) ; M = {tr:1} ; N = {'#':1} ; O = X({param:1}, K) ; P = X({form:1}, A, D, E, I) ; Q = {li:1} ; return { col: {}, tr: {td:1, th:1}, img: {}, colgroup: {col:1}, noscript: P, td: P, br: {}, th: P, center: P, kbd: L, button: X(I, E), basefont: {}, h5: L, h4: L, samp: L, h6: L, ol: Q, h1: L, h3: L, option: N, h2: L, form: X(A, D, E, I), select: {optgroup:1, option:1}, font: J, // Changed from L to J (see (1)) ins: P, menu: Q, abbr: L, label: L, table: {thead:1, col:1, tbody:1, tr:1, colgroup:1, caption:1, tfoot:1}, code: L, script: N, tfoot: M, cite: L, li: P, input: {}, iframe: P, strong: J, // Changed from L to J (see (1)) textarea: N, noframes: P, big: J, // Changed from L to J (see (1)) small: J, // Changed from L to J (see (1)) span: J, // Changed from L to J (see (1)) hr: {}, dt: L, sub: J, // Changed from L to J (see (1)) optgroup: {option:1}, param: {}, bdo: L, 'var': J, // Changed from L to J (see (1)) div: P, object: O, sup: J, // Changed from L to J (see (1)) dd: P, strike: J, // Changed from L to J (see (1)) area: {}, dir: Q, map: X({area:1, form:1, p:1}, A, F, E), applet: O, dl: {dt:1, dd:1}, del: P, isindex: {}, fieldset: X({legend:1}, K), thead: M, ul: Q, acronym: L, b: J, // Changed from L to J (see (1)) a: J, blockquote: P, caption: L, i: J, // Changed from L to J (see (1)) u: J, // Changed from L to J (see (1)) tbody: M, s: L, address: X(D, I), tt: J, // Changed from L to J (see (1)) legend: L, q: L, pre: X(G, C), p: L, em: J, // Changed from L to J (see (1)) dfn: L } ; })() ; /* Notes: (1) According to the DTD, many elements, like <b> accept <a> elements inside of them. But, to produce better output results, we have manually changed the map to avoid breaking the links on pieces, having "<b>this is a </b><a><b>link</b> test</a>", instead of "<b>this is a <a>link</a></b><a> test</a>". */
JavaScript
/* * 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 == * * Chinese Simplified language file. */ var FCKLang = { // Language direction : "ltr" (left to right) or "rtl" (right to left). Dir : "ltr", ToolbarCollapse : "折叠工具栏", ToolbarExpand : "展开工具栏", // Toolbar Items and Context Menu Save : "保存", NewPage : "新建", Preview : "预览", Cut : "剪切", Copy : "复制", Paste : "粘贴", PasteText : "粘贴为无格式文本", PasteWord : "从 MS Word 粘贴", Print : "打印", SelectAll : "全选", RemoveFormat : "清除格式", InsertLinkLbl : "超链接", InsertLink : "插入/编辑超链接", RemoveLink : "取消超链接", VisitLink : "打开超链接", Anchor : "插入/编辑锚点链接", AnchorDelete : "清除锚点链接", InsertImageLbl : "图象", InsertImage : "插入/编辑图象", InsertFlashLbl : "Flash", InsertFlash : "插入/编辑 Flash", InsertTableLbl : "表格", InsertTable : "插入/编辑表格", InsertLineLbl : "水平线", InsertLine : "插入水平线", InsertSpecialCharLbl: "特殊符号", InsertSpecialChar : "插入特殊符号", InsertSmileyLbl : "表情符", InsertSmiley : "插入表情图标", About : "关于 FCKeditor", Bold : "加粗", Italic : "倾斜", Underline : "下划线", StrikeThrough : "删除线", Subscript : "下标", Superscript : "上标", LeftJustify : "左对齐", CenterJustify : "居中对齐", RightJustify : "右对齐", BlockJustify : "两端对齐", DecreaseIndent : "减少缩进量", IncreaseIndent : "增加缩进量", Blockquote : "块引用", CreateDiv : "插入 Div 标签", EditDiv : "编辑 Div 标签", DeleteDiv : "删除 Div 标签", Undo : "撤消", Redo : "重做", NumberedListLbl : "编号列表", NumberedList : "插入/删除编号列表", BulletedListLbl : "项目列表", BulletedList : "插入/删除项目列表", ShowTableBorders : "显示表格边框", ShowDetails : "显示详细资料", Style : "样式", FontFormat : "格式", Font : "字体", FontSize : "大小", TextColor : "文本颜色", BGColor : "背景颜色", Source : "源代码", Find : "查找", Replace : "替换", SpellCheck : "拼写检查", UniversalKeyboard : "软键盘", PageBreakLbl : "分页符", PageBreak : "插入分页符", Form : "表单", Checkbox : "复选框", RadioButton : "单选按钮", TextField : "单行文本", Textarea : "多行文本", HiddenField : "隐藏域", Button : "按钮", SelectionField : "列表/菜单", ImageButton : "图像域", FitWindow : "全屏编辑", ShowBlocks : "显示区块", // Context Menu EditLink : "编辑超链接", CellCM : "单元格", RowCM : "行", ColumnCM : "列", InsertRowAfter : "在下方插入行", InsertRowBefore : "在上方插入行", DeleteRows : "删除行", InsertColumnAfter : "在右侧插入列", InsertColumnBefore : "在左侧插入列", DeleteColumns : "删除列", InsertCellAfter : "在右侧插入单元格", InsertCellBefore : "在左侧插入单元格", DeleteCells : "删除单元格", MergeCells : "合并单元格", MergeRight : "向右合并单元格", MergeDown : "向下合并单元格", HorizontalSplitCell : "水平拆分单元格", VerticalSplitCell : "垂直拆分单元格", TableDelete : "删除表格", CellProperties : "单元格属性", TableProperties : "表格属性", ImageProperties : "图象属性", FlashProperties : "Flash 属性", AnchorProp : "锚点链接属性", ButtonProp : "按钮属性", CheckboxProp : "复选框属性", HiddenFieldProp : "隐藏域属性", RadioButtonProp : "单选按钮属性", ImageButtonProp : "图像域属性", TextFieldProp : "单行文本属性", SelectionFieldProp : "菜单/列表属性", TextareaProp : "多行文本属性", FormProp : "表单属性", FontFormats : "普通;已编排格式;地址;标题 1;标题 2;标题 3;标题 4;标题 5;标题 6;段落(DIV)", // Alerts and Messages ProcessingXHTML : "正在处理 XHTML,请稍等...", Done : "完成", PasteWordConfirm : "您要粘贴的内容好像是来自 MS Word,是否要清除 MS Word 格式后再粘贴?", NotCompatiblePaste : "该命令需要 Internet Explorer 5.5 或更高版本的支持,是否按常规粘贴进行?", UnknownToolbarItem : "未知工具栏项目 \"%1\"", UnknownCommand : "未知命令名称 \"%1\"", NotImplemented : "命令无法执行", UnknownToolbarSet : "工具栏设置 \"%1\" 不存在", NoActiveX : "浏览器安全设置限制了本编辑器的某些功能。您必须启用安全设置中的“运行 ActiveX 控件和插件”,否则将出现某些错误并缺少功能。", BrowseServerBlocked : "无法打开资源浏览器,请确认是否启用了禁止弹出窗口。", DialogBlocked : "无法打开对话框窗口,请确认是否启用了禁止弹出窗口或网页对话框(IE)。", VisitLinkBlocked : "无法打开新窗口,请确认是否启用了禁止弹出窗口或网页对话框(IE)。", // Dialogs DlgBtnOK : "确定", DlgBtnCancel : "取消", DlgBtnClose : "关闭", DlgBtnBrowseServer : "浏览服务器", DlgAdvancedTag : "高级", DlgOpOther : "<其它>", DlgInfoTab : "信息", DlgAlertUrl : "请插入 URL", // General Dialogs Labels DlgGenNotSet : "<没有设置>", DlgGenId : "ID", DlgGenLangDir : "语言方向", DlgGenLangDirLtr : "从左到右 (LTR)", DlgGenLangDirRtl : "从右到左 (RTL)", DlgGenLangCode : "语言代码", DlgGenAccessKey : "访问键", DlgGenName : "名称", DlgGenTabIndex : "Tab 键次序", DlgGenLongDescr : "详细说明地址", DlgGenClass : "样式类名称", DlgGenTitle : "标题", DlgGenContType : "内容类型", DlgGenLinkCharset : "字符编码", DlgGenStyle : "行内样式", // Image Dialog DlgImgTitle : "图象属性", DlgImgInfoTab : "图象", DlgImgBtnUpload : "发送到服务器上", DlgImgURL : "源文件", DlgImgUpload : "上传", DlgImgAlt : "替换文本", DlgImgWidth : "宽度", DlgImgHeight : "高度", DlgImgLockRatio : "锁定比例", DlgBtnResetSize : "恢复尺寸", DlgImgBorder : "边框大小", DlgImgHSpace : "水平间距", DlgImgVSpace : "垂直间距", DlgImgAlign : "对齐方式", DlgImgAlignLeft : "左对齐", DlgImgAlignAbsBottom: "绝对底边", DlgImgAlignAbsMiddle: "绝对居中", DlgImgAlignBaseline : "基线", DlgImgAlignBottom : "底边", DlgImgAlignMiddle : "居中", DlgImgAlignRight : "右对齐", DlgImgAlignTextTop : "文本上方", DlgImgAlignTop : "顶端", DlgImgPreview : "预览", DlgImgAlertUrl : "请输入图象地址", DlgImgLinkTab : "链接", // Flash Dialog DlgFlashTitle : "Flash 属性", DlgFlashChkPlay : "自动播放", DlgFlashChkLoop : "循环", DlgFlashChkMenu : "启用 Flash 菜单", DlgFlashScale : "缩放", DlgFlashScaleAll : "全部显示", DlgFlashScaleNoBorder : "无边框", DlgFlashScaleFit : "严格匹配", // Link Dialog DlgLnkWindowTitle : "超链接", DlgLnkInfoTab : "超链接信息", DlgLnkTargetTab : "目标", DlgLnkType : "超链接类型", DlgLnkTypeURL : "超链接", DlgLnkTypeAnchor : "页内锚点链接", DlgLnkTypeEMail : "电子邮件", DlgLnkProto : "协议", DlgLnkProtoOther : "<其它>", DlgLnkURL : "地址", DlgLnkAnchorSel : "选择一个锚点", DlgLnkAnchorByName : "按锚点名称", DlgLnkAnchorById : "按锚点 ID", DlgLnkNoAnchors : "(此文档没有可用的锚点)", DlgLnkEMail : "地址", DlgLnkEMailSubject : "主题", DlgLnkEMailBody : "内容", DlgLnkUpload : "上传", DlgLnkBtnUpload : "发送到服务器上", DlgLnkTarget : "目标", DlgLnkTargetFrame : "<框架>", DlgLnkTargetPopup : "<弹出窗口>", DlgLnkTargetBlank : "新窗口 (_blank)", DlgLnkTargetParent : "父窗口 (_parent)", DlgLnkTargetSelf : "本窗口 (_self)", DlgLnkTargetTop : "整页 (_top)", DlgLnkTargetFrameName : "目标框架名称", DlgLnkPopWinName : "弹出窗口名称", DlgLnkPopWinFeat : "弹出窗口属性", DlgLnkPopResize : "调整大小", DlgLnkPopLocation : "地址栏", DlgLnkPopMenu : "菜单栏", DlgLnkPopScroll : "滚动条", DlgLnkPopStatus : "状态栏", DlgLnkPopToolbar : "工具栏", DlgLnkPopFullScrn : "全屏 (IE)", DlgLnkPopDependent : "依附 (NS)", DlgLnkPopWidth : "宽", DlgLnkPopHeight : "高", DlgLnkPopLeft : "左", DlgLnkPopTop : "右", DlnLnkMsgNoUrl : "请输入超链接地址", DlnLnkMsgNoEMail : "请输入电子邮件地址", DlnLnkMsgNoAnchor : "请选择一个锚点", DlnLnkMsgInvPopName : "弹出窗口名称必须以字母开头,并且不能含有空格。", // Color Dialog DlgColorTitle : "选择颜色", DlgColorBtnClear : "清除", DlgColorHighlight : "预览", DlgColorSelected : "选择", // Smiley Dialog DlgSmileyTitle : "插入表情图标", // Special Character Dialog DlgSpecialCharTitle : "选择特殊符号", // Table Dialog DlgTableTitle : "表格属性", DlgTableRows : "行数", DlgTableColumns : "列数", DlgTableBorder : "边框", DlgTableAlign : "对齐", DlgTableAlignNotSet : "<没有设置>", DlgTableAlignLeft : "左对齐", DlgTableAlignCenter : "居中", DlgTableAlignRight : "右对齐", DlgTableWidth : "宽度", DlgTableWidthPx : "像素", DlgTableWidthPc : "百分比", DlgTableHeight : "高度", DlgTableCellSpace : "间距", DlgTableCellPad : "边距", DlgTableCaption : "标题", DlgTableSummary : "摘要", DlgTableHeaders : "标题单元格", DlgTableHeadersNone : "无", DlgTableHeadersColumn : "第一列", DlgTableHeadersRow : "第一行", DlgTableHeadersBoth : "第一列和第一行", // Table Cell Dialog DlgCellTitle : "单元格属性", DlgCellWidth : "宽度", DlgCellWidthPx : "像素", DlgCellWidthPc : "百分比", DlgCellHeight : "高度", DlgCellWordWrap : "自动换行", DlgCellWordWrapNotSet : "<没有设置>", DlgCellWordWrapYes : "是", DlgCellWordWrapNo : "否", DlgCellHorAlign : "水平对齐", DlgCellHorAlignNotSet : "<没有设置>", DlgCellHorAlignLeft : "左对齐", DlgCellHorAlignCenter : "居中", DlgCellHorAlignRight: "右对齐", DlgCellVerAlign : "垂直对齐", DlgCellVerAlignNotSet : "<没有设置>", DlgCellVerAlignTop : "顶端", DlgCellVerAlignMiddle : "居中", DlgCellVerAlignBottom : "底部", DlgCellVerAlignBaseline : "基线", DlgCellType : "单元格类型", DlgCellTypeData : "资料", DlgCellTypeHeader : "标题", DlgCellRowSpan : "纵跨行数", DlgCellCollSpan : "横跨列数", DlgCellBackColor : "背景颜色", DlgCellBorderColor : "边框颜色", DlgCellBtnSelect : "选择...", // Find and Replace Dialog DlgFindAndReplaceTitle : "查找和替换", // Find Dialog DlgFindTitle : "查找", DlgFindFindBtn : "查找", DlgFindNotFoundMsg : "指定文本没有找到。", // Replace Dialog DlgReplaceTitle : "替换", DlgReplaceFindLbl : "查找:", DlgReplaceReplaceLbl : "替换:", DlgReplaceCaseChk : "区分大小写", DlgReplaceReplaceBtn : "替换", DlgReplaceReplAllBtn : "全部替换", DlgReplaceWordChk : "全字匹配", // Paste Operations / Dialog PasteErrorCut : "您的浏览器安全设置不允许编辑器自动执行剪切操作,请使用键盘快捷键(Ctrl+X)来完成。", PasteErrorCopy : "您的浏览器安全设置不允许编辑器自动执行复制操作,请使用键盘快捷键(Ctrl+C)来完成。", PasteAsText : "粘贴为无格式文本", PasteFromWord : "从 MS Word 粘贴", DlgPasteMsg2 : "请使用键盘快捷键(<STRONG>Ctrl+V</STRONG>)把内容粘贴到下面的方框里,再按 <STRONG>确定</STRONG>。", DlgPasteSec : "因为你的浏览器的安全设置原因,本编辑器不能直接访问你的剪贴板内容,你需要在本窗口重新粘贴一次。", DlgPasteIgnoreFont : "忽略 Font 标签", DlgPasteRemoveStyles : "清理 CSS 样式", // Color Picker ColorAutomatic : "自动", ColorMoreColors : "其它颜色...", // Document Properties DocProps : "页面属性", // Anchor Dialog DlgAnchorTitle : "命名锚点", DlgAnchorName : "锚点名称", DlgAnchorErrorName : "请输入锚点名称", // Speller Pages Dialog DlgSpellNotInDic : "没有在字典里", DlgSpellChangeTo : "更改为", DlgSpellBtnIgnore : "忽略", DlgSpellBtnIgnoreAll : "全部忽略", DlgSpellBtnReplace : "替换", DlgSpellBtnReplaceAll : "全部替换", DlgSpellBtnUndo : "撤消", DlgSpellNoSuggestions : "- 没有建议 -", DlgSpellProgress : "正在进行拼写检查...", DlgSpellNoMispell : "拼写检查完成:没有发现拼写错误", DlgSpellNoChanges : "拼写检查完成:没有更改任何单词", DlgSpellOneChange : "拼写检查完成:更改了一个单词", DlgSpellManyChanges : "拼写检查完成:更改了 %1 个单词", IeSpellDownload : "拼写检查插件还没安装,你是否想现在就下载?", // Button Dialog DlgButtonText : "标签(值)", DlgButtonType : "类型", DlgButtonTypeBtn : "按钮", DlgButtonTypeSbm : "提交", DlgButtonTypeRst : "重设", // Checkbox and Radio Button Dialogs DlgCheckboxName : "名称", DlgCheckboxValue : "选定值", DlgCheckboxSelected : "已勾选", // Form Dialog DlgFormName : "名称", DlgFormAction : "动作", DlgFormMethod : "方法", // Select Field Dialog DlgSelectName : "名称", DlgSelectValue : "选定", DlgSelectSize : "高度", DlgSelectLines : "行", DlgSelectChkMulti : "允许多选", DlgSelectOpAvail : "列表值", DlgSelectOpText : "标签", DlgSelectOpValue : "值", DlgSelectBtnAdd : "新增", DlgSelectBtnModify : "修改", DlgSelectBtnUp : "上移", DlgSelectBtnDown : "下移", DlgSelectBtnSetValue : "设为初始化时选定", DlgSelectBtnDelete : "删除", // Textarea Dialog DlgTextareaName : "名称", DlgTextareaCols : "字符宽度", DlgTextareaRows : "行数", // Text Field Dialog DlgTextName : "名称", DlgTextValue : "初始值", DlgTextCharWidth : "字符宽度", DlgTextMaxChars : "最多字符数", DlgTextType : "类型", DlgTextTypeText : "文本", DlgTextTypePass : "密码", // Hidden Field Dialog DlgHiddenName : "名称", DlgHiddenValue : "初始值", // Bulleted List Dialog BulletedListProp : "项目列表属性", NumberedListProp : "编号列表属性", DlgLstStart : "开始序号", DlgLstType : "列表类型", DlgLstTypeCircle : "圆圈", DlgLstTypeDisc : "圆点", DlgLstTypeSquare : "方块", DlgLstTypeNumbers : "数字 (1, 2, 3)", DlgLstTypeLCase : "小写字母 (a, b, c)", DlgLstTypeUCase : "大写字母 (A, B, C)", DlgLstTypeSRoman : "小写罗马数字 (i, ii, iii)", DlgLstTypeLRoman : "大写罗马数字 (I, II, III)", // Document Properties Dialog DlgDocGeneralTab : "常规", DlgDocBackTab : "背景", DlgDocColorsTab : "颜色和边距", DlgDocMetaTab : "Meta 数据", DlgDocPageTitle : "页面标题", DlgDocLangDir : "语言方向", DlgDocLangDirLTR : "从左到右 (LTR)", DlgDocLangDirRTL : "从右到左 (RTL)", DlgDocLangCode : "语言代码", DlgDocCharSet : "字符编码", DlgDocCharSetCE : "中欧", DlgDocCharSetCT : "繁体中文 (Big5)", DlgDocCharSetCR : "西里尔文", DlgDocCharSetGR : "希腊文", DlgDocCharSetJP : "日文", DlgDocCharSetKR : "韩文", DlgDocCharSetTR : "土耳其文", DlgDocCharSetUN : "Unicode (UTF-8)", DlgDocCharSetWE : "西欧", DlgDocCharSetOther : "其它字符编码", DlgDocDocType : "文档类型", DlgDocDocTypeOther : "其它文档类型", DlgDocIncXHTML : "包含 XHTML 声明", DlgDocBgColor : "背景颜色", DlgDocBgImage : "背景图像", DlgDocBgNoScroll : "不滚动背景图像", DlgDocCText : "文本", DlgDocCLink : "超链接", DlgDocCVisited : "已访问的超链接", DlgDocCActive : "活动超链接", DlgDocMargins : "页面边距", DlgDocMaTop : "上", DlgDocMaLeft : "左", DlgDocMaRight : "右", DlgDocMaBottom : "下", DlgDocMeIndex : "页面索引关键字 (用半角逗号[,]分隔)", DlgDocMeDescr : "页面说明", DlgDocMeAuthor : "作者", DlgDocMeCopy : "版权", DlgDocPreview : "预览", // Templates Dialog Templates : "模板", DlgTemplatesTitle : "内容模板", DlgTemplatesSelMsg : "请选择编辑器内容模板:", DlgTemplatesLoading : "正在加载模板列表,请稍等...", DlgTemplatesNoTpl : "(没有模板)", DlgTemplatesReplace : "替换当前内容", // About Dialog DlgAboutAboutTab : "关于", DlgAboutBrowserInfoTab : "浏览器信息", DlgAboutLicenseTab : "许可证", DlgAboutVersion : "版本", DlgAboutInfo : "要获得更多信息请访问 ", // Div Dialog DlgDivGeneralTab : "常规", DlgDivAdvancedTab : "高级", DlgDivStyle : "样式", DlgDivInlineStyle : "CSS 样式" };
JavaScript
/* * 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 == * * English language file. */ var FCKLang = { // Language direction : "ltr" (left to right) or "rtl" (right to left). Dir : "ltr", ToolbarCollapse : "Collapse Toolbar", ToolbarExpand : "Expand Toolbar", // Toolbar Items and Context Menu Save : "Save", NewPage : "New Page", Preview : "Preview", Cut : "Cut", Copy : "Copy", Paste : "Paste", PasteText : "Paste as plain text", PasteWord : "Paste from Word", Print : "Print", SelectAll : "Select All", RemoveFormat : "Remove Format", InsertLinkLbl : "Link", InsertLink : "Insert/Edit Link", RemoveLink : "Remove Link", VisitLink : "Open Link", Anchor : "Insert/Edit Anchor", AnchorDelete : "Remove Anchor", InsertImageLbl : "Image", InsertImage : "Insert/Edit Image", InsertFlashLbl : "Flash", InsertFlash : "Insert/Edit Flash", InsertTableLbl : "Table", InsertTable : "Insert/Edit Table", InsertLineLbl : "Line", InsertLine : "Insert Horizontal Line", InsertSpecialCharLbl: "Special Character", InsertSpecialChar : "Insert Special Character", InsertSmileyLbl : "Smiley", InsertSmiley : "Insert Smiley", About : "About FCKeditor", Bold : "Bold", Italic : "Italic", Underline : "Underline", StrikeThrough : "Strike Through", Subscript : "Subscript", Superscript : "Superscript", LeftJustify : "Left Justify", CenterJustify : "Center Justify", RightJustify : "Right Justify", BlockJustify : "Block Justify", DecreaseIndent : "Decrease Indent", IncreaseIndent : "Increase Indent", Blockquote : "Blockquote", CreateDiv : "Create Div Container", EditDiv : "Edit Div Container", DeleteDiv : "Remove Div Container", Undo : "Undo", Redo : "Redo", NumberedListLbl : "Numbered List", NumberedList : "Insert/Remove Numbered List", BulletedListLbl : "Bulleted List", BulletedList : "Insert/Remove Bulleted List", ShowTableBorders : "Show Table Borders", ShowDetails : "Show Details", Style : "Style", FontFormat : "Format", Font : "Font", FontSize : "Size", TextColor : "Text Color", BGColor : "Background Color", Source : "Source", Find : "Find", Replace : "Replace", SpellCheck : "Check Spelling", UniversalKeyboard : "Universal Keyboard", PageBreakLbl : "Page Break", PageBreak : "Insert Page Break", Form : "Form", Checkbox : "Checkbox", RadioButton : "Radio Button", TextField : "Text Field", Textarea : "Textarea", HiddenField : "Hidden Field", Button : "Button", SelectionField : "Selection Field", ImageButton : "Image Button", FitWindow : "Maximize the editor size", ShowBlocks : "Show Blocks", // Context Menu EditLink : "Edit Link", CellCM : "Cell", RowCM : "Row", ColumnCM : "Column", InsertRowAfter : "Insert Row After", InsertRowBefore : "Insert Row Before", DeleteRows : "Delete Rows", InsertColumnAfter : "Insert Column After", InsertColumnBefore : "Insert Column Before", DeleteColumns : "Delete Columns", InsertCellAfter : "Insert Cell After", InsertCellBefore : "Insert Cell Before", DeleteCells : "Delete Cells", MergeCells : "Merge Cells", MergeRight : "Merge Right", MergeDown : "Merge Down", HorizontalSplitCell : "Split Cell Horizontally", VerticalSplitCell : "Split Cell Vertically", TableDelete : "Delete Table", CellProperties : "Cell Properties", TableProperties : "Table Properties", ImageProperties : "Image Properties", FlashProperties : "Flash Properties", AnchorProp : "Anchor Properties", ButtonProp : "Button Properties", CheckboxProp : "Checkbox Properties", HiddenFieldProp : "Hidden Field Properties", RadioButtonProp : "Radio Button Properties", ImageButtonProp : "Image Button Properties", TextFieldProp : "Text Field Properties", SelectionFieldProp : "Selection Field Properties", TextareaProp : "Textarea Properties", FormProp : "Form Properties", FontFormats : "Normal;Formatted;Address;Heading 1;Heading 2;Heading 3;Heading 4;Heading 5;Heading 6;Normal (DIV)", // Alerts and Messages ProcessingXHTML : "Processing XHTML. Please wait...", Done : "Done", PasteWordConfirm : "The text you want to paste seems to be copied from Word. Do you want to clean it before pasting?", NotCompatiblePaste : "This command is available for Internet Explorer version 5.5 or more. Do you want to paste without cleaning?", UnknownToolbarItem : "Unknown toolbar item \"%1\"", UnknownCommand : "Unknown command name \"%1\"", NotImplemented : "Command not implemented", UnknownToolbarSet : "Toolbar set \"%1\" doesn't exist", NoActiveX : "Your browser's security settings could limit some features of the editor. You must enable the option \"Run ActiveX controls and plug-ins\". You may experience errors and notice missing features.", BrowseServerBlocked : "The resources browser could not be opened. Make sure that all popup blockers are disabled.", DialogBlocked : "It was not possible to open the dialog window. Make sure all popup blockers are disabled.", VisitLinkBlocked : "It was not possible to open a new window. Make sure all popup blockers are disabled.", // Dialogs DlgBtnOK : "OK", DlgBtnCancel : "Cancel", DlgBtnClose : "Close", DlgBtnBrowseServer : "Browse Server", DlgAdvancedTag : "Advanced", DlgOpOther : "<Other>", DlgInfoTab : "Info", DlgAlertUrl : "Please insert the URL", // General Dialogs Labels DlgGenNotSet : "<not set>", DlgGenId : "Id", DlgGenLangDir : "Language Direction", DlgGenLangDirLtr : "Left to Right (LTR)", DlgGenLangDirRtl : "Right to Left (RTL)", DlgGenLangCode : "Language Code", DlgGenAccessKey : "Access Key", DlgGenName : "Name", DlgGenTabIndex : "Tab Index", DlgGenLongDescr : "Long Description URL", DlgGenClass : "Stylesheet Classes", DlgGenTitle : "Advisory Title", DlgGenContType : "Advisory Content Type", DlgGenLinkCharset : "Linked Resource Charset", DlgGenStyle : "Style", // Image Dialog DlgImgTitle : "Image Properties", DlgImgInfoTab : "Image Info", DlgImgBtnUpload : "Send it to the Server", DlgImgURL : "URL", DlgImgUpload : "Upload", DlgImgAlt : "Alternative Text", DlgImgWidth : "Width", DlgImgHeight : "Height", DlgImgLockRatio : "Lock Ratio", DlgBtnResetSize : "Reset Size", DlgImgBorder : "Border", DlgImgHSpace : "HSpace", DlgImgVSpace : "VSpace", DlgImgAlign : "Align", DlgImgAlignLeft : "Left", DlgImgAlignAbsBottom: "Abs Bottom", DlgImgAlignAbsMiddle: "Abs Middle", DlgImgAlignBaseline : "Baseline", DlgImgAlignBottom : "Bottom", DlgImgAlignMiddle : "Middle", DlgImgAlignRight : "Right", DlgImgAlignTextTop : "Text Top", DlgImgAlignTop : "Top", DlgImgPreview : "Preview", DlgImgAlertUrl : "Please type the image URL", DlgImgLinkTab : "Link", // Flash Dialog DlgFlashTitle : "Flash Properties", DlgFlashChkPlay : "Auto Play", DlgFlashChkLoop : "Loop", DlgFlashChkMenu : "Enable Flash Menu", DlgFlashScale : "Scale", DlgFlashScaleAll : "Show all", DlgFlashScaleNoBorder : "No Border", DlgFlashScaleFit : "Exact Fit", // Link Dialog DlgLnkWindowTitle : "Link", DlgLnkInfoTab : "Link Info", DlgLnkTargetTab : "Target", DlgLnkType : "Link Type", DlgLnkTypeURL : "URL", DlgLnkTypeAnchor : "Link to anchor in the text", DlgLnkTypeEMail : "E-Mail", DlgLnkProto : "Protocol", DlgLnkProtoOther : "<other>", DlgLnkURL : "URL", DlgLnkAnchorSel : "Select an Anchor", DlgLnkAnchorByName : "By Anchor Name", DlgLnkAnchorById : "By Element Id", DlgLnkNoAnchors : "(No anchors available in the document)", DlgLnkEMail : "E-Mail Address", DlgLnkEMailSubject : "Message Subject", DlgLnkEMailBody : "Message Body", DlgLnkUpload : "Upload", DlgLnkBtnUpload : "Send it to the Server", DlgLnkTarget : "Target", DlgLnkTargetFrame : "<frame>", DlgLnkTargetPopup : "<popup window>", DlgLnkTargetBlank : "New Window (_blank)", DlgLnkTargetParent : "Parent Window (_parent)", DlgLnkTargetSelf : "Same Window (_self)", DlgLnkTargetTop : "Topmost Window (_top)", DlgLnkTargetFrameName : "Target Frame Name", DlgLnkPopWinName : "Popup Window Name", DlgLnkPopWinFeat : "Popup Window Features", DlgLnkPopResize : "Resizable", DlgLnkPopLocation : "Location Bar", DlgLnkPopMenu : "Menu Bar", DlgLnkPopScroll : "Scroll Bars", DlgLnkPopStatus : "Status Bar", DlgLnkPopToolbar : "Toolbar", DlgLnkPopFullScrn : "Full Screen (IE)", DlgLnkPopDependent : "Dependent (Netscape)", DlgLnkPopWidth : "Width", DlgLnkPopHeight : "Height", DlgLnkPopLeft : "Left Position", DlgLnkPopTop : "Top Position", DlnLnkMsgNoUrl : "Please type the link URL", DlnLnkMsgNoEMail : "Please type the e-mail address", DlnLnkMsgNoAnchor : "Please select an anchor", DlnLnkMsgInvPopName : "The popup name must begin with an alphabetic character and must not contain spaces", // Color Dialog DlgColorTitle : "Select Color", DlgColorBtnClear : "Clear", DlgColorHighlight : "Highlight", DlgColorSelected : "Selected", // Smiley Dialog DlgSmileyTitle : "Insert a Smiley", // Special Character Dialog DlgSpecialCharTitle : "Select Special Character", // Table Dialog DlgTableTitle : "Table Properties", DlgTableRows : "Rows", DlgTableColumns : "Columns", DlgTableBorder : "Border size", DlgTableAlign : "Alignment", DlgTableAlignNotSet : "<Not set>", DlgTableAlignLeft : "Left", DlgTableAlignCenter : "Center", DlgTableAlignRight : "Right", DlgTableWidth : "Width", DlgTableWidthPx : "pixels", DlgTableWidthPc : "percent", DlgTableHeight : "Height", DlgTableCellSpace : "Cell spacing", DlgTableCellPad : "Cell padding", DlgTableCaption : "Caption", DlgTableSummary : "Summary", DlgTableHeaders : "Headers", DlgTableHeadersNone : "None", DlgTableHeadersColumn : "First column", DlgTableHeadersRow : "First Row", DlgTableHeadersBoth : "Both", // Table Cell Dialog DlgCellTitle : "Cell Properties", DlgCellWidth : "Width", DlgCellWidthPx : "pixels", DlgCellWidthPc : "percent", DlgCellHeight : "Height", DlgCellWordWrap : "Word Wrap", DlgCellWordWrapNotSet : "<Not set>", DlgCellWordWrapYes : "Yes", DlgCellWordWrapNo : "No", DlgCellHorAlign : "Horizontal Alignment", DlgCellHorAlignNotSet : "<Not set>", DlgCellHorAlignLeft : "Left", DlgCellHorAlignCenter : "Center", DlgCellHorAlignRight: "Right", DlgCellVerAlign : "Vertical Alignment", DlgCellVerAlignNotSet : "<Not set>", DlgCellVerAlignTop : "Top", DlgCellVerAlignMiddle : "Middle", DlgCellVerAlignBottom : "Bottom", DlgCellVerAlignBaseline : "Baseline", DlgCellType : "Cell Type", DlgCellTypeData : "Data", DlgCellTypeHeader : "Header", DlgCellRowSpan : "Rows Span", DlgCellCollSpan : "Columns Span", DlgCellBackColor : "Background Color", DlgCellBorderColor : "Border Color", DlgCellBtnSelect : "Select...", // Find and Replace Dialog DlgFindAndReplaceTitle : "Find and Replace", // Find Dialog DlgFindTitle : "Find", DlgFindFindBtn : "Find", DlgFindNotFoundMsg : "The specified text was not found.", // Replace Dialog DlgReplaceTitle : "Replace", DlgReplaceFindLbl : "Find what:", DlgReplaceReplaceLbl : "Replace with:", DlgReplaceCaseChk : "Match case", DlgReplaceReplaceBtn : "Replace", DlgReplaceReplAllBtn : "Replace All", DlgReplaceWordChk : "Match whole word", // Paste Operations / Dialog PasteErrorCut : "Your browser security settings don't permit the editor to automatically execute cutting operations. Please use the keyboard for that (Ctrl+X).", PasteErrorCopy : "Your browser security settings don't permit the editor to automatically execute copying operations. Please use the keyboard for that (Ctrl+C).", PasteAsText : "Paste as Plain Text", PasteFromWord : "Paste from Word", DlgPasteMsg2 : "Please paste inside the following box using the keyboard (<strong>Ctrl+V</strong>) and hit <strong>OK</strong>.", DlgPasteSec : "Because of your browser security settings, the editor is not able to access your clipboard data directly. You are required to paste it again in this window.", DlgPasteIgnoreFont : "Ignore Font Face definitions", DlgPasteRemoveStyles : "Remove Styles definitions", // Color Picker ColorAutomatic : "Automatic", ColorMoreColors : "More Colors...", // Document Properties DocProps : "Document Properties", // Anchor Dialog DlgAnchorTitle : "Anchor Properties", DlgAnchorName : "Anchor Name", DlgAnchorErrorName : "Please type the anchor name", // Speller Pages Dialog DlgSpellNotInDic : "Not in dictionary", DlgSpellChangeTo : "Change to", DlgSpellBtnIgnore : "Ignore", DlgSpellBtnIgnoreAll : "Ignore All", DlgSpellBtnReplace : "Replace", DlgSpellBtnReplaceAll : "Replace All", DlgSpellBtnUndo : "Undo", DlgSpellNoSuggestions : "- No suggestions -", DlgSpellProgress : "Spell check in progress...", DlgSpellNoMispell : "Spell check complete: No misspellings found", DlgSpellNoChanges : "Spell check complete: No words changed", DlgSpellOneChange : "Spell check complete: One word changed", DlgSpellManyChanges : "Spell check complete: %1 words changed", IeSpellDownload : "Spell checker not installed. Do you want to download it now?", // Button Dialog DlgButtonText : "Text (Value)", DlgButtonType : "Type", DlgButtonTypeBtn : "Button", DlgButtonTypeSbm : "Submit", DlgButtonTypeRst : "Reset", // Checkbox and Radio Button Dialogs DlgCheckboxName : "Name", DlgCheckboxValue : "Value", DlgCheckboxSelected : "Selected", // Form Dialog DlgFormName : "Name", DlgFormAction : "Action", DlgFormMethod : "Method", // Select Field Dialog DlgSelectName : "Name", DlgSelectValue : "Value", DlgSelectSize : "Size", DlgSelectLines : "lines", DlgSelectChkMulti : "Allow multiple selections", DlgSelectOpAvail : "Available Options", DlgSelectOpText : "Text", DlgSelectOpValue : "Value", DlgSelectBtnAdd : "Add", DlgSelectBtnModify : "Modify", DlgSelectBtnUp : "Up", DlgSelectBtnDown : "Down", DlgSelectBtnSetValue : "Set as selected value", DlgSelectBtnDelete : "Delete", // Textarea Dialog DlgTextareaName : "Name", DlgTextareaCols : "Columns", DlgTextareaRows : "Rows", // Text Field Dialog DlgTextName : "Name", DlgTextValue : "Value", DlgTextCharWidth : "Character Width", DlgTextMaxChars : "Maximum Characters", DlgTextType : "Type", DlgTextTypeText : "Text", DlgTextTypePass : "Password", // Hidden Field Dialog DlgHiddenName : "Name", DlgHiddenValue : "Value", // Bulleted List Dialog BulletedListProp : "Bulleted List Properties", NumberedListProp : "Numbered List Properties", DlgLstStart : "Start", DlgLstType : "Type", DlgLstTypeCircle : "Circle", DlgLstTypeDisc : "Disc", DlgLstTypeSquare : "Square", DlgLstTypeNumbers : "Numbers (1, 2, 3)", DlgLstTypeLCase : "Lowercase Letters (a, b, c)", DlgLstTypeUCase : "Uppercase Letters (A, B, C)", DlgLstTypeSRoman : "Small Roman Numerals (i, ii, iii)", DlgLstTypeLRoman : "Large Roman Numerals (I, II, III)", // Document Properties Dialog DlgDocGeneralTab : "General", DlgDocBackTab : "Background", DlgDocColorsTab : "Colors and Margins", DlgDocMetaTab : "Meta Data", DlgDocPageTitle : "Page Title", DlgDocLangDir : "Language Direction", DlgDocLangDirLTR : "Left to Right (LTR)", DlgDocLangDirRTL : "Right to Left (RTL)", DlgDocLangCode : "Language Code", DlgDocCharSet : "Character Set Encoding", DlgDocCharSetCE : "Central European", DlgDocCharSetCT : "Chinese Traditional (Big5)", DlgDocCharSetCR : "Cyrillic", DlgDocCharSetGR : "Greek", DlgDocCharSetJP : "Japanese", DlgDocCharSetKR : "Korean", DlgDocCharSetTR : "Turkish", DlgDocCharSetUN : "Unicode (UTF-8)", DlgDocCharSetWE : "Western European", DlgDocCharSetOther : "Other Character Set Encoding", DlgDocDocType : "Document Type Heading", DlgDocDocTypeOther : "Other Document Type Heading", DlgDocIncXHTML : "Include XHTML Declarations", DlgDocBgColor : "Background Color", DlgDocBgImage : "Background Image URL", DlgDocBgNoScroll : "Nonscrolling Background", DlgDocCText : "Text", DlgDocCLink : "Link", DlgDocCVisited : "Visited Link", DlgDocCActive : "Active Link", DlgDocMargins : "Page Margins", DlgDocMaTop : "Top", DlgDocMaLeft : "Left", DlgDocMaRight : "Right", DlgDocMaBottom : "Bottom", DlgDocMeIndex : "Document Indexing Keywords (comma separated)", DlgDocMeDescr : "Document Description", DlgDocMeAuthor : "Author", DlgDocMeCopy : "Copyright", DlgDocPreview : "Preview", // Templates Dialog Templates : "Templates", DlgTemplatesTitle : "Content Templates", DlgTemplatesSelMsg : "Please select the template to open in the editor<br />(the actual contents will be lost):", DlgTemplatesLoading : "Loading templates list. Please wait...", DlgTemplatesNoTpl : "(No templates defined)", DlgTemplatesReplace : "Replace actual contents", // About Dialog DlgAboutAboutTab : "About", DlgAboutBrowserInfoTab : "Browser Info", DlgAboutLicenseTab : "License", DlgAboutVersion : "version", DlgAboutInfo : "For further information go to", // Div Dialog DlgDivGeneralTab : "General", DlgDivAdvancedTab : "Advanced", DlgDivStyle : "Style", DlgDivInlineStyle : "Inline Style" };
JavaScript
/* * 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 == * * Chinese Traditional language file. */ var FCKLang = { // Language direction : "ltr" (left to right) or "rtl" (right to left). Dir : "ltr", ToolbarCollapse : "隱藏面板", ToolbarExpand : "顯示面板", // Toolbar Items and Context Menu Save : "儲存", NewPage : "開新檔案", Preview : "預覽", Cut : "剪下", Copy : "複製", Paste : "貼上", PasteText : "貼為純文字格式", PasteWord : "自 Word 貼上", Print : "列印", SelectAll : "全選", RemoveFormat : "清除格式", InsertLinkLbl : "超連結", InsertLink : "插入/編輯超連結", RemoveLink : "移除超連結", VisitLink : "開啟超連結", Anchor : "插入/編輯錨點", AnchorDelete : "移除錨點", InsertImageLbl : "影像", InsertImage : "插入/編輯影像", InsertFlashLbl : "Flash", InsertFlash : "插入/編輯 Flash", InsertTableLbl : "表格", InsertTable : "插入/編輯表格", InsertLineLbl : "水平線", InsertLine : "插入水平線", InsertSpecialCharLbl: "特殊符號", InsertSpecialChar : "插入特殊符號", InsertSmileyLbl : "表情符號", InsertSmiley : "插入表情符號", About : "關於 FCKeditor", Bold : "粗體", Italic : "斜體", Underline : "底線", StrikeThrough : "刪除線", Subscript : "下標", Superscript : "上標", LeftJustify : "靠左對齊", CenterJustify : "置中", RightJustify : "靠右對齊", BlockJustify : "左右對齊", DecreaseIndent : "減少縮排", IncreaseIndent : "增加縮排", Blockquote : "引用文字", CreateDiv : "新增 Div 標籤", EditDiv : "變更 Div 標籤", DeleteDiv : "移除 Div 標籤", Undo : "復原", Redo : "重複", NumberedListLbl : "編號清單", NumberedList : "插入/移除編號清單", BulletedListLbl : "項目清單", BulletedList : "插入/移除項目清單", ShowTableBorders : "顯示表格邊框", ShowDetails : "顯示詳細資料", Style : "樣式", FontFormat : "格式", Font : "字體", FontSize : "大小", TextColor : "文字顏色", BGColor : "背景顏色", Source : "原始碼", Find : "尋找", Replace : "取代", SpellCheck : "拼字檢查", UniversalKeyboard : "萬國鍵盤", PageBreakLbl : "分頁符號", PageBreak : "插入分頁符號", Form : "表單", Checkbox : "核取方塊", RadioButton : "選項按鈕", TextField : "文字方塊", Textarea : "文字區域", HiddenField : "隱藏欄位", Button : "按鈕", SelectionField : "清單/選單", ImageButton : "影像按鈕", FitWindow : "編輯器最大化", ShowBlocks : "顯示區塊", // Context Menu EditLink : "編輯超連結", CellCM : "儲存格", RowCM : "列", ColumnCM : "欄", InsertRowAfter : "向下插入列", InsertRowBefore : "向上插入列", DeleteRows : "刪除列", InsertColumnAfter : "向右插入欄", InsertColumnBefore : "向左插入欄", DeleteColumns : "刪除欄", InsertCellAfter : "向右插入儲存格", InsertCellBefore : "向左插入儲存格", DeleteCells : "刪除儲存格", MergeCells : "合併儲存格", MergeRight : "向右合併儲存格", MergeDown : "向下合併儲存格", HorizontalSplitCell : "橫向分割儲存格", VerticalSplitCell : "縱向分割儲存格", TableDelete : "刪除表格", CellProperties : "儲存格屬性", TableProperties : "表格屬性", ImageProperties : "影像屬性", FlashProperties : "Flash 屬性", AnchorProp : "錨點屬性", ButtonProp : "按鈕屬性", CheckboxProp : "核取方塊屬性", HiddenFieldProp : "隱藏欄位屬性", RadioButtonProp : "選項按鈕屬性", ImageButtonProp : "影像按鈕屬性", TextFieldProp : "文字方塊屬性", SelectionFieldProp : "清單/選單屬性", TextareaProp : "文字區域屬性", FormProp : "表單屬性", FontFormats : "一般;已格式化;位址;標題 1;標題 2;標題 3;標題 4;標題 5;標題 6;一般 (DIV)", // Alerts and Messages ProcessingXHTML : "處理 XHTML 中,請稍候…", Done : "完成", PasteWordConfirm : "您想貼上的文字似乎是自 Word 複製而來,請問您是否要先清除 Word 的格式後再行貼上?", NotCompatiblePaste : "此指令僅在 Internet Explorer 5.5 或以上的版本有效。請問您是否同意不清除格式即貼上?", UnknownToolbarItem : "未知工具列項目 \"%1\"", UnknownCommand : "未知指令名稱 \"%1\"", NotImplemented : "尚未安裝此指令", UnknownToolbarSet : "工具列設定 \"%1\" 不存在", NoActiveX : "瀏覽器的安全性設定限制了本編輯器的某些功能。您必須啟用安全性設定中的「執行ActiveX控制項與外掛程式」項目,否則本編輯器將會出現錯誤並缺少某些功能", BrowseServerBlocked : "無法開啟資源瀏覽器,請確定所有快顯視窗封鎖程式是否關閉", DialogBlocked : "無法開啟對話視窗,請確定所有快顯視窗封鎖程式是否關閉", VisitLinkBlocked : "無法開啟新視窗,請確定所有快顯視窗封鎖程式是否關閉", // Dialogs DlgBtnOK : "確定", DlgBtnCancel : "取消", DlgBtnClose : "關閉", DlgBtnBrowseServer : "瀏覽伺服器端", DlgAdvancedTag : "進階", DlgOpOther : "<其他>", DlgInfoTab : "資訊", DlgAlertUrl : "請插入 URL", // General Dialogs Labels DlgGenNotSet : "<尚未設定>", DlgGenId : "ID", DlgGenLangDir : "語言方向", DlgGenLangDirLtr : "由左而右 (LTR)", DlgGenLangDirRtl : "由右而左 (RTL)", DlgGenLangCode : "語言代碼", DlgGenAccessKey : "存取鍵", DlgGenName : "名稱", DlgGenTabIndex : "定位順序", DlgGenLongDescr : "詳細 URL", DlgGenClass : "樣式表類別", DlgGenTitle : "標題", DlgGenContType : "內容類型", DlgGenLinkCharset : "連結資源之編碼", DlgGenStyle : "樣式", // Image Dialog DlgImgTitle : "影像屬性", DlgImgInfoTab : "影像資訊", DlgImgBtnUpload : "上傳至伺服器", DlgImgURL : "URL", DlgImgUpload : "上傳", DlgImgAlt : "替代文字", DlgImgWidth : "寬度", DlgImgHeight : "高度", DlgImgLockRatio : "等比例", DlgBtnResetSize : "重設為原大小", DlgImgBorder : "邊框", DlgImgHSpace : "水平距離", DlgImgVSpace : "垂直距離", DlgImgAlign : "對齊", DlgImgAlignLeft : "靠左對齊", DlgImgAlignAbsBottom: "絕對下方", DlgImgAlignAbsMiddle: "絕對中間", DlgImgAlignBaseline : "基準線", DlgImgAlignBottom : "靠下對齊", DlgImgAlignMiddle : "置中對齊", DlgImgAlignRight : "靠右對齊", DlgImgAlignTextTop : "文字上方", DlgImgAlignTop : "靠上對齊", DlgImgPreview : "預覽", DlgImgAlertUrl : "請輸入影像 URL", DlgImgLinkTab : "超連結", // Flash Dialog DlgFlashTitle : "Flash 屬性", DlgFlashChkPlay : "自動播放", DlgFlashChkLoop : "重複", DlgFlashChkMenu : "開啟選單", DlgFlashScale : "縮放", DlgFlashScaleAll : "全部顯示", DlgFlashScaleNoBorder : "無邊框", DlgFlashScaleFit : "精確符合", // Link Dialog DlgLnkWindowTitle : "超連結", DlgLnkInfoTab : "超連結資訊", DlgLnkTargetTab : "目標", DlgLnkType : "超連接類型", DlgLnkTypeURL : "URL", DlgLnkTypeAnchor : "本頁錨點", DlgLnkTypeEMail : "電子郵件", DlgLnkProto : "通訊協定", DlgLnkProtoOther : "<其他>", DlgLnkURL : "URL", DlgLnkAnchorSel : "請選擇錨點", DlgLnkAnchorByName : "依錨點名稱", DlgLnkAnchorById : "依元件 ID", DlgLnkNoAnchors : "(本文件尚無可用之錨點)", DlgLnkEMail : "電子郵件", DlgLnkEMailSubject : "郵件主旨", DlgLnkEMailBody : "郵件內容", DlgLnkUpload : "上傳", DlgLnkBtnUpload : "傳送至伺服器", DlgLnkTarget : "目標", DlgLnkTargetFrame : "<框架>", DlgLnkTargetPopup : "<快顯視窗>", DlgLnkTargetBlank : "新視窗 (_blank)", DlgLnkTargetParent : "父視窗 (_parent)", DlgLnkTargetSelf : "本視窗 (_self)", DlgLnkTargetTop : "最上層視窗 (_top)", DlgLnkTargetFrameName : "目標框架名稱", DlgLnkPopWinName : "快顯視窗名稱", DlgLnkPopWinFeat : "快顯視窗屬性", DlgLnkPopResize : "可調整大小", DlgLnkPopLocation : "網址列", DlgLnkPopMenu : "選單列", DlgLnkPopScroll : "捲軸", DlgLnkPopStatus : "狀態列", DlgLnkPopToolbar : "工具列", DlgLnkPopFullScrn : "全螢幕 (IE)", DlgLnkPopDependent : "從屬 (NS)", DlgLnkPopWidth : "寬", DlgLnkPopHeight : "高", DlgLnkPopLeft : "左", DlgLnkPopTop : "右", DlnLnkMsgNoUrl : "請輸入欲連結的 URL", DlnLnkMsgNoEMail : "請輸入電子郵件位址", DlnLnkMsgNoAnchor : "請選擇錨點", DlnLnkMsgInvPopName : "快顯名稱必須以「英文字母」為開頭,且不得含有空白", // Color Dialog DlgColorTitle : "請選擇顏色", DlgColorBtnClear : "清除", DlgColorHighlight : "預覽", DlgColorSelected : "選擇", // Smiley Dialog DlgSmileyTitle : "插入表情符號", // Special Character Dialog DlgSpecialCharTitle : "請選擇特殊符號", // Table Dialog DlgTableTitle : "表格屬性", DlgTableRows : "列數", DlgTableColumns : "欄數", DlgTableBorder : "邊框", DlgTableAlign : "對齊", DlgTableAlignNotSet : "<未設定>", DlgTableAlignLeft : "靠左對齊", DlgTableAlignCenter : "置中", DlgTableAlignRight : "靠右對齊", DlgTableWidth : "寬度", DlgTableWidthPx : "像素", DlgTableWidthPc : "百分比", DlgTableHeight : "高度", DlgTableCellSpace : "間距", DlgTableCellPad : "內距", DlgTableCaption : "標題", DlgTableSummary : "摘要", DlgTableHeaders : "Headers", //MISSING DlgTableHeadersNone : "None", //MISSING DlgTableHeadersColumn : "First column", //MISSING DlgTableHeadersRow : "First Row", //MISSING DlgTableHeadersBoth : "Both", //MISSING // Table Cell Dialog DlgCellTitle : "儲存格屬性", DlgCellWidth : "寬度", DlgCellWidthPx : "像素", DlgCellWidthPc : "百分比", DlgCellHeight : "高度", DlgCellWordWrap : "自動換行", DlgCellWordWrapNotSet : "<尚未設定>", DlgCellWordWrapYes : "是", DlgCellWordWrapNo : "否", DlgCellHorAlign : "水平對齊", DlgCellHorAlignNotSet : "<尚未設定>", DlgCellHorAlignLeft : "靠左對齊", DlgCellHorAlignCenter : "置中", DlgCellHorAlignRight: "靠右對齊", DlgCellVerAlign : "垂直對齊", DlgCellVerAlignNotSet : "<尚未設定>", DlgCellVerAlignTop : "靠上對齊", DlgCellVerAlignMiddle : "置中", DlgCellVerAlignBottom : "靠下對齊", DlgCellVerAlignBaseline : "基準線", DlgCellType : "儲存格類型", DlgCellTypeData : "資料", DlgCellTypeHeader : "標題", DlgCellRowSpan : "合併列數", DlgCellCollSpan : "合併欄数", DlgCellBackColor : "背景顏色", DlgCellBorderColor : "邊框顏色", DlgCellBtnSelect : "請選擇…", // Find and Replace Dialog DlgFindAndReplaceTitle : "尋找與取代", // Find Dialog DlgFindTitle : "尋找", DlgFindFindBtn : "尋找", DlgFindNotFoundMsg : "未找到指定的文字。", // Replace Dialog DlgReplaceTitle : "取代", DlgReplaceFindLbl : "尋找:", DlgReplaceReplaceLbl : "取代:", DlgReplaceCaseChk : "大小寫須相符", DlgReplaceReplaceBtn : "取代", DlgReplaceReplAllBtn : "全部取代", DlgReplaceWordChk : "全字相符", // Paste Operations / Dialog PasteErrorCut : "瀏覽器的安全性設定不允許編輯器自動執行剪下動作。請使用快捷鍵 (Ctrl+X) 剪下。", PasteErrorCopy : "瀏覽器的安全性設定不允許編輯器自動執行複製動作。請使用快捷鍵 (Ctrl+C) 複製。", PasteAsText : "貼為純文字格式", PasteFromWord : "自 Word 貼上", DlgPasteMsg2 : "請使用快捷鍵 (<strong>Ctrl+V</strong>) 貼到下方區域中並按下 <strong>確定</strong>", DlgPasteSec : "因為瀏覽器的安全性設定,本編輯器無法直接存取您的剪貼簿資料,請您自行在本視窗進行貼上動作。", DlgPasteIgnoreFont : "移除字型設定", DlgPasteRemoveStyles : "移除樣式設定", // Color Picker ColorAutomatic : "自動", ColorMoreColors : "更多顏色…", // Document Properties DocProps : "文件屬性", // Anchor Dialog DlgAnchorTitle : "命名錨點", DlgAnchorName : "錨點名稱", DlgAnchorErrorName : "請輸入錨點名稱", // Speller Pages Dialog DlgSpellNotInDic : "不在字典中", DlgSpellChangeTo : "更改為", DlgSpellBtnIgnore : "忽略", DlgSpellBtnIgnoreAll : "全部忽略", DlgSpellBtnReplace : "取代", DlgSpellBtnReplaceAll : "全部取代", DlgSpellBtnUndo : "復原", DlgSpellNoSuggestions : "- 無建議值 -", DlgSpellProgress : "進行拼字檢查中…", DlgSpellNoMispell : "拼字檢查完成:未發現拼字錯誤", DlgSpellNoChanges : "拼字檢查完成:未更改任何單字", DlgSpellOneChange : "拼字檢查完成:更改了 1 個單字", DlgSpellManyChanges : "拼字檢查完成:更改了 %1 個單字", IeSpellDownload : "尚未安裝拼字檢查元件。您是否想要現在下載?", // Button Dialog DlgButtonText : "顯示文字 (值)", DlgButtonType : "類型", DlgButtonTypeBtn : "按鈕 (Button)", DlgButtonTypeSbm : "送出 (Submit)", DlgButtonTypeRst : "重設 (Reset)", // Checkbox and Radio Button Dialogs DlgCheckboxName : "名稱", DlgCheckboxValue : "選取值", DlgCheckboxSelected : "已選取", // Form Dialog DlgFormName : "名稱", DlgFormAction : "動作", DlgFormMethod : "方法", // Select Field Dialog DlgSelectName : "名稱", DlgSelectValue : "選取值", DlgSelectSize : "大小", DlgSelectLines : "行", DlgSelectChkMulti : "可多選", DlgSelectOpAvail : "可用選項", DlgSelectOpText : "顯示文字", DlgSelectOpValue : "值", DlgSelectBtnAdd : "新增", DlgSelectBtnModify : "修改", DlgSelectBtnUp : "上移", DlgSelectBtnDown : "下移", DlgSelectBtnSetValue : "設為預設值", DlgSelectBtnDelete : "刪除", // Textarea Dialog DlgTextareaName : "名稱", DlgTextareaCols : "字元寬度", DlgTextareaRows : "列數", // Text Field Dialog DlgTextName : "名稱", DlgTextValue : "值", DlgTextCharWidth : "字元寬度", DlgTextMaxChars : "最多字元數", DlgTextType : "類型", DlgTextTypeText : "文字", DlgTextTypePass : "密碼", // Hidden Field Dialog DlgHiddenName : "名稱", DlgHiddenValue : "值", // Bulleted List Dialog BulletedListProp : "項目清單屬性", NumberedListProp : "編號清單屬性", DlgLstStart : "起始編號", DlgLstType : "清單類型", DlgLstTypeCircle : "圓圈", DlgLstTypeDisc : "圓點", DlgLstTypeSquare : "方塊", DlgLstTypeNumbers : "數字 (1, 2, 3)", DlgLstTypeLCase : "小寫字母 (a, b, c)", DlgLstTypeUCase : "大寫字母 (A, B, C)", DlgLstTypeSRoman : "小寫羅馬數字 (i, ii, iii)", DlgLstTypeLRoman : "大寫羅馬數字 (I, II, III)", // Document Properties Dialog DlgDocGeneralTab : "一般", DlgDocBackTab : "背景", DlgDocColorsTab : "顯色與邊界", DlgDocMetaTab : "Meta 資料", DlgDocPageTitle : "頁面標題", DlgDocLangDir : "語言方向", DlgDocLangDirLTR : "由左而右 (LTR)", DlgDocLangDirRTL : "由右而左 (RTL)", DlgDocLangCode : "語言代碼", DlgDocCharSet : "字元編碼", DlgDocCharSetCE : "中歐語系", DlgDocCharSetCT : "正體中文 (Big5)", DlgDocCharSetCR : "斯拉夫文", DlgDocCharSetGR : "希臘文", DlgDocCharSetJP : "日文", DlgDocCharSetKR : "韓文", DlgDocCharSetTR : "土耳其文", DlgDocCharSetUN : "Unicode (UTF-8)", DlgDocCharSetWE : "西歐語系", DlgDocCharSetOther : "其他字元編碼", DlgDocDocType : "文件類型", DlgDocDocTypeOther : "其他文件類型", DlgDocIncXHTML : "包含 XHTML 定義", DlgDocBgColor : "背景顏色", DlgDocBgImage : "背景影像", DlgDocBgNoScroll : "浮水印", DlgDocCText : "文字", DlgDocCLink : "超連結", DlgDocCVisited : "已瀏覽過的超連結", DlgDocCActive : "作用中的超連結", DlgDocMargins : "頁面邊界", DlgDocMaTop : "上", DlgDocMaLeft : "左", DlgDocMaRight : "右", DlgDocMaBottom : "下", DlgDocMeIndex : "文件索引關鍵字 (用半形逗號[,]分隔)", DlgDocMeDescr : "文件說明", DlgDocMeAuthor : "作者", DlgDocMeCopy : "版權所有", DlgDocPreview : "預覽", // Templates Dialog Templates : "樣版", DlgTemplatesTitle : "內容樣版", DlgTemplatesSelMsg : "請選擇欲開啟的樣版<br> (原有的內容將會被清除):", DlgTemplatesLoading : "讀取樣版清單中,請稍候…", DlgTemplatesNoTpl : "(無樣版)", DlgTemplatesReplace : "取代原有內容", // About Dialog DlgAboutAboutTab : "關於", DlgAboutBrowserInfoTab : "瀏覽器資訊", DlgAboutLicenseTab : "許可證", DlgAboutVersion : "版本", DlgAboutInfo : "想獲得更多資訊請至 ", // Div Dialog DlgDivGeneralTab : "一般", DlgDivAdvancedTab : "進階", DlgDivStyle : "樣式", DlgDivInlineStyle : "CSS 樣式" };
JavaScript
/* * 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 == * * Scripts for the fck_select.html page. */ function Select( combo ) { var iIndex = combo.selectedIndex ; oListText.selectedIndex = iIndex ; oListValue.selectedIndex = iIndex ; var oTxtText = document.getElementById( "txtText" ) ; var oTxtValue = document.getElementById( "txtValue" ) ; oTxtText.value = oListText.value ; oTxtValue.value = oListValue.value ; } function Add() { var oTxtText = document.getElementById( "txtText" ) ; var oTxtValue = document.getElementById( "txtValue" ) ; AddComboOption( oListText, oTxtText.value, oTxtText.value ) ; AddComboOption( oListValue, oTxtValue.value, oTxtValue.value ) ; oListText.selectedIndex = oListText.options.length - 1 ; oListValue.selectedIndex = oListValue.options.length - 1 ; oTxtText.value = '' ; oTxtValue.value = '' ; oTxtText.focus() ; } function Modify() { var iIndex = oListText.selectedIndex ; if ( iIndex < 0 ) return ; var oTxtText = document.getElementById( "txtText" ) ; var oTxtValue = document.getElementById( "txtValue" ) ; oListText.options[ iIndex ].innerHTML = HTMLEncode( oTxtText.value ) ; oListText.options[ iIndex ].value = oTxtText.value ; oListValue.options[ iIndex ].innerHTML = HTMLEncode( oTxtValue.value ) ; oListValue.options[ iIndex ].value = oTxtValue.value ; oTxtText.value = '' ; oTxtValue.value = '' ; oTxtText.focus() ; } function Move( steps ) { ChangeOptionPosition( oListText, steps ) ; ChangeOptionPosition( oListValue, steps ) ; } function Delete() { RemoveSelectedOptions( oListText ) ; RemoveSelectedOptions( oListValue ) ; } function SetSelectedValue() { var iIndex = oListValue.selectedIndex ; if ( iIndex < 0 ) return ; var oTxtValue = document.getElementById( "txtSelValue" ) ; oTxtValue.value = oListValue.options[ iIndex ].value ; } // Moves the selected option by a number of steps (also negative) function ChangeOptionPosition( combo, steps ) { var iActualIndex = combo.selectedIndex ; if ( iActualIndex < 0 ) return ; var iFinalIndex = iActualIndex + steps ; if ( iFinalIndex < 0 ) iFinalIndex = 0 ; if ( iFinalIndex > ( combo.options.length - 1 ) ) iFinalIndex = combo.options.length - 1 ; if ( iActualIndex == iFinalIndex ) return ; var oOption = combo.options[ iActualIndex ] ; var sText = HTMLDecode( oOption.innerHTML ) ; var sValue = oOption.value ; combo.remove( iActualIndex ) ; oOption = AddComboOption( combo, sText, sValue, null, iFinalIndex ) ; oOption.selected = true ; } // Remove all selected options from a SELECT object function RemoveSelectedOptions(combo) { // Save the selected index var iSelectedIndex = combo.selectedIndex ; var oOptions = combo.options ; // Remove all selected options for ( var i = oOptions.length - 1 ; i >= 0 ; i-- ) { if (oOptions[i].selected) combo.remove(i) ; } // Reset the selection based on the original selected index if ( combo.options.length > 0 ) { if ( iSelectedIndex >= combo.options.length ) iSelectedIndex = combo.options.length - 1 ; combo.selectedIndex = iSelectedIndex ; } } // Add a new option to a SELECT object (combo or list) function AddComboOption( combo, optionText, optionValue, documentObject, index ) { var oOption ; if ( documentObject ) oOption = documentObject.createElement("OPTION") ; else oOption = document.createElement("OPTION") ; if ( index != null ) combo.options.add( oOption, index ) ; else combo.options.add( oOption ) ; oOption.innerHTML = optionText.length > 0 ? HTMLEncode( optionText ) : '&nbsp;' ; oOption.value = optionValue ; return oOption ; } function HTMLEncode( text ) { if ( !text ) return '' ; text = text.replace( /&/g, '&amp;' ) ; text = text.replace( /</g, '&lt;' ) ; text = text.replace( />/g, '&gt;' ) ; return text ; } function HTMLDecode( text ) { if ( !text ) return '' ; text = text.replace( /&gt;/g, '>' ) ; text = text.replace( /&lt;/g, '<' ) ; text = text.replace( /&amp;/g, '&' ) ; return text ; }
JavaScript
/* * 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 == * * Scripts related to the Link dialog window (see fck_link.html). */ var dialog = window.parent ; var oEditor = dialog.InnerDialogLoaded() ; var FCK = oEditor.FCK ; var FCKLang = oEditor.FCKLang ; var FCKConfig = oEditor.FCKConfig ; var FCKRegexLib = oEditor.FCKRegexLib ; var FCKTools = oEditor.FCKTools ; //#### Dialog Tabs // Set the dialog tabs. dialog.AddTab( 'Info', FCKLang.DlgLnkInfoTab ) ; if ( !FCKConfig.LinkDlgHideTarget ) dialog.AddTab( 'Target', FCKLang.DlgLnkTargetTab, true ) ; if ( FCKConfig.LinkUpload ) dialog.AddTab( 'Upload', FCKLang.DlgLnkUpload, true ) ; if ( !FCKConfig.LinkDlgHideAdvanced ) dialog.AddTab( 'Advanced', FCKLang.DlgAdvancedTag ) ; // Function called when a dialog tag is selected. function OnDialogTabChange( tabCode ) { ShowE('divInfo' , ( tabCode == 'Info' ) ) ; ShowE('divTarget' , ( tabCode == 'Target' ) ) ; ShowE('divUpload' , ( tabCode == 'Upload' ) ) ; ShowE('divAttribs' , ( tabCode == 'Advanced' ) ) ; dialog.SetAutoSize( true ) ; } //#### Regular Expressions library. var oRegex = new Object() ; oRegex.UriProtocol = /^(((http|https|ftp|news):\/\/)|mailto:)/gi ; oRegex.UrlOnChangeProtocol = /^(http|https|ftp|news):\/\/(?=.)/gi ; oRegex.UrlOnChangeTestOther = /^((javascript:)|[#\/\.])/gi ; oRegex.ReserveTarget = /^_(blank|self|top|parent)$/i ; oRegex.PopupUri = /^javascript:void\(\s*window.open\(\s*'([^']+)'\s*,\s*(?:'([^']*)'|null)\s*,\s*'([^']*)'\s*\)\s*\)\s*$/ ; // Accessible popups oRegex.OnClickPopup = /^\s*on[cC]lick="\s*window.open\(\s*this\.href\s*,\s*(?:'([^']*)'|null)\s*,\s*'([^']*)'\s*\)\s*;\s*return\s*false;*\s*"$/ ; oRegex.PopupFeatures = /(?:^|,)([^=]+)=(\d+|yes|no)/gi ; //#### Parser Functions var oParser = new Object() ; // This method simply returns the two inputs in numerical order. You can even // provide strings, as the method would parseInt() the values. oParser.SortNumerical = function(a, b) { return parseInt( a, 10 ) - parseInt( b, 10 ) ; } oParser.ParseEMailParams = function(sParams) { // Initialize the oEMailParams object. var oEMailParams = new Object() ; oEMailParams.Subject = '' ; oEMailParams.Body = '' ; var aMatch = sParams.match( /(^|^\?|&)subject=([^&]+)/i ) ; if ( aMatch ) oEMailParams.Subject = decodeURIComponent( aMatch[2] ) ; aMatch = sParams.match( /(^|^\?|&)body=([^&]+)/i ) ; if ( aMatch ) oEMailParams.Body = decodeURIComponent( aMatch[2] ) ; return oEMailParams ; } // This method returns either an object containing the email info, or FALSE // if the parameter is not an email link. oParser.ParseEMailUri = function( sUrl ) { // Initializes the EMailInfo object. var oEMailInfo = new Object() ; oEMailInfo.Address = '' ; oEMailInfo.Subject = '' ; oEMailInfo.Body = '' ; var aLinkInfo = sUrl.match( /^(\w+):(.*)$/ ) ; if ( aLinkInfo && aLinkInfo[1] == 'mailto' ) { // This seems to be an unprotected email link. var aParts = aLinkInfo[2].match( /^([^\?]+)\??(.+)?/ ) ; if ( aParts ) { // Set the e-mail address. oEMailInfo.Address = aParts[1] ; // Look for the optional e-mail parameters. if ( aParts[2] ) { var oEMailParams = oParser.ParseEMailParams( aParts[2] ) ; oEMailInfo.Subject = oEMailParams.Subject ; oEMailInfo.Body = oEMailParams.Body ; } } return oEMailInfo ; } else if ( aLinkInfo && aLinkInfo[1] == 'javascript' ) { // This may be a protected email. // Try to match the url against the EMailProtectionFunction. var func = FCKConfig.EMailProtectionFunction ; if ( func != null ) { try { // Escape special chars. func = func.replace( /([\/^$*+.?()\[\]])/g, '\\$1' ) ; // Define the possible keys. var keys = new Array('NAME', 'DOMAIN', 'SUBJECT', 'BODY') ; // Get the order of the keys (hold them in the array <pos>) and // the function replaced by regular expression patterns. var sFunc = func ; var pos = new Array() ; for ( var i = 0 ; i < keys.length ; i ++ ) { var rexp = new RegExp( keys[i] ) ; var p = func.search( rexp ) ; if ( p >= 0 ) { sFunc = sFunc.replace( rexp, '\'([^\']*)\'' ) ; pos[pos.length] = p + ':' + keys[i] ; } } // Sort the available keys. pos.sort( oParser.SortNumerical ) ; // Replace the excaped single quotes in the url, such they do // not affect the regexp afterwards. aLinkInfo[2] = aLinkInfo[2].replace( /\\'/g, '###SINGLE_QUOTE###' ) ; // Create the regexp and execute it. var rFunc = new RegExp( '^' + sFunc + '$' ) ; var aMatch = rFunc.exec( aLinkInfo[2] ) ; if ( aMatch ) { var aInfo = new Array(); for ( var i = 1 ; i < aMatch.length ; i ++ ) { var k = pos[i-1].match(/^\d+:(.+)$/) ; aInfo[k[1]] = aMatch[i].replace(/###SINGLE_QUOTE###/g, '\'') ; } // Fill the EMailInfo object that will be returned oEMailInfo.Address = aInfo['NAME'] + '@' + aInfo['DOMAIN'] ; oEMailInfo.Subject = decodeURIComponent( aInfo['SUBJECT'] ) ; oEMailInfo.Body = decodeURIComponent( aInfo['BODY'] ) ; return oEMailInfo ; } } catch (e) { } } // Try to match the email against the encode protection. var aMatch = aLinkInfo[2].match( /^(?:void\()?location\.href='mailto:'\+(String\.fromCharCode\([\d,]+\))\+'(.*)'\)?$/ ) ; if ( aMatch ) { // The link is encoded oEMailInfo.Address = eval( aMatch[1] ) ; if ( aMatch[2] ) { var oEMailParams = oParser.ParseEMailParams( aMatch[2] ) ; oEMailInfo.Subject = oEMailParams.Subject ; oEMailInfo.Body = oEMailParams.Body ; } return oEMailInfo ; } } return false; } oParser.CreateEMailUri = function( address, subject, body ) { // Switch for the EMailProtection setting. switch ( FCKConfig.EMailProtection ) { case 'function' : var func = FCKConfig.EMailProtectionFunction ; if ( func == null ) { if ( FCKConfig.Debug ) { alert('EMailProtection alert!\nNo function defined. Please set "FCKConfig.EMailProtectionFunction"') ; } return ''; } // Split the email address into name and domain parts. var aAddressParts = address.split( '@', 2 ) ; if ( aAddressParts[1] == undefined ) { aAddressParts[1] = '' ; } // Replace the keys by their values (embedded in single quotes). func = func.replace(/NAME/g, "'" + aAddressParts[0].replace(/'/g, '\\\'') + "'") ; func = func.replace(/DOMAIN/g, "'" + aAddressParts[1].replace(/'/g, '\\\'') + "'") ; func = func.replace(/SUBJECT/g, "'" + encodeURIComponent( subject ).replace(/'/g, '\\\'') + "'") ; func = func.replace(/BODY/g, "'" + encodeURIComponent( body ).replace(/'/g, '\\\'') + "'") ; return 'javascript:' + func ; case 'encode' : var aParams = [] ; var aAddressCode = [] ; if ( subject.length > 0 ) aParams.push( 'subject='+ encodeURIComponent( subject ) ) ; if ( body.length > 0 ) aParams.push( 'body=' + encodeURIComponent( body ) ) ; for ( var i = 0 ; i < address.length ; i++ ) aAddressCode.push( address.charCodeAt( i ) ) ; return 'javascript:void(location.href=\'mailto:\'+String.fromCharCode(' + aAddressCode.join( ',' ) + ')+\'?' + aParams.join( '&' ) + '\')' ; } // EMailProtection 'none' var sBaseUri = 'mailto:' + address ; var sParams = '' ; if ( subject.length > 0 ) sParams = '?subject=' + encodeURIComponent( subject ) ; if ( body.length > 0 ) { sParams += ( sParams.length == 0 ? '?' : '&' ) ; sParams += 'body=' + encodeURIComponent( body ) ; } return sBaseUri + sParams ; } //#### Initialization Code // oLink: The actual selected link in the editor. var oLink = dialog.Selection.GetSelection().MoveToAncestorNode( 'A' ) ; if ( oLink ) FCK.Selection.SelectNode( oLink ) ; window.onload = function() { // Translate the dialog box texts. oEditor.FCKLanguageManager.TranslatePage(document) ; // Fill the Anchor Names and Ids combos. LoadAnchorNamesAndIds() ; // Load the selected link information (if any). LoadSelection() ; // Update the dialog box. SetLinkType( GetE('cmbLinkType').value ) ; // Show/Hide the "Browse Server" button. GetE('divBrowseServer').style.display = FCKConfig.LinkBrowser ? '' : 'none' ; // Show the initial dialog content. GetE('divInfo').style.display = '' ; // Set the actual uploader URL. if ( FCKConfig.LinkUpload ) GetE('frmUpload').action = FCKConfig.LinkUploadURL ; // Set the default target (from configuration). SetDefaultTarget() ; // Activate the "OK" button. dialog.SetOkButton( true ) ; // Select the first field. switch( GetE('cmbLinkType').value ) { case 'url' : SelectField( 'txtUrl' ) ; break ; case 'email' : SelectField( 'txtEMailAddress' ) ; break ; case 'anchor' : if ( GetE('divSelAnchor').style.display != 'none' ) SelectField( 'cmbAnchorName' ) ; else SelectField( 'cmbLinkType' ) ; } } var bHasAnchors ; function LoadAnchorNamesAndIds() { // Since version 2.0, the anchors are replaced in the DOM by IMGs so the user see the icon // to edit them. So, we must look for that images now. var aAnchors = new Array() ; var i ; var oImages = oEditor.FCK.EditorDocument.getElementsByTagName( 'IMG' ) ; for( i = 0 ; i < oImages.length ; i++ ) { if ( oImages[i].getAttribute('_fckanchor') ) aAnchors[ aAnchors.length ] = oEditor.FCK.GetRealElement( oImages[i] ) ; } // Add also real anchors var oLinks = oEditor.FCK.EditorDocument.getElementsByTagName( 'A' ) ; for( i = 0 ; i < oLinks.length ; i++ ) { if ( oLinks[i].name && ( oLinks[i].name.length > 0 ) ) aAnchors[ aAnchors.length ] = oLinks[i] ; } var aIds = FCKTools.GetAllChildrenIds( oEditor.FCK.EditorDocument.body ) ; bHasAnchors = ( aAnchors.length > 0 || aIds.length > 0 ) ; for ( i = 0 ; i < aAnchors.length ; i++ ) { var sName = aAnchors[i].name ; if ( sName && sName.length > 0 ) FCKTools.AddSelectOption( GetE('cmbAnchorName'), sName, sName ) ; } for ( i = 0 ; i < aIds.length ; i++ ) { FCKTools.AddSelectOption( GetE('cmbAnchorId'), aIds[i], aIds[i] ) ; } ShowE( 'divSelAnchor' , bHasAnchors ) ; ShowE( 'divNoAnchor' , !bHasAnchors ) ; } function LoadSelection() { if ( !oLink ) return ; var sType = 'url' ; // Get the actual Link href. var sHRef = oLink.getAttribute( '_fcksavedurl' ) ; if ( sHRef == null ) sHRef = oLink.getAttribute( 'href' , 2 ) || '' ; // Look for a popup javascript link. var oPopupMatch = oRegex.PopupUri.exec( sHRef ) ; if( oPopupMatch ) { GetE('cmbTarget').value = 'popup' ; sHRef = oPopupMatch[1] ; FillPopupFields( oPopupMatch[2], oPopupMatch[3] ) ; SetTarget( 'popup' ) ; } // Accessible popups, the popup data is in the onclick attribute if ( !oPopupMatch ) { var onclick = oLink.getAttribute( 'onclick_fckprotectedatt' ) ; if ( onclick ) { // Decode the protected string onclick = decodeURIComponent( onclick ) ; oPopupMatch = oRegex.OnClickPopup.exec( onclick ) ; if( oPopupMatch ) { GetE( 'cmbTarget' ).value = 'popup' ; FillPopupFields( oPopupMatch[1], oPopupMatch[2] ) ; SetTarget( 'popup' ) ; } } } // Search for the protocol. var sProtocol = oRegex.UriProtocol.exec( sHRef ) ; // Search for a protected email link. var oEMailInfo = oParser.ParseEMailUri( sHRef ); if ( oEMailInfo ) { sType = 'email' ; GetE('txtEMailAddress').value = oEMailInfo.Address ; GetE('txtEMailSubject').value = oEMailInfo.Subject ; GetE('txtEMailBody').value = oEMailInfo.Body ; } else if ( sProtocol ) { sProtocol = sProtocol[0].toLowerCase() ; GetE('cmbLinkProtocol').value = sProtocol ; // Remove the protocol and get the remaining URL. var sUrl = sHRef.replace( oRegex.UriProtocol, '' ) ; sType = 'url' ; GetE('txtUrl').value = sUrl ; } else if ( sHRef.substr(0,1) == '#' && sHRef.length > 1 ) // It is an anchor link. { sType = 'anchor' ; GetE('cmbAnchorName').value = GetE('cmbAnchorId').value = sHRef.substr(1) ; } else // It is another type of link. { sType = 'url' ; GetE('cmbLinkProtocol').value = '' ; GetE('txtUrl').value = sHRef ; } if ( !oPopupMatch ) { // Get the target. var sTarget = oLink.target ; if ( sTarget && sTarget.length > 0 ) { if ( oRegex.ReserveTarget.test( sTarget ) ) { sTarget = sTarget.toLowerCase() ; GetE('cmbTarget').value = sTarget ; } else GetE('cmbTarget').value = 'frame' ; GetE('txtTargetFrame').value = sTarget ; } } // Get Advances Attributes GetE('txtAttId').value = oLink.id ; GetE('txtAttName').value = oLink.name ; GetE('cmbAttLangDir').value = oLink.dir ; GetE('txtAttLangCode').value = oLink.lang ; GetE('txtAttAccessKey').value = oLink.accessKey ; GetE('txtAttTabIndex').value = oLink.tabIndex <= 0 ? '' : oLink.tabIndex ; GetE('txtAttTitle').value = oLink.title ; GetE('txtAttContentType').value = oLink.type ; GetE('txtAttCharSet').value = oLink.charset ; var sClass ; if ( oEditor.FCKBrowserInfo.IsIE ) { sClass = oLink.getAttribute('className',2) || '' ; // Clean up temporary classes for internal use: sClass = sClass.replace( FCKRegexLib.FCK_Class, '' ) ; GetE('txtAttStyle').value = oLink.style.cssText ; } else { sClass = oLink.getAttribute('class',2) || '' ; GetE('txtAttStyle').value = oLink.getAttribute('style',2) || '' ; } GetE('txtAttClasses').value = sClass ; // Update the Link type combo. GetE('cmbLinkType').value = sType ; } //#### Link type selection. function SetLinkType( linkType ) { ShowE('divLinkTypeUrl' , (linkType == 'url') ) ; ShowE('divLinkTypeAnchor' , (linkType == 'anchor') ) ; ShowE('divLinkTypeEMail' , (linkType == 'email') ) ; if ( !FCKConfig.LinkDlgHideTarget ) dialog.SetTabVisibility( 'Target' , (linkType == 'url') ) ; if ( FCKConfig.LinkUpload ) dialog.SetTabVisibility( 'Upload' , (linkType == 'url') ) ; if ( !FCKConfig.LinkDlgHideAdvanced ) dialog.SetTabVisibility( 'Advanced' , (linkType != 'anchor' || bHasAnchors) ) ; if ( linkType == 'email' ) dialog.SetAutoSize( true ) ; } //#### Target type selection. function SetTarget( targetType ) { GetE('tdTargetFrame').style.display = ( targetType == 'popup' ? 'none' : '' ) ; GetE('tdPopupName').style.display = GetE('tablePopupFeatures').style.display = ( targetType == 'popup' ? '' : 'none' ) ; switch ( targetType ) { case "_blank" : case "_self" : case "_parent" : case "_top" : GetE('txtTargetFrame').value = targetType ; break ; case "" : GetE('txtTargetFrame').value = '' ; break ; } if ( targetType == 'popup' ) dialog.SetAutoSize( true ) ; } //#### Called while the user types the URL. function OnUrlChange() { var sUrl = GetE('txtUrl').value ; var sProtocol = oRegex.UrlOnChangeProtocol.exec( sUrl ) ; if ( sProtocol ) { sUrl = sUrl.substr( sProtocol[0].length ) ; GetE('txtUrl').value = sUrl ; GetE('cmbLinkProtocol').value = sProtocol[0].toLowerCase() ; } else if ( oRegex.UrlOnChangeTestOther.test( sUrl ) ) { GetE('cmbLinkProtocol').value = '' ; } } //#### Called while the user types the target name. function OnTargetNameChange() { var sFrame = GetE('txtTargetFrame').value ; if ( sFrame.length == 0 ) GetE('cmbTarget').value = '' ; else if ( oRegex.ReserveTarget.test( sFrame ) ) GetE('cmbTarget').value = sFrame.toLowerCase() ; else GetE('cmbTarget').value = 'frame' ; } // Accessible popups function BuildOnClickPopup() { var sWindowName = "'" + GetE('txtPopupName').value.replace(/\W/gi, "") + "'" ; var sFeatures = '' ; var aChkFeatures = document.getElementsByName( 'chkFeature' ) ; for ( var i = 0 ; i < aChkFeatures.length ; i++ ) { if ( i > 0 ) sFeatures += ',' ; sFeatures += aChkFeatures[i].value + '=' + ( aChkFeatures[i].checked ? 'yes' : 'no' ) ; } if ( GetE('txtPopupWidth').value.length > 0 ) sFeatures += ',width=' + GetE('txtPopupWidth').value ; if ( GetE('txtPopupHeight').value.length > 0 ) sFeatures += ',height=' + GetE('txtPopupHeight').value ; if ( GetE('txtPopupLeft').value.length > 0 ) sFeatures += ',left=' + GetE('txtPopupLeft').value ; if ( GetE('txtPopupTop').value.length > 0 ) sFeatures += ',top=' + GetE('txtPopupTop').value ; if ( sFeatures != '' ) sFeatures = sFeatures + ",status" ; return ( "window.open(this.href," + sWindowName + ",'" + sFeatures + "'); return false" ) ; } //#### Fills all Popup related fields. function FillPopupFields( windowName, features ) { if ( windowName ) GetE('txtPopupName').value = windowName ; var oFeatures = new Object() ; var oFeaturesMatch ; while( ( oFeaturesMatch = oRegex.PopupFeatures.exec( features ) ) != null ) { var sValue = oFeaturesMatch[2] ; if ( sValue == ( 'yes' || '1' ) ) oFeatures[ oFeaturesMatch[1] ] = true ; else if ( ! isNaN( sValue ) && sValue != 0 ) oFeatures[ oFeaturesMatch[1] ] = sValue ; } // Update all features check boxes. var aChkFeatures = document.getElementsByName('chkFeature') ; for ( var i = 0 ; i < aChkFeatures.length ; i++ ) { if ( oFeatures[ aChkFeatures[i].value ] ) aChkFeatures[i].checked = true ; } // Update position and size text boxes. if ( oFeatures['width'] ) GetE('txtPopupWidth').value = oFeatures['width'] ; if ( oFeatures['height'] ) GetE('txtPopupHeight').value = oFeatures['height'] ; if ( oFeatures['left'] ) GetE('txtPopupLeft').value = oFeatures['left'] ; if ( oFeatures['top'] ) GetE('txtPopupTop').value = oFeatures['top'] ; } //#### The OK button was hit. function Ok() { var sUri, sInnerHtml ; oEditor.FCKUndo.SaveUndoStep() ; switch ( GetE('cmbLinkType').value ) { case 'url' : sUri = GetE('txtUrl').value ; if ( sUri.length == 0 ) { alert( FCKLang.DlnLnkMsgNoUrl ) ; return false ; } sUri = GetE('cmbLinkProtocol').value + sUri ; break ; case 'email' : sUri = GetE('txtEMailAddress').value ; if ( sUri.length == 0 ) { alert( FCKLang.DlnLnkMsgNoEMail ) ; return false ; } sUri = oParser.CreateEMailUri( sUri, GetE('txtEMailSubject').value, GetE('txtEMailBody').value ) ; break ; case 'anchor' : var sAnchor = GetE('cmbAnchorName').value ; if ( sAnchor.length == 0 ) sAnchor = GetE('cmbAnchorId').value ; if ( sAnchor.length == 0 ) { alert( FCKLang.DlnLnkMsgNoAnchor ) ; return false ; } sUri = '#' + sAnchor ; break ; } // If no link is selected, create a new one (it may result in more than one link creation - #220). var aLinks = oLink ? [ oLink ] : oEditor.FCK.CreateLink( sUri, true ) ; // If no selection, no links are created, so use the uri as the link text (by dom, 2006-05-26) var aHasSelection = ( aLinks.length > 0 ) ; if ( !aHasSelection ) { sInnerHtml = sUri; // Built a better text for empty links. switch ( GetE('cmbLinkType').value ) { // anchor: use old behavior --> return true case 'anchor': sInnerHtml = sInnerHtml.replace( /^#/, '' ) ; break ; // url: try to get path case 'url': var oLinkPathRegEx = new RegExp("//?([^?\"']+)([?].*)?$") ; var asLinkPath = oLinkPathRegEx.exec( sUri ) ; if (asLinkPath != null) sInnerHtml = asLinkPath[1]; // use matched path break ; // mailto: try to get email address case 'email': sInnerHtml = GetE('txtEMailAddress').value ; break ; } // Create a new (empty) anchor. aLinks = [ oEditor.FCK.InsertElement( 'a' ) ] ; } for ( var i = 0 ; i < aLinks.length ; i++ ) { oLink = aLinks[i] ; if ( aHasSelection ) sInnerHtml = oLink.innerHTML ; // Save the innerHTML (IE changes it if it is like an URL). oLink.href = sUri ; SetAttribute( oLink, '_fcksavedurl', sUri ) ; var onclick; // Accessible popups if( GetE('cmbTarget').value == 'popup' ) { onclick = BuildOnClickPopup() ; // Encode the attribute onclick = encodeURIComponent( " onclick=\"" + onclick + "\"" ) ; SetAttribute( oLink, 'onclick_fckprotectedatt', onclick ) ; } else { // Check if the previous onclick was for a popup: // In that case remove the onclick handler. onclick = oLink.getAttribute( 'onclick_fckprotectedatt' ) ; if ( onclick ) { // Decode the protected string onclick = decodeURIComponent( onclick ) ; if( oRegex.OnClickPopup.test( onclick ) ) SetAttribute( oLink, 'onclick_fckprotectedatt', '' ) ; } } oLink.innerHTML = sInnerHtml ; // Set (or restore) the innerHTML // Target if( GetE('cmbTarget').value != 'popup' ) SetAttribute( oLink, 'target', GetE('txtTargetFrame').value ) ; else SetAttribute( oLink, 'target', null ) ; // Let's set the "id" only for the first link to avoid duplication. if ( i == 0 ) SetAttribute( oLink, 'id', GetE('txtAttId').value ) ; // Advances Attributes SetAttribute( oLink, 'name' , GetE('txtAttName').value ) ; SetAttribute( oLink, 'dir' , GetE('cmbAttLangDir').value ) ; SetAttribute( oLink, 'lang' , GetE('txtAttLangCode').value ) ; SetAttribute( oLink, 'accesskey', GetE('txtAttAccessKey').value ) ; SetAttribute( oLink, 'tabindex' , ( GetE('txtAttTabIndex').value > 0 ? GetE('txtAttTabIndex').value : null ) ) ; SetAttribute( oLink, 'title' , GetE('txtAttTitle').value ) ; SetAttribute( oLink, 'type' , GetE('txtAttContentType').value ) ; SetAttribute( oLink, 'charset' , GetE('txtAttCharSet').value ) ; if ( oEditor.FCKBrowserInfo.IsIE ) { var sClass = GetE('txtAttClasses').value ; // If it's also an anchor add an internal class if ( GetE('txtAttName').value.length != 0 ) sClass += ' FCK__AnchorC' ; SetAttribute( oLink, 'className', sClass ) ; oLink.style.cssText = GetE('txtAttStyle').value ; } else { SetAttribute( oLink, 'class', GetE('txtAttClasses').value ) ; SetAttribute( oLink, 'style', GetE('txtAttStyle').value ) ; } } // Select the (first) link. oEditor.FCKSelection.SelectNode( aLinks[0] ); return true ; } function BrowseServer() { OpenFileBrowser( FCKConfig.LinkBrowserURL, FCKConfig.LinkBrowserWindowWidth, FCKConfig.LinkBrowserWindowHeight ) ; } function SetUrl( url ) { GetE('txtUrl').value = url ; OnUrlChange() ; dialog.SetSelectedTab( 'Info' ) ; } function OnUploadCompleted( errorNumber, fileUrl, fileName, customMsg ) { // Remove animation window.parent.Throbber.Hide() ; GetE( 'divUpload' ).style.display = '' ; switch ( errorNumber ) { case 0 : // No errors alert( 'Your file has been successfully uploaded' ) ; break ; case 1 : // Custom error alert( customMsg ) ; return ; case 101 : // Custom warning alert( customMsg ) ; break ; case 201 : alert( 'A file with the same name is already available. The uploaded file has been renamed to "' + fileName + '"' ) ; break ; case 202 : alert( 'Invalid file type' ) ; return ; case 203 : alert( "Security error. You probably don't have enough permissions to upload. Please check your server." ) ; return ; case 500 : alert( 'The connector is disabled' ) ; break ; default : alert( 'Error on file upload. Error number: ' + errorNumber ) ; return ; } SetUrl( fileUrl ) ; GetE('frmUpload').reset() ; } var oUploadAllowedExtRegex = new RegExp( FCKConfig.LinkUploadAllowedExtensions, 'i' ) ; var oUploadDeniedExtRegex = new RegExp( FCKConfig.LinkUploadDeniedExtensions, 'i' ) ; function CheckUpload() { var sFile = GetE('txtUploadFile').value ; if ( sFile.length == 0 ) { alert( 'Please select a file to upload' ) ; return false ; } if ( ( FCKConfig.LinkUploadAllowedExtensions.length > 0 && !oUploadAllowedExtRegex.test( sFile ) ) || ( FCKConfig.LinkUploadDeniedExtensions.length > 0 && oUploadDeniedExtRegex.test( sFile ) ) ) { OnUploadCompleted( 202 ) ; return false ; } // Show animation window.parent.Throbber.Show( 100 ) ; GetE( 'divUpload' ).style.display = 'none' ; return true ; } function SetDefaultTarget() { var target = FCKConfig.DefaultLinkTarget || '' ; if ( oLink || target.length == 0 ) return ; switch ( target ) { case '_blank' : case '_self' : case '_parent' : case '_top' : GetE('cmbTarget').value = target ; break ; default : GetE('cmbTarget').value = 'frame' ; break ; } GetE('txtTargetFrame').value = target ; }
JavaScript
//////////////////////////////////////////////////// // wordWindow object //////////////////////////////////////////////////// function wordWindow() { // private properties this._forms = []; // private methods this._getWordObject = _getWordObject; //this._getSpellerObject = _getSpellerObject; this._wordInputStr = _wordInputStr; this._adjustIndexes = _adjustIndexes; this._isWordChar = _isWordChar; this._lastPos = _lastPos; // public properties this.wordChar = /[a-zA-Z]/; this.windowType = "wordWindow"; this.originalSpellings = new Array(); this.suggestions = new Array(); this.checkWordBgColor = "pink"; this.normWordBgColor = "white"; this.text = ""; this.textInputs = new Array(); this.indexes = new Array(); //this.speller = this._getSpellerObject(); // public methods this.resetForm = resetForm; this.totalMisspellings = totalMisspellings; this.totalWords = totalWords; this.totalPreviousWords = totalPreviousWords; //this.getTextObjectArray = getTextObjectArray; this.getTextVal = getTextVal; this.setFocus = setFocus; this.removeFocus = removeFocus; this.setText = setText; //this.getTotalWords = getTotalWords; this.writeBody = writeBody; this.printForHtml = printForHtml; } function resetForm() { if( this._forms ) { for( var i = 0; i < this._forms.length; i++ ) { this._forms[i].reset(); } } return true; } function totalMisspellings() { var total_words = 0; for( var i = 0; i < this.textInputs.length; i++ ) { total_words += this.totalWords( i ); } return total_words; } function totalWords( textIndex ) { return this.originalSpellings[textIndex].length; } function totalPreviousWords( textIndex, wordIndex ) { var total_words = 0; for( var i = 0; i <= textIndex; i++ ) { for( var j = 0; j < this.totalWords( i ); j++ ) { if( i == textIndex && j == wordIndex ) { break; } else { total_words++; } } } return total_words; } //function getTextObjectArray() { // return this._form.elements; //} function getTextVal( textIndex, wordIndex ) { var word = this._getWordObject( textIndex, wordIndex ); if( word ) { return word.value; } } function setFocus( textIndex, wordIndex ) { var word = this._getWordObject( textIndex, wordIndex ); if( word ) { if( word.type == "text" ) { word.focus(); word.style.backgroundColor = this.checkWordBgColor; } } } function removeFocus( textIndex, wordIndex ) { var word = this._getWordObject( textIndex, wordIndex ); if( word ) { if( word.type == "text" ) { word.blur(); word.style.backgroundColor = this.normWordBgColor; } } } function setText( textIndex, wordIndex, newText ) { var word = this._getWordObject( textIndex, wordIndex ); var beginStr; var endStr; if( word ) { var pos = this.indexes[textIndex][wordIndex]; var oldText = word.value; // update the text given the index of the string beginStr = this.textInputs[textIndex].substring( 0, pos ); endStr = this.textInputs[textIndex].substring( pos + oldText.length, this.textInputs[textIndex].length ); this.textInputs[textIndex] = beginStr + newText + endStr; // adjust the indexes on the stack given the differences in // length between the new word and old word. var lengthDiff = newText.length - oldText.length; this._adjustIndexes( textIndex, wordIndex, lengthDiff ); word.size = newText.length; word.value = newText; this.removeFocus( textIndex, wordIndex ); } } function writeBody() { var d = window.document; var is_html = false; d.open(); // iterate through each text input. for( var txtid = 0; txtid < this.textInputs.length; txtid++ ) { var end_idx = 0; var begin_idx = 0; d.writeln( '<form name="textInput'+txtid+'">' ); var wordtxt = this.textInputs[txtid]; this.indexes[txtid] = []; if( wordtxt ) { var orig = this.originalSpellings[txtid]; if( !orig ) break; //!!! plain text, or HTML mode? d.writeln( '<div class="plainText">' ); // iterate through each occurrence of a misspelled word. for( var i = 0; i < orig.length; i++ ) { // find the position of the current misspelled word, // starting at the last misspelled word. // and keep looking if it's a substring of another word do { begin_idx = wordtxt.indexOf( orig[i], end_idx ); end_idx = begin_idx + orig[i].length; // word not found? messed up! if( begin_idx == -1 ) break; // look at the characters immediately before and after // the word. If they are word characters we'll keep looking. var before_char = wordtxt.charAt( begin_idx - 1 ); var after_char = wordtxt.charAt( end_idx ); } while ( this._isWordChar( before_char ) || this._isWordChar( after_char ) ); // keep track of its position in the original text. this.indexes[txtid][i] = begin_idx; // write out the characters before the current misspelled word for( var j = this._lastPos( txtid, i ); j < begin_idx; j++ ) { // !!! html mode? make it html compatible d.write( this.printForHtml( wordtxt.charAt( j ))); } // write out the misspelled word. d.write( this._wordInputStr( orig[i] )); // if it's the last word, write out the rest of the text if( i == orig.length-1 ){ d.write( printForHtml( wordtxt.substr( end_idx ))); } } d.writeln( '</div>' ); } d.writeln( '</form>' ); } //for ( var j = 0; j < d.forms.length; j++ ) { // alert( d.forms[j].name ); // for( var k = 0; k < d.forms[j].elements.length; k++ ) { // alert( d.forms[j].elements[k].name + ": " + d.forms[j].elements[k].value ); // } //} // set the _forms property this._forms = d.forms; d.close(); } // return the character index in the full text after the last word we evaluated function _lastPos( txtid, idx ) { if( idx > 0 ) return this.indexes[txtid][idx-1] + this.originalSpellings[txtid][idx-1].length; else return 0; } function printForHtml( n ) { return n ; // by FredCK /* var htmlstr = n; if( htmlstr.length == 1 ) { // do simple case statement if it's just one character switch ( n ) { case "\n": htmlstr = '<br/>'; break; case "<": htmlstr = '&lt;'; break; case ">": htmlstr = '&gt;'; break; } return htmlstr; } else { htmlstr = htmlstr.replace( /</g, '&lt' ); htmlstr = htmlstr.replace( />/g, '&gt' ); htmlstr = htmlstr.replace( /\n/g, '<br/>' ); return htmlstr; } */ } function _isWordChar( letter ) { if( letter.search( this.wordChar ) == -1 ) { return false; } else { return true; } } function _getWordObject( textIndex, wordIndex ) { if( this._forms[textIndex] ) { if( this._forms[textIndex].elements[wordIndex] ) { return this._forms[textIndex].elements[wordIndex]; } } return null; } function _wordInputStr( word ) { var str = '<input readonly '; str += 'class="blend" type="text" value="' + word + '" size="' + word.length + '">'; return str; } function _adjustIndexes( textIndex, wordIndex, lengthDiff ) { for( var i = wordIndex + 1; i < this.originalSpellings[textIndex].length; i++ ) { this.indexes[textIndex][i] = this.indexes[textIndex][i] + lengthDiff; } }
JavaScript
//////////////////////////////////////////////////// // controlWindow object //////////////////////////////////////////////////// function controlWindow( controlForm ) { // private properties this._form = controlForm; // public properties this.windowType = "controlWindow"; // this.noSuggestionSelection = "- No suggestions -"; // by FredCK this.noSuggestionSelection = FCKLang.DlgSpellNoSuggestions ; // set up the properties for elements of the given control form this.suggestionList = this._form.sugg; this.evaluatedText = this._form.misword; this.replacementText = this._form.txtsugg; this.undoButton = this._form.btnUndo; // public methods this.addSuggestion = addSuggestion; this.clearSuggestions = clearSuggestions; this.selectDefaultSuggestion = selectDefaultSuggestion; this.resetForm = resetForm; this.setSuggestedText = setSuggestedText; this.enableUndo = enableUndo; this.disableUndo = disableUndo; } function resetForm() { if( this._form ) { this._form.reset(); } } function setSuggestedText() { var slct = this.suggestionList; var txt = this.replacementText; var str = ""; if( (slct.options[0].text) && slct.options[0].text != this.noSuggestionSelection ) { str = slct.options[slct.selectedIndex].text; } txt.value = str; } function selectDefaultSuggestion() { var slct = this.suggestionList; var txt = this.replacementText; if( slct.options.length == 0 ) { this.addSuggestion( this.noSuggestionSelection ); } else { slct.options[0].selected = true; } this.setSuggestedText(); } function addSuggestion( sugg_text ) { var slct = this.suggestionList; if( sugg_text ) { var i = slct.options.length; var newOption = new Option( sugg_text, 'sugg_text'+i ); slct.options[i] = newOption; } } function clearSuggestions() { var slct = this.suggestionList; for( var j = slct.length - 1; j > -1; j-- ) { if( slct.options[j] ) { slct.options[j] = null; } } } function enableUndo() { if( this.undoButton ) { if( this.undoButton.disabled == true ) { this.undoButton.disabled = false; } } } function disableUndo() { if( this.undoButton ) { if( this.undoButton.disabled == false ) { this.undoButton.disabled = true; } } }
JavaScript
//////////////////////////////////////////////////// // spellChecker.js // // spellChecker object // // This file is sourced on web pages that have a textarea object to evaluate // for spelling. It includes the implementation for the spellCheckObject. // //////////////////////////////////////////////////// // constructor function spellChecker( textObject ) { // public properties - configurable // this.popUpUrl = '/speller/spellchecker.html'; // by FredCK this.popUpUrl = 'fck_spellerpages/spellerpages/spellchecker.html'; // by FredCK this.popUpName = 'spellchecker'; // this.popUpProps = "menu=no,width=440,height=350,top=70,left=120,resizable=yes,status=yes"; // by FredCK this.popUpProps = null ; // by FredCK // this.spellCheckScript = '/speller/server-scripts/spellchecker.php'; // by FredCK //this.spellCheckScript = '/cgi-bin/spellchecker.pl'; // values used to keep track of what happened to a word this.replWordFlag = "R"; // single replace this.ignrWordFlag = "I"; // single ignore this.replAllFlag = "RA"; // replace all occurances this.ignrAllFlag = "IA"; // ignore all occurances this.fromReplAll = "~RA"; // an occurance of a "replace all" word this.fromIgnrAll = "~IA"; // an occurance of a "ignore all" word // properties set at run time this.wordFlags = new Array(); this.currentTextIndex = 0; this.currentWordIndex = 0; this.spellCheckerWin = null; this.controlWin = null; this.wordWin = null; this.textArea = textObject; // deprecated this.textInputs = arguments; // private methods this._spellcheck = _spellcheck; this._getSuggestions = _getSuggestions; this._setAsIgnored = _setAsIgnored; this._getTotalReplaced = _getTotalReplaced; this._setWordText = _setWordText; this._getFormInputs = _getFormInputs; // public methods this.openChecker = openChecker; this.startCheck = startCheck; this.checkTextBoxes = checkTextBoxes; this.checkTextAreas = checkTextAreas; this.spellCheckAll = spellCheckAll; this.ignoreWord = ignoreWord; this.ignoreAll = ignoreAll; this.replaceWord = replaceWord; this.replaceAll = replaceAll; this.terminateSpell = terminateSpell; this.undo = undo; // set the current window's "speller" property to the instance of this class. // this object can now be referenced by child windows/frames. window.speller = this; } // call this method to check all text boxes (and only text boxes) in the HTML document function checkTextBoxes() { this.textInputs = this._getFormInputs( "^text$" ); this.openChecker(); } // call this method to check all textareas (and only textareas ) in the HTML document function checkTextAreas() { this.textInputs = this._getFormInputs( "^textarea$" ); this.openChecker(); } // call this method to check all text boxes and textareas in the HTML document function spellCheckAll() { this.textInputs = this._getFormInputs( "^text(area)?$" ); this.openChecker(); } // call this method to check text boxe(s) and/or textarea(s) that were passed in to the // object's constructor or to the textInputs property function openChecker() { this.spellCheckerWin = window.open( this.popUpUrl, this.popUpName, this.popUpProps ); if( !this.spellCheckerWin.opener ) { this.spellCheckerWin.opener = window; } } function startCheck( wordWindowObj, controlWindowObj ) { // set properties from args this.wordWin = wordWindowObj; this.controlWin = controlWindowObj; // reset properties this.wordWin.resetForm(); this.controlWin.resetForm(); this.currentTextIndex = 0; this.currentWordIndex = 0; // initialize the flags to an array - one element for each text input this.wordFlags = new Array( this.wordWin.textInputs.length ); // each element will be an array that keeps track of each word in the text for( var i=0; i<this.wordFlags.length; i++ ) { this.wordFlags[i] = []; } // start this._spellcheck(); return true; } function ignoreWord() { var wi = this.currentWordIndex; var ti = this.currentTextIndex; if( !this.wordWin ) { alert( 'Error: Word frame not available.' ); return false; } if( !this.wordWin.getTextVal( ti, wi )) { alert( 'Error: "Not in dictionary" text is missing.' ); return false; } // set as ignored if( this._setAsIgnored( ti, wi, this.ignrWordFlag )) { this.currentWordIndex++; this._spellcheck(); } return true; } function ignoreAll() { var wi = this.currentWordIndex; var ti = this.currentTextIndex; if( !this.wordWin ) { alert( 'Error: Word frame not available.' ); return false; } // get the word that is currently being evaluated. var s_word_to_repl = this.wordWin.getTextVal( ti, wi ); if( !s_word_to_repl ) { alert( 'Error: "Not in dictionary" text is missing' ); return false; } // set this word as an "ignore all" word. this._setAsIgnored( ti, wi, this.ignrAllFlag ); // loop through all the words after this word for( var i = ti; i < this.wordWin.textInputs.length; i++ ) { for( var j = 0; j < this.wordWin.totalWords( i ); j++ ) { if(( i == ti && j > wi ) || i > ti ) { // future word: set as "from ignore all" if // 1) do not already have a flag and // 2) have the same value as current word if(( this.wordWin.getTextVal( i, j ) == s_word_to_repl ) && ( !this.wordFlags[i][j] )) { this._setAsIgnored( i, j, this.fromIgnrAll ); } } } } // finally, move on this.currentWordIndex++; this._spellcheck(); return true; } function replaceWord() { var wi = this.currentWordIndex; var ti = this.currentTextIndex; if( !this.wordWin ) { alert( 'Error: Word frame not available.' ); return false; } if( !this.wordWin.getTextVal( ti, wi )) { alert( 'Error: "Not in dictionary" text is missing' ); return false; } if( !this.controlWin.replacementText ) { return false ; } var txt = this.controlWin.replacementText; if( txt.value ) { var newspell = new String( txt.value ); if( this._setWordText( ti, wi, newspell, this.replWordFlag )) { this.currentWordIndex++; this._spellcheck(); } } return true; } function replaceAll() { var ti = this.currentTextIndex; var wi = this.currentWordIndex; if( !this.wordWin ) { alert( 'Error: Word frame not available.' ); return false; } var s_word_to_repl = this.wordWin.getTextVal( ti, wi ); if( !s_word_to_repl ) { alert( 'Error: "Not in dictionary" text is missing' ); return false; } var txt = this.controlWin.replacementText; if( !txt.value ) return false; var newspell = new String( txt.value ); // set this word as a "replace all" word. this._setWordText( ti, wi, newspell, this.replAllFlag ); // loop through all the words after this word for( var i = ti; i < this.wordWin.textInputs.length; i++ ) { for( var j = 0; j < this.wordWin.totalWords( i ); j++ ) { if(( i == ti && j > wi ) || i > ti ) { // future word: set word text to s_word_to_repl if // 1) do not already have a flag and // 2) have the same value as s_word_to_repl if(( this.wordWin.getTextVal( i, j ) == s_word_to_repl ) && ( !this.wordFlags[i][j] )) { this._setWordText( i, j, newspell, this.fromReplAll ); } } } } // finally, move on this.currentWordIndex++; this._spellcheck(); return true; } function terminateSpell() { // called when we have reached the end of the spell checking. var msg = ""; // by FredCK var numrepl = this._getTotalReplaced(); if( numrepl == 0 ) { // see if there were no misspellings to begin with if( !this.wordWin ) { msg = ""; } else { if( this.wordWin.totalMisspellings() ) { // msg += "No words changed."; // by FredCK msg += FCKLang.DlgSpellNoChanges ; // by FredCK } else { // msg += "No misspellings found."; // by FredCK msg += FCKLang.DlgSpellNoMispell ; // by FredCK } } } else if( numrepl == 1 ) { // msg += "One word changed."; // by FredCK msg += FCKLang.DlgSpellOneChange ; // by FredCK } else { // msg += numrepl + " words changed."; // by FredCK msg += FCKLang.DlgSpellManyChanges.replace( /%1/g, numrepl ) ; } if( msg ) { // msg += "\n"; // by FredCK alert( msg ); } if( numrepl > 0 ) { // update the text field(s) on the opener window for( var i = 0; i < this.textInputs.length; i++ ) { // this.textArea.value = this.wordWin.text; if( this.wordWin ) { if( this.wordWin.textInputs[i] ) { this.textInputs[i].value = this.wordWin.textInputs[i]; } } } } // return back to the calling window // this.spellCheckerWin.close(); // by FredCK if ( typeof( this.OnFinished ) == 'function' ) // by FredCK this.OnFinished(numrepl) ; // by FredCK return true; } function undo() { // skip if this is the first word! var ti = this.currentTextIndex; var wi = this.currentWordIndex; if( this.wordWin.totalPreviousWords( ti, wi ) > 0 ) { this.wordWin.removeFocus( ti, wi ); // go back to the last word index that was acted upon do { // if the current word index is zero then reset the seed if( this.currentWordIndex == 0 && this.currentTextIndex > 0 ) { this.currentTextIndex--; this.currentWordIndex = this.wordWin.totalWords( this.currentTextIndex )-1; if( this.currentWordIndex < 0 ) this.currentWordIndex = 0; } else { if( this.currentWordIndex > 0 ) { this.currentWordIndex--; } } } while ( this.wordWin.totalWords( this.currentTextIndex ) == 0 || this.wordFlags[this.currentTextIndex][this.currentWordIndex] == this.fromIgnrAll || this.wordFlags[this.currentTextIndex][this.currentWordIndex] == this.fromReplAll ); var text_idx = this.currentTextIndex; var idx = this.currentWordIndex; var preReplSpell = this.wordWin.originalSpellings[text_idx][idx]; // if we got back to the first word then set the Undo button back to disabled if( this.wordWin.totalPreviousWords( text_idx, idx ) == 0 ) { this.controlWin.disableUndo(); } var i, j, origSpell ; // examine what happened to this current word. switch( this.wordFlags[text_idx][idx] ) { // replace all: go through this and all the future occurances of the word // and revert them all to the original spelling and clear their flags case this.replAllFlag : for( i = text_idx; i < this.wordWin.textInputs.length; i++ ) { for( j = 0; j < this.wordWin.totalWords( i ); j++ ) { if(( i == text_idx && j >= idx ) || i > text_idx ) { origSpell = this.wordWin.originalSpellings[i][j]; if( origSpell == preReplSpell ) { this._setWordText ( i, j, origSpell, undefined ); } } } } break; // ignore all: go through all the future occurances of the word // and clear their flags case this.ignrAllFlag : for( i = text_idx; i < this.wordWin.textInputs.length; i++ ) { for( j = 0; j < this.wordWin.totalWords( i ); j++ ) { if(( i == text_idx && j >= idx ) || i > text_idx ) { origSpell = this.wordWin.originalSpellings[i][j]; if( origSpell == preReplSpell ) { this.wordFlags[i][j] = undefined; } } } } break; // replace: revert the word to its original spelling case this.replWordFlag : this._setWordText ( text_idx, idx, preReplSpell, undefined ); break; } // For all four cases, clear the wordFlag of this word. re-start the process this.wordFlags[text_idx][idx] = undefined; this._spellcheck(); } } function _spellcheck() { var ww = this.wordWin; // check if this is the last word in the current text element if( this.currentWordIndex == ww.totalWords( this.currentTextIndex) ) { this.currentTextIndex++; this.currentWordIndex = 0; // keep going if we're not yet past the last text element if( this.currentTextIndex < this.wordWin.textInputs.length ) { this._spellcheck(); return; } else { this.terminateSpell(); return; } } // if this is after the first one make sure the Undo button is enabled if( this.currentWordIndex > 0 ) { this.controlWin.enableUndo(); } // skip the current word if it has already been worked on if( this.wordFlags[this.currentTextIndex][this.currentWordIndex] ) { // increment the global current word index and move on. this.currentWordIndex++; this._spellcheck(); } else { var evalText = ww.getTextVal( this.currentTextIndex, this.currentWordIndex ); if( evalText ) { this.controlWin.evaluatedText.value = evalText; ww.setFocus( this.currentTextIndex, this.currentWordIndex ); this._getSuggestions( this.currentTextIndex, this.currentWordIndex ); } } } function _getSuggestions( text_num, word_num ) { this.controlWin.clearSuggestions(); // add suggestion in list for each suggested word. // get the array of suggested words out of the // three-dimensional array containing all suggestions. var a_suggests = this.wordWin.suggestions[text_num][word_num]; if( a_suggests ) { // got an array of suggestions. for( var ii = 0; ii < a_suggests.length; ii++ ) { this.controlWin.addSuggestion( a_suggests[ii] ); } } this.controlWin.selectDefaultSuggestion(); } function _setAsIgnored( text_num, word_num, flag ) { // set the UI this.wordWin.removeFocus( text_num, word_num ); // do the bookkeeping this.wordFlags[text_num][word_num] = flag; return true; } function _getTotalReplaced() { var i_replaced = 0; for( var i = 0; i < this.wordFlags.length; i++ ) { for( var j = 0; j < this.wordFlags[i].length; j++ ) { if(( this.wordFlags[i][j] == this.replWordFlag ) || ( this.wordFlags[i][j] == this.replAllFlag ) || ( this.wordFlags[i][j] == this.fromReplAll )) { i_replaced++; } } } return i_replaced; } function _setWordText( text_num, word_num, newText, flag ) { // set the UI and form inputs this.wordWin.setText( text_num, word_num, newText ); // keep track of what happened to this word: this.wordFlags[text_num][word_num] = flag; return true; } function _getFormInputs( inputPattern ) { var inputs = new Array(); for( var i = 0; i < document.forms.length; i++ ) { for( var j = 0; j < document.forms[i].elements.length; j++ ) { if( document.forms[i].elements[j].type.match( inputPattern )) { inputs[inputs.length] = document.forms[i].elements[j]; } } } return inputs; }
JavaScript
/* * 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 == * * Useful functions used by almost all dialog window pages. * Dialogs should link to this file as the very first script on the page. */ // Automatically detect the correct document.domain (#123). (function() { var d = document.domain ; while ( true ) { // Test if we can access a parent property. try { var test = window.parent.document.domain ; break ; } catch( e ) {} // Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ... d = d.replace( /.*?(?:\.|$)/, '' ) ; if ( d.length == 0 ) break ; // It was not able to detect the domain. try { document.domain = d ; } catch (e) { break ; } } })() ; // Attention: FCKConfig must be available in the page. function GetCommonDialogCss( prefix ) { // CSS minified by http://iceyboard.no-ip.org/projects/css_compressor (see _dev/css_compression.txt). return FCKConfig.BasePath + 'dialog/common/' + '|.ImagePreviewArea{border:#000 1px solid;overflow:auto;width:100%;height:170px;background-color:#fff}.FlashPreviewArea{border:#000 1px solid;padding:5px;overflow:auto;width:100%;height:170px;background-color:#fff}.BtnReset{float:left;background-position:center center;background-image:url(images/reset.gif);width:16px;height:16px;background-repeat:no-repeat;border:1px none;font-size:1px}.BtnLocked,.BtnUnlocked{float:left;background-position:center center;background-image:url(images/locked.gif);width:16px;height:16px;background-repeat:no-repeat;border:none 1px;font-size:1px}.BtnUnlocked{background-image:url(images/unlocked.gif)}.BtnOver{border:outset 1px;cursor:pointer;cursor:hand}' ; } // Gets a element by its Id. Used for shorter coding. function GetE( elementId ) { return document.getElementById( elementId ) ; } function ShowE( element, isVisible ) { if ( typeof( element ) == 'string' ) element = GetE( element ) ; element.style.display = isVisible ? '' : 'none' ; } function SetAttribute( element, attName, attValue ) { if ( attValue == null || attValue.length == 0 ) element.removeAttribute( attName, 0 ) ; // 0 : Case Insensitive else element.setAttribute( attName, attValue, 0 ) ; // 0 : Case Insensitive } function GetAttribute( element, attName, valueIfNull ) { var oAtt = element.attributes[attName] ; if ( oAtt == null || !oAtt.specified ) return valueIfNull ? valueIfNull : '' ; var oValue = element.getAttribute( attName, 2 ) ; if ( oValue == null ) oValue = oAtt.nodeValue ; return ( oValue == null ? valueIfNull : oValue ) ; } function SelectField( elementId ) { var element = GetE( elementId ) ; element.focus() ; // element.select may not be available for some fields (like <select>). if ( element.select ) element.select() ; } // Functions used by text fields to accept numbers only. var IsDigit = ( function() { var KeyIdentifierMap = { End : 35, Home : 36, Left : 37, Right : 39, 'U+00007F' : 46 // Delete } ; return function ( e ) { if ( !e ) e = event ; var iCode = ( e.keyCode || e.charCode ) ; if ( !iCode && e.keyIdentifier && ( e.keyIdentifier in KeyIdentifierMap ) ) iCode = KeyIdentifierMap[ e.keyIdentifier ] ; return ( ( iCode >= 48 && iCode <= 57 ) // Numbers || (iCode >= 35 && iCode <= 40) // Arrows, Home, End || iCode == 8 // Backspace || iCode == 46 // Delete || iCode == 9 // Tab ) ; } } )() ; String.prototype.Trim = function() { return this.replace( /(^\s*)|(\s*$)/g, '' ) ; } String.prototype.StartsWith = function( value ) { return ( this.substr( 0, value.length ) == value ) ; } String.prototype.Remove = function( start, length ) { var s = '' ; if ( start > 0 ) s = this.substring( 0, start ) ; if ( start + length < this.length ) s += this.substring( start + length , this.length ) ; return s ; } String.prototype.ReplaceAll = function( searchArray, replaceArray ) { var replaced = this ; for ( var i = 0 ; i < searchArray.length ; i++ ) { replaced = replaced.replace( searchArray[i], replaceArray[i] ) ; } return replaced ; } function OpenFileBrowser( url, width, height ) { // oEditor must be defined. var iLeft = ( oEditor.FCKConfig.ScreenWidth - width ) / 2 ; var iTop = ( oEditor.FCKConfig.ScreenHeight - height ) / 2 ; var sOptions = "toolbar=no,status=no,resizable=yes,dependent=yes,scrollbars=yes" ; sOptions += ",width=" + width ; sOptions += ",height=" + height ; sOptions += ",left=" + iLeft ; sOptions += ",top=" + iTop ; window.open( url, 'FCKBrowseWindow', sOptions ) ; } /** Utility function to create/update an element with a name attribute in IE, so it behaves properly when moved around It also allows to change the name or other special attributes in an existing node oEditor : instance of FCKeditor where the element will be created oOriginal : current element being edited or null if it has to be created nodeName : string with the name of the element to create oAttributes : Hash object with the attributes that must be set at creation time in IE Those attributes will be set also after the element has been created for any other browser to avoid redudant code */ function CreateNamedElement( oEditor, oOriginal, nodeName, oAttributes ) { var oNewNode ; // IE doesn't allow easily to change properties of an existing object, // so remove the old and force the creation of a new one. var oldNode = null ; if ( oOriginal && oEditor.FCKBrowserInfo.IsIE ) { // Force the creation only if some of the special attributes have changed: var bChanged = false; for( var attName in oAttributes ) bChanged |= ( oOriginal.getAttribute( attName, 2) != oAttributes[attName] ) ; if ( bChanged ) { oldNode = oOriginal ; oOriginal = null ; } } // If the node existed (and it's not IE), then we just have to update its attributes if ( oOriginal ) { oNewNode = oOriginal ; } else { // #676, IE doesn't play nice with the name or type attribute if ( oEditor.FCKBrowserInfo.IsIE ) { var sbHTML = [] ; sbHTML.push( '<' + nodeName ) ; for( var prop in oAttributes ) { sbHTML.push( ' ' + prop + '="' + oAttributes[prop] + '"' ) ; } sbHTML.push( '>' ) ; if ( !oEditor.FCKListsLib.EmptyElements[nodeName.toLowerCase()] ) sbHTML.push( '</' + nodeName + '>' ) ; oNewNode = oEditor.FCK.EditorDocument.createElement( sbHTML.join('') ) ; // Check if we are just changing the properties of an existing node: copy its properties if ( oldNode ) { CopyAttributes( oldNode, oNewNode, oAttributes ) ; oEditor.FCKDomTools.MoveChildren( oldNode, oNewNode ) ; oldNode.parentNode.removeChild( oldNode ) ; oldNode = null ; if ( oEditor.FCK.Selection.SelectionData ) { // Trick to refresh the selection object and avoid error in // fckdialog.html Selection.EnsureSelection var oSel = oEditor.FCK.EditorDocument.selection ; oEditor.FCK.Selection.SelectionData = oSel.createRange() ; // Now oSel.type will be 'None' reflecting the real situation } } oNewNode = oEditor.FCK.InsertElement( oNewNode ) ; // FCK.Selection.SelectionData is broken by now since we've // deleted the previously selected element. So we need to reassign it. if ( oEditor.FCK.Selection.SelectionData ) { var range = oEditor.FCK.EditorDocument.body.createControlRange() ; range.add( oNewNode ) ; oEditor.FCK.Selection.SelectionData = range ; } } else { oNewNode = oEditor.FCK.InsertElement( nodeName ) ; } } // Set the basic attributes for( var attName in oAttributes ) oNewNode.setAttribute( attName, oAttributes[attName], 0 ) ; // 0 : Case Insensitive return oNewNode ; } // Copy all the attributes from one node to the other, kinda like a clone // But oSkipAttributes is an object with the attributes that must NOT be copied function CopyAttributes( oSource, oDest, oSkipAttributes ) { var aAttributes = oSource.attributes ; for ( var n = 0 ; n < aAttributes.length ; n++ ) { var oAttribute = aAttributes[n] ; if ( oAttribute.specified ) { var sAttName = oAttribute.nodeName ; // We can set the type only once, so do it with the proper value, not copying it. if ( sAttName in oSkipAttributes ) continue ; var sAttValue = oSource.getAttribute( sAttName, 2 ) ; if ( sAttValue == null ) sAttValue = oAttribute.nodeValue ; oDest.setAttribute( sAttName, sAttValue, 0 ) ; // 0 : Case Insensitive } } // The style: if ( oSource.style.cssText !== '' ) oDest.style.cssText = oSource.style.cssText ; } /** * Replaces a tag with another one, keeping its contents: * for example TD --> TH, and TH --> TD. * input: the original node, and the new tag name * http://www.w3.org/TR/DOM-Level-3-Core/core.html#Document3-renameNode */ function RenameNode( oNode , newTag ) { // TODO: if the browser natively supports document.renameNode call it. // does any browser currently support it in order to test? // Only rename element nodes. if ( oNode.nodeType != 1 ) return null ; // If it's already correct exit here. if ( oNode.nodeName == newTag ) return oNode ; var oDoc = oNode.ownerDocument ; // Create the new node var newNode = oDoc.createElement( newTag ) ; // Copy all attributes CopyAttributes( oNode, newNode, {} ) ; // Move children to the new node FCKDomTools.MoveChildren( oNode, newNode ) ; // Finally replace the node and return the new one oNode.parentNode.replaceChild( newNode, oNode ) ; return newNode ; }
JavaScript
/* * 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 == * * Scripts related to the Image dialog window (see fck_image.html). */ var dialog = window.parent ; var oEditor = dialog.InnerDialogLoaded() ; var FCK = oEditor.FCK ; var FCKLang = oEditor.FCKLang ; var FCKConfig = oEditor.FCKConfig ; var FCKDebug = oEditor.FCKDebug ; var FCKTools = oEditor.FCKTools ; var bImageButton = ( document.location.search.length > 0 && document.location.search.substr(1) == 'ImageButton' ) ; //#### Dialog Tabs // Set the dialog tabs. dialog.AddTab( 'Info', FCKLang.DlgImgInfoTab ) ; if ( !bImageButton && !FCKConfig.ImageDlgHideLink ) dialog.AddTab( 'Link', FCKLang.DlgImgLinkTab ) ; if ( FCKConfig.ImageUpload ) dialog.AddTab( 'Upload', FCKLang.DlgLnkUpload ) ; if ( !FCKConfig.ImageDlgHideAdvanced ) dialog.AddTab( 'Advanced', FCKLang.DlgAdvancedTag ) ; // Function called when a dialog tag is selected. function OnDialogTabChange( tabCode ) { ShowE('divInfo' , ( tabCode == 'Info' ) ) ; ShowE('divLink' , ( tabCode == 'Link' ) ) ; ShowE('divUpload' , ( tabCode == 'Upload' ) ) ; ShowE('divAdvanced' , ( tabCode == 'Advanced' ) ) ; } // Get the selected image (if available). var oImage = dialog.Selection.GetSelectedElement() ; if ( oImage && oImage.tagName != 'IMG' && !( oImage.tagName == 'INPUT' && oImage.type == 'image' ) ) oImage = null ; // Get the active link. var oLink = dialog.Selection.GetSelection().MoveToAncestorNode( 'A' ) ; var oImageOriginal ; function UpdateOriginal( resetSize ) { if ( !eImgPreview ) return ; if ( GetE('txtUrl').value.length == 0 ) { oImageOriginal = null ; return ; } oImageOriginal = document.createElement( 'IMG' ) ; // new Image() ; if ( resetSize ) { oImageOriginal.onload = function() { this.onload = null ; ResetSizes() ; } } oImageOriginal.src = eImgPreview.src ; } var bPreviewInitialized ; window.onload = function() { // Translate the dialog box texts. oEditor.FCKLanguageManager.TranslatePage(document) ; GetE('btnLockSizes').title = FCKLang.DlgImgLockRatio ; GetE('btnResetSize').title = FCKLang.DlgBtnResetSize ; // Load the selected element information (if any). LoadSelection() ; // Show/Hide the "Browse Server" button. GetE('tdBrowse').style.display = FCKConfig.ImageBrowser ? '' : 'none' ; GetE('divLnkBrowseServer').style.display = FCKConfig.LinkBrowser ? '' : 'none' ; UpdateOriginal() ; // Set the actual uploader URL. if ( FCKConfig.ImageUpload ) GetE('frmUpload').action = FCKConfig.ImageUploadURL ; dialog.SetAutoSize( true ) ; // Activate the "OK" button. dialog.SetOkButton( true ) ; SelectField( 'txtUrl' ) ; } function LoadSelection() { if ( ! oImage ) return ; var sUrl = oImage.getAttribute( '_fcksavedurl' ) ; if ( sUrl == null ) sUrl = GetAttribute( oImage, 'src', '' ) ; GetE('txtUrl').value = sUrl ; GetE('txtAlt').value = GetAttribute( oImage, 'alt', '' ) ; GetE('txtVSpace').value = GetAttribute( oImage, 'vspace', '' ) ; GetE('txtHSpace').value = GetAttribute( oImage, 'hspace', '' ) ; GetE('txtBorder').value = GetAttribute( oImage, 'border', '' ) ; GetE('cmbAlign').value = GetAttribute( oImage, 'align', '' ) ; var iWidth, iHeight ; var regexSize = /^\s*(\d+)px\s*$/i ; if ( oImage.style.width ) { var aMatchW = oImage.style.width.match( regexSize ) ; if ( aMatchW ) { iWidth = aMatchW[1] ; oImage.style.width = '' ; SetAttribute( oImage, 'width' , iWidth ) ; } } if ( oImage.style.height ) { var aMatchH = oImage.style.height.match( regexSize ) ; if ( aMatchH ) { iHeight = aMatchH[1] ; oImage.style.height = '' ; SetAttribute( oImage, 'height', iHeight ) ; } } GetE('txtWidth').value = iWidth ? iWidth : GetAttribute( oImage, "width", '' ) ; GetE('txtHeight').value = iHeight ? iHeight : GetAttribute( oImage, "height", '' ) ; // Get Advances Attributes GetE('txtAttId').value = oImage.id ; GetE('cmbAttLangDir').value = oImage.dir ; GetE('txtAttLangCode').value = oImage.lang ; GetE('txtAttTitle').value = oImage.title ; GetE('txtLongDesc').value = oImage.longDesc ; if ( oEditor.FCKBrowserInfo.IsIE ) { GetE('txtAttClasses').value = oImage.className || '' ; GetE('txtAttStyle').value = oImage.style.cssText ; } else { GetE('txtAttClasses').value = oImage.getAttribute('class',2) || '' ; GetE('txtAttStyle').value = oImage.getAttribute('style',2) ; } if ( oLink ) { var sLinkUrl = oLink.getAttribute( '_fcksavedurl' ) ; if ( sLinkUrl == null ) sLinkUrl = oLink.getAttribute('href',2) ; GetE('txtLnkUrl').value = sLinkUrl ; GetE('cmbLnkTarget').value = oLink.target ; } UpdatePreview() ; } //#### The OK button was hit. function Ok() { if ( GetE('txtUrl').value.length == 0 ) { dialog.SetSelectedTab( 'Info' ) ; GetE('txtUrl').focus() ; alert( FCKLang.DlgImgAlertUrl ) ; return false ; } var bHasImage = ( oImage != null ) ; if ( bHasImage && bImageButton && oImage.tagName == 'IMG' ) { if ( confirm( 'Do you want to transform the selected image on a image button?' ) ) oImage = null ; } else if ( bHasImage && !bImageButton && oImage.tagName == 'INPUT' ) { if ( confirm( 'Do you want to transform the selected image button on a simple image?' ) ) oImage = null ; } oEditor.FCKUndo.SaveUndoStep() ; if ( !bHasImage ) { if ( bImageButton ) { oImage = FCK.EditorDocument.createElement( 'input' ) ; oImage.type = 'image' ; oImage = FCK.InsertElement( oImage ) ; } else oImage = FCK.InsertElement( 'img' ) ; } UpdateImage( oImage ) ; var sLnkUrl = GetE('txtLnkUrl').value.Trim() ; if ( sLnkUrl.length == 0 ) { if ( oLink ) FCK.ExecuteNamedCommand( 'Unlink' ) ; } else { if ( oLink ) // Modifying an existent link. oLink.href = sLnkUrl ; else // Creating a new link. { if ( !bHasImage ) oEditor.FCKSelection.SelectNode( oImage ) ; oLink = oEditor.FCK.CreateLink( sLnkUrl )[0] ; if ( !bHasImage ) { oEditor.FCKSelection.SelectNode( oLink ) ; oEditor.FCKSelection.Collapse( false ) ; } } SetAttribute( oLink, '_fcksavedurl', sLnkUrl ) ; SetAttribute( oLink, 'target', GetE('cmbLnkTarget').value ) ; } return true ; } function UpdateImage( e, skipId ) { e.src = GetE('txtUrl').value ; SetAttribute( e, "_fcksavedurl", GetE('txtUrl').value ) ; SetAttribute( e, "alt" , GetE('txtAlt').value ) ; SetAttribute( e, "width" , GetE('txtWidth').value ) ; SetAttribute( e, "height", GetE('txtHeight').value ) ; SetAttribute( e, "vspace", GetE('txtVSpace').value ) ; SetAttribute( e, "hspace", GetE('txtHSpace').value ) ; SetAttribute( e, "border", GetE('txtBorder').value ) ; SetAttribute( e, "align" , GetE('cmbAlign').value ) ; // Advances Attributes if ( ! skipId ) SetAttribute( e, 'id', GetE('txtAttId').value ) ; SetAttribute( e, 'dir' , GetE('cmbAttLangDir').value ) ; SetAttribute( e, 'lang' , GetE('txtAttLangCode').value ) ; SetAttribute( e, 'title' , GetE('txtAttTitle').value ) ; SetAttribute( e, 'longDesc' , GetE('txtLongDesc').value ) ; if ( oEditor.FCKBrowserInfo.IsIE ) { e.className = GetE('txtAttClasses').value ; e.style.cssText = GetE('txtAttStyle').value ; } else { SetAttribute( e, 'class' , GetE('txtAttClasses').value ) ; SetAttribute( e, 'style', GetE('txtAttStyle').value ) ; } } var eImgPreview ; var eImgPreviewLink ; function SetPreviewElements( imageElement, linkElement ) { eImgPreview = imageElement ; eImgPreviewLink = linkElement ; UpdatePreview() ; UpdateOriginal() ; bPreviewInitialized = true ; } function UpdatePreview() { if ( !eImgPreview || !eImgPreviewLink ) return ; if ( GetE('txtUrl').value.length == 0 ) eImgPreviewLink.style.display = 'none' ; else { UpdateImage( eImgPreview, true ) ; if ( GetE('txtLnkUrl').value.Trim().length > 0 ) eImgPreviewLink.href = 'javascript:void(null);' ; else SetAttribute( eImgPreviewLink, 'href', '' ) ; eImgPreviewLink.style.display = '' ; } } var bLockRatio = true ; function SwitchLock( lockButton ) { bLockRatio = !bLockRatio ; lockButton.className = bLockRatio ? 'BtnLocked' : 'BtnUnlocked' ; lockButton.title = bLockRatio ? 'Lock sizes' : 'Unlock sizes' ; if ( bLockRatio ) { if ( GetE('txtWidth').value.length > 0 ) OnSizeChanged( 'Width', GetE('txtWidth').value ) ; else OnSizeChanged( 'Height', GetE('txtHeight').value ) ; } } // Fired when the width or height input texts change function OnSizeChanged( dimension, value ) { // Verifies if the aspect ration has to be maintained if ( oImageOriginal && bLockRatio ) { var e = dimension == 'Width' ? GetE('txtHeight') : GetE('txtWidth') ; if ( value.length == 0 || isNaN( value ) ) { e.value = '' ; return ; } if ( dimension == 'Width' ) value = value == 0 ? 0 : Math.round( oImageOriginal.height * ( value / oImageOriginal.width ) ) ; else value = value == 0 ? 0 : Math.round( oImageOriginal.width * ( value / oImageOriginal.height ) ) ; if ( !isNaN( value ) ) e.value = value ; } UpdatePreview() ; } // Fired when the Reset Size button is clicked function ResetSizes() { if ( ! oImageOriginal ) return ; if ( oEditor.FCKBrowserInfo.IsGecko && !oImageOriginal.complete ) { setTimeout( ResetSizes, 50 ) ; return ; } GetE('txtWidth').value = oImageOriginal.width ; GetE('txtHeight').value = oImageOriginal.height ; UpdatePreview() ; } function BrowseServer() { OpenServerBrowser( 'Image', FCKConfig.ImageBrowserURL, FCKConfig.ImageBrowserWindowWidth, FCKConfig.ImageBrowserWindowHeight ) ; } function LnkBrowseServer() { OpenServerBrowser( 'Link', FCKConfig.LinkBrowserURL, FCKConfig.LinkBrowserWindowWidth, FCKConfig.LinkBrowserWindowHeight ) ; } function OpenServerBrowser( type, url, width, height ) { sActualBrowser = type ; OpenFileBrowser( url, width, height ) ; } var sActualBrowser ; function SetUrl( url, width, height, alt ) { if ( sActualBrowser == 'Link' ) { GetE('txtLnkUrl').value = url ; UpdatePreview() ; } else { GetE('txtUrl').value = url ; GetE('txtWidth').value = width ? width : '' ; GetE('txtHeight').value = height ? height : '' ; if ( alt ) GetE('txtAlt').value = alt; UpdatePreview() ; UpdateOriginal( true ) ; } dialog.SetSelectedTab( 'Info' ) ; } function OnUploadCompleted( errorNumber, fileUrl, fileName, customMsg ) { // Remove animation window.parent.Throbber.Hide() ; GetE( 'divUpload' ).style.display = '' ; switch ( errorNumber ) { case 0 : // No errors //alert( 'Your file has been successfully uploaded' ) ; break ; case 1 : // Custom error alert( customMsg ) ; return ; case 101 : // Custom warning alert( customMsg ) ; break ; case 201 : alert( 'A file with the same name is already available. The uploaded file has been renamed to "' + fileName + '"' ) ; break ; case 202 : alert( 'Invalid file type' ) ; return ; case 203 : alert( "Security error. You probably don't have enough permissions to upload. Please check your server." ) ; return ; case 500 : alert( 'The connector is disabled' ) ; break ; default : alert( 'Error on file upload. Error number: ' + errorNumber ) ; return ; } sActualBrowser = '' ; SetUrl( fileUrl ) ; GetE('frmUpload').reset() ; } function UploadCompleted( errorNumber, fileUrl, fileName, customMsg ) { // Remove animation window.parent.Throbber.Hide() ; GetE( 'divUpload' ).style.display = '' ; switch ( errorNumber ) { case 0 : // No errors alert( 'Your file has been successfully uploaded' ) ; break ; case 1 : // Custom error alert( customMsg ) ; return ; case 101 : // Custom warning alert( customMsg ) ; break ; case 201 : alert( 'A file with the same name is already available. The uploaded file has been renamed to "' + fileName + '"' ) ; break ; case 202 : alert( 'Invalid file type' ) ; return ; case 203 : alert( "Security error. You probably don't have enough permissions to upload. Please check your server." ) ; return ; case 500 : alert( 'The connector is disabled' ) ; break ; default : alert( 'Error on file upload. Error number: ' + errorNumber ) ; return ; } sActualBrowser = '' ; SetUrl( fileUrl ) ; GetE('frmUpload').reset() ; } var oUploadAllowedExtRegex = new RegExp( FCKConfig.ImageUploadAllowedExtensions, 'i' ) ; var oUploadDeniedExtRegex = new RegExp( FCKConfig.ImageUploadDeniedExtensions, 'i' ) ; function CheckUpload() { var sFile = GetE('txtUploadFile').value; if ( sFile.length == 0 ) { alert( 'Please select a file to upload' ) ; return false ; } if ( ( FCKConfig.ImageUploadAllowedExtensions.length > 0 && !oUploadAllowedExtRegex.test( sFile ) ) || ( FCKConfig.ImageUploadDeniedExtensions.length > 0 && oUploadDeniedExtRegex.test( sFile ) ) ) { OnUploadCompleted( 202 ) ; return false ; } // Show animation window.parent.Throbber.Show( 100 ) ; GetE( 'divUpload' ).style.display = 'none' ; return true ; } document.write("<link href=\""+FCKConfig.PUBLIC_DIR+"/style/uploadify.css\" rel=\"stylesheet\" type=\"text/css\" />"); document.write("<script type=\"text/javascript\" src=\""+FCKConfig.PUBLIC_DIR+"/javascript/jquery.js\"></script>"); document.write("<script type=\"text/javascript\" src=\""+FCKConfig.PUBLIC_DIR+"/javascript/swfobject.js\"></script>"); document.write("<script type=\"text/javascript\" src=\""+FCKConfig.PUBLIC_DIR+"/javascript/jquery.uploadify.v2.1.0.min.js\"></script>");
JavaScript
/* * 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 == * * Scripts related to the Flash dialog window (see fck_flash.html). */ var dialog = window.parent ; var oEditor = dialog.InnerDialogLoaded() ; var FCK = oEditor.FCK ; var FCKLang = oEditor.FCKLang ; var FCKConfig = oEditor.FCKConfig ; var FCKTools = oEditor.FCKTools ; //#### Dialog Tabs // Set the dialog tabs. dialog.AddTab( 'Info', oEditor.FCKLang.DlgInfoTab ) ; if ( FCKConfig.FlashUpload ) dialog.AddTab( 'Upload', FCKLang.DlgLnkUpload ) ; if ( !FCKConfig.FlashDlgHideAdvanced ) dialog.AddTab( 'Advanced', oEditor.FCKLang.DlgAdvancedTag ) ; // Function called when a dialog tag is selected. function OnDialogTabChange( tabCode ) { ShowE('divInfo' , ( tabCode == 'Info' ) ) ; ShowE('divUpload' , ( tabCode == 'Upload' ) ) ; ShowE('divAdvanced' , ( tabCode == 'Advanced' ) ) ; } // Get the selected flash embed (if available). var oFakeImage = dialog.Selection.GetSelectedElement() ; var oEmbed ; if ( oFakeImage ) { if ( oFakeImage.tagName == 'IMG' && oFakeImage.getAttribute('_fckflash') ) oEmbed = FCK.GetRealElement( oFakeImage ) ; else oFakeImage = null ; } window.onload = function() { // Translate the dialog box texts. oEditor.FCKLanguageManager.TranslatePage(document) ; // Load the selected element information (if any). LoadSelection() ; // Show/Hide the "Browse Server" button. GetE('tdBrowse').style.display = FCKConfig.FlashBrowser ? '' : 'none' ; // Set the actual uploader URL. if ( FCKConfig.FlashUpload ) GetE('frmUpload').action = FCKConfig.FlashUploadURL ; dialog.SetAutoSize( true ) ; // Activate the "OK" button. dialog.SetOkButton( true ) ; SelectField( 'txtUrl' ) ; } function LoadSelection() { if ( ! oEmbed ) return ; GetE('txtUrl').value = GetAttribute( oEmbed, 'src', '' ) ; GetE('txtWidth').value = GetAttribute( oEmbed, 'width', '' ) ; GetE('txtHeight').value = GetAttribute( oEmbed, 'height', '' ) ; // Get Advances Attributes GetE('txtAttId').value = oEmbed.id ; GetE('chkAutoPlay').checked = GetAttribute( oEmbed, 'play', 'true' ) == 'true' ; GetE('chkLoop').checked = GetAttribute( oEmbed, 'loop', 'true' ) == 'true' ; GetE('chkMenu').checked = GetAttribute( oEmbed, 'menu', 'true' ) == 'true' ; GetE('cmbScale').value = GetAttribute( oEmbed, 'scale', '' ).toLowerCase() ; GetE('txtAttTitle').value = oEmbed.title ; if ( oEditor.FCKBrowserInfo.IsIE ) { GetE('txtAttClasses').value = oEmbed.getAttribute('className') || '' ; GetE('txtAttStyle').value = oEmbed.style.cssText ; } else { GetE('txtAttClasses').value = oEmbed.getAttribute('class',2) || '' ; GetE('txtAttStyle').value = oEmbed.getAttribute('style',2) || '' ; } UpdatePreview() ; } //#### The OK button was hit. function Ok() { if ( GetE('txtUrl').value.length == 0 ) { dialog.SetSelectedTab( 'Info' ) ; GetE('txtUrl').focus() ; alert( oEditor.FCKLang.DlgAlertUrl ) ; return false ; } oEditor.FCKUndo.SaveUndoStep() ; if ( !oEmbed ) { oEmbed = FCK.EditorDocument.createElement( 'EMBED' ) ; oFakeImage = null ; } UpdateEmbed( oEmbed ) ; if ( !oFakeImage ) { oFakeImage = oEditor.FCKDocumentProcessor_CreateFakeImage( 'FCK__Flash', oEmbed ) ; oFakeImage.setAttribute( '_fckflash', 'true', 0 ) ; oFakeImage = FCK.InsertElement( oFakeImage ) ; } oEditor.FCKEmbedAndObjectProcessor.RefreshView( oFakeImage, oEmbed ) ; return true ; } function UpdateEmbed( e ) { SetAttribute( e, 'type' , 'application/x-shockwave-flash' ) ; SetAttribute( e, 'pluginspage' , 'http://www.macromedia.com/go/getflashplayer' ) ; SetAttribute( e, 'src', GetE('txtUrl').value ) ; SetAttribute( e, "width" , GetE('txtWidth').value ) ; SetAttribute( e, "height", GetE('txtHeight').value ) ; // Advances Attributes SetAttribute( e, 'id' , GetE('txtAttId').value ) ; SetAttribute( e, 'scale', GetE('cmbScale').value ) ; SetAttribute( e, 'play', GetE('chkAutoPlay').checked ? 'true' : 'false' ) ; SetAttribute( e, 'loop', GetE('chkLoop').checked ? 'true' : 'false' ) ; SetAttribute( e, 'menu', GetE('chkMenu').checked ? 'true' : 'false' ) ; SetAttribute( e, 'title' , GetE('txtAttTitle').value ) ; if ( oEditor.FCKBrowserInfo.IsIE ) { SetAttribute( e, 'className', GetE('txtAttClasses').value ) ; e.style.cssText = GetE('txtAttStyle').value ; } else { SetAttribute( e, 'class', GetE('txtAttClasses').value ) ; SetAttribute( e, 'style', GetE('txtAttStyle').value ) ; } } var ePreview ; function SetPreviewElement( previewEl ) { ePreview = previewEl ; if ( GetE('txtUrl').value.length > 0 ) UpdatePreview() ; } function UpdatePreview() { if ( !ePreview ) return ; while ( ePreview.firstChild ) ePreview.removeChild( ePreview.firstChild ) ; if ( GetE('txtUrl').value.length == 0 ) ePreview.innerHTML = '&nbsp;' ; else { var oDoc = ePreview.ownerDocument || ePreview.document ; var e = oDoc.createElement( 'EMBED' ) ; SetAttribute( e, 'src', GetE('txtUrl').value ) ; SetAttribute( e, 'type', 'application/x-shockwave-flash' ) ; SetAttribute( e, 'width', '100%' ) ; SetAttribute( e, 'height', '100%' ) ; ePreview.appendChild( e ) ; } } // <embed id="ePreview" src="fck_flash/claims.swf" width="100%" height="100%" style="visibility:hidden" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"> function BrowseServer() { OpenFileBrowser( FCKConfig.FlashBrowserURL, FCKConfig.FlashBrowserWindowWidth, FCKConfig.FlashBrowserWindowHeight ) ; } function SetUrl( url, width, height ) { GetE('txtUrl').value = url ; if ( width ) GetE('txtWidth').value = width ; if ( height ) GetE('txtHeight').value = height ; UpdatePreview() ; dialog.SetSelectedTab( 'Info' ) ; } function OnUploadCompleted( errorNumber, fileUrl, fileName, customMsg ) { // Remove animation window.parent.Throbber.Hide() ; GetE( 'divUpload' ).style.display = '' ; switch ( errorNumber ) { case 0 : // No errors alert( 'Your file has been successfully uploaded' ) ; break ; case 1 : // Custom error alert( customMsg ) ; return ; case 101 : // Custom warning alert( customMsg ) ; break ; case 201 : alert( 'A file with the same name is already available. The uploaded file has been renamed to "' + fileName + '"' ) ; break ; case 202 : alert( 'Invalid file type' ) ; return ; case 203 : alert( "Security error. You probably don't have enough permissions to upload. Please check your server." ) ; return ; case 500 : alert( 'The connector is disabled' ) ; break ; default : alert( 'Error on file upload. Error number: ' + errorNumber ) ; return ; } SetUrl( fileUrl ) ; GetE('frmUpload').reset() ; } var oUploadAllowedExtRegex = new RegExp( FCKConfig.FlashUploadAllowedExtensions, 'i' ) ; var oUploadDeniedExtRegex = new RegExp( FCKConfig.FlashUploadDeniedExtensions, 'i' ) ; function CheckUpload() { var sFile = GetE('txtUploadFile').value ; if ( sFile.length == 0 ) { alert( 'Please select a file to upload' ) ; return false ; } if ( ( FCKConfig.FlashUploadAllowedExtensions.length > 0 && !oUploadAllowedExtRegex.test( sFile ) ) || ( FCKConfig.FlashUploadDeniedExtensions.length > 0 && oUploadDeniedExtRegex.test( sFile ) ) ) { OnUploadCompleted( 202 ) ; return false ; } // Show animation window.parent.Throbber.Show( 100 ) ; GetE( 'divUpload' ).style.display = 'none' ; return true ; }
JavaScript
/* * 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 == * * Plugin to insert "Placeholders" in the editor. */ // Register the related command. FCKCommands.RegisterCommand( 'Placeholder', new FCKDialogCommand( 'Placeholder', FCKLang.PlaceholderDlgTitle, FCKPlugins.Items['placeholder'].Path + 'fck_placeholder.html', 340, 160 ) ) ; // Create the "Plaholder" toolbar button. var oPlaceholderItem = new FCKToolbarButton( 'Placeholder', FCKLang.PlaceholderBtn ) ; oPlaceholderItem.IconPath = FCKPlugins.Items['placeholder'].Path + 'placeholder.gif' ; FCKToolbarItems.RegisterItem( 'Placeholder', oPlaceholderItem ) ; // The object used for all Placeholder operations. var FCKPlaceholders = new Object() ; // Add a new placeholder at the actual selection. FCKPlaceholders.Add = function( name ) { var oSpan = FCK.InsertElement( 'span' ) ; this.SetupSpan( oSpan, name ) ; } FCKPlaceholders.SetupSpan = function( span, name ) { span.innerHTML = '[[ ' + name + ' ]]' ; span.style.backgroundColor = '#ffff00' ; span.style.color = '#000000' ; if ( FCKBrowserInfo.IsGecko ) span.style.cursor = 'default' ; span._fckplaceholder = name ; span.contentEditable = false ; // To avoid it to be resized. span.onresizestart = function() { FCK.EditorWindow.event.returnValue = false ; return false ; } } // On Gecko we must do this trick so the user select all the SPAN when clicking on it. FCKPlaceholders._SetupClickListener = function() { FCKPlaceholders._ClickListener = function( e ) { if ( e.target.tagName == 'SPAN' && e.target._fckplaceholder ) FCKSelection.SelectNode( e.target ) ; } FCK.EditorDocument.addEventListener( 'click', FCKPlaceholders._ClickListener, true ) ; } // Open the Placeholder dialog on double click. FCKPlaceholders.OnDoubleClick = function( span ) { if ( span.tagName == 'SPAN' && span._fckplaceholder ) FCKCommands.GetCommand( 'Placeholder' ).Execute() ; } FCK.RegisterDoubleClickHandler( FCKPlaceholders.OnDoubleClick, 'SPAN' ) ; // Check if a Placholder name is already in use. FCKPlaceholders.Exist = function( name ) { var aSpans = FCK.EditorDocument.getElementsByTagName( 'SPAN' ) ; for ( var i = 0 ; i < aSpans.length ; i++ ) { if ( aSpans[i]._fckplaceholder == name ) return true ; } return false ; } if ( FCKBrowserInfo.IsIE ) { FCKPlaceholders.Redraw = function() { if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG ) return ; var aPlaholders = FCK.EditorDocument.body.innerText.match( /\[\[[^\[\]]+\]\]/g ) ; if ( !aPlaholders ) return ; var oRange = FCK.EditorDocument.body.createTextRange() ; for ( var i = 0 ; i < aPlaholders.length ; i++ ) { if ( oRange.findText( aPlaholders[i] ) ) { var sName = aPlaholders[i].match( /\[\[\s*([^\]]*?)\s*\]\]/ )[1] ; oRange.pasteHTML( '<span style="color: #000000; background-color: #ffff00" contenteditable="false" _fckplaceholder="' + sName + '">' + aPlaholders[i] + '</span>' ) ; } } } } else { FCKPlaceholders.Redraw = function() { if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG ) return ; var oInteractor = FCK.EditorDocument.createTreeWalker( FCK.EditorDocument.body, NodeFilter.SHOW_TEXT, FCKPlaceholders._AcceptNode, true ) ; var aNodes = new Array() ; while ( ( oNode = oInteractor.nextNode() ) ) { aNodes[ aNodes.length ] = oNode ; } for ( var n = 0 ; n < aNodes.length ; n++ ) { var aPieces = aNodes[n].nodeValue.split( /(\[\[[^\[\]]+\]\])/g ) ; for ( var i = 0 ; i < aPieces.length ; i++ ) { if ( aPieces[i].length > 0 ) { if ( aPieces[i].indexOf( '[[' ) == 0 ) { var sName = aPieces[i].match( /\[\[\s*([^\]]*?)\s*\]\]/ )[1] ; var oSpan = FCK.EditorDocument.createElement( 'span' ) ; FCKPlaceholders.SetupSpan( oSpan, sName ) ; aNodes[n].parentNode.insertBefore( oSpan, aNodes[n] ) ; } else aNodes[n].parentNode.insertBefore( FCK.EditorDocument.createTextNode( aPieces[i] ) , aNodes[n] ) ; } } aNodes[n].parentNode.removeChild( aNodes[n] ) ; } FCKPlaceholders._SetupClickListener() ; } FCKPlaceholders._AcceptNode = function( node ) { if ( /\[\[[^\[\]]+\]\]/.test( node.nodeValue ) ) return NodeFilter.FILTER_ACCEPT ; else return NodeFilter.FILTER_SKIP ; } } FCK.Events.AttachEvent( 'OnAfterSetHTML', FCKPlaceholders.Redraw ) ; // We must process the SPAN tags to replace then with the real resulting value of the placeholder. FCKXHtml.TagProcessors['span'] = function( node, htmlNode ) { if ( htmlNode._fckplaceholder ) node = FCKXHtml.XML.createTextNode( '[[' + htmlNode._fckplaceholder + ']]' ) ; else FCKXHtml._AppendChildNodes( node, htmlNode, false ) ; return node ; }
JavaScript
/* * 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 == * * Placholder Italian language file. */ FCKLang.PlaceholderBtn = 'Aggiungi/Modifica Placeholder' ; FCKLang.PlaceholderDlgTitle = 'Proprietà del Placeholder' ; FCKLang.PlaceholderDlgName = 'Nome del Placeholder' ; FCKLang.PlaceholderErrNoName = 'Digitare il nome del placeholder' ; FCKLang.PlaceholderErrNameInUse = 'Il nome inserito è già in uso' ;
JavaScript
/* * 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 == * * Placholder German language file. */ FCKLang.PlaceholderBtn = 'Einfügen/editieren Platzhalter' ; FCKLang.PlaceholderDlgTitle = 'Platzhalter Eigenschaften' ; FCKLang.PlaceholderDlgName = 'Platzhalter Name' ; FCKLang.PlaceholderErrNoName = 'Bitte den Namen des Platzhalters schreiben' ; FCKLang.PlaceholderErrNameInUse = 'Der angegebene Namen ist schon in Gebrauch' ;
JavaScript
/* * 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 == * * Placholder Polish language file. */ FCKLang.PlaceholderBtn = 'Wstaw/Edytuj nagłówek' ; FCKLang.PlaceholderDlgTitle = 'Właśności nagłówka' ; FCKLang.PlaceholderDlgName = 'Nazwa nagłówka' ; FCKLang.PlaceholderErrNoName = 'Proszę wprowadzić nazwę nagłówka' ; FCKLang.PlaceholderErrNameInUse = 'Podana nazwa jest już w użyciu' ;
JavaScript
/* * 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 == * * Placeholder French language file. */ FCKLang.PlaceholderBtn = "Insérer/Modifier l'Espace réservé" ; FCKLang.PlaceholderDlgTitle = "Propriétés de l'Espace réservé" ; FCKLang.PlaceholderDlgName = "Nom de l'Espace réservé" ; FCKLang.PlaceholderErrNoName = "Veuillez saisir le nom de l'Espace réservé" ; FCKLang.PlaceholderErrNameInUse = "Ce nom est déjà utilisé" ;
JavaScript
/* * 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 == * * Placholder English language file. */ FCKLang.PlaceholderBtn = 'Insert/Edit Placeholder' ; FCKLang.PlaceholderDlgTitle = 'Placeholder Properties' ; FCKLang.PlaceholderDlgName = 'Placeholder Name' ; FCKLang.PlaceholderErrNoName = 'Please type the placeholder name' ; FCKLang.PlaceholderErrNameInUse = 'The specified name is already in use' ;
JavaScript
/* * 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 == * * Placholder Spanish language file. */ FCKLang.PlaceholderBtn = 'Insertar/Editar contenedor' ; FCKLang.PlaceholderDlgTitle = 'Propiedades del contenedor ' ; FCKLang.PlaceholderDlgName = 'Nombre de contenedor' ; FCKLang.PlaceholderErrNoName = 'Por favor escriba el nombre de contenedor' ; FCKLang.PlaceholderErrNameInUse = 'El nombre especificado ya esta en uso' ;
JavaScript
var FCKDragTableHandler = { "_DragState" : 0, "_LeftCell" : null, "_RightCell" : null, "_MouseMoveMode" : 0, // 0 - find candidate cells for resizing, 1 - drag to resize "_ResizeBar" : null, "_OriginalX" : null, "_MinimumX" : null, "_MaximumX" : null, "_LastX" : null, "_TableMap" : null, "_doc" : document, "_IsInsideNode" : function( w, domNode, pos ) { var myCoords = FCKTools.GetWindowPosition( w, domNode ) ; var xMin = myCoords.x ; var yMin = myCoords.y ; var xMax = parseInt( xMin, 10 ) + parseInt( domNode.offsetWidth, 10 ) ; var yMax = parseInt( yMin, 10 ) + parseInt( domNode.offsetHeight, 10 ) ; if ( pos.x >= xMin && pos.x <= xMax && pos.y >= yMin && pos.y <= yMax ) return true; return false; }, "_GetBorderCells" : function( w, tableNode, tableMap, mouse ) { // Enumerate all the cells in the table. var cells = [] ; for ( var i = 0 ; i < tableNode.rows.length ; i++ ) { var r = tableNode.rows[i] ; for ( var j = 0 ; j < r.cells.length ; j++ ) cells.push( r.cells[j] ) ; } if ( cells.length < 1 ) return null ; // Get the cells whose right or left border is nearest to the mouse cursor's x coordinate. var minRxDist = null ; var lxDist = null ; var minYDist = null ; var rbCell = null ; var lbCell = null ; for ( var i = 0 ; i < cells.length ; i++ ) { var pos = FCKTools.GetWindowPosition( w, cells[i] ) ; var rightX = pos.x + parseInt( cells[i].clientWidth, 10 ) ; var rxDist = mouse.x - rightX ; var yDist = mouse.y - ( pos.y + ( cells[i].clientHeight / 2 ) ) ; if ( minRxDist == null || ( Math.abs( rxDist ) <= Math.abs( minRxDist ) && ( minYDist == null || Math.abs( yDist ) <= Math.abs( minYDist ) ) ) ) { minRxDist = rxDist ; minYDist = yDist ; rbCell = cells[i] ; } } /* var rowNode = FCKTools.GetElementAscensor( rbCell, "tr" ) ; var cellIndex = rbCell.cellIndex + 1 ; if ( cellIndex >= rowNode.cells.length ) return null ; lbCell = rowNode.cells.item( cellIndex ) ; */ var rowIdx = rbCell.parentNode.rowIndex ; var colIdx = FCKTableHandler._GetCellIndexSpan( tableMap, rowIdx, rbCell ) ; var colSpan = isNaN( rbCell.colSpan ) ? 1 : rbCell.colSpan ; lbCell = tableMap[rowIdx][colIdx + colSpan] ; if ( ! lbCell ) return null ; // Abort if too far from the border. lxDist = mouse.x - FCKTools.GetWindowPosition( w, lbCell ).x ; if ( lxDist < 0 && minRxDist < 0 && minRxDist < -2 ) return null ; if ( lxDist > 0 && minRxDist > 0 && lxDist > 3 ) return null ; return { "leftCell" : rbCell, "rightCell" : lbCell } ; }, "_GetResizeBarPosition" : function() { var row = FCKTools.GetElementAscensor( this._RightCell, "tr" ) ; return FCKTableHandler._GetCellIndexSpan( this._TableMap, row.rowIndex, this._RightCell ) ; }, "_ResizeBarMouseDownListener" : function( evt ) { if ( FCKDragTableHandler._LeftCell ) FCKDragTableHandler._MouseMoveMode = 1 ; if ( FCKBrowserInfo.IsIE ) FCKDragTableHandler._ResizeBar.filters.item("DXImageTransform.Microsoft.Alpha").opacity = 50 ; else FCKDragTableHandler._ResizeBar.style.opacity = 0.5 ; FCKDragTableHandler._OriginalX = evt.clientX ; // Calculate maximum and minimum x-coordinate delta. var borderIndex = FCKDragTableHandler._GetResizeBarPosition() ; var offset = FCKDragTableHandler._GetIframeOffset(); var table = FCKTools.GetElementAscensor( FCKDragTableHandler._LeftCell, "table" ); var minX = null ; var maxX = null ; for ( var r = 0 ; r < FCKDragTableHandler._TableMap.length ; r++ ) { var leftCell = FCKDragTableHandler._TableMap[r][borderIndex - 1] ; var rightCell = FCKDragTableHandler._TableMap[r][borderIndex] ; var leftPosition = FCKTools.GetWindowPosition( FCK.EditorWindow, leftCell ) ; var rightPosition = FCKTools.GetWindowPosition( FCK.EditorWindow, rightCell ) ; var leftPadding = FCKDragTableHandler._GetCellPadding( table, leftCell ) ; var rightPadding = FCKDragTableHandler._GetCellPadding( table, rightCell ) ; if ( minX == null || leftPosition.x + leftPadding > minX ) minX = leftPosition.x + leftPadding ; if ( maxX == null || rightPosition.x + rightCell.clientWidth - rightPadding < maxX ) maxX = rightPosition.x + rightCell.clientWidth - rightPadding ; } FCKDragTableHandler._MinimumX = minX + offset.x ; FCKDragTableHandler._MaximumX = maxX + offset.x ; FCKDragTableHandler._LastX = null ; if (evt.preventDefault) evt.preventDefault(); else evt.returnValue = false; }, "_ResizeBarMouseUpListener" : function( evt ) { FCKDragTableHandler._MouseMoveMode = 0 ; FCKDragTableHandler._HideResizeBar() ; if ( FCKDragTableHandler._LastX == null ) return ; // Calculate the delta value. var deltaX = FCKDragTableHandler._LastX - FCKDragTableHandler._OriginalX ; // Then, build an array of current column width values. // This algorithm can be very slow if the cells have insane colSpan values. (e.g. colSpan=1000). var table = FCKTools.GetElementAscensor( FCKDragTableHandler._LeftCell, "table" ) ; var colArray = [] ; var tableMap = FCKDragTableHandler._TableMap ; for ( var i = 0 ; i < tableMap.length ; i++ ) { for ( var j = 0 ; j < tableMap[i].length ; j++ ) { var cell = tableMap[i][j] ; var width = FCKDragTableHandler._GetCellWidth( table, cell ) ; var colSpan = isNaN( cell.colSpan) ? 1 : cell.colSpan ; if ( colArray.length <= j ) colArray.push( { width : width / colSpan, colSpan : colSpan } ) ; else { var guessItem = colArray[j] ; if ( guessItem.colSpan > colSpan ) { guessItem.width = width / colSpan ; guessItem.colSpan = colSpan ; } } } } // Find out the equivalent column index of the two cells selected for resizing. colIndex = FCKDragTableHandler._GetResizeBarPosition() ; // Note that colIndex must be at least 1 here, so it's safe to subtract 1 from it. colIndex-- ; // Modify the widths in the colArray according to the mouse coordinate delta value. colArray[colIndex].width += deltaX ; colArray[colIndex + 1].width -= deltaX ; // Clear all cell widths, delete all <col> elements from the table. for ( var r = 0 ; r < table.rows.length ; r++ ) { var row = table.rows.item( r ) ; for ( var c = 0 ; c < row.cells.length ; c++ ) { var cell = row.cells.item( c ) ; cell.width = "" ; cell.style.width = "" ; } } var colElements = table.getElementsByTagName( "col" ) ; for ( var i = colElements.length - 1 ; i >= 0 ; i-- ) colElements[i].parentNode.removeChild( colElements[i] ) ; // Set new cell widths. var processedCells = [] ; for ( var i = 0 ; i < tableMap.length ; i++ ) { for ( var j = 0 ; j < tableMap[i].length ; j++ ) { var cell = tableMap[i][j] ; if ( cell._Processed ) continue ; if ( tableMap[i][j-1] != cell ) cell.width = colArray[j].width ; else cell.width = parseInt( cell.width, 10 ) + parseInt( colArray[j].width, 10 ) ; if ( tableMap[i][j+1] != cell ) { processedCells.push( cell ) ; cell._Processed = true ; } } } for ( var i = 0 ; i < processedCells.length ; i++ ) { if ( FCKBrowserInfo.IsIE ) processedCells[i].removeAttribute( '_Processed' ) ; else delete processedCells[i]._Processed ; } FCKDragTableHandler._LastX = null ; }, "_ResizeBarMouseMoveListener" : function( evt ) { if ( FCKDragTableHandler._MouseMoveMode == 0 ) return FCKDragTableHandler._MouseFindHandler( FCK, evt ) ; else return FCKDragTableHandler._MouseDragHandler( FCK, evt ) ; }, // Calculate the padding of a table cell. // It returns the value of paddingLeft + paddingRight of a table cell. // This function is used, in part, to calculate the width parameter that should be used for setting cell widths. // The equation in question is clientWidth = paddingLeft + paddingRight + width. // So that width = clientWidth - paddingLeft - paddingRight. // The return value of this function must be pixel accurate acorss all supported browsers, so be careful if you need to modify it. "_GetCellPadding" : function( table, cell ) { var attrGuess = parseInt( table.cellPadding, 10 ) * 2 ; var cssGuess = null ; if ( typeof( window.getComputedStyle ) == "function" ) { var styleObj = window.getComputedStyle( cell, null ) ; cssGuess = parseInt( styleObj.getPropertyValue( "padding-left" ), 10 ) + parseInt( styleObj.getPropertyValue( "padding-right" ), 10 ) ; } else cssGuess = parseInt( cell.currentStyle.paddingLeft, 10 ) + parseInt (cell.currentStyle.paddingRight, 10 ) ; var cssRuntime = cell.style.padding ; if ( isFinite( cssRuntime ) ) cssGuess = parseInt( cssRuntime, 10 ) * 2 ; else { cssRuntime = cell.style.paddingLeft ; if ( isFinite( cssRuntime ) ) cssGuess = parseInt( cssRuntime, 10 ) ; cssRuntime = cell.style.paddingRight ; if ( isFinite( cssRuntime ) ) cssGuess += parseInt( cssRuntime, 10 ) ; } attrGuess = parseInt( attrGuess, 10 ) ; cssGuess = parseInt( cssGuess, 10 ) ; if ( isNaN( attrGuess ) ) attrGuess = 0 ; if ( isNaN( cssGuess ) ) cssGuess = 0 ; return Math.max( attrGuess, cssGuess ) ; }, // Calculate the real width of the table cell. // The real width of the table cell is the pixel width that you can set to the width attribute of the table cell and after // that, the table cell should be of exactly the same width as before. // The real width of a table cell can be calculated as: // width = clientWidth - paddingLeft - paddingRight. "_GetCellWidth" : function( table, cell ) { var clientWidth = cell.clientWidth ; if ( isNaN( clientWidth ) ) clientWidth = 0 ; return clientWidth - this._GetCellPadding( table, cell ) ; }, "MouseMoveListener" : function( FCK, evt ) { if ( FCKDragTableHandler._MouseMoveMode == 0 ) return FCKDragTableHandler._MouseFindHandler( FCK, evt ) ; else return FCKDragTableHandler._MouseDragHandler( FCK, evt ) ; }, "_MouseFindHandler" : function( FCK, evt ) { if ( FCK.MouseDownFlag ) return ; var node = evt.srcElement || evt.target ; try { if ( ! node || node.nodeType != 1 ) { this._HideResizeBar() ; return ; } } catch ( e ) { this._HideResizeBar() ; return ; } // Since this function might be called from the editing area iframe or the outer fckeditor iframe, // the mouse point coordinates from evt.clientX/Y can have different reference points. // We need to resolve the mouse pointer position relative to the editing area iframe. var mouseX = evt.clientX ; var mouseY = evt.clientY ; if ( FCKTools.GetElementDocument( node ) == document ) { var offset = this._GetIframeOffset() ; mouseX -= offset.x ; mouseY -= offset.y ; } if ( this._ResizeBar && this._LeftCell ) { var leftPos = FCKTools.GetWindowPosition( FCK.EditorWindow, this._LeftCell ) ; var rightPos = FCKTools.GetWindowPosition( FCK.EditorWindow, this._RightCell ) ; var rxDist = mouseX - ( leftPos.x + this._LeftCell.clientWidth ) ; var lxDist = mouseX - rightPos.x ; var inRangeFlag = false ; if ( lxDist >= 0 && rxDist <= 0 ) inRangeFlag = true ; else if ( rxDist > 0 && lxDist <= 3 ) inRangeFlag = true ; else if ( lxDist < 0 && rxDist >= -2 ) inRangeFlag = true ; if ( inRangeFlag ) { this._ShowResizeBar( FCK.EditorWindow, FCKTools.GetElementAscensor( this._LeftCell, "table" ), { "x" : mouseX, "y" : mouseY } ) ; return ; } } var tagName = node.tagName.toLowerCase() ; if ( tagName != "table" && tagName != "td" && tagName != "th" ) { if ( this._LeftCell ) this._LeftCell = this._RightCell = this._TableMap = null ; this._HideResizeBar() ; return ; } node = FCKTools.GetElementAscensor( node, "table" ) ; var tableMap = FCKTableHandler._CreateTableMap( node ) ; var cellTuple = this._GetBorderCells( FCK.EditorWindow, node, tableMap, { "x" : mouseX, "y" : mouseY } ) ; if ( cellTuple == null ) { if ( this._LeftCell ) this._LeftCell = this._RightCell = this._TableMap = null ; this._HideResizeBar() ; } else { this._LeftCell = cellTuple["leftCell"] ; this._RightCell = cellTuple["rightCell"] ; this._TableMap = tableMap ; this._ShowResizeBar( FCK.EditorWindow, FCKTools.GetElementAscensor( this._LeftCell, "table" ), { "x" : mouseX, "y" : mouseY } ) ; } }, "_MouseDragHandler" : function( FCK, evt ) { var mouse = { "x" : evt.clientX, "y" : evt.clientY } ; // Convert mouse coordinates in reference to the outer iframe. var node = evt.srcElement || evt.target ; if ( FCKTools.GetElementDocument( node ) == FCK.EditorDocument ) { var offset = this._GetIframeOffset() ; mouse.x += offset.x ; mouse.y += offset.y ; } // Calculate the mouse position delta and see if we've gone out of range. if ( mouse.x >= this._MaximumX - 5 ) mouse.x = this._MaximumX - 5 ; if ( mouse.x <= this._MinimumX + 5 ) mouse.x = this._MinimumX + 5 ; var docX = mouse.x + FCKTools.GetScrollPosition( window ).X ; this._ResizeBar.style.left = ( docX - this._ResizeBar.offsetWidth / 2 ) + "px" ; this._LastX = mouse.x ; }, "_ShowResizeBar" : function( w, table, mouse ) { if ( this._ResizeBar == null ) { this._ResizeBar = this._doc.createElement( "div" ) ; var paddingBar = this._ResizeBar ; var paddingStyles = { 'position' : 'absolute', 'cursor' : 'e-resize' } ; if ( FCKBrowserInfo.IsIE ) paddingStyles.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=10,enabled=true)" ; else paddingStyles.opacity = 0.10 ; FCKDomTools.SetElementStyles( paddingBar, paddingStyles ) ; this._avoidStyles( paddingBar ); paddingBar.setAttribute('_fcktemp', true); this._doc.body.appendChild( paddingBar ) ; FCKTools.AddEventListener( paddingBar, "mousemove", this._ResizeBarMouseMoveListener ) ; FCKTools.AddEventListener( paddingBar, "mousedown", this._ResizeBarMouseDownListener ) ; FCKTools.AddEventListener( document, "mouseup", this._ResizeBarMouseUpListener ) ; FCKTools.AddEventListener( FCK.EditorDocument, "mouseup", this._ResizeBarMouseUpListener ) ; // IE doesn't let the tranparent part of the padding block to receive mouse events unless there's something inside. // So we need to create a spacer image to fill the block up. var filler = this._doc.createElement( "img" ) ; filler.setAttribute('_fcktemp', true); filler.border = 0 ; filler.src = FCKConfig.BasePath + "images/spacer.gif" ; filler.style.position = "absolute" ; paddingBar.appendChild( filler ) ; // Disable drag and drop, and selection for the filler image. var disabledListener = function( evt ) { if ( evt.preventDefault ) evt.preventDefault() ; else evt.returnValue = false ; } FCKTools.AddEventListener( filler, "dragstart", disabledListener ) ; FCKTools.AddEventListener( filler, "selectstart", disabledListener ) ; } var paddingBar = this._ResizeBar ; var offset = this._GetIframeOffset() ; var tablePos = this._GetTablePosition( w, table ) ; var barHeight = table.offsetHeight ; var barTop = offset.y + tablePos.y ; // Do not let the resize bar intrude into the toolbar area. if ( tablePos.y < 0 ) { barHeight += tablePos.y ; barTop -= tablePos.y ; } var bw = parseInt( table.border, 10 ) ; if ( isNaN( bw ) ) bw = 0 ; var cs = parseInt( table.cellSpacing, 10 ) ; if ( isNaN( cs ) ) cs = 0 ; var barWidth = Math.max( bw+100, cs+100 ) ; var paddingStyles = { 'top' : barTop + 'px', 'height' : barHeight + 'px', 'width' : barWidth + 'px', 'left' : ( offset.x + mouse.x + FCKTools.GetScrollPosition( w ).X - barWidth / 2 ) + 'px' } ; if ( FCKBrowserInfo.IsIE ) paddingBar.filters.item("DXImageTransform.Microsoft.Alpha").opacity = 10 ; else paddingStyles.opacity = 0.1 ; FCKDomTools.SetElementStyles( paddingBar, paddingStyles ) ; var filler = paddingBar.getElementsByTagName( "img" )[0] ; FCKDomTools.SetElementStyles( filler, { width : paddingBar.offsetWidth + 'px', height : barHeight + 'px' } ) ; barWidth = Math.max( bw, cs, 3 ) ; var visibleBar = null ; if ( paddingBar.getElementsByTagName( "div" ).length < 1 ) { visibleBar = this._doc.createElement( "div" ) ; this._avoidStyles( visibleBar ); visibleBar.setAttribute('_fcktemp', true); paddingBar.appendChild( visibleBar ) ; } else visibleBar = paddingBar.getElementsByTagName( "div" )[0] ; FCKDomTools.SetElementStyles( visibleBar, { position : 'absolute', backgroundColor : 'blue', width : barWidth + 'px', height : barHeight + 'px', left : '50px', top : '0px' } ) ; }, "_HideResizeBar" : function() { if ( this._ResizeBar ) // IE bug: display : none does not hide the resize bar for some reason. // so set the position to somewhere invisible. FCKDomTools.SetElementStyles( this._ResizeBar, { top : '-100000px', left : '-100000px' } ) ; }, "_GetIframeOffset" : function () { return FCKTools.GetDocumentPosition( window, FCK.EditingArea.IFrame ) ; }, "_GetTablePosition" : function ( w, table ) { return FCKTools.GetWindowPosition( w, table ) ; }, "_avoidStyles" : function( element ) { FCKDomTools.SetElementStyles( element, { padding : '0', backgroundImage : 'none', border : '0' } ) ; }, "Reset" : function() { FCKDragTableHandler._LeftCell = FCKDragTableHandler._RightCell = FCKDragTableHandler._TableMap = null ; } }; FCK.Events.AttachEvent( "OnMouseMove", FCKDragTableHandler.MouseMoveListener ) ; FCK.Events.AttachEvent( "OnAfterSetHTML", FCKDragTableHandler.Reset ) ;
JavaScript
/* * 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 == * * Plugin: automatically resizes the editor until a configurable maximun * height (FCKConfig.AutoGrowMax), based on its contents. */ var FCKAutoGrow = { MIN_HEIGHT : window.frameElement.offsetHeight, Check : function() { var delta = FCKAutoGrow.GetHeightDelta() ; if ( delta != 0 ) { var newHeight = window.frameElement.offsetHeight + delta ; newHeight = FCKAutoGrow.GetEffectiveHeight( newHeight ) ; if ( newHeight != window.frameElement.height ) { window.frameElement.style.height = newHeight + "px" ; // Gecko browsers use an onresize handler to update the innermost // IFRAME's height. If the document is modified before the onresize // is triggered, the plugin will miscalculate the new height. Thus, // forcibly trigger onresize. #1336 if ( typeof window.onresize == 'function' ) { window.onresize() ; } } } }, CheckEditorStatus : function( sender, status ) { if ( status == FCK_STATUS_COMPLETE ) FCKAutoGrow.Check() ; }, GetEffectiveHeight : function( height ) { if ( height < FCKAutoGrow.MIN_HEIGHT ) height = FCKAutoGrow.MIN_HEIGHT; else { var max = FCKConfig.AutoGrowMax; if ( max && max > 0 && height > max ) height = max; } return height; }, GetHeightDelta : function() { var oInnerDoc = FCK.EditorDocument ; var iFrameHeight ; var iInnerHeight ; if ( FCKBrowserInfo.IsIE ) { iFrameHeight = FCK.EditorWindow.frameElement.offsetHeight ; iInnerHeight = oInnerDoc.body.scrollHeight ; } else { iFrameHeight = FCK.EditorWindow.innerHeight ; iInnerHeight = oInnerDoc.body.offsetHeight + ( parseInt( FCKDomTools.GetCurrentElementStyle( oInnerDoc.body, 'margin-top' ), 10 ) || 0 ) + ( parseInt( FCKDomTools.GetCurrentElementStyle( oInnerDoc.body, 'margin-bottom' ), 10 ) || 0 ) ; } return iInnerHeight - iFrameHeight ; }, SetListeners : function() { if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG ) return ; FCK.EditorWindow.attachEvent( 'onscroll', FCKAutoGrow.Check ) ; FCK.EditorDocument.attachEvent( 'onkeyup', FCKAutoGrow.Check ) ; } }; FCK.AttachToOnSelectionChange( FCKAutoGrow.Check ) ; if ( FCKBrowserInfo.IsIE ) FCK.Events.AttachEvent( 'OnAfterSetHTML', FCKAutoGrow.SetListeners ) ; FCK.Events.AttachEvent( 'OnStatusChange', FCKAutoGrow.CheckEditorStatus ) ;
JavaScript
/* * 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 == * * This is a sample implementation for a custom Data Processor for basic BBCode. */ FCK.DataProcessor = { /* * Returns a string representing the HTML format of "data". The returned * value will be loaded in the editor. * The HTML must be from <html> to </html>, eventually including * the DOCTYPE. * @param {String} data The data to be converted in the * DataProcessor specific format. */ ConvertToHtml : function( data ) { // Convert < and > to their HTML entities. data = data.replace( /</g, '&lt;' ) ; data = data.replace( />/g, '&gt;' ) ; // Convert line breaks to <br>. data = data.replace( /(?:\r\n|\n|\r)/g, '<br>' ) ; // [url] data = data.replace( /\[url\](.+?)\[\/url]/gi, '<a href="$1">$1</a>' ) ; data = data.replace( /\[url\=([^\]]+)](.+?)\[\/url]/gi, '<a href="$1">$2</a>' ) ; // [b] data = data.replace( /\[b\](.+?)\[\/b]/gi, '<b>$1</b>' ) ; // [i] data = data.replace( /\[i\](.+?)\[\/i]/gi, '<i>$1</i>' ) ; // [u] data = data.replace( /\[u\](.+?)\[\/u]/gi, '<u>$1</u>' ) ; return '<html><head><title></title></head><body>' + data + '</body></html>' ; }, /* * Converts a DOM (sub-)tree to a string in the data format. * @param {Object} rootNode The node that contains the DOM tree to be * converted to the data format. * @param {Boolean} excludeRoot Indicates that the root node must not * be included in the conversion, only its children. * @param {Boolean} format Indicates that the data must be formatted * for human reading. Not all Data Processors may provide it. */ ConvertToDataFormat : function( rootNode, excludeRoot, ignoreIfEmptyParagraph, format ) { var data = rootNode.innerHTML ; // Convert <br> to line breaks. data = data.replace( /<br(?=[ \/>]).*?>/gi, '\r\n') ; // [url] data = data.replace( /<a .*?href=(["'])(.+?)\1.*?>(.+?)<\/a>/gi, '[url=$2]$3[/url]') ; // [b] data = data.replace( /<(?:b|strong)>/gi, '[b]') ; data = data.replace( /<\/(?:b|strong)>/gi, '[/b]') ; // [i] data = data.replace( /<(?:i|em)>/gi, '[i]') ; data = data.replace( /<\/(?:i|em)>/gi, '[/i]') ; // [u] data = data.replace( /<u>/gi, '[u]') ; data = data.replace( /<\/u>/gi, '[/u]') ; // Remove remaining tags. data = data.replace( /<[^>]+>/g, '') ; return data ; }, /* * Makes any necessary changes to a piece of HTML for insertion in the * editor selection position. * @param {String} html The HTML to be fixed. */ FixHtml : function( html ) { return html ; } } ; // This Data Processor doesn't support <p>, so let's use <br>. FCKConfig.EnterMode = 'br' ; // To avoid pasting invalid markup (which is discarded in any case), let's // force pasting to plain text. FCKConfig.ForcePasteAsPlainText = true ; // Rename the "Source" buttom to "BBCode". FCKToolbarItems.RegisterItem( 'Source', new FCKToolbarButton( 'Source', 'BBCode', null, FCK_TOOLBARITEM_ICONTEXT, true, true, 1 ) ) ; // Let's enforce the toolbar to the limits of this Data Processor. A custom // toolbar set may be defined in the configuration file with more or less entries. FCKConfig.ToolbarSets["Default"] = [ ['Source'], ['Bold','Italic','Underline','-','Link'], ['About'] ] ;
JavaScript
/* * 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 == * * Sample custom configuration settings used by the BBCode plugin. It simply * loads the plugin. All the rest is done by the plugin itself. */ // Add the BBCode plugin. FCKConfig.Plugins.Add( 'bbcode' ) ;
JavaScript
/* * 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 == * * This plugin register the required Toolbar items to be able to insert the * table commands in the toolbar. */ FCKToolbarItems.RegisterItem( 'TableInsertRowAfter' , new FCKToolbarButton( 'TableInsertRowAfter' , FCKLang.InsertRowAfter, null, null, null, true, 62 ) ) ; FCKToolbarItems.RegisterItem( 'TableDeleteRows' , new FCKToolbarButton( 'TableDeleteRows' , FCKLang.DeleteRows, null, null, null, true, 63 ) ) ; FCKToolbarItems.RegisterItem( 'TableInsertColumnAfter' , new FCKToolbarButton( 'TableInsertColumnAfter' , FCKLang.InsertColumnAfter, null, null, null, true, 64 ) ) ; FCKToolbarItems.RegisterItem( 'TableDeleteColumns' , new FCKToolbarButton( 'TableDeleteColumns', FCKLang.DeleteColumns, null, null, null, true, 65 ) ) ; FCKToolbarItems.RegisterItem( 'TableInsertCellAfter' , new FCKToolbarButton( 'TableInsertCellAfter' , FCKLang.InsertCellAfter, null, null, null, true, 58 ) ) ; FCKToolbarItems.RegisterItem( 'TableDeleteCells' , new FCKToolbarButton( 'TableDeleteCells' , FCKLang.DeleteCells, null, null, null, true, 59 ) ) ; FCKToolbarItems.RegisterItem( 'TableMergeCells' , new FCKToolbarButton( 'TableMergeCells' , FCKLang.MergeCells, null, null, null, true, 60 ) ) ; FCKToolbarItems.RegisterItem( 'TableHorizontalSplitCell' , new FCKToolbarButton( 'TableHorizontalSplitCell' , FCKLang.SplitCell, null, null, null, true, 61 ) ) ; FCKToolbarItems.RegisterItem( 'TableCellProp' , new FCKToolbarButton( 'TableCellProp' , FCKLang.CellProperties, null, null, null, true, 57 ) ) ;
JavaScript
/* * 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 == * * This plugin register Toolbar items for the combos modifying the style to * not show the box. */ FCKToolbarItems.RegisterItem( 'SourceSimple' , new FCKToolbarButton( 'Source', FCKLang.Source, null, FCK_TOOLBARITEM_ONLYICON, true, true, 1 ) ) ; FCKToolbarItems.RegisterItem( 'StyleSimple' , new FCKToolbarStyleCombo( null, FCK_TOOLBARITEM_ONLYTEXT ) ) ; FCKToolbarItems.RegisterItem( 'FontNameSimple' , new FCKToolbarFontsCombo( null, FCK_TOOLBARITEM_ONLYTEXT ) ) ; FCKToolbarItems.RegisterItem( 'FontSizeSimple' , new FCKToolbarFontSizeCombo( null, FCK_TOOLBARITEM_ONLYTEXT ) ) ; FCKToolbarItems.RegisterItem( 'FontFormatSimple', new FCKToolbarFontFormatCombo( null, FCK_TOOLBARITEM_ONLYTEXT ) ) ;
JavaScript
/* * 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 == * * Common objects and functions shared by all pages that compose the * File Browser dialog window. */ // Automatically detect the correct document.domain (#1919). (function() { var d = document.domain ; while ( true ) { // Test if we can access a parent property. try { var test = window.top.opener.document.domain ; break ; } catch( e ) {} // Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ... d = d.replace( /.*?(?:\.|$)/, '' ) ; if ( d.length == 0 ) break ; // It was not able to detect the domain. try { document.domain = d ; } catch (e) { break ; } } })() ; function AddSelectOption( selectElement, optionText, optionValue ) { var oOption = document.createElement("OPTION") ; oOption.text = optionText ; oOption.value = optionValue ; selectElement.options.add(oOption) ; return oOption ; } var oConnector = window.parent.oConnector ; var oIcons = window.parent.oIcons ; function StringBuilder( value ) { this._Strings = new Array( value || '' ) ; } StringBuilder.prototype.Append = function( value ) { if ( value ) this._Strings.push( value ) ; } StringBuilder.prototype.ToString = function() { return this._Strings.join( '' ) ; }
JavaScript
/* * 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 == * * Defines the FCKXml object that is used for XML data calls * and XML processing. * * This script is shared by almost all pages that compose the * File Browser frameset. */ var FCKXml = function() {} FCKXml.prototype.GetHttpRequest = function() { // Gecko / IE7 try { return new XMLHttpRequest(); } catch(e) {} // IE6 try { return new ActiveXObject( 'Msxml2.XMLHTTP' ) ; } catch(e) {} // IE5 try { return new ActiveXObject( 'Microsoft.XMLHTTP' ) ; } catch(e) {} return null ; } FCKXml.prototype.LoadUrl = function( urlToCall, asyncFunctionPointer ) { var oFCKXml = this ; var bAsync = ( typeof(asyncFunctionPointer) == 'function' ) ; var oXmlHttp = this.GetHttpRequest() ; oXmlHttp.open( "GET", urlToCall, bAsync ) ; if ( bAsync ) { oXmlHttp.onreadystatechange = function() { if ( oXmlHttp.readyState == 4 ) { var oXml ; try { // this is the same test for an FF2 bug as in fckxml_gecko.js // but we've moved the responseXML assignment into the try{} // so we don't even have to check the return status codes. var test = oXmlHttp.responseXML.firstChild ; oXml = oXmlHttp.responseXML ; } catch ( e ) { try { oXml = (new DOMParser()).parseFromString( oXmlHttp.responseText, 'text/xml' ) ; } catch ( e ) {} } if ( !oXml || !oXml.firstChild || oXml.firstChild.nodeName == 'parsererror' ) { alert( 'The server didn\'t send back a proper XML response. Please contact your system administrator.\n\n' + 'XML request error: ' + oXmlHttp.statusText + ' (' + oXmlHttp.status + ')\n\n' + 'Requested URL:\n' + urlToCall + '\n\n' + 'Response text:\n' + oXmlHttp.responseText ) ; return ; } oFCKXml.DOMDocument = oXml ; asyncFunctionPointer( oFCKXml ) ; } } } oXmlHttp.send( null ) ; if ( ! bAsync ) { if ( oXmlHttp.status == 200 || oXmlHttp.status == 304 ) this.DOMDocument = oXmlHttp.responseXML ; else { alert( 'XML request error: ' + oXmlHttp.statusText + ' (' + oXmlHttp.status + ')' ) ; } } } FCKXml.prototype.SelectNodes = function( xpath ) { if ( navigator.userAgent.indexOf('MSIE') >= 0 ) // IE return this.DOMDocument.selectNodes( xpath ) ; else // Gecko { var aNodeArray = new Array(); var xPathResult = this.DOMDocument.evaluate( xpath, this.DOMDocument, this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), XPathResult.ORDERED_NODE_ITERATOR_TYPE, null) ; if ( xPathResult ) { var oNode = xPathResult.iterateNext() ; while( oNode ) { aNodeArray[aNodeArray.length] = oNode ; oNode = xPathResult.iterateNext(); } } return aNodeArray ; } } FCKXml.prototype.SelectSingleNode = function( xpath ) { if ( navigator.userAgent.indexOf('MSIE') >= 0 ) // IE return this.DOMDocument.selectSingleNode( xpath ) ; else // Gecko { var xPathResult = this.DOMDocument.evaluate( xpath, this.DOMDocument, this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), 9, null); if ( xPathResult && xPathResult.singleNodeValue ) return xPathResult.singleNodeValue ; else return null ; } }
JavaScript
/* * 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 == * * This is the integration file for JavaScript. * * It defines the FCKeditor class that can be used to create editor * instances in a HTML page in the client side. For server side * operations, use the specific integration system. */ // FCKeditor Class var FCKeditor = function( instanceName, width, height, toolbarSet, value ) { // Properties this.InstanceName = instanceName ; this.Width = width || '100%' ; this.Height = height || '200' ; this.ToolbarSet = toolbarSet || 'Default' ; this.Value = value || '' ; this.BasePath = FCKeditor.BasePath ; this.CheckBrowser = true ; this.DisplayErrors = true ; this.Config = new Object() ; // Events this.OnError = null ; // function( source, errorNumber, errorDescription ) } /** * This is the default BasePath used by all editor instances. */ FCKeditor.BasePath = '/fckeditor/' ; /** * The minimum height used when replacing textareas. */ FCKeditor.MinHeight = 200 ; /** * The minimum width used when replacing textareas. */ FCKeditor.MinWidth = 750 ; FCKeditor.prototype.Version = '2.6.4' ; FCKeditor.prototype.VersionBuild = '21629' ; FCKeditor.prototype.Create = function() { document.write( this.CreateHtml() ) ; } FCKeditor.prototype.CreateHtml = function() { // Check for errors if ( !this.InstanceName || this.InstanceName.length == 0 ) { this._ThrowError( 701, 'You must specify an instance name.' ) ; return '' ; } var sHtml = '' ; if ( !this.CheckBrowser || this._IsCompatibleBrowser() ) { sHtml += '<input type="hidden" id="' + this.InstanceName + '" name="' + this.InstanceName + '" value="' + this._HTMLEncode( this.Value ) + '" style="display:none" />' ; sHtml += this._GetConfigHtml() ; sHtml += this._GetIFrameHtml() ; } else { var sWidth = this.Width.toString().indexOf('%') > 0 ? this.Width : this.Width + 'px' ; var sHeight = this.Height.toString().indexOf('%') > 0 ? this.Height : this.Height + 'px' ; sHtml += '<textarea name="' + this.InstanceName + '" rows="4" cols="40" style="width:' + sWidth + ';height:' + sHeight ; if ( this.TabIndex ) sHtml += '" tabindex="' + this.TabIndex ; sHtml += '">' + this._HTMLEncode( this.Value ) + '<\/textarea>' ; } return sHtml ; } FCKeditor.prototype.ReplaceTextarea = function() { if ( document.getElementById( this.InstanceName + '___Frame' ) ) return ; if ( !this.CheckBrowser || this._IsCompatibleBrowser() ) { // We must check the elements firstly using the Id and then the name. var oTextarea = document.getElementById( this.InstanceName ) ; var colElementsByName = document.getElementsByName( this.InstanceName ) ; var i = 0; while ( oTextarea || i == 0 ) { if ( oTextarea && oTextarea.tagName.toLowerCase() == 'textarea' ) break ; oTextarea = colElementsByName[i++] ; } if ( !oTextarea ) { alert( 'Error: The TEXTAREA with id or name set to "' + this.InstanceName + '" was not found' ) ; return ; } oTextarea.style.display = 'none' ; if ( oTextarea.tabIndex ) this.TabIndex = oTextarea.tabIndex ; this._InsertHtmlBefore( this._GetConfigHtml(), oTextarea ) ; this._InsertHtmlBefore( this._GetIFrameHtml(), oTextarea ) ; } } FCKeditor.prototype._InsertHtmlBefore = function( html, element ) { if ( element.insertAdjacentHTML ) // IE element.insertAdjacentHTML( 'beforeBegin', html ) ; else // Gecko { var oRange = document.createRange() ; oRange.setStartBefore( element ) ; var oFragment = oRange.createContextualFragment( html ); element.parentNode.insertBefore( oFragment, element ) ; } } FCKeditor.prototype._GetConfigHtml = function() { var sConfig = '' ; for ( var o in this.Config ) { if ( sConfig.length > 0 ) sConfig += '&amp;' ; sConfig += encodeURIComponent( o ) + '=' + encodeURIComponent( this.Config[o] ) ; } return '<input type="hidden" id="' + this.InstanceName + '___Config" value="' + sConfig + '" style="display:none" />' ; } FCKeditor.prototype._GetIFrameHtml = function() { var sFile = 'fckeditor.html' ; try { if ( (/fcksource=true/i).test( window.top.location.search ) ) sFile = 'fckeditor.original.html' ; } catch (e) { /* Ignore it. Much probably we are inside a FRAME where the "top" is in another domain (security error). */ } var sLink = this.BasePath + 'editor/' + sFile + '?InstanceName=' + encodeURIComponent( this.InstanceName ) ; if (this.ToolbarSet) sLink += '&amp;Toolbar=' + this.ToolbarSet ; var html = '<iframe id="' + this.InstanceName + '___Frame" src="' + sLink + '" width="' + this.Width + '" height="' + this.Height ; if ( this.TabIndex ) html += '" tabindex="' + this.TabIndex ; html += '" frameborder="0" scrolling="no"></iframe>' ; return html ; } FCKeditor.prototype._IsCompatibleBrowser = function() { return FCKeditor_IsCompatibleBrowser() ; } FCKeditor.prototype._ThrowError = function( errorNumber, errorDescription ) { this.ErrorNumber = errorNumber ; this.ErrorDescription = errorDescription ; if ( this.DisplayErrors ) { document.write( '<div style="COLOR: #ff0000">' ) ; document.write( '[ FCKeditor Error ' + this.ErrorNumber + ': ' + this.ErrorDescription + ' ]' ) ; document.write( '</div>' ) ; } if ( typeof( this.OnError ) == 'function' ) this.OnError( this, errorNumber, errorDescription ) ; } FCKeditor.prototype._HTMLEncode = function( text ) { if ( typeof( text ) != "string" ) text = text.toString() ; text = text.replace( /&/g, "&amp;").replace( /"/g, "&quot;").replace( /</g, "&lt;").replace( />/g, "&gt;") ; return text ; } ;(function() { var textareaToEditor = function( textarea ) { var editor = new FCKeditor( textarea.name ) ; editor.Width = Math.max( textarea.offsetWidth, FCKeditor.MinWidth ) ; editor.Height = Math.max( textarea.offsetHeight, FCKeditor.MinHeight ) ; return editor ; } /** * Replace all <textarea> elements available in the document with FCKeditor * instances. * * // Replace all <textarea> elements in the page. * FCKeditor.ReplaceAllTextareas() ; * * // Replace all <textarea class="myClassName"> elements in the page. * FCKeditor.ReplaceAllTextareas( 'myClassName' ) ; * * // Selectively replace <textarea> elements, based on custom assertions. * FCKeditor.ReplaceAllTextareas( function( textarea, editor ) * { * // Custom code to evaluate the replace, returning false if it * // must not be done. * // It also passes the "editor" parameter, so the developer can * // customize the instance. * } ) ; */ FCKeditor.ReplaceAllTextareas = function() { var textareas = document.getElementsByTagName( 'textarea' ) ; for ( var i = 0 ; i < textareas.length ; i++ ) { var editor = null ; var textarea = textareas[i] ; var name = textarea.name ; // The "name" attribute must exist. if ( !name || name.length == 0 ) continue ; if ( typeof arguments[0] == 'string' ) { // The textarea class name could be passed as the function // parameter. var classRegex = new RegExp( '(?:^| )' + arguments[0] + '(?:$| )' ) ; if ( !classRegex.test( textarea.className ) ) continue ; } else if ( typeof arguments[0] == 'function' ) { // An assertion function could be passed as the function parameter. // It must explicitly return "false" to ignore a specific <textarea>. editor = textareaToEditor( textarea ) ; if ( arguments[0]( textarea, editor ) === false ) continue ; } if ( !editor ) editor = textareaToEditor( textarea ) ; editor.ReplaceTextarea() ; } } })() ; function FCKeditor_IsCompatibleBrowser() { var sAgent = navigator.userAgent.toLowerCase() ; // Internet Explorer 5.5+ if ( /*@cc_on!@*/false && sAgent.indexOf("mac") == -1 ) { var sBrowserVersion = navigator.appVersion.match(/MSIE (.\..)/)[1] ; return ( sBrowserVersion >= 5.5 ) ; } // Gecko (Opera 9 tries to behave like Gecko at this point). if ( navigator.product == "Gecko" && navigator.productSub >= 20030210 && !( typeof(opera) == 'object' && opera.postError ) ) return true ; // Opera 9.50+ if ( window.opera && window.opera.version && parseFloat( window.opera.version() ) >= 9.5 ) return true ; // Adobe AIR // Checked before Safari because AIR have the WebKit rich text editor // features from Safari 3.0.4, but the version reported is 420. if ( sAgent.indexOf( ' adobeair/' ) != -1 ) return ( sAgent.match( / adobeair\/(\d+)/ )[1] >= 1 ) ; // Build must be at least v1 // Safari 3+ if ( sAgent.indexOf( ' applewebkit/' ) != -1 ) return ( sAgent.match( / applewebkit\/(\d+)/ )[1] >= 522 ) ; // Build must be at least 522 (v3) return false ; }
JavaScript
/* * 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 == * * Editor configuration settings. * * Follow this link for more information: * http://docs.fckeditor.net/FCKeditor_2.x/Developers_Guide/Configuration/Configuration_Options */ FCKConfig.CustomConfigurationsPath = '' ; FCKConfig.EditorAreaCSS = FCKConfig.BasePath + 'css/fck_editorarea.css' ; FCKConfig.EditorAreaStyles = '' ; FCKConfig.ToolbarComboPreviewCSS = '' ; FCKConfig.DocType = '' ; FCKConfig.BaseHref = '' ; FCKConfig.FullPage = false ; // The following option determines whether the "Show Blocks" feature is enabled or not at startup. FCKConfig.StartupShowBlocks = false ; FCKConfig.Debug = false ; FCKConfig.AllowQueryStringDebug = true ; FCKConfig.SkinPath = FCKConfig.BasePath + 'skins/silver/' ; FCKConfig.SkinEditorCSS = '' ; // FCKConfig.SkinPath + "|<minified css>" ; FCKConfig.SkinDialogCSS = '' ; // FCKConfig.SkinPath + "|<minified css>" ; FCKConfig.PreloadImages = [ FCKConfig.SkinPath + 'images/toolbar.start.gif', FCKConfig.SkinPath + 'images/toolbar.buttonarrow.gif' ] ; FCKConfig.PluginsPath = FCKConfig.BasePath + 'plugins/' ; //FCKConfig.Plugins.Add( 'autogrow' ) ; //FCKConfig.Plugins.Add( 'dragresizetable' ); FCKConfig.AutoGrowMax = 400 ; FCKConfig.ProtectedSource.Add( /<\?[\s\S]*?\?>/g ) ; // PHP style server side code FCKConfig.AutoDetectLanguage = true ; FCKConfig.DefaultLanguage = 'zh-cn' ; FCKConfig.ContentLangDirection = 'ltr' ; FCKConfig.ProcessHTMLEntities = true ; FCKConfig.IncludeLatinEntities = true ; FCKConfig.IncludeGreekEntities = true ; FCKConfig.ProcessNumericEntities = false ; FCKConfig.AdditionalNumericEntities = '' ; // Single Quote: "'" FCKConfig.FillEmptyBlocks = true ; FCKConfig.FormatSource = true ; FCKConfig.FormatOutput = true ; FCKConfig.FormatIndentator = ' ' ; FCKConfig.EMailProtection = 'none' ; // none | encode | function FCKConfig.EMailProtectionFunction = 'mt(NAME,DOMAIN,SUBJECT,BODY)' ; FCKConfig.StartupFocus = false ; FCKConfig.ForcePasteAsPlainText = false ; FCKConfig.AutoDetectPasteFromWord = true ; // IE only. FCKConfig.ShowDropDialog = true ; FCKConfig.ForceSimpleAmpersand = false ; FCKConfig.TabSpaces = 0 ; FCKConfig.ShowBorders = true ; FCKConfig.SourcePopup = false ; FCKConfig.ToolbarStartExpanded = true ; FCKConfig.ToolbarCanCollapse = true ; FCKConfig.IgnoreEmptyParagraphValue = true ; FCKConfig.FloatingPanelsZIndex = 10000 ; FCKConfig.HtmlEncodeOutput = false ; FCKConfig.TemplateReplaceAll = true ; FCKConfig.TemplateReplaceCheckbox = true ; FCKConfig.ToolbarLocation = 'In' ; FCKConfig.ToolbarSets["Default"] = [ ['Source','DocProps','-','Save','NewPage','Preview','-','Templates'], ['Cut','Copy','Paste','PasteText','PasteWord','-','Print','SpellCheck'], ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'], ['Form','Checkbox','Radio','TextField','Textarea','Select','Button','ImageButton','HiddenField'], '/', ['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'], ['OrderedList','UnorderedList','-','Outdent','Indent','Blockquote','CreateDiv'], ['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'], ['Link','Unlink','Anchor'], ['Image','Flash','Table','Rule','Smiley','SpecialChar','PageBreak'], '/', ['Style','FontFormat','FontName','FontSize'], ['TextColor','BGColor'], ['FitWindow','ShowBlocks','-','About'] // No comma for the last row. ] ; FCKConfig.ToolbarSets["01cms"] = [ ['Source'], ['PasteText','PasteWord'], ['Find','RemoveFormat'], ['Bold','Italic','Underline','StrikeThrough','SpecialChar'], ['TextColor','BGColor'], ['JustifyLeft','JustifyCenter','JustifyRight'], ['FitWindow'], '/', ['PageBreak','Image','Flash','Table','Link','Unlink'], ['FontFormat','FontName','FontSize'] ] ; FCKConfig.ToolbarSets["Basic"] = [ ['Source','PasteText','PasteWord','Bold','Italic','OrderedList','UnorderedList','Link','Unlink','Image','Flash','TextColor','BGColor','FontName','FontSize'] ] ; FCKConfig.EnterMode = 'p' ; // p | div | br FCKConfig.ShiftEnterMode = 'br' ; // p | div | br FCKConfig.Keystrokes = [ [ CTRL + 65 /*A*/, true ], [ CTRL + 67 /*C*/, true ], [ CTRL + 70 /*F*/, true ], [ CTRL + 83 /*S*/, true ], [ CTRL + 84 /*T*/, true ], [ CTRL + 88 /*X*/, true ], [ CTRL + 86 /*V*/, 'Paste' ], [ CTRL + 45 /*INS*/, true ], [ SHIFT + 45 /*INS*/, 'Paste' ], [ CTRL + 88 /*X*/, 'Cut' ], [ SHIFT + 46 /*DEL*/, 'Cut' ], [ CTRL + 90 /*Z*/, 'Undo' ], [ CTRL + 89 /*Y*/, 'Redo' ], [ CTRL + SHIFT + 90 /*Z*/, 'Redo' ], [ CTRL + 76 /*L*/, 'Link' ], [ CTRL + 66 /*B*/, 'Bold' ], [ CTRL + 73 /*I*/, 'Italic' ], [ CTRL + 85 /*U*/, 'Underline' ], [ CTRL + SHIFT + 83 /*S*/, 'Save' ], [ CTRL + ALT + 13 /*ENTER*/, 'FitWindow' ], [ SHIFT + 32 /*SPACE*/, 'Nbsp' ] ] ; FCKConfig.ContextMenu = ['Generic','Link','Anchor','Image','Flash','Select','Textarea','Checkbox','Radio','TextField','HiddenField','ImageButton','Button','BulletedList','NumberedList','Table','Form','DivContainer'] ; FCKConfig.BrowserContextMenuOnCtrl = false ; FCKConfig.BrowserContextMenu = false ; FCKConfig.EnableMoreFontColors = true ; FCKConfig.FontColors = '000000,993300,333300,003300,003366,000080,333399,333333,800000,FF6600,808000,808080,008080,0000FF,666699,808080,FF0000,FF9900,99CC00,339966,33CCCC,3366FF,800080,999999,FF00FF,FFCC00,FFFF00,00FF00,00FFFF,00CCFF,993366,C0C0C0,FF99CC,FFCC99,FFFF99,CCFFCC,CCFFFF,99CCFF,CC99FF,FFFFFF' ; FCKConfig.FontFormats = 'p;h1;h2;h3;h4;h5;h6;pre;address;div' ; FCKConfig.FontNames = 'Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana' ; FCKConfig.FontSizes = 'smaller;larger;xx-small;x-small;small;medium;large;x-large;xx-large' ; FCKConfig.StylesXmlPath = FCKConfig.EditorPath + 'fckstyles.xml' ; FCKConfig.TemplatesXmlPath = FCKConfig.EditorPath + 'fcktemplates.xml' ; FCKConfig.SpellChecker = 'WSC' ; // 'WSC' | 'SpellerPages' | 'ieSpell' FCKConfig.IeSpellDownloadUrl = 'http://www.iespell.com/download.php' ; FCKConfig.SpellerPagesServerScript = 'server-scripts/spellchecker.php' ; // Available extension: .php .cfm .pl FCKConfig.FirefoxSpellChecker = false ; FCKConfig.MaxUndoLevels = 15 ; FCKConfig.DisableObjectResizing = false ; FCKConfig.DisableFFTableHandles = true ; FCKConfig.LinkDlgHideTarget = false ; FCKConfig.LinkDlgHideAdvanced = false ; FCKConfig.ImageDlgHideLink = false ; FCKConfig.ImageDlgHideAdvanced = false ; FCKConfig.FlashDlgHideAdvanced = false ; FCKConfig.ProtectedTags = '' ; // This will be applied to the body element of the editor FCKConfig.BodyId = '' ; FCKConfig.BodyClass = '' ; FCKConfig.DefaultStyleLabel = '' ; FCKConfig.DefaultFontFormatLabel = '' ; FCKConfig.DefaultFontLabel = '' ; FCKConfig.DefaultFontSizeLabel = '' ; FCKConfig.DefaultLinkTarget = '' ; // The option switches between trying to keep the html structure or do the changes so the content looks like it was in Word FCKConfig.CleanWordKeepsStructure = false ; // Only inline elements are valid. FCKConfig.RemoveFormatTags = 'b,big,code,del,dfn,em,font,i,ins,kbd,q,samp,small,span,strike,strong,sub,sup,tt,u,var' ; // Attributes that will be removed FCKConfig.RemoveAttributes = 'class,style,lang,width,height,align,hspace,valign' ; FCKConfig.CustomStyles = { 'Red Title' : { Element : 'h3', Styles : { 'color' : 'Red' } } }; // Do not add, rename or remove styles here. Only apply definition changes. FCKConfig.CoreStyles = { // Basic Inline Styles. 'Bold' : { Element : 'strong', Overrides : 'b' }, 'Italic' : { Element : 'em', Overrides : 'i' }, 'Underline' : { Element : 'u' }, 'StrikeThrough' : { Element : 'strike' }, 'Subscript' : { Element : 'sub' }, 'Superscript' : { Element : 'sup' }, // Basic Block Styles (Font Format Combo). 'p' : { Element : 'p' }, 'div' : { Element : 'div' }, 'pre' : { Element : 'pre' }, 'address' : { Element : 'address' }, 'h1' : { Element : 'h1' }, 'h2' : { Element : 'h2' }, 'h3' : { Element : 'h3' }, 'h4' : { Element : 'h4' }, 'h5' : { Element : 'h5' }, 'h6' : { Element : 'h6' }, // Other formatting features. 'FontFace' : { Element : 'span', Styles : { 'font-family' : '#("Font")' }, Overrides : [ { Element : 'font', Attributes : { 'face' : null } } ] }, 'Size' : { Element : 'span', Styles : { 'font-size' : '#("Size","fontSize")' }, Overrides : [ { Element : 'font', Attributes : { 'size' : null } } ] }, 'Color' : { Element : 'span', Styles : { 'color' : '#("Color","color")' }, Overrides : [ { Element : 'font', Attributes : { 'color' : null } } ] }, 'BackColor' : { Element : 'span', Styles : { 'background-color' : '#("Color","color")' } }, 'SelectionHighlight' : { Element : 'span', Styles : { 'background-color' : 'navy', 'color' : 'white' } } }; // The distance of an indentation step. FCKConfig.IndentLength = 40 ; FCKConfig.IndentUnit = 'px' ; // Alternatively, FCKeditor allows the use of CSS classes for block indentation. // This overrides the IndentLength/IndentUnit settings. FCKConfig.IndentClasses = [] ; // [ Left, Center, Right, Justified ] FCKConfig.JustifyClasses = [] ; // The following value defines which File Browser connector and Quick Upload // "uploader" to use. It is valid for the default implementaion and it is here // just to make this configuration file cleaner. // It is not possible to change this value using an external file or even // inline when creating the editor instance. In that cases you must set the // values of LinkBrowserURL, ImageBrowserURL and so on. // Custom implementations should just ignore it. var _FileBrowserLanguage = 'php' ; // asp | aspx | cfm | lasso | perl | php | py var _QuickUploadLanguage = 'php' ; // asp | aspx | cfm | lasso | perl | php | py // Don't care about the following two lines. It just calculates the correct connector // extension to use for the default File Browser (Perl uses "cgi"). var _FileBrowserExtension = _FileBrowserLanguage == 'perl' ? 'cgi' : _FileBrowserLanguage ; var _QuickUploadExtension = _QuickUploadLanguage == 'perl' ? 'cgi' : _QuickUploadLanguage ; FCKConfig.LinkBrowser = true ; FCKConfig.LinkBrowserURL = FCKConfig.BasePath + 'filemanager/browser/default/browser.html?Connector=' + encodeURIComponent( FCKConfig.BasePath + 'filemanager/connectors/' + _FileBrowserLanguage + '/connector.' + _FileBrowserExtension ) ; FCKConfig.LinkBrowserWindowWidth = FCKConfig.ScreenWidth * 0.7 ; // 70% FCKConfig.LinkBrowserWindowHeight = FCKConfig.ScreenHeight * 0.7 ; // 70% FCKConfig.ImageBrowser = true ; //FCKConfig.ImageBrowserURL = FCKConfig.BasePath + 'filemanager/browser/default/browser.html?Type=Image&Connector=' + encodeURIComponent( FCKConfig.BasePath + 'filemanager/connectors/' + _FileBrowserLanguage + '/connector.' + _FileBrowserExtension ) ; FCKConfig.ImageBrowserURL = FCKURLParams['BOOT_URL']+'/file/fckeditor'; FCKConfig.ImageBrowserWindowWidth = FCKConfig.ScreenWidth * 0.7 ; // 70% ; FCKConfig.ImageBrowserWindowHeight = FCKConfig.ScreenHeight * 0.7 ; // 70% ; FCKConfig.FlashBrowser = true ; FCKConfig.FlashBrowserURL = FCKConfig.BasePath + 'filemanager/browser/default/browser.html?Type=Flash&Connector=' + encodeURIComponent( FCKConfig.BasePath + 'filemanager/connectors/' + _FileBrowserLanguage + '/connector.' + _FileBrowserExtension ) ; FCKConfig.FlashBrowserWindowWidth = FCKConfig.ScreenWidth * 0.7 ; //70% ; FCKConfig.FlashBrowserWindowHeight = FCKConfig.ScreenHeight * 0.7 ; //70% ; FCKConfig.LinkUpload = true ; FCKConfig.LinkUploadURL = FCKConfig.BasePath + 'filemanager/connectors/' + _QuickUploadLanguage + '/upload.' + _QuickUploadExtension ; FCKConfig.LinkUploadAllowedExtensions = ".(7z|aiff|asf|avi|bmp|csv|doc|fla|flv|gif|gz|gzip|jpeg|jpg|mid|mov|mp3|mp4|mpc|mpeg|mpg|ods|odt|pdf|png|ppt|pxd|qt|ram|rar|rm|rmi|rmvb|rtf|sdc|sitd|swf|sxc|sxw|tar|tgz|tif|tiff|txt|vsd|wav|wma|wmv|xls|xml|zip)$" ; // empty for all FCKConfig.LinkUploadDeniedExtensions = "" ; // empty for no one FCKConfig.ImageUpload = true ; //FCKConfig.ImageUploadURL = FCKConfig.BasePath + 'filemanager/connectors/' + _QuickUploadLanguage + '/upload.' + _QuickUploadExtension + '?Type=Image' ; FCKConfig.ROOT_DIR = FCKURLParams['ROOT_DIR']; FCKConfig.PUBLIC_DIR = FCKURLParams['PUBLIC_DIR']; FCKConfig.BOOT_URL = FCKURLParams['BOOT_URL']; FCKConfig.ImageUploadURL = FCKConfig.BOOT_URL+'/file/upload/doEdit/NewFile'; FCKConfig.ImageUploadAllowedExtensions = ".(jpg|gif|jpeg|png)$" ; // empty for all FCKConfig.ImageUploadDeniedExtensions = "" ; // empty for no one FCKConfig.FlashUpload = true ; FCKConfig.FlashUploadURL = FCKConfig.BasePath + 'filemanager/connectors/' + _QuickUploadLanguage + '/upload.' + _QuickUploadExtension + '?Type=Flash' ; FCKConfig.FlashUploadAllowedExtensions = ".(swf|flv)$" ; // empty for all FCKConfig.FlashUploadDeniedExtensions = "" ; // empty for no one FCKConfig.SmileyPath = FCKConfig.BasePath + 'images/smiley/msn/' ; FCKConfig.SmileyImages = ['regular_smile.gif','sad_smile.gif','wink_smile.gif','teeth_smile.gif','confused_smile.gif','tounge_smile.gif','embaressed_smile.gif','omg_smile.gif','whatchutalkingabout_smile.gif','angry_smile.gif','angel_smile.gif','shades_smile.gif','devil_smile.gif','cry_smile.gif','lightbulb.gif','thumbs_down.gif','thumbs_up.gif','heart.gif','broken_heart.gif','kiss.gif','envelope.gif'] ; FCKConfig.SmileyColumns = 8 ; FCKConfig.SmileyWindowWidth = 320 ; FCKConfig.SmileyWindowHeight = 210 ; FCKConfig.BackgroundBlockerColor = '#ffffff' ; FCKConfig.BackgroundBlockerOpacity = 0.50 ; FCKConfig.MsWebBrowserControlCompat = false ; FCKConfig.PreventSubmitHandler = false ;
JavaScript
$(document).ready(function(){   $("input[type='text']").addClass('input_blur');   $("input[type='password']").addClass('input_blur'); $("input[type='submit']").addClass('button_style'); $("input[type='reset']").addClass('button_style'); $("input[type='button']").addClass('button_style'); $("input[type='radio']").addClass('radio_style'); $("input[type='checkbox']").addClass('checkbox_style'); $("input[type='textarea']").addClass('textarea_style'); $("input[type='file']").addClass('file_style');   $(".table_list tr").mouseover(function () { this.className='mouseover'; } );   $(".table_list tr").mouseout(function () { this.className=''; } ); });
JavaScript
/* * jQuery UI 1.7.2 * * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about) * Dual licensed under the MIT (MIT-LICENSE.txt) * and GPL (GPL-LICENSE.txt) licenses. * * http://docs.jquery.com/UI */ ;jQuery.ui || (function($) { var _remove = $.fn.remove, isFF2 = $.browser.mozilla && (parseFloat($.browser.version) < 1.9); //Helper functions and ui object $.ui = { version: "1.7.2", // $.ui.plugin is deprecated. Use the proxy pattern instead. plugin: { add: function(module, option, set) { var proto = $.ui[module].prototype; for(var i in set) { proto.plugins[i] = proto.plugins[i] || []; proto.plugins[i].push([option, set[i]]); } }, call: function(instance, name, args) { var set = instance.plugins[name]; if(!set || !instance.element[0].parentNode) { return; } for (var i = 0; i < set.length; i++) { if (instance.options[set[i][0]]) { set[i][1].apply(instance.element, args); } } } }, contains: function(a, b) { return document.compareDocumentPosition ? a.compareDocumentPosition(b) & 16 : a !== b && a.contains(b); }, hasScroll: function(el, a) { //If overflow is hidden, the element might have extra content, but the user wants to hide it if ($(el).css('overflow') == 'hidden') { return false; } var scroll = (a && a == 'left') ? 'scrollLeft' : 'scrollTop', has = false; if (el[scroll] > 0) { return true; } // TODO: determine which cases actually cause this to happen // if the element doesn't have the scroll set, see if it's possible to // set the scroll el[scroll] = 1; has = (el[scroll] > 0); el[scroll] = 0; return has; }, isOverAxis: function(x, reference, size) { //Determines when x coordinate is over "b" element axis return (x > reference) && (x < (reference + size)); }, isOver: function(y, x, top, left, height, width) { //Determines when x, y coordinates is over "b" element return $.ui.isOverAxis(y, top, height) && $.ui.isOverAxis(x, left, width); }, keyCode: { BACKSPACE: 8, CAPS_LOCK: 20, COMMA: 188, CONTROL: 17, DELETE: 46, DOWN: 40, END: 35, ENTER: 13, ESCAPE: 27, HOME: 36, INSERT: 45, LEFT: 37, NUMPAD_ADD: 107, NUMPAD_DECIMAL: 110, NUMPAD_DIVIDE: 111, NUMPAD_ENTER: 108, NUMPAD_MULTIPLY: 106, NUMPAD_SUBTRACT: 109, PAGE_DOWN: 34, PAGE_UP: 33, PERIOD: 190, RIGHT: 39, SHIFT: 16, SPACE: 32, TAB: 9, UP: 38 } }; // WAI-ARIA normalization if (isFF2) { var attr = $.attr, removeAttr = $.fn.removeAttr, ariaNS = "http://www.w3.org/2005/07/aaa", ariaState = /^aria-/, ariaRole = /^wairole:/; $.attr = function(elem, name, value) { var set = value !== undefined; return (name == 'role' ? (set ? attr.call(this, elem, name, "wairole:" + value) : (attr.apply(this, arguments) || "").replace(ariaRole, "")) : (ariaState.test(name) ? (set ? elem.setAttributeNS(ariaNS, name.replace(ariaState, "aaa:"), value) : attr.call(this, elem, name.replace(ariaState, "aaa:"))) : attr.apply(this, arguments))); }; $.fn.removeAttr = function(name) { return (ariaState.test(name) ? this.each(function() { this.removeAttributeNS(ariaNS, name.replace(ariaState, "")); }) : removeAttr.call(this, name)); }; } //jQuery plugins $.fn.extend({ remove: function() { // Safari has a native remove event which actually removes DOM elements, // so we have to use triggerHandler instead of trigger (#3037). $("*", this).add(this).each(function() { $(this).triggerHandler("remove"); }); return _remove.apply(this, arguments ); }, enableSelection: function() { return this .attr('unselectable', 'off') .css('MozUserSelect', '') .unbind('selectstart.ui'); }, disableSelection: function() { return this .attr('unselectable', 'on') .css('MozUserSelect', 'none') .bind('selectstart.ui', function() { return false; }); }, scrollParent: function() { var scrollParent; if(($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) { scrollParent = this.parents().filter(function() { return (/(relative|absolute|fixed)/).test($.curCSS(this,'position',1)) && (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1)); }).eq(0); } else { scrollParent = this.parents().filter(function() { return (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1)); }).eq(0); } return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent; } }); //Additional selectors $.extend($.expr[':'], { data: function(elem, i, match) { return !!$.data(elem, match[3]); }, focusable: function(element) { var nodeName = element.nodeName.toLowerCase(), tabIndex = $.attr(element, 'tabindex'); return (/input|select|textarea|button|object/.test(nodeName) ? !element.disabled : 'a' == nodeName || 'area' == nodeName ? element.href || !isNaN(tabIndex) : !isNaN(tabIndex)) // the element and all of its ancestors must be visible // the browser may report that the area is hidden && !$(element)['area' == nodeName ? 'parents' : 'closest'](':hidden').length; }, tabbable: function(element) { var tabIndex = $.attr(element, 'tabindex'); return (isNaN(tabIndex) || tabIndex >= 0) && $(element).is(':focusable'); } }); // $.widget is a factory to create jQuery plugins // taking some boilerplate code out of the plugin code function getter(namespace, plugin, method, args) { function getMethods(type) { var methods = $[namespace][plugin][type] || []; return (typeof methods == 'string' ? methods.split(/,?\s+/) : methods); } var methods = getMethods('getter'); if (args.length == 1 && typeof args[0] == 'string') { methods = methods.concat(getMethods('getterSetter')); } return ($.inArray(method, methods) != -1); } $.widget = function(name, prototype) { var namespace = name.split(".")[0]; name = name.split(".")[1]; // create plugin method $.fn[name] = function(options) { var isMethodCall = (typeof options == 'string'), args = Array.prototype.slice.call(arguments, 1); // prevent calls to internal methods if (isMethodCall && options.substring(0, 1) == '_') { return this; } // handle getter methods if (isMethodCall && getter(namespace, name, options, args)) { var instance = $.data(this[0], name); return (instance ? instance[options].apply(instance, args) : undefined); } // handle initialization and non-getter methods return this.each(function() { var instance = $.data(this, name); // constructor (!instance && !isMethodCall && $.data(this, name, new $[namespace][name](this, options))._init()); // method call (instance && isMethodCall && $.isFunction(instance[options]) && instance[options].apply(instance, args)); }); }; // create widget constructor $[namespace] = $[namespace] || {}; $[namespace][name] = function(element, options) { var self = this; this.namespace = namespace; this.widgetName = name; this.widgetEventPrefix = $[namespace][name].eventPrefix || name; this.widgetBaseClass = namespace + '-' + name; this.options = $.extend({}, $.widget.defaults, $[namespace][name].defaults, $.metadata && $.metadata.get(element)[name], options); this.element = $(element) .bind('setData.' + name, function(event, key, value) { if (event.target == element) { return self._setData(key, value); } }) .bind('getData.' + name, function(event, key) { if (event.target == element) { return self._getData(key); } }) .bind('remove', function() { return self.destroy(); }); }; // add widget prototype $[namespace][name].prototype = $.extend({}, $.widget.prototype, prototype); // TODO: merge getter and getterSetter properties from widget prototype // and plugin prototype $[namespace][name].getterSetter = 'option'; }; $.widget.prototype = { _init: function() {}, destroy: function() { this.element.removeData(this.widgetName) .removeClass(this.widgetBaseClass + '-disabled' + ' ' + this.namespace + '-state-disabled') .removeAttr('aria-disabled'); }, option: function(key, value) { var options = key, self = this; if (typeof key == "string") { if (value === undefined) { return this._getData(key); } options = {}; options[key] = value; } $.each(options, function(key, value) { self._setData(key, value); }); }, _getData: function(key) { return this.options[key]; }, _setData: function(key, value) { this.options[key] = value; if (key == 'disabled') { this.element [value ? 'addClass' : 'removeClass']( this.widgetBaseClass + '-disabled' + ' ' + this.namespace + '-state-disabled') .attr("aria-disabled", value); } }, enable: function() { this._setData('disabled', false); }, disable: function() { this._setData('disabled', true); }, _trigger: function(type, event, data) { var callback = this.options[type], eventName = (type == this.widgetEventPrefix ? type : this.widgetEventPrefix + type); event = $.Event(event); event.type = eventName; // copy original event properties over to the new event // this would happen if we could call $.event.fix instead of $.Event // but we don't have a way to force an event to be fixed multiple times if (event.originalEvent) { for (var i = $.event.props.length, prop; i;) { prop = $.event.props[--i]; event[prop] = event.originalEvent[prop]; } } this.element.trigger(event, data); return !($.isFunction(callback) && callback.call(this.element[0], event, data) === false || event.isDefaultPrevented()); } }; $.widget.defaults = { disabled: false }; /** Mouse Interaction Plugin **/ $.ui.mouse = { _mouseInit: function() { var self = this; this.element .bind('mousedown.'+this.widgetName, function(event) { return self._mouseDown(event); }) .bind('click.'+this.widgetName, function(event) { if(self._preventClickEvent) { self._preventClickEvent = false; event.stopImmediatePropagation(); return false; } }); // Prevent text selection in IE if ($.browser.msie) { this._mouseUnselectable = this.element.attr('unselectable'); this.element.attr('unselectable', 'on'); } this.started = false; }, // TODO: make sure destroying one instance of mouse doesn't mess with // other instances of mouse _mouseDestroy: function() { this.element.unbind('.'+this.widgetName); // Restore text selection in IE ($.browser.msie && this.element.attr('unselectable', this._mouseUnselectable)); }, _mouseDown: function(event) { // don't let more than one widget handle mouseStart // TODO: figure out why we have to use originalEvent event.originalEvent = event.originalEvent || {}; if (event.originalEvent.mouseHandled) { return; } // we may have missed mouseup (out of window) (this._mouseStarted && this._mouseUp(event)); this._mouseDownEvent = event; var self = this, btnIsLeft = (event.which == 1), elIsCancel = (typeof this.options.cancel == "string" ? $(event.target).parents().add(event.target).filter(this.options.cancel).length : false); if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) { return true; } this.mouseDelayMet = !this.options.delay; if (!this.mouseDelayMet) { this._mouseDelayTimer = setTimeout(function() { self.mouseDelayMet = true; }, this.options.delay); } if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) { this._mouseStarted = (this._mouseStart(event) !== false); if (!this._mouseStarted) { event.preventDefault(); return true; } } // these delegates are required to keep context this._mouseMoveDelegate = function(event) { return self._mouseMove(event); }; this._mouseUpDelegate = function(event) { return self._mouseUp(event); }; $(document) .bind('mousemove.'+this.widgetName, this._mouseMoveDelegate) .bind('mouseup.'+this.widgetName, this._mouseUpDelegate); // preventDefault() is used to prevent the selection of text here - // however, in Safari, this causes select boxes not to be selectable // anymore, so this fix is needed ($.browser.safari || event.preventDefault()); event.originalEvent.mouseHandled = true; return true; }, _mouseMove: function(event) { // IE mouseup check - mouseup happened when mouse was out of window if ($.browser.msie && !event.button) { return this._mouseUp(event); } if (this._mouseStarted) { this._mouseDrag(event); return event.preventDefault(); } if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) { this._mouseStarted = (this._mouseStart(this._mouseDownEvent, event) !== false); (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event)); } return !this._mouseStarted; }, _mouseUp: function(event) { $(document) .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate) .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate); if (this._mouseStarted) { this._mouseStarted = false; this._preventClickEvent = (event.target == this._mouseDownEvent.target); this._mouseStop(event); } return false; }, _mouseDistanceMet: function(event) { return (Math.max( Math.abs(this._mouseDownEvent.pageX - event.pageX), Math.abs(this._mouseDownEvent.pageY - event.pageY) ) >= this.options.distance ); }, _mouseDelayMet: function(event) { return this.mouseDelayMet; }, // These are placeholder methods, to be overriden by extending plugin _mouseStart: function(event) {}, _mouseDrag: function(event) {}, _mouseStop: function(event) {}, _mouseCapture: function(event) { return true; } }; $.ui.mouse.defaults = { cancel: null, distance: 1, delay: 0 }; })(jQuery);
JavaScript
/* * jQuery UI Effects Scale 1.7.2 * * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about) * Dual licensed under the MIT (MIT-LICENSE.txt) * and GPL (GPL-LICENSE.txt) licenses. * * http://docs.jquery.com/UI/Effects/Scale * * Depends: * effects.core.js */ (function($) { $.effects.puff = function(o) { return this.queue(function() { // Create element var el = $(this); // Set options var options = $.extend(true, {}, o.options); var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode var percent = parseInt(o.options.percent,10) || 150; // Set default puff percent options.fade = true; // It's not a puff if it doesn't fade! :) var original = {height: el.height(), width: el.width()}; // Save original // Adjust var factor = percent / 100; el.from = (mode == 'hide') ? original : {height: original.height * factor, width: original.width * factor}; // Animation options.from = el.from; options.percent = (mode == 'hide') ? percent : 100; options.mode = mode; // Animate el.effect('scale', options, o.duration, o.callback); el.dequeue(); }); }; $.effects.scale = function(o) { return this.queue(function() { // Create element var el = $(this); // Set options var options = $.extend(true, {}, o.options); var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode var percent = parseInt(o.options.percent,10) || (parseInt(o.options.percent,10) == 0 ? 0 : (mode == 'hide' ? 0 : 100)); // Set default scaling percent var direction = o.options.direction || 'both'; // Set default axis var origin = o.options.origin; // The origin of the scaling if (mode != 'effect') { // Set default origin and restore for show/hide options.origin = origin || ['middle','center']; options.restore = true; } var original = {height: el.height(), width: el.width()}; // Save original el.from = o.options.from || (mode == 'show' ? {height: 0, width: 0} : original); // Default from state // Adjust var factor = { // Set scaling factor y: direction != 'horizontal' ? (percent / 100) : 1, x: direction != 'vertical' ? (percent / 100) : 1 }; el.to = {height: original.height * factor.y, width: original.width * factor.x}; // Set to state if (o.options.fade) { // Fade option to support puff if (mode == 'show') {el.from.opacity = 0; el.to.opacity = 1;}; if (mode == 'hide') {el.from.opacity = 1; el.to.opacity = 0;}; }; // Animation options.from = el.from; options.to = el.to; options.mode = mode; // Animate el.effect('size', options, o.duration, o.callback); el.dequeue(); }); }; $.effects.size = function(o) { return this.queue(function() { // Create element var el = $(this), props = ['position','top','left','width','height','overflow','opacity']; var props1 = ['position','top','left','overflow','opacity']; // Always restore var props2 = ['width','height','overflow']; // Copy for children var cProps = ['fontSize']; var vProps = ['borderTopWidth', 'borderBottomWidth', 'paddingTop', 'paddingBottom']; var hProps = ['borderLeftWidth', 'borderRightWidth', 'paddingLeft', 'paddingRight']; // Set options var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode var restore = o.options.restore || false; // Default restore var scale = o.options.scale || 'both'; // Default scale mode var origin = o.options.origin; // The origin of the sizing var original = {height: el.height(), width: el.width()}; // Save original el.from = o.options.from || original; // Default from state el.to = o.options.to || original; // Default to state // Adjust if (origin) { // Calculate baseline shifts var baseline = $.effects.getBaseline(origin, original); el.from.top = (original.height - el.from.height) * baseline.y; el.from.left = (original.width - el.from.width) * baseline.x; el.to.top = (original.height - el.to.height) * baseline.y; el.to.left = (original.width - el.to.width) * baseline.x; }; var factor = { // Set scaling factor from: {y: el.from.height / original.height, x: el.from.width / original.width}, to: {y: el.to.height / original.height, x: el.to.width / original.width} }; if (scale == 'box' || scale == 'both') { // Scale the css box if (factor.from.y != factor.to.y) { // Vertical props scaling props = props.concat(vProps); el.from = $.effects.setTransition(el, vProps, factor.from.y, el.from); el.to = $.effects.setTransition(el, vProps, factor.to.y, el.to); }; if (factor.from.x != factor.to.x) { // Horizontal props scaling props = props.concat(hProps); el.from = $.effects.setTransition(el, hProps, factor.from.x, el.from); el.to = $.effects.setTransition(el, hProps, factor.to.x, el.to); }; }; if (scale == 'content' || scale == 'both') { // Scale the content if (factor.from.y != factor.to.y) { // Vertical props scaling props = props.concat(cProps); el.from = $.effects.setTransition(el, cProps, factor.from.y, el.from); el.to = $.effects.setTransition(el, cProps, factor.to.y, el.to); }; }; $.effects.save(el, restore ? props : props1); el.show(); // Save & Show $.effects.createWrapper(el); // Create Wrapper el.css('overflow','hidden').css(el.from); // Shift // Animate if (scale == 'content' || scale == 'both') { // Scale the children vProps = vProps.concat(['marginTop','marginBottom']).concat(cProps); // Add margins/font-size hProps = hProps.concat(['marginLeft','marginRight']); // Add margins props2 = props.concat(vProps).concat(hProps); // Concat el.find("*[width]").each(function(){ child = $(this); if (restore) $.effects.save(child, props2); var c_original = {height: child.height(), width: child.width()}; // Save original child.from = {height: c_original.height * factor.from.y, width: c_original.width * factor.from.x}; child.to = {height: c_original.height * factor.to.y, width: c_original.width * factor.to.x}; if (factor.from.y != factor.to.y) { // Vertical props scaling child.from = $.effects.setTransition(child, vProps, factor.from.y, child.from); child.to = $.effects.setTransition(child, vProps, factor.to.y, child.to); }; if (factor.from.x != factor.to.x) { // Horizontal props scaling child.from = $.effects.setTransition(child, hProps, factor.from.x, child.from); child.to = $.effects.setTransition(child, hProps, factor.to.x, child.to); }; child.css(child.from); // Shift children child.animate(child.to, o.duration, o.options.easing, function(){ if (restore) $.effects.restore(child, props2); // Restore children }); // Animate children }); }; // Animate el.animate(el.to, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() { if(mode == 'hide') el.hide(); // Hide $.effects.restore(el, restore ? props : props1); $.effects.removeWrapper(el); // Restore if(o.callback) o.callback.apply(this, arguments); // Callback el.dequeue(); }}); }); }; })(jQuery);
JavaScript
/* Chinese initialisation for the jQuery UI date picker plugin. */ /* Written by Cloudream (cloudream@gmail.com). */ jQuery(function($){ $.datepicker.regional['zh-CN'] = { closeText: '关闭', prevText: '&#x3c;上月', nextText: '下月&#x3e;', currentText: '今天', monthNames: ['一月','二月','三月','四月','五月','六月', '七月','八月','九月','十月','十一月','十二月'], monthNamesShort: ['一','二','三','四','五','六', '七','八','九','十','十一','十二'], dayNames: ['星期日','星期一','星期二','星期三','星期四','星期五','星期六'], dayNamesShort: ['周日','周一','周二','周三','周四','周五','周六'], dayNamesMin: ['日','一','二','三','四','五','六'], dateFormat: 'yy-mm-dd', firstDay: 1, isRTL: false}; $.datepicker.setDefaults($.datepicker.regional['zh-CN']); });
JavaScript
function postDialog() { $(':submit').attr('disabled',true); if($('#autoFrame').length == 0) { $('body').append('<iframe class="hidden" id="autoFrame" name="autoFrame" ></iframe>'); } if($('.ui-dialog').length > 0) { $('.ui-dialog').remove(); } $('<div class="ui-dialog-message"><span class="ui-dialog-loading">&nbsp;</span>正在处理,请稍候...</div>').dialog({ close: function(){$(".ui-dialog").remove();$(".ui-dialog-message").remove();$(':submit').attr('disabled',false);}, title: '提示信息', resizable : false }); } function postResponse(response) { $(".ui-dialog-message").html(response.message); if (response.javascript) { eval(response.javascript); } if (response.goUrl) { redirect(response.goUrl, response.stayTime) } else if (response.stayTime > 0) { window.setTimeout(function(){$(':submit').attr('disabled',false);$(".ui-dialog").hide('slow',function(){$(".ui-dialog").remove();$(".ui-dialog-message").remove();});},response.stayTime * 1000); } } function getDialog(url, goUrl, stayTime) { if(stayTime == undefined) { stayTime = 3; } if($('.ui-dialog').length > 0) { $('.ui-dialog').remove(); } $('<div class="ui-dialog-message"><span class="ui-dialog-loading">&nbsp;</span>正在处理,请稍候...</div>').dialog({ title:'提示信息', resizable : false }); $.ajax({ type : 'get', dataType : 'json', url : url, success : function(response) { $(".ui-dialog-message").html(response.message); if (response.javascript) { eval(response.javascript); } if (response.success && goUrl) { redirect(goUrl, stayTime); } else if (stayTime > 0) { window.setTimeout(function(){$(".ui-dialog").hide('slow');},stayTime*1000); } } }); } function selAll(name) { $("input[name='"+name+"']").attr("checked", true); return false; } function selNone(name) { $("input[name='"+name+"']").attr("checked", false); return false; } function selAnti(name) { $("input[name='"+name+"']").each(function(i){ this.checked=!this.checked; }); return false; } function redirect(goUrl, time) { if(time == undefined) { time = 2; } window.setTimeout(function(){window.location.href=goUrl;},time*1000); } $(document).ready(function(){ $(".content table tr,.rowLine") .mouseover(function(){ if($(this).find("input[name='selected[]']").length > 0 && $(this).parents().find("input[name='selected[]']").length > 2) { $(this).removeClass("selected"); $(this).addClass("titleBg"); } }) .mouseout(function(){ if($(this).find("input[name='selected[]']").length > 0 && $(this).parents().find("input[name='selected[]']").length > 2) { if($(this).find("input[name='selected[]']").get(0).checked) { $(this).addClass("selected"); } else { $(this).removeClass("selected"); } $(this).removeClass("titleBg"); } }) });
JavaScript