[ 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: fck_dialog_common.js 22 * Useful functions used by almost all dialog window pages. 23 * 24 * File Authors: 25 * Frederico Caldeira Knabben (www.fckeditor.net) 26 */ 27 28 var GECKO_BOGUS = '<br type="_moz">' ; 29 30 // Gets a element by its Id. Used for shorter coding. 31 function GetE( elementId ) 32 { 33 return document.getElementById( elementId ) ; 34 } 35 36 function ShowE( element, isVisible ) 37 { 38 if ( typeof( element ) == 'string' ) 39 element = GetE( element ) ; 40 element.style.display = isVisible ? '' : 'none' ; 41 } 42 43 function SetAttribute( element, attName, attValue ) 44 { 45 if ( attValue == null || attValue.length == 0 ) 46 element.removeAttribute( attName, 0 ) ; // 0 : Case Insensitive 47 else 48 element.setAttribute( attName, attValue, 0 ) ; // 0 : Case Insensitive 49 } 50 51 function GetAttribute( element, attName, valueIfNull ) 52 { 53 var oAtt = element.attributes[attName] ; 54 55 if ( oAtt == null || !oAtt.specified ) 56 return valueIfNull ? valueIfNull : '' ; 57 58 var oValue = element.getAttribute( attName, 2 ) ; 59 60 if ( oValue == null ) 61 oValue = oAtt.nodeValue ; 62 63 return ( oValue == null ? valueIfNull : oValue ) ; 64 } 65 66 // Functions used by text fiels to accept numbers only. 67 function IsDigit( e ) 68 { 69 if ( !e ) 70 e = event ; 71 72 var iCode = ( e.keyCode || e.charCode ) ; 73 74 return ( 75 ( iCode >= 48 && iCode <= 57 ) // Numbers 76 || (iCode >= 37 && iCode <= 40) // Arrows 77 || iCode == 8 // Backspace 78 || iCode == 46 // Delete 79 ) ; 80 } 81 82 String.prototype.Trim = function() 83 { 84 return this.replace( /(^\s*)|(\s*$)/g, '' ) ; 85 } 86 87 String.prototype.StartsWith = function( value ) 88 { 89 return ( this.substr( 0, value.length ) == value ) ; 90 } 91 92 String.prototype.Remove = function( start, length ) 93 { 94 var s = '' ; 95 96 if ( start > 0 ) 97 s = this.substring( 0, start ) ; 98 99 if ( start + length < this.length ) 100 s += this.substring( start + length , this.length ) ; 101 102 return s ; 103 } 104 105 String.prototype.ReplaceAll = function( searchArray, replaceArray ) 106 { 107 var replaced = this ; 108 109 for ( var i = 0 ; i < searchArray.length ; i++ ) 110 { 111 replaced = replaced.replace( searchArray[i], replaceArray[i] ) ; 112 } 113 114 return replaced ; 115 } 116 117 function OpenFileBrowser( url, width, height ) 118 { 119 // oEditor must be defined. 120 121 var iLeft = ( oEditor.FCKConfig.ScreenWidth - width ) / 2 ; 122 var iTop = ( oEditor.FCKConfig.ScreenHeight - height ) / 2 ; 123 124 var sOptions = "toolbar=no,status=no,resizable=yes,dependent=yes,scrollbars=yes" ; 125 sOptions += ",width=" + width ; 126 sOptions += ",height=" + height ; 127 sOptions += ",left=" + iLeft ; 128 sOptions += ",top=" + iTop ; 129 130 // The "PreserveSessionOnFileBrowser" because the above code could be 131 // blocked by popup blockers. 132 if ( oEditor.FCKConfig.PreserveSessionOnFileBrowser && oEditor.FCKBrowserInfo.IsIE ) 133 { 134 // The following change has been made otherwise IE will open the file 135 // browser on a different server session (on some cases): 136 // http://support.microsoft.com/default.aspx?scid=kb;en-us;831678 137 // by Simone Chiaretta. 138 var oWindow = oEditor.window.open( url, 'FCKBrowseWindow', sOptions ) ; 139 140 if ( oWindow ) 141 { 142 // Detect Yahoo popup blocker. 143 try 144 { 145 var sTest = oWindow.name ; // Yahoo returns "something", but we can't access it, so detect that and avoid strange errors for the user. 146 oWindow.opener = window ; 147 } 148 catch(e) 149 { 150 alert( oEditor.FCKLang.BrowseServerBlocked ) ; 151 } 152 } 153 else 154 alert( oEditor.FCKLang.BrowseServerBlocked ) ; 155 } 156 else 157 window.open( url, 'FCKBrowseWindow', sOptions ) ; 158 }
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 |