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