您目前尚未登陆,请选择【登陆】或【注册
首页->新闻文章->达达ASP.NET简单新闻发布源码>>fckeditor/fckeditor.js>>代码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:达达ASP.NET简单新闻发布源码


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

- 柠檬居IT技术网多用户Blog源码

- 明日Asp.net在线论坛源码

- Asp.net简单校友录系统源码

- 某贸易公司项目管理系统源码

- Asp.net2.0应用之RSS在线阅读..

- 51aspx实现的Asp.net无刷新中..

- Asp.net简单公文流转系统(MV..

- ASP.Net网络资源管理器 v2.0

51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号