[ Index ] |
|
Code source de FCKeditor 2.4 |
1 /* 2 * FCKeditor - The text editor for Internet - http://www.fckeditor.net 3 * Copyright (C) 2003-2007 Frederico Caldeira Knabben 4 * 5 * == BEGIN LICENSE == 6 * 7 * Licensed under the terms of any of the following licenses at your 8 * choice: 9 * 10 * - GNU General Public License Version 2 or later (the "GPL") 11 * http://www.gnu.org/licenses/gpl.html 12 * 13 * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") 14 * http://www.gnu.org/licenses/lgpl.html 15 * 16 * - Mozilla Public License Version 1.1 or later (the "MPL") 17 * http://www.mozilla.org/MPL/MPL-1.1.html 18 * 19 * == END LICENSE == 20 * 21 * File Name: fcktools_ie.js 22 * Utility functions. (IE version). 23 * 24 * File Authors: 25 * Frederico Caldeira Knabben (www.fckeditor.net) 26 */ 27 28 FCKTools.CancelEvent = function( e ) 29 { 30 return false ; 31 } 32 33 // Appends one or more CSS files to a document. 34 FCKTools._AppendStyleSheet = function( documentElement, cssFileUrl ) 35 { 36 return documentElement.createStyleSheet( cssFileUrl ).owningElement ; 37 } 38 39 // Removes all attributes and values from the element. 40 FCKTools.ClearElementAttributes = function( element ) 41 { 42 element.clearAttributes() ; 43 } 44 45 FCKTools.GetAllChildrenIds = function( parentElement ) 46 { 47 var aIds = new Array() ; 48 for ( var i = 0 ; i < parentElement.all.length ; i++ ) 49 { 50 var sId = parentElement.all[i].id ; 51 if ( sId && sId.length > 0 ) 52 aIds[ aIds.length ] = sId ; 53 } 54 return aIds ; 55 } 56 57 FCKTools.RemoveOuterTags = function( e ) 58 { 59 e.insertAdjacentHTML( 'beforeBegin', e.innerHTML ) ; 60 e.parentNode.removeChild( e ) ; 61 } 62 63 FCKTools.CreateXmlObject = function( object ) 64 { 65 var aObjs ; 66 67 switch ( object ) 68 { 69 case 'XmlHttp' : 70 aObjs = [ 'MSXML2.XmlHttp', 'Microsoft.XmlHttp' ] ; 71 break ; 72 73 case 'DOMDocument' : 74 aObjs = [ 'MSXML2.DOMDocument', 'Microsoft.XmlDom' ] ; 75 break ; 76 } 77 78 for ( var i = 0 ; i < 2 ; i++ ) 79 { 80 try { return new ActiveXObject( aObjs[i] ) ; } 81 catch (e) 82 {} 83 } 84 85 if ( FCKLang.NoActiveX ) 86 { 87 alert( FCKLang.NoActiveX ) ; 88 FCKLang.NoActiveX = null ; 89 } 90 return null ; 91 } 92 93 FCKTools.DisableSelection = function( element ) 94 { 95 element.unselectable = 'on' ; 96 97 var e, i = 0 ; 98 // The extra () is to avoid a warning with strict error checking. This is ok. 99 while ( (e = element.all[ i++ ]) ) 100 { 101 switch ( e.tagName ) 102 { 103 case 'IFRAME' : 104 case 'TEXTAREA' : 105 case 'INPUT' : 106 case 'SELECT' : 107 /* Ignore the above tags */ 108 break ; 109 default : 110 e.unselectable = 'on' ; 111 } 112 } 113 } 114 115 FCKTools.GetScrollPosition = function( relativeWindow ) 116 { 117 var oDoc = relativeWindow.document ; 118 119 // Try with the doc element. 120 var oPos = { X : oDoc.documentElement.scrollLeft, Y : oDoc.documentElement.scrollTop } ; 121 122 if ( oPos.X > 0 || oPos.Y > 0 ) 123 return oPos ; 124 125 // If no scroll, try with the body. 126 return { X : oDoc.body.scrollLeft, Y : oDoc.body.scrollTop } ; 127 } 128 129 FCKTools.AddEventListener = function( sourceObject, eventName, listener ) 130 { 131 sourceObject.attachEvent( 'on' + eventName, listener ) ; 132 } 133 134 FCKTools.RemoveEventListener = function( sourceObject, eventName, listener ) 135 { 136 sourceObject.detachEvent( 'on' + eventName, listener ) ; 137 } 138 139 // Listeners attached with this function cannot be detached. 140 FCKTools.AddEventListenerEx = function( sourceObject, eventName, listener, paramsArray ) 141 { 142 // Ok... this is a closures party, but is the only way to make it clean of memory leaks. 143 var o = new Object() ; 144 o.Source = sourceObject ; 145 o.Params = paramsArray || [] ; // Memory leak if we have DOM objects here. 146 o.Listener = function( ev ) 147 { 148 return listener.apply( o.Source, [ ev ].concat( o.Params ) ) ; 149 } 150 151 if ( FCK.IECleanup ) 152 FCK.IECleanup.AddItem( null, function() { o.Source = null ; o.Params = null ; } ) ; 153 154 sourceObject.attachEvent( 'on' + eventName, o.Listener ) ; 155 156 sourceObject = null ; // Memory leak cleaner (because of the above closure). 157 paramsArray = null ; // Memory leak cleaner (because of the above closure). 158 } 159 160 // Returns and object with the "Width" and "Height" properties. 161 FCKTools.GetViewPaneSize = function( win ) 162 { 163 var oSizeSource ; 164 165 var oDoc = win.document.documentElement ; 166 if ( oDoc && oDoc.clientWidth ) // IE6 Strict Mode 167 oSizeSource = oDoc ; 168 else 169 oSizeSource = top.document.body ; // Other IEs 170 171 if ( oSizeSource ) 172 return { Width : oSizeSource.clientWidth, Height : oSizeSource.clientHeight } ; 173 else 174 return { Width : 0, Height : 0 } ; 175 } 176 177 FCKTools.SaveStyles = function( element ) 178 { 179 var oSavedStyles = new Object() ; 180 181 if ( element.className.length > 0 ) 182 { 183 oSavedStyles.Class = element.className ; 184 element.className = '' ; 185 } 186 187 var sInlineStyle = element.style.cssText ; 188 189 if ( sInlineStyle.length > 0 ) 190 { 191 oSavedStyles.Inline = sInlineStyle ; 192 element.style.cssText = '' ; 193 } 194 195 return oSavedStyles ; 196 } 197 198 FCKTools.RestoreStyles = function( element, savedStyles ) 199 { 200 element.className = savedStyles.Class || '' ; 201 element.style.cssText = savedStyles.Inline || '' ; 202 } 203 204 FCKTools.RegisterDollarFunction = function( targetWindow ) 205 { 206 targetWindow.$ = targetWindow.document.getElementById ; 207 } 208 209 FCKTools.AppendElement = function( target, elementName ) 210 { 211 return target.appendChild( this.GetElementDocument( target ).createElement( elementName ) ) ; 212 } 213 214 // This function may be used by Regex replacements. 215 FCKTools.ToLowerCase = function( strValue ) 216 { 217 return strValue.toLowerCase() ; 218 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 15:28:05 2007 | par Balluche grâce à PHPXref 0.7 |