JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.5.3
[ckeditor.git] / _source / plugins / filebrowser / plugin.js
index ae628cf..799d68f 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\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
@@ -112,7 +112,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
  */\r
 ( function()\r
 {\r
-       /**\r
+       /*\r
         * Adds (additional) arguments to given url.\r
         *\r
         * @param {String}\r
@@ -135,7 +135,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                return url + ( ( url.indexOf( "?" ) != -1 ) ? "&" : "?" ) + queryString.join( "&" );\r
        }\r
 \r
-       /**\r
+       /*\r
         * Make a string's first character uppercase.\r
         *\r
         * @param {String}\r
@@ -148,7 +148,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                return f + str.substr( 1 );\r
        }\r
 \r
-       /**\r
+       /*\r
         * The onlick function assigned to the 'Browse Server' button. Opens the\r
         * file browser and updates target field when file is selected.\r
         *\r
@@ -174,10 +174,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                        params.langCode = editor.langCode;\r
 \r
                var url = addQueryString( this.filebrowser.url, params );\r
-               editor.popup( url, width, height );\r
+               editor.popup( url, width, height, editor.config.fileBrowserWindowFeatures );\r
        }\r
 \r
-       /**\r
+       /*\r
         * The onlick function assigned to the 'Upload' button. Makes the final\r
         * decision whether form is really submitted and updates target field when\r
         * file is uploaded.\r
@@ -202,7 +202,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                return true;\r
        }\r
 \r
-       /**\r
+       /*\r
         * Setups the file element.\r
         *\r
         * @param {CKEDITOR.ui.dialog.file}\r
@@ -223,16 +223,16 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                fileInput.filebrowser = filebrowser;\r
        }\r
 \r
-       /**\r
+       /*\r
         * Traverse through the content definition and attach filebrowser to\r
         * elements with 'filebrowser' attribute.\r
         *\r
         * @param String\r
         *            dialogName Dialog name.\r
-        * @param {CKEDITOR.dialog.dialogDefinitionObject}\r
+        * @param {CKEDITOR.dialog.definitionObject}\r
         *            definition Dialog definition.\r
         * @param {Array}\r
-        *            elements Array of {@link CKEDITOR.dialog.contentDefinition}\r
+        *            elements Array of {@link CKEDITOR.dialog.definition.content}\r
         *            objects.\r
         */\r
        function attachFileBrowser( editor, dialogName, definition, elements )\r
@@ -261,8 +261,13 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \r
                        if ( element.filebrowser.action == 'Browse' )\r
                        {\r
-                               var url = element.filebrowser.url || editor.config[ 'filebrowser' + ucFirst( dialogName ) + 'BrowseUrl' ]\r
-                                                       || editor.config.filebrowserBrowseUrl;\r
+                               var url = element.filebrowser.url;\r
+                               if ( url === undefined )\r
+                               {\r
+                                       url = editor.config[ 'filebrowser' + ucFirst( dialogName ) + 'BrowseUrl' ];\r
+                                       if ( url === undefined )\r
+                                               url = editor.config.filebrowserBrowseUrl;\r
+                               }\r
 \r
                                if ( url )\r
                                {\r
@@ -273,8 +278,13 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                        }\r
                        else if ( element.filebrowser.action == 'QuickUpload' && element[ 'for' ] )\r
                        {\r
-                               url =  element.filebrowser.url || editor.config[ 'filebrowser' + ucFirst( dialogName ) + 'UploadUrl' ]\r
-                                                       || editor.config.filebrowserUploadUrl;\r
+                               url = element.filebrowser.url;\r
+                               if ( url === undefined )\r
+                               {\r
+                                       url = editor.config[ 'filebrowser' + ucFirst( dialogName ) + 'UploadUrl' ];\r
+                                       if ( url === undefined )\r
+                                               url = editor.config.filebrowserUploadUrl;\r
+                               }\r
 \r
                                if ( url )\r
                                {\r
@@ -298,7 +308,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                }\r
        }\r
 \r
-       /**\r
+       /*\r
         * Updates the target element with the url of uploaded/selected file.\r
         *\r
         * @param {String}\r
@@ -323,10 +333,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                }\r
        }\r
 \r
-       /**\r
+       /*\r
         * Returns true if filebrowser is configured in one of the elements.\r
         *\r
-        * @param {CKEDITOR.dialog.dialogDefinitionObject}\r
+        * @param {CKEDITOR.dialog.definitionObject}\r
         *            definition Dialog definition.\r
         * @param String\r
         *            tabId The tab id where element(s) can be found.\r
@@ -340,7 +350,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                        var ids = elementId.split( ";" );\r
                        for ( var i = 0 ; i < ids.length ; i++ )\r
                        {\r
-                               if ( isConfigured( definition, tabId, ids[i]) )\r
+                               if ( isConfigured( definition, tabId, ids[i] ) )\r
                                        return true;\r
                        }\r
                        return false;\r
@@ -378,22 +388,25 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                init : function( editor, pluginPath )\r
                {\r
                        editor._.filebrowserFn = CKEDITOR.tools.addFunction( setUrl, editor );\r
+                       editor.on( 'destroy', function () { CKEDITOR.tools.removeFunction( this._.filebrowserFn ); } );\r
+               }\r
+       } );\r
 \r
-                       CKEDITOR.on( 'dialogDefinition', function( evt )\r
+       CKEDITOR.on( 'dialogDefinition', function( evt )\r
+       {\r
+               var definition = evt.data.definition,\r
+                       element;\r
+               // Associate filebrowser to elements with 'filebrowser' attribute.\r
+               for ( var i in definition.contents )\r
+               {\r
+                       if ( ( element = definition.contents[ i ] ) )\r
                        {\r
-                               var definition = evt.data.definition,\r
-                                       element;\r
-                               // Associate filebrowser to elements with 'filebrowser' attribute.\r
-                               for ( var i in definition.contents )\r
+                               attachFileBrowser( evt.editor, evt.data.name, definition, element.elements );\r
+                               if ( element.hidden && element.filebrowser )\r
                                {\r
-                                       element = definition.contents[ i ] ;\r
-                                       attachFileBrowser( evt.editor, evt.data.name, definition, element.elements );\r
-                                       if ( element.hidden && element.filebrowser )\r
-                                       {\r
-                                               element.hidden = !isConfigured( definition, element[ 'id' ], element.filebrowser );\r
-                                       }\r
+                                       element.hidden = !isConfigured( definition, element[ 'id' ], element.filebrowser );\r
                                }\r
-                       } );\r
+                       }\r
                }\r
        } );\r
 \r
@@ -477,3 +490,35 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
  * @example\r
  * config.filebrowserImageBrowseLinkUrl = '/browser/browse.php';\r
  */\r
+\r
+/**\r
+ * The "features" to use in the file browser popup window.\r
+ * @name CKEDITOR.config.filebrowserWindowFeatures\r
+ * @since 3.4.1\r
+ * @type String\r
+ * @default 'location=no,menubar=no,toolbar=no,dependent=yes,minimizable=no,modal=yes,alwaysRaised=yes,resizable=yes,scrollbars=yes'\r
+ * @example\r
+ * config.filebrowserWindowFeatures = 'resizable=yes,scrollbars=no';\r
+ */\r
+\r
+/**\r
+ * The width of the file browser popup window. It can be a number or a percent string.\r
+ * @name CKEDITOR.config.filebrowserWindowWidth\r
+ * @type Number|String\r
+ * @default '80%'\r
+ * @example\r
+ * config.filebrowserWindowWidth = 750;\r
+ * @example\r
+ * config.filebrowserWindowWidth = '50%';\r
+ */\r
+\r
+/**\r
+ * The height of the file browser popup window. It can be a number or a percent string.\r
+ * @name CKEDITOR.config.filebrowserWindowHeight\r
+ * @type Number|String\r
+ * @default '70%'\r
+ * @example\r
+ * config.filebrowserWindowHeight = 580;\r
+ * @example\r
+ * config.filebrowserWindowHeight = '50%';\r
+ */\r