source: branches/1.2/workflow/js/fckeditor/editor/dialog/common/fck_dialog_common.js @ 1349

Revision 1349, 3.9 KB checked in by niltonneto, 15 years ago (diff)

Ticket #561 - Inclusão do módulo Workflow faltante nessa versão.

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