diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2017-01-20 00:55:51 +0100 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2017-01-20 00:55:51 +0100 |
commit | c63493c899de714b05b0521bb38aab60d19030ef (patch) | |
tree | fcb2b261afa0f3c2bd6b48929b64724c71192bae /sources/plugins/popup | |
download | ludivine-ckeditor-component-c63493c899de714b05b0521bb38aab60d19030ef.tar.gz ludivine-ckeditor-component-c63493c899de714b05b0521bb38aab60d19030ef.tar.zst ludivine-ckeditor-component-c63493c899de714b05b0521bb38aab60d19030ef.zip |
Validation initiale4.6.2.1
Diffstat (limited to 'sources/plugins/popup')
-rw-r--r-- | sources/plugins/popup/plugin.js | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/sources/plugins/popup/plugin.js b/sources/plugins/popup/plugin.js new file mode 100644 index 0000000..352d239 --- /dev/null +++ b/sources/plugins/popup/plugin.js | |||
@@ -0,0 +1,65 @@ | |||
1 | /** | ||
2 | * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved. | ||
3 | * For licensing, see LICENSE.md or http://ckeditor.com/license | ||
4 | */ | ||
5 | |||
6 | CKEDITOR.plugins.add( 'popup' ); | ||
7 | |||
8 | CKEDITOR.tools.extend( CKEDITOR.editor.prototype, { | ||
9 | /** | ||
10 | * Opens Browser in a popup. The `width` and `height` parameters accept | ||
11 | * numbers (pixels) or percent (of screen size) values. | ||
12 | * | ||
13 | * @member CKEDITOR.editor | ||
14 | * @param {String} url The url of the external file browser. | ||
15 | * @param {Number/String} [width='80%'] Popup window width. | ||
16 | * @param {Number/String} [height='70%'] Popup window height. | ||
17 | * @param {String} [options='location=no,menubar=no,toolbar=no,dependent=yes,minimizable=no,modal=yes,alwaysRaised=yes,resizable=yes,scrollbars=yes'] | ||
18 | * Popup window features. | ||
19 | */ | ||
20 | popup: function( url, width, height, options ) { | ||
21 | width = width || '80%'; | ||
22 | height = height || '70%'; | ||
23 | |||
24 | if ( typeof width == 'string' && width.length > 1 && width.substr( width.length - 1, 1 ) == '%' ) | ||
25 | width = parseInt( window.screen.width * parseInt( width, 10 ) / 100, 10 ); | ||
26 | |||
27 | if ( typeof height == 'string' && height.length > 1 && height.substr( height.length - 1, 1 ) == '%' ) | ||
28 | height = parseInt( window.screen.height * parseInt( height, 10 ) / 100, 10 ); | ||
29 | |||
30 | if ( width < 640 ) | ||
31 | width = 640; | ||
32 | |||
33 | if ( height < 420 ) | ||
34 | height = 420; | ||
35 | |||
36 | var top = parseInt( ( window.screen.height - height ) / 2, 10 ), | ||
37 | left = parseInt( ( window.screen.width - width ) / 2, 10 ); | ||
38 | |||
39 | options = ( options || 'location=no,menubar=no,toolbar=no,dependent=yes,minimizable=no,modal=yes,alwaysRaised=yes,resizable=yes,scrollbars=yes' ) + ',width=' + width + | ||
40 | ',height=' + height + | ||
41 | ',top=' + top + | ||
42 | ',left=' + left; | ||
43 | |||
44 | var popupWindow = window.open( '', null, options, true ); | ||
45 | |||
46 | // Blocked by a popup blocker. | ||
47 | if ( !popupWindow ) | ||
48 | return false; | ||
49 | |||
50 | try { | ||
51 | // Chrome is problematic with moveTo/resizeTo, but it's not really needed here (#8855). | ||
52 | var ua = navigator.userAgent.toLowerCase(); | ||
53 | if ( ua.indexOf( ' chrome/' ) == -1 ) { | ||
54 | popupWindow.moveTo( left, top ); | ||
55 | popupWindow.resizeTo( width, height ); | ||
56 | } | ||
57 | popupWindow.focus(); | ||
58 | popupWindow.location.href = url; | ||
59 | } catch ( e ) { | ||
60 | popupWindow = window.open( url, null, options, true ); | ||
61 | } | ||
62 | |||
63 | return true; | ||
64 | } | ||
65 | } ); | ||