温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:科信客户关系管理系统源码
当前文件路径:KeXinCrm/fckeditor/fckeditor.js

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: fckeditor.js 22
* This is the integration file for JavaScript. 23
* 24
* It defines the FCKeditor class that can be used to create editor 25
* instances in a HTML page in the client side. For server side 26
* operations, use the specific integration system. 27
* 28
* File Authors: 29
* Frederico Caldeira Knabben (www.fckeditor.net) 30
*/ 31
32
// FCKeditor Class 33
var FCKeditor = function( instanceName, width, height, toolbarSet, value ) 34
{ 35
// Properties 36
this.InstanceName = instanceName ; 37
this.Width = width || '100%' ; 38
this.Height = height || '200' ; 39
this.ToolbarSet = toolbarSet || 'Default' ; 40
this.Value = value || '' ; 41
this.BasePath = '/fckeditor/' ; 42
this.CheckBrowser = true ; 43
this.DisplayErrors = true ; 44
this.EnableSafari = false ; // This is a temporary property, while Safari support is under development. 45
this.EnableOpera = false ; // This is a temporary property, while Opera support is under development. 46
47
this.Config = new Object() ; 48
49
// Events 50
this.OnError = null ; // function( source, errorNumber, errorDescription ) 51
} 52
53
FCKeditor.prototype.Version = '2.4' ; 54
FCKeditor.prototype.VersionBuild = '1148' ; 55
56
FCKeditor.prototype.Create = function() 57
{ 58
document.write( this.CreateHtml() ) ; 59
} 60
61
FCKeditor.prototype.CreateHtml = function() 62
{ 63
// Check for errors 64
if ( !this.InstanceName || this.InstanceName.length == 0 ) 65
{ 66
this._ThrowError( 701, 'You must specify an instance name.' ) ; 67
return '' ; 68
} 69
70
var sHtml = '<div>' ; 71
72
if ( !this.CheckBrowser || this._IsCompatibleBrowser() ) 73
{ 74
sHtml += '<input type="hidden" id="' + this.InstanceName + '" name="' + this.InstanceName + '" value="' + this._HTMLEncode( this.Value ) + '" style="display:none" />' ; 75
sHtml += this._GetConfigHtml() ; 76
sHtml += this._GetIFrameHtml() ; 77
} 78
else 79
{ 80
var sWidth = this.Width.toString().indexOf('%') > 0 ? this.Width : this.Width + 'px' ; 81
var sHeight = this.Height.toString().indexOf('%') > 0 ? this.Height : this.Height + 'px' ; 82
sHtml += '<textarea name="' + this.InstanceName + '" rows="4" cols="40" style="width:' + sWidth + ';height:' + sHeight + '">' + this._HTMLEncode( this.Value ) + '<\/textarea>' ; 83
} 84
85
sHtml += '</div>' ; 86
87
return sHtml ; 88
} 89
90
FCKeditor.prototype.ReplaceTextarea = function() 91
{ 92
if ( !this.CheckBrowser || this._IsCompatibleBrowser() ) 93
{ 94
// We must check the elements firstly using the Id and then the name. 95
var oTextarea = document.getElementById( this.InstanceName ) ; 96
var colElementsByName = document.getElementsByName( this.InstanceName ) ; 97
var i = 0; 98
while ( oTextarea || i == 0 ) 99
{ 100
if ( oTextarea && oTextarea.tagName.toLowerCase() == 'textarea' ) 101
break ; 102
oTextarea = colElementsByName[i++] ; 103
} 104
105
if ( !oTextarea ) 106
{ 107
alert( 'Error: The TEXTAREA with id or name set to "' + this.InstanceName + '" was not found' ) ; 108
return ; 109
} 110
111
oTextarea.style.display = 'none' ; 112
this._InsertHtmlBefore( this._GetConfigHtml(), oTextarea ) ; 113
this._InsertHtmlBefore( this._GetIFrameHtml(), oTextarea ) ; 114
} 115
} 116
117
FCKeditor.prototype._InsertHtmlBefore = function( html, element ) 118
{ 119
if ( element.insertAdjacentHTML ) // IE 120
element.insertAdjacentHTML( 'beforeBegin', html ) ; 121
else // Gecko 122
{ 123
var oRange = document.createRange() ; 124
oRange.setStartBefore( element ) ; 125
var oFragment = oRange.createContextualFragment( html ); 126
element.parentNode.insertBefore( oFragment, element ) ; 127
} 128
} 129
130
FCKeditor.prototype._GetConfigHtml = function() 131
{ 132
var sConfig = '' ; 133
for ( var o in this.Config ) 134
{ 135
if ( sConfig.length > 0 ) sConfig += '&' ; 136
sConfig += encodeURIComponent( o ) + '=' + encodeURIComponent( this.Config[o] ) ; 137
} 138
139
return '<input type="hidden" id="' + this.InstanceName + '___Config" value="' + sConfig + '" style="display:none" />' ; 140
} 141
142
FCKeditor.prototype._GetIFrameHtml = function() 143
{ 144
var sFile = 'fckeditor.html' ; 145
146
try 147
{ 148
if ( (/fcksource=true/i).test( window.top.location.search ) ) 149
sFile = 'fckeditor.original.html' ; 150
} 151
catch (e) { /* Ignore it. Much probably we are inside a FRAME where the "top" is in another domain (security error). */ } 152
153
var sLink = this.BasePath + 'editor/' + sFile + '?InstanceName=' + encodeURIComponent( this.InstanceName ) ; 154
if (this.ToolbarSet) sLink += '&Toolbar=' + this.ToolbarSet ; 155
156
return '<iframe id="' + this.InstanceName + '___Frame" src="' + sLink + '" width="' + this.Width + '" height="' + this.Height + '" frameborder="0" scrolling="no"></iframe>' ; 157
} 158
159
FCKeditor.prototype._IsCompatibleBrowser = function() 160
{ 161
return FCKeditor_IsCompatibleBrowser( this.EnableSafari, this.EnableOpera ) ; 162
} 163
164
FCKeditor.prototype._ThrowError = function( errorNumber, errorDescription ) 165
{ 166
this.ErrorNumber = errorNumber ; 167
this.ErrorDescription = errorDescription ; 168
169
if ( this.DisplayErrors ) 170
{ 171
document.write( '<div style="COLOR: #ff0000">' ) ; 172
document.write( '[ FCKeditor Error ' + this.ErrorNumber + ': ' + this.ErrorDescription + ' ]' ) ; 173
document.write( '</div>' ) ; 174
} 175
176
if ( typeof( this.OnError ) == 'function' ) 177
this.OnError( this, errorNumber, errorDescription ) ; 178
} 179
180
FCKeditor.prototype._HTMLEncode = function( text ) 181
{ 182
if ( typeof( text ) != "string" ) 183
text = text.toString() ; 184
185
text = text.replace( 186
/&/g, "&").replace( 187
/"/g, """).replace( 188
/</g, "<").replace( 189
/>/g, ">") ; 190
191
return text ; 192
} 193
194
function FCKeditor_IsCompatibleBrowser( enableSafari, enableOpera ) 195
{ 196
var sAgent = navigator.userAgent.toLowerCase() ; 197
198
// Internet Explorer 199
if ( sAgent.indexOf("msie") != -1 && sAgent.indexOf("mac") == -1 && sAgent.indexOf("opera") == -1 ) 200
{ 201
var sBrowserVersion = navigator.appVersion.match(/MSIE (.\..)/)[1] ; 202
return ( sBrowserVersion >= 5.5 ) ; 203
} 204
205
// Gecko (Opera 9 tries to behave like Gecko at this point). 206
if ( navigator.product == "Gecko" && navigator.productSub >= 20030210 && !( typeof(opera) == 'object' && opera.postError ) ) 207
return true ; 208
209
// Opera 210
if ( enableOpera && navigator.appName == 'Opera' && parseInt( navigator.appVersion, 10 ) >= 9 ) 211
return true ; 212
213
// Safari 214
if ( enableSafari && sAgent.indexOf( 'safari' ) != -1 ) 215
return ( sAgent.match( /safari\/(\d+)/ )[1] >= 312 ) ; // Build must be at least 312 (1.3) 216
217
return false ; 218
}



* FCKeditor - The text editor for Internet - http://www.fckeditor.net

}