X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Ffilebrowser%2Fplugin.js;h=665a5ac6e0a579cd23cb292a3bec078aa4541b17;hb=039a051ccf3901311661022a30afd60fc38130c9;hp=458f29614ad96a0db0b3828b8d74bedb0b267ab6;hpb=ea7e3453c7b0f023b050aca6d9f83ab372860d91;p=ckeditor.git diff --git a/_source/plugins/filebrowser/plugin.js b/_source/plugins/filebrowser/plugin.js index 458f296..665a5ac 100644 --- a/_source/plugins/filebrowser/plugin.js +++ b/_source/plugins/filebrowser/plugin.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -174,7 +174,7 @@ 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 ); } /** @@ -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,12 +278,28 @@ 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; + var url = element.filebrowser.url; + if ( url === undefined ) + { + url = editor.config[ 'filebrowser' + ucFirst( dialogName ) + 'UploadUrl' ]; + if ( url === undefined ) + url = editor.config.filebrowserUploadUrl; + } if ( url ) { - element.onClick = uploadFile; + var onClick = element.onClick; + element.onClick = function( evt ) + { + // "element" here means the definition object, so we need to find the correct + // button to scope the event call + var sender = evt.sender; + if ( onClick && onClick.call( sender, evt ) === false ) + return false; + + return uploadFile.call( sender, evt ); + }; + element.filebrowser.url = url; element.hidden = false; setupFileElement( editor, definition.getContents( element[ 'for' ][ 0 ] ).get( element[ 'for' ][ 1 ] ), element.filebrowser ); @@ -329,13 +350,14 @@ 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; } - return ( definition.getContents( tabId ).get( elementId ).filebrowser && definition.getContents( tabId ).get( elementId ).filebrowser.url ); + var elementFileBrowser = definition.getContents( tabId ).get( elementId ).filebrowser; + return ( elementFileBrowser && elementFileBrowser.url ); } function setUrl( fileUrl, data ) @@ -347,6 +369,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license if ( targetInput ) dialog.getContentElement( targetInput[ 0 ], targetInput[ 1 ] ).reset(); + if ( typeof data == 'function' && data.call( this._.filebrowserSe ) === false ) + return; + if ( onSelect && onSelect.call( this._.filebrowserSe, fileUrl, data ) === false ) return; @@ -363,21 +388,114 @@ For licensing, see LICENSE.html or http://ckeditor.com/license init : function( editor, pluginPath ) { editor._.filebrowserFn = CKEDITOR.tools.addFunction( setUrl, editor ); + } + } ); - 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 ] ) ) { - // Associate filebrowser to elements with 'filebrowser' attribute. - for ( var i in evt.data.definition.contents ) + attachFileBrowser( evt.editor, evt.data.name, definition, element.elements ); + if ( element.hidden && element.filebrowser ) { - attachFileBrowser( evt.editor, evt.data.name, evt.data.definition, evt.data.definition.contents[ i ].elements ); - if ( evt.data.definition.contents[ i ].hidden && evt.data.definition.contents[ i ].filebrowser ) - { - evt.data.definition.contents[ i ].hidden = - !isConfigured( evt.data.definition, evt.data.definition.contents[ i ][ 'id' ], evt.data.definition.contents[ i ].filebrowser ); - } + element.hidden = !isConfigured( definition, element[ 'id' ], element.filebrowser ); } - } ); + } } } ); } )(); + +/** + * The location of an external file browser, that should be launched when "Browse Server" button is pressed. + * If configured, the "Browse Server" button will appear in Link, Image and Flash dialogs. + * @see The File Browser/Uploader documentation. + * @name CKEDITOR.config.filebrowserBrowseUrl + * @since 3.0 + * @type String + * @default '' (empty string = disabled) + * @example + * config.filebrowserBrowseUrl = '/browser/browse.php'; + */ + +/** + * The location of a script that handles file uploads. + * If set, the "Upload" tab will appear in "Link", "Image" and "Flash" dialogs. + * @name CKEDITOR.config.filebrowserUploadUrl + * @see The File Browser/Uploader documentation. + * @since 3.0 + * @type String + * @default '' (empty string = disabled) + * @example + * config.filebrowserUploadUrl = '/uploader/upload.php'; + */ + +/** + * The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Image dialog. + * If not set, CKEditor will use {@link CKEDITOR.config.filebrowserBrowseUrl}. + * @name CKEDITOR.config.filebrowserImageBrowseUrl + * @since 3.0 + * @type String + * @default '' (empty string = disabled) + * @example + * config.filebrowserImageBrowseUrl = '/browser/browse.php?type=Images'; + */ + +/** + * The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Flash dialog. + * If not set, CKEditor will use {@link CKEDITOR.config.filebrowserBrowseUrl}. + * @name CKEDITOR.config.filebrowserFlashBrowseUrl + * @since 3.0 + * @type String + * @default '' (empty string = disabled) + * @example + * config.filebrowserFlashBrowseUrl = '/browser/browse.php?type=Flash'; + */ + +/** + * The location of a script that handles file uploads in the Image dialog. + * If not set, CKEditor will use {@link CKEDITOR.config.filebrowserUploadUrl}. + * @name CKEDITOR.config.filebrowserImageUploadUrl + * @since 3.0 + * @type String + * @default '' (empty string = disabled) + * @example + * config.filebrowserImageUploadUrl = '/uploader/upload.php?type=Images'; + */ + +/** + * The location of a script that handles file uploads in the Flash dialog. + * If not set, CKEditor will use {@link CKEDITOR.config.filebrowserUploadUrl}. + * @name CKEDITOR.config.filebrowserFlashUploadUrl + * @since 3.0 + * @type String + * @default '' (empty string = disabled) + * @example + * config.filebrowserFlashUploadUrl = '/uploader/upload.php?type=Flash'; + */ + +/** + * The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Link tab of Image dialog. + * If not set, CKEditor will use {@link CKEDITOR.config.filebrowserBrowseUrl}. + * @name CKEDITOR.config.filebrowserImageBrowseLinkUrl + * @since 3.2 + * @type String + * @default '' (empty string = disabled) + * @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'; + */