[ Index ] |
|
Code source de GeekLog 1.4.1 |
1 /* 2 * FCKeditor - The text editor for internet 3 * Copyright (C) 2003-2006 Frederico Caldeira Knabben 4 * 5 * Licensed under the terms of the GNU Lesser General Public License: 6 * http://www.opensource.org/licenses/lgpl-license.php 7 * 8 * For further information visit: 9 * http://www.fckeditor.net/ 10 * 11 * "Support Open Source software. What about a donation today?" 12 * 13 * File Name: fck_2.js 14 * This is the second part of the "FCK" object creation. This is the main 15 * object that represents an editor instance. 16 * 17 * File Authors: 18 * Frederico Caldeira Knabben (fredck@fckeditor.net) 19 */ 20 21 // This collection is used by the browser specific implementations to tell 22 // wich named commands must be handled separately. 23 FCK.RedirectNamedCommands = new Object() ; 24 25 FCK.ExecuteNamedCommand = function( commandName, commandParameter, noRedirect ) 26 { 27 FCKUndo.SaveUndoStep() ; 28 29 if ( !noRedirect && FCK.RedirectNamedCommands[ commandName ] != null ) 30 FCK.ExecuteRedirectedNamedCommand( commandName, commandParameter ) ; 31 else 32 { 33 FCK.Focus() ; 34 FCK.EditorDocument.execCommand( commandName, false, commandParameter ) ; 35 FCK.Events.FireEvent( 'OnSelectionChange' ) ; 36 } 37 38 FCKUndo.SaveUndoStep() ; 39 } 40 41 FCK.GetNamedCommandState = function( commandName ) 42 { 43 try 44 { 45 if ( !FCK.EditorDocument.queryCommandEnabled( commandName ) ) 46 return FCK_TRISTATE_DISABLED ; 47 else 48 return FCK.EditorDocument.queryCommandState( commandName ) ? FCK_TRISTATE_ON : FCK_TRISTATE_OFF ; 49 } 50 catch ( e ) 51 { 52 return FCK_TRISTATE_OFF ; 53 } 54 } 55 56 FCK.GetNamedCommandValue = function( commandName ) 57 { 58 var sValue = '' ; 59 var eState = FCK.GetNamedCommandState( commandName ) ; 60 61 if ( eState == FCK_TRISTATE_DISABLED ) 62 return null ; 63 64 try 65 { 66 sValue = this.EditorDocument.queryCommandValue( commandName ) ; 67 } 68 catch(e) {} 69 70 return sValue ? sValue : '' ; 71 } 72 73 FCK.PasteFromWord = function() 74 { 75 FCKDialog.OpenDialog( 'FCKDialog_Paste', FCKLang.PasteFromWord, 'dialog/fck_paste.html', 400, 330, 'Word' ) ; 76 } 77 78 FCK.Preview = function() 79 { 80 var iWidth = FCKConfig.ScreenWidth * 0.8 ; 81 var iHeight = FCKConfig.ScreenHeight * 0.7 ; 82 var iLeft = ( FCKConfig.ScreenWidth - iWidth ) / 2 ; 83 var oWindow = window.open( '', null, 'toolbar=yes,location=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=' + iWidth + ',height=' + iHeight + ',left=' + iLeft ) ; 84 85 var sHTML ; 86 87 if ( FCKConfig.FullPage ) 88 { 89 if ( FCK.TempBaseTag.length > 0 ) 90 sHTML = FCK.GetXHTML().replace( FCKRegexLib.HeadOpener, '$&' + FCK.TempBaseTag ) ; 91 else 92 sHTML = FCK.GetXHTML() ; 93 } 94 else 95 { 96 sHTML = 97 FCKConfig.DocType + 98 '<html dir="' + FCKConfig.ContentLangDirection + '">' + 99 '<head>' + 100 FCK.TempBaseTag + 101 '<title>' + FCKLang.Preview + '</title>' + 102 FCK._GetEditorAreaStyleTags() + 103 '</head><body>' + 104 FCK.GetXHTML() + 105 '</body></html>' ; 106 } 107 108 oWindow.document.write( sHTML ); 109 oWindow.document.close(); 110 } 111 112 FCK.SwitchEditMode = function( noUndo ) 113 { 114 var bIsWysiwyg = ( FCK.EditMode == FCK_EDITMODE_WYSIWYG ) ; 115 var sHtml ; 116 117 // Update the HTML in the view output to show. 118 if ( bIsWysiwyg ) 119 { 120 if ( !noUndo && FCKBrowserInfo.IsIE ) 121 FCKUndo.SaveUndoStep() ; 122 123 sHtml = FCK.GetXHTML( FCKConfig.FormatSource ) ; 124 } 125 else 126 sHtml = this.EditingArea.Textarea.value ; 127 128 FCK.EditMode = bIsWysiwyg ? FCK_EDITMODE_SOURCE : FCK_EDITMODE_WYSIWYG ; 129 130 FCK.SetHTML( sHtml ) ; 131 132 if ( FCKBrowserInfo.IsGecko ) 133 window.onresize() ; 134 135 // Set the Focus. 136 FCK.Focus() ; 137 138 // Update the toolbar (Running it directly causes IE to fail). 139 FCKTools.RunFunction( FCK.ToolbarSet.RefreshModeState, FCK.ToolbarSet ) ; 140 } 141 142 FCK.CreateElement = function( tag ) 143 { 144 var e = FCK.EditorDocument.createElement( tag ) ; 145 return FCK.InsertElementAndGetIt( e ) ; 146 } 147 148 FCK.InsertElementAndGetIt = function( e ) 149 { 150 e.setAttribute( 'FCKTempLabel', 'true' ) ; 151 152 this.InsertElement( e ) ; 153 154 var aEls = FCK.EditorDocument.getElementsByTagName( e.tagName ) ; 155 156 for ( var i = 0 ; i < aEls.length ; i++ ) 157 { 158 if ( aEls[i].getAttribute( 'FCKTempLabel' ) ) 159 { 160 aEls[i].removeAttribute( 'FCKTempLabel' ) ; 161 return aEls[i] ; 162 } 163 } 164 return null ; 165 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Wed Nov 21 12:27:40 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |