--- /dev/null
+/*\r
+Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
+For licensing, see LICENSE.html or http://ckeditor.com/license\r
+*/\r
+\r
+CKEDITOR.plugins.add( 'popup' );\r
+\r
+CKEDITOR.tools.extend( CKEDITOR.editor.prototype,\r
+{\r
+ /**\r
+ * Opens Browser in a popup. The "width" and "height" parameters accept\r
+ * numbers (pixels) or percent (of screen size) values.\r
+ * @param {String} url The url of the external file browser.\r
+ * @param {String} width Popup window width.\r
+ * @param {String} height Popup window height.\r
+ * @param {String} options Popup window features.\r
+ */\r
+ popup : function( url, width, height, options )\r
+ {\r
+ width = width || '80%';\r
+ height = height || '70%';\r
+\r
+ if ( typeof width == 'string' && width.length > 1 && width.substr( width.length - 1, 1 ) == '%' )\r
+ width = parseInt( window.screen.width * parseInt( width, 10 ) / 100, 10 );\r
+\r
+ if ( typeof height == 'string' && height.length > 1 && height.substr( height.length - 1, 1 ) == '%' )\r
+ height = parseInt( window.screen.height * parseInt( height, 10 ) / 100, 10 );\r
+\r
+ if ( width < 640 )\r
+ width = 640;\r
+\r
+ if ( height < 420 )\r
+ height = 420;\r
+\r
+ var top = parseInt( ( window.screen.height - height ) / 2, 10 ),\r
+ left = parseInt( ( window.screen.width - width ) / 2, 10 );\r
+\r
+ options = ( options || 'location=no,menubar=no,toolbar=no,dependent=yes,minimizable=no,modal=yes,alwaysRaised=yes,resizable=yes,scrollbars=yes' ) +\r
+ ',width=' + width +\r
+ ',height=' + height +\r
+ ',top=' + top +\r
+ ',left=' + left;\r
+\r
+ var popupWindow = window.open( '', null, options, true );\r
+\r
+ // Blocked by a popup blocker.\r
+ if ( !popupWindow )\r
+ return false;\r
+\r
+ try\r
+ {\r
+ popupWindow.moveTo( left, top );\r
+ popupWindow.resizeTo( width, height );\r
+ popupWindow.focus();\r
+ popupWindow.location.href = url;\r
+ }\r
+ catch ( e )\r
+ {\r
+ popupWindow = window.open( url, null, options, true );\r
+ }\r
+\r
+ return true;\r
+ }\r
+});\r