source: sandbox/2.3-MailArchiver/expressoMail1_2/js/fckeditor/editor/dialog/common/fck_dialog_common.js @ 6779

Revision 6779, 3.7 KB checked in by rafaelraymundo, 12 years ago (diff)

Ticket #2946 - Liberado Expresso(branch 2.3) integrado ao MailArchiver?.

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