fck_dialog_common.js
上传用户:li2971742
上传日期:2021-11-18
资源大小:39096k
文件大小:4k
源码类别:

OA系统

开发平台:

C#

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