OSDN Git Service

version 0.5.9.9.3
[nucleus-jp/nucleus-plugins.git] / trunk / NP_MitasNom / mitasnom / editor / dialog / common / fck_dialog_common.js
index a181dac..872d16e 100644 (file)
-/*
- * FCKeditor - The text editor for internet
- * Copyright (C) 2003-2005 Frederico Caldeira Knabben
- * 
- * Licensed under the terms of the GNU Lesser General Public License:
- *             http://www.opensource.org/licenses/lgpl-license.php
- * 
- * For further information visit:
- *             http://www.fckeditor.net/
- * 
- * "Support Open Source software. What about a donation today?"
- * 
- * File Name: fck_dialog_common.js
- *     Useful functions used by almost all dialog window pages.
- * 
- * File Authors:
- *             Frederico Caldeira Knabben (fredck@fckeditor.net)
- */
-
-/*
- * Modified for Nucleus Plugin by Katsumi
- * The license turned to GPL.
- */
-
-// Gets a element by its Id. Used for shorter coding.
-function GetE( elementId )
-{
-       return document.getElementById( elementId )  ;
-}
-
-function ShowE( element, isVisible )
-{
-       if ( typeof( element ) == 'string' )
-               element = GetE( element ) ;
-       element.style.display = isVisible ? '' : 'none' ;
-}
-
-function SetAttribute( element, attName, attValue )
-{
-       if ( attValue == null || attValue.length == 0 )
-               element.removeAttribute( attName, 0 ) ;                 // 0 : Case Insensitive
-       else
-               element.setAttribute( attName, attValue, 0 ) ;  // 0 : Case Insensitive
-}
-
-function GetAttribute( element, attName, valueIfNull )
-{
-       var oAtt = element.attributes[attName] ;
-
-       if ( oAtt == null || !oAtt.specified )
-               return valueIfNull ? valueIfNull : '' ;
-
-       var oValue ;
-       
-       if ( !( oValue = element.getAttribute( attName, 2 ) ) )
-               oValue = oAtt.nodeValue ;
-
-       return ( oValue == null ? valueIfNull : oValue ) ;
-}
-
-// Functions used by text fiels to accept numbers only.
-function IsDigit( e )
-{
-       e = e || event ;
-       var iCode = ( e.keyCode || e.charCode ) ;
-
-       event.returnValue =
-               (
-                       ( iCode >= 48 && iCode <= 57 )          // Numbers
-                       || (iCode >= 37 && iCode <= 40)         // Arrows
-                       || iCode == 8                                           // Backspace
-                       || iCode == 46                                          // Delete
-               ) ;
-
-       return event.returnValue ;
-}
-
-String.prototype.trim = function()
-{
-       return this.replace( /(^\s*)|(\s*$)/g, '' ) ;
-}
-
-String.prototype.startsWith = function( value )
-{
-       return ( this.substr( 0, value.length ) == value ) ;
-}
-
-String.prototype.remove = function( start, length )
-{
-       var s = '' ;
-
-       if ( start > 0 )
-               s = this.substring( 0, start ) ;
-
-       if ( start + length < this.length )
-               s += this.substring( start + length , this.length ) ;
-
-       return s ;
-}
-
-function OpenFileBrowser( url, width, height )
-{
-       // oEditor must be defined.
-       
-       var iLeft = ( oEditor.FCKConfig.ScreenWidth  - width ) / 2 ;
-       var iTop  = ( oEditor.FCKConfig.ScreenHeight - height ) / 2 ;
-
-       var sOptions = "toolbar=no,status=no,resizable=yes,dependent=yes" ;
-       sOptions += ",width=" + width ; 
-       sOptions += ",height=" + height ; 
-       sOptions += ",left=" + iLeft ; 
-       sOptions += ",top=" + iTop ; 
-       sOptions += ",scrollbars=yes";
-       // The "PreserveSessionOnFileBrowser" because the above code could be 
-       // blocked by popup blockers.
-       if ( oEditor.FCKConfig.PreserveSessionOnFileBrowser && oEditor.FCKBrowserInfo.IsIE )
-       {
-               // The following change has been made otherwise IE will open the file 
-               // browser on a different server session (on some cases):
-               // http://support.microsoft.com/default.aspx?scid=kb;en-us;831678
-               // by Simone Chiaretta.
-               var oWindow = oEditor.window.open( url, 'FCKBrowseWindow', sOptions ) ;
-               if ( oWindow )
-                       oWindow.opener = window ;
-               else
-                       alert( oEditor.FCKLang.BrowseServerBlocked ) ;
-       }
-       else { var oWindow =window.open( url, 'FCKBrowseWindow', sOptions ) ; }
-       if ( oWindow ) {
-               if (FCKConfig.NucleusUseImageManager) {// Image-Manager plugin
-                       SetImageManager_oWindow=oWindow;
-                       SetImageManager_timer=setInterval("SetImageManager()",1);// Check the window every 1 mili second.
-               } else {//media.php
-                       oWindow.window.opener.includeImage=function(collection,filename,type,width,height)
-                       {
-                               if (this.GetE('txtUrl')) this.GetE('txtUrl').value=FCKConfig.NucleusMediaDir+collection+'/'+filename;
-                               if (this.GetE('txtWidth')) this.GetE('txtWidth').value=width;
-                               if (this.GetE('txtHeight')) this.GetE('txtHeight').value=height;
-                               //if (this.GetE('txtAttTitle')) this.GetE('txtAttTitle').value=filename;
-                       };
-                       oWindow.window.opener.includeOtherMedia=function(collection, filename)
-                       {
-                               if (this.GetE('txtUrl')) this.GetE('txtUrl').value=FCKConfig.NucleusMediaDir+collection+'/'+filename;
-                       };
-               }
-       }
-}
-
-var SetImageManager_oWindow;
-var SetImageManager_timer;
-function SetImageManager(){
-       var oWindow=SetImageManager_oWindow;
-       if (!oWindow.window.onOK) return;
-       clearInterval(SetImageManager_timer);
-       oWindow.window.base_url=FCKConfig.NucleusMediaDir;
-       oWindow.window.__dlg_close=function(val)
-               {
-                       var sActualBrowser;
-                       try {
-                               sActualBrowser=oWindow.window.opener.sActualBrowser.toLowerCase();
-                       } catch(e) {
-                               sActualBrowser='';
-                       }
-                       if (val) switch (sActualBrowser){
-                       case "link":
-                               if (oWindow.window.opener.GetE('txtLnkUrl')) oWindow.window.opener.GetE('txtLnkUrl').value=val['f_url'];
-                               break;
-                       default:
-                               if (oWindow.window.opener.GetE('txtUrl')) oWindow.window.opener.GetE('txtUrl').value=val['f_url'];
-                               if (oWindow.window.opener.GetE('txtWidth')) oWindow.window.opener.GetE('txtWidth').value=val['f_width'];
-                               if (oWindow.window.opener.GetE('txtWidth')) oWindow.window.opener.GetE('txtHeight').value=val['f_height'];
-                               //if (oWindow.window.opener.GetE('txtAttTitle')) oWindow.window.opener.GetE('txtAttTitle').value=filename;
-                       }
-                       oWindow.close();
-               };
+/*\r
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net\r
+ * Copyright (C) 2003-2007 Frederico Caldeira Knabben\r
+ * \r
+ * == BEGIN LICENSE ==\r
+ * \r
+ * Licensed under the terms of any of the following licenses at your\r
+ * choice:\r
+ * \r
+ *  - GNU General Public License Version 2 or later (the "GPL")\r
+ *    http://www.gnu.org/licenses/gpl.html\r
+ *\r
+ *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")\r
+ *    http://www.gnu.org/licenses/lgpl.html\r
+ *\r
+ *  - Mozilla Public License Version 1.1 or later (the "MPL")\r
+ *    http://www.mozilla.org/MPL/MPL-1.1.html\r
+ *\r
+ * == END LICENSE ==\r
+ * \r
+ *     Useful functions used by almost all dialog window pages.\r
+ */\r
+/*\r
+ * Modified for Nucleus Plugin by Katsumi\r
+ * The license turned to GPL.\r
+ */\r
+\r
+// Gets a element by its Id. Used for shorter coding.\r
+function GetE( elementId )\r
+{\r
+       return document.getElementById( elementId )  ;\r
+}\r
+\r
+function ShowE( element, isVisible )\r
+{\r
+       if ( typeof( element ) == 'string' )\r
+               element = GetE( element ) ;\r
+       element.style.display = isVisible ? '' : 'none' ;\r
+}\r
+\r
+function SetAttribute( element, attName, attValue )\r
+{\r
+       if ( attValue == null || attValue.length == 0 )\r
+               element.removeAttribute( attName, 0 ) ;                 // 0 : Case Insensitive\r
+       else\r
+               element.setAttribute( attName, attValue, 0 ) ;  // 0 : Case Insensitive\r
+}\r
+\r
+function GetAttribute( element, attName, valueIfNull )\r
+{\r
+       var oAtt = element.attributes[attName] ;\r
+\r
+       if ( oAtt == null || !oAtt.specified )\r
+               return valueIfNull ? valueIfNull : '' ;\r
+\r
+       var oValue = element.getAttribute( attName, 2 ) ;\r
+       \r
+       if ( oValue == null )\r
+               oValue = oAtt.nodeValue ;\r
+\r
+       return ( oValue == null ? valueIfNull : oValue ) ;\r
+}\r
+\r
+var KeyIdentifierMap = \r
+{\r
+       End             : 35,\r
+       Home    : 36,\r
+       Left    : 37,\r
+       Right   : 39,\r
+       'U+00007F' : 46         // Delete\r
+} \r
+\r
+// Functions used by text fields to accept numbers only.\r
+function IsDigit( e )\r
+{\r
+       if ( !e )\r
+               e = event ;\r
+\r
+       var iCode = ( e.keyCode || e.charCode ) ;\r
+\r
+       if ( !iCode && e.keyIdentifier && ( e.keyIdentifier in KeyIdentifierMap ) ) \r
+                       iCode = KeyIdentifierMap[ e.keyIdentifier ] ;\r
+\r
+       return (\r
+                       ( iCode >= 48 && iCode <= 57 )          // Numbers\r
+                       || (iCode >= 35 && iCode <= 40)         // Arrows, Home, End\r
+                       || iCode == 8                                           // Backspace\r
+                       || iCode == 46                                          // Delete\r
+                       || iCode == 9                                           // Tab\r
+               ) ;\r
+}\r
+\r
+String.prototype.Trim = function()\r
+{\r
+       return this.replace( /(^\s*)|(\s*$)/g, '' ) ;\r
+}\r
+\r
+String.prototype.StartsWith = function( value )\r
+{\r
+       return ( this.substr( 0, value.length ) == value ) ;\r
+}\r
+\r
+String.prototype.Remove = function( start, length )\r
+{\r
+       var s = '' ;\r
+\r
+       if ( start > 0 )\r
+               s = this.substring( 0, start ) ;\r
+\r
+       if ( start + length < this.length )\r
+               s += this.substring( start + length , this.length ) ;\r
+\r
+       return s ;\r
+}\r
+\r
+String.prototype.ReplaceAll = function( searchArray, replaceArray )\r
+{\r
+       var replaced = this ;\r
+\r
+       for ( var i = 0 ; i < searchArray.length ; i++ )\r
+       {\r
+               replaced = replaced.replace( searchArray[i], replaceArray[i] ) ;\r
+       }\r
+\r
+       return replaced ;\r
+}\r
+\r
+function OpenFileBrowser( url, width, height )\r
+{\r
+       // oEditor must be defined.\r
+       \r
+       var iLeft = ( oEditor.FCKConfig.ScreenWidth  - width ) / 2 ;\r
+       var iTop  = ( oEditor.FCKConfig.ScreenHeight - height ) / 2 ;\r
+\r
+       var sOptions = "toolbar=no,status=no,resizable=yes,dependent=yes,scrollbars=yes" ;\r
+       sOptions += ",width=" + width ; \r
+       sOptions += ",height=" + height ; \r
+       sOptions += ",left=" + iLeft ; \r
+       sOptions += ",top=" + iTop ; \r
+\r
+       // The "PreserveSessionOnFileBrowser" because the above code could be \r
+       // blocked by popup blockers.\r
+       if ( oEditor.FCKConfig.PreserveSessionOnFileBrowser && oEditor.FCKBrowserInfo.IsIE )\r
+       {\r
+               // The following change has been made otherwise IE will open the file \r
+               // browser on a different server session (on some cases):\r
+               // http://support.microsoft.com/default.aspx?scid=kb;en-us;831678\r
+               // by Simone Chiaretta.\r
+               var oWindow = oEditor.window.open( url, 'FCKBrowseWindow', sOptions ) ;\r
+               if ( oWindow )\r
+               {\r
+                       // Detect Yahoo popup blocker.\r
+                       try\r
+                       {\r
+                               var sTest = oWindow.name ; // Yahoo returns "something", but we can't access it, so detect that and avoid strange errors for the user.\r
+                       oWindow.opener = window ;\r
+                       }\r
+                       catch(e)\r
+                       {\r
+                       alert( oEditor.FCKLang.BrowseServerBlocked ) ;\r
+       }\r
+               }\r
+               else\r
+                       alert( oEditor.FCKLang.BrowseServerBlocked ) ;\r
+       }\r
+    else { var oWindow =window.open( url, 'FCKBrowseWindow', sOptions ) ; }\r
+       if ( oWindow ) {\r
+               if (FCKConfig.NucleusUseImageManager) {// Image-Manager plugin\r
+                       SetImageManager_oWindow=oWindow;\r
+                       SetImageManager_timer=setInterval("SetImageManager()",1);// Check the window every 1 mili second.\r
+               } else {//media.php\r
+                       oWindow.window.opener.includeImage=function(collection,filename,type,width,height)\r
+                       {\r
+                               if (this.GetE('txtUrl')) this.GetE('txtUrl').value=FCKConfig.NucleusMediaDir+collection+'/'+filename;\r
+                               if (this.GetE('txtWidth')) this.GetE('txtWidth').value=width;\r
+                               if (this.GetE('txtHeight')) this.GetE('txtHeight').value=height;\r
+                               //if (this.GetE('txtAttTitle')) this.GetE('txtAttTitle').value=filename;\r
+                       };\r
+                       oWindow.window.opener.includeOtherMedia=function(collection, filename)\r
+                       {\r
+                               if (this.GetE('txtUrl')) this.GetE('txtUrl').value=FCKConfig.NucleusMediaDir+collection+'/'+filename;\r
+                       };\r
+               }\r
+       }\r
+}\r
+\r
+var SetImageManager_oWindow;\r
+var SetImageManager_timer;\r
+function SetImageManager(){\r
+       var oWindow=SetImageManager_oWindow;\r
+       if (!oWindow.window.onOK) return;\r
+       clearInterval(SetImageManager_timer);\r
+       oWindow.window.base_url=FCKConfig.NucleusMediaDir;\r
+       oWindow.window.__dlg_close=function(val)\r
+               {\r
+                       var sActualBrowser;\r
+                       try {\r
+                               sActualBrowser=oWindow.window.opener.sActualBrowser.toLowerCase();\r
+                       } catch(e) {\r
+                               sActualBrowser='';\r
+                       }\r
+                       if (val) switch (sActualBrowser){\r
+                       case "link":\r
+                               if (oWindow.window.opener.GetE('txtLnkUrl')) oWindow.window.opener.GetE('txtLnkUrl').value=val['f_url'];\r
+                               break;\r
+                       default:\r
+                               if (oWindow.window.opener.GetE('txtUrl')) oWindow.window.opener.GetE('txtUrl').value=val['f_url'];\r
+                               if (oWindow.window.opener.GetE('txtWidth')) oWindow.window.opener.GetE('txtWidth').value=val['f_width'];\r
+                               if (oWindow.window.opener.GetE('txtWidth')) oWindow.window.opener.GetE('txtHeight').value=val['f_height'];\r
+                               //if (oWindow.window.opener.GetE('txtAttTitle')) oWindow.window.opener.GetE('txtAttTitle').value=filename;\r
+                       }\r
+                       oWindow.close();\r
+               };\r
 }
\ No newline at end of file