[ 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_1_ie.js 14 * This is the first part of the "FCK" object creation. This is the main 15 * object that represents an editor instance. 16 * (IE specific implementations) 17 * 18 * File Authors: 19 * Frederico Caldeira Knabben (fredck@fckeditor.net) 20 */ 21 22 FCK.Description = "FCKeditor for Internet Explorer 5.5+" ; 23 24 FCK._GetBehaviorsStyle = function() 25 { 26 if ( !FCK._BehaviorsStyle ) 27 { 28 var sBasePath = FCKConfig.FullBasePath ; 29 var sTableBehavior = '' ; 30 var sStyle ; 31 32 // The behaviors should be pointed using the FullBasePath to avoid security 33 // errors when using a differente BaseHref. 34 sStyle = 35 '<style type="text/css" _fcktemp="true">' + 36 'INPUT { behavior: url(' + sBasePath + 'css/behaviors/hiddenfield.htc) ; }' ; 37 38 if ( FCKConfig.ShowBorders ) 39 sTableBehavior = 'url(' + sBasePath + 'css/behaviors/showtableborders.htc)' ; 40 41 // Disable resize handlers. 42 sStyle += 'INPUT,TEXTAREA,SELECT,.FCK__Anchor,.FCK__PageBreak' ; 43 44 if ( FCKConfig.DisableObjectResizing ) 45 { 46 sStyle += ',IMG' ; 47 sTableBehavior += ' url(' + sBasePath + 'css/behaviors/disablehandles.htc)' ; 48 } 49 50 sStyle += ' { behavior: url(' + sBasePath + 'css/behaviors/disablehandles.htc) ; }' ; 51 52 if ( sTableBehavior.length > 0 ) 53 sStyle += 'TABLE { behavior: ' + sTableBehavior + ' ; }' ; 54 55 sStyle += '</style>' ; 56 FCK._BehaviorsStyle = sStyle ; 57 } 58 59 return FCK._BehaviorsStyle ; 60 } 61 62 function Doc_OnMouseUp() 63 { 64 if ( FCK.EditorWindow.event.srcElement.tagName == 'HTML' ) 65 { 66 FCK.Focus() ; 67 FCK.EditorWindow.event.cancelBubble = true ; 68 FCK.EditorWindow.event.returnValue = false ; 69 } 70 } 71 72 function Doc_OnPaste() 73 { 74 if ( FCK.Status == FCK_STATUS_COMPLETE ) 75 FCK.Events.FireEvent( "OnPaste" ) ; 76 77 return false ; 78 } 79 80 /* 81 function Doc_OnContextMenu() 82 { 83 var e = FCK.EditorWindow.event ; 84 85 FCK.ShowContextMenu( e.screenX, e.screenY ) ; 86 return false ; 87 } 88 */ 89 90 function Doc_OnKeyDown() 91 { 92 var e = FCK.EditorWindow.event ; 93 94 95 switch ( e.keyCode ) 96 { 97 case 13 : // ENTER 98 if ( FCKConfig.UseBROnCarriageReturn && !(e.ctrlKey || e.altKey || e.shiftKey) ) 99 { 100 Doc_OnKeyDownUndo() ; 101 102 // We must ignore it if we are inside a List. 103 if ( FCK.EditorDocument.queryCommandState( 'InsertOrderedList' ) || FCK.EditorDocument.queryCommandState( 'InsertUnorderedList' ) ) 104 return true ; 105 106 // Insert the <BR> (The must be also inserted to make it work) 107 FCK.InsertHtml( '<br> ' ) ; 108 109 // Remove the 110 var oRange = FCK.EditorDocument.selection.createRange() ; 111 oRange.moveStart( 'character', -1 ) ; 112 oRange.select() ; 113 FCK.EditorDocument.selection.clear() ; 114 115 return false ; 116 } 117 break ; 118 119 case 8 : // BACKSPACE 120 // We must delete a control selection by code and cancels the 121 // keystroke, otherwise IE will execute the browser's "back" button. 122 if ( FCKSelection.GetType() == 'Control' ) 123 { 124 FCKSelection.Delete() ; 125 return false ; 126 } 127 break ; 128 129 case 9 : // TAB 130 if ( FCKConfig.TabSpaces > 0 && !(e.ctrlKey || e.altKey || e.shiftKey) ) 131 { 132 Doc_OnKeyDownUndo() ; 133 134 FCK.InsertHtml( window.FCKTabHTML ) ; 135 return false ; 136 } 137 break ; 138 case 90 : // Z 139 if ( e.ctrlKey && !(e.altKey || e.shiftKey) ) 140 { 141 FCKUndo.Undo() ; 142 return false ; 143 } 144 break ; 145 case 89 : // Y 146 if ( e.ctrlKey && !(e.altKey || e.shiftKey) ) 147 { 148 FCKUndo.Redo() ; 149 return false ; 150 } 151 break ; 152 } 153 154 if ( !( e.keyCode >=16 && e.keyCode <= 18 ) ) 155 Doc_OnKeyDownUndo() ; 156 return true ; 157 } 158 159 function Doc_OnKeyDownUndo() 160 { 161 if ( !FCKUndo.Typing ) 162 { 163 FCKUndo.SaveUndoStep() ; 164 FCKUndo.Typing = true ; 165 FCK.Events.FireEvent( "OnSelectionChange" ) ; 166 } 167 168 FCKUndo.TypesCount++ ; 169 170 if ( FCKUndo.TypesCount > FCKUndo.MaxTypes ) 171 { 172 FCKUndo.TypesCount = 0 ; 173 FCKUndo.SaveUndoStep() ; 174 } 175 } 176 177 function Doc_OnDblClick() 178 { 179 FCK.OnDoubleClick( FCK.EditorWindow.event.srcElement ) ; 180 FCK.EditorWindow.event.cancelBubble = true ; 181 } 182 183 function Doc_OnSelectionChange() 184 { 185 FCK.Events.FireEvent( "OnSelectionChange" ) ; 186 } 187 188 FCK.InitializeBehaviors = function( dontReturn ) 189 { 190 // Set the focus to the editable area when clicking in the document area. 191 // TODO: The cursor must be positioned at the end. 192 this.EditorDocument.attachEvent( 'onmouseup', Doc_OnMouseUp ) ; 193 194 // Intercept pasting operations 195 this.EditorDocument.body.attachEvent( 'onpaste', Doc_OnPaste ) ; 196 197 // Reset the context menu. 198 FCK.ContextMenu._InnerContextMenu.AttachToElement( FCK.EditorDocument.body ) ; 199 200 // Build the "TAB" key replacement (if necessary). 201 if ( FCKConfig.TabSpaces > 0 ) 202 { 203 window.FCKTabHTML = '' ; 204 for ( i = 0 ; i < FCKConfig.TabSpaces ; i++ ) 205 window.FCKTabHTML += " " ; 206 } 207 this.EditorDocument.attachEvent("onkeydown", Doc_OnKeyDown ) ; 208 209 this.EditorDocument.attachEvent("ondblclick", Doc_OnDblClick ) ; 210 211 // Catch cursor movements 212 this.EditorDocument.attachEvent("onselectionchange", Doc_OnSelectionChange ) ; 213 214 //Enable editing 215 // this.EditorDocument.body.contentEditable = true ; 216 } 217 218 FCK.InsertHtml = function( html ) 219 { 220 html = FCKConfig.ProtectedSource.Protect( html ) ; 221 html = FCK.ProtectUrls( html ) ; 222 223 FCK.Focus() ; 224 225 FCKUndo.SaveUndoStep() ; 226 227 // Gets the actual selection. 228 var oSel = FCK.EditorDocument.selection ; 229 230 // Deletes the actual selection contents. 231 if ( oSel.type.toLowerCase() == 'control' ) 232 oSel.clear() ; 233 234 // Insert the HTML. 235 oSel.createRange().pasteHTML( html ) ; 236 } 237 238 FCK.SetInnerHtml = function( html ) // IE Only 239 { 240 var oDoc = FCK.EditorDocument ; 241 // Using the following trick, any comment in the begining of the HTML will 242 // be preserved. 243 oDoc.body.innerHTML = '<div id="__fakeFCKRemove__"> </div>' + html ; 244 oDoc.getElementById('__fakeFCKRemove__').removeNode( true ) ; 245 } 246 247 var FCK_PreloadImages_Count = 0 ; 248 var FCK_PreloadImages_Images = new Array() ; 249 250 function FCK_PreloadImages() 251 { 252 // Get the images to preload. 253 var aImages = FCKConfig.PreloadImages || [] ; 254 255 if ( typeof( aImages ) == 'string' ) 256 aImages = aImages.split( ';' ) ; 257 258 // Add the skin icons strip. 259 aImages.push( FCKConfig.SkinPath + 'fck_strip.gif' ) ; 260 261 FCK_PreloadImages_Count = aImages.length ; 262 263 var aImageElements = new Array() ; 264 265 for ( var i = 0 ; i < aImages.length ; i++ ) 266 { 267 var eImg = document.createElement( 'img' ) ; 268 eImg.onload = eImg.onerror = FCK_PreloadImages_OnImage ; 269 eImg.src = aImages[i] ; 270 271 FCK_PreloadImages_Images[i] = eImg ; 272 } 273 } 274 275 function FCK_PreloadImages_OnImage() 276 { 277 if ( (--FCK_PreloadImages_Count) == 0 ) 278 FCKTools.RunFunction( LoadToolbarSetup ) ; 279 } 280 281 // Disable the context menu in the editor (outside the editing area). 282 function Document_OnContextMenu() 283 { 284 return ( event.srcElement._FCKShowContextMenu == true ) ; 285 } 286 document.oncontextmenu = Document_OnContextMenu ; 287 288 function FCK_Cleanup() 289 { 290 this.EditorWindow = null ; 291 this.EditorDocument = null ; 292 }
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 |
![]() |