source: sandbox/2.3-MailArchiver/filemanager/tp/ckeditor/_source/plugins/popup/plugin.js @ 6779

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

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

Line 
1/*
2Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
3For licensing, see LICENSE.html or http://ckeditor.com/license
4*/
5
6CKEDITOR.plugins.add( 'popup');
7
8CKEDITOR.tools.extend( CKEDITOR.editor.prototype,
9{
10        /**
11         * Opens Browser in a popup. The "width" and "height" parameters accept
12         * numbers (pixels) or percent (of screen size) values.
13         * @param {String} url The url of the external file browser.
14         * @param {String} width Popup window width.
15         * @param {String} height Popup window height.
16         */
17        popup : function( url, width, height )
18        {
19                width = width || '80%';
20                height = height || '70%';
21
22                if ( typeof width == 'string' && width.length > 1 && width.substr( width.length - 1, 1 ) == '%' )
23                        width = parseInt( window.screen.width * parseInt( width, 10 ) / 100, 10 );
24
25                if ( typeof height == 'string' && height.length > 1 && height.substr( height.length - 1, 1 ) == '%' )
26                        height = parseInt( window.screen.height * parseInt( height, 10 ) / 100, 10 );
27
28                if ( width < 640 )
29                        width = 640;
30
31                if ( height < 420 )
32                        height = 420;
33
34                var top = parseInt( ( window.screen.height - height ) / 2, 10 ),
35                        left = parseInt( ( window.screen.width  - width ) / 2, 10 ),
36                        options = 'location=no,menubar=no,toolbar=no,dependent=yes,minimizable=no,modal=yes,alwaysRaised=yes,resizable=yes' +
37                        ',width='  + width +
38                        ',height=' + height +
39                        ',top='  + top +
40                        ',left=' + left;
41
42                var popupWindow = window.open( '', null, options, true );
43
44                // Blocked by a popup blocker.
45                if ( !popupWindow )
46                        return false;
47
48                try
49                {
50                        popupWindow.moveTo( left, top );
51                        popupWindow.resizeTo( width, height );
52                        popupWindow.focus();
53                        popupWindow.location.href = url;
54                }
55                catch (e)
56                {
57                        popupWindow = window.open( url, null, options, true );
58                }
59
60                return true ;
61        }
62});
Note: See TracBrowser for help on using the repository browser.