Proper plugins/filebrowser/plugin.js
File had been badly copy/pasted resulting in bad javascript... Following shows a bit of the problem... <a href="http://i.imgur.com/ZQGTSE8.png"><img src="http://imgur.com/ZQGTSE8l.png" /></a> Also updated source to 2016 as per -- https://github.com/ckeditor/ckeditor-dev/blob/master/plugins/filebrowser/plugin.js
This commit is contained in:
636
public/lb-faveo/plugins/filebrowser/plugin.js
vendored
636
public/lb-faveo/plugins/filebrowser/plugin.js
vendored
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/**
|
||||||
Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
|
* @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
|
||||||
For licensing, see LICENSE.html or http://ckeditor.com/license
|
* For licensing, see LICENSE.md or http://ckeditor.com/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -47,11 +47,11 @@
|
|||||||
* The following settings are supported:
|
* The following settings are supported:
|
||||||
*
|
*
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li><code>action</code> – <code>Browse</code> or <code>QuickUpload</code>.</li>
|
* <li><code>action</code> – <code>Browse</code> or <code>QuickUpload</code>.</li>
|
||||||
* <li><code>target</code> – the field to update in the <code><em>tabId:elementId</em></code> format.</li>
|
* <li><code>target</code> – the field to update in the <code><em>tabId:elementId</em></code> format.</li>
|
||||||
* <li><code>params</code> – additional arguments to be passed to the server connector (optional).</li>
|
* <li><code>params</code> – additional arguments to be passed to the server connector (optional).</li>
|
||||||
* <li><code>onSelect</code> – a function to execute when the file is selected/uploaded (optional).</li>
|
* <li><code>onSelect</code> – a function to execute when the file is selected/uploaded (optional).</li>
|
||||||
* <li><code>url</code> – the URL to be called (optional).</li>
|
* <li><code>url</code> – the URL to be called (optional).</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* <strong>Example 3: (Quick Upload)</strong>
|
* <strong>Example 3: (Quick Upload)</strong>
|
||||||
@@ -61,113 +61,104 @@
|
|||||||
* type : 'fileButton',
|
* type : 'fileButton',
|
||||||
* label : editor.lang.common.uploadSubmit,
|
* label : editor.lang.common.uploadSubmit,
|
||||||
* id : 'buttonId',
|
* id : 'buttonId',
|
||||||
64 * filebrowser :
|
* filebrowser :
|
||||||
65 * {
|
* {
|
||||||
66 * action : 'QuickUpload', // required
|
* action : 'QuickUpload', // required
|
||||||
67 * target : 'tab1:elementId', // required
|
* target : 'tab1:elementId', // required
|
||||||
68 * params : // optional
|
* params : // optional
|
||||||
69 * {
|
* {
|
||||||
70 * type : 'Files',
|
* type : 'Files',
|
||||||
71 * currentFolder : '/folder/'
|
* currentFolder : '/folder/'
|
||||||
72 * },
|
* },
|
||||||
73 * onSelect : function( fileUrl, errorMessage ) // optional
|
* onSelect : function( fileUrl, errorMessage ) // optional
|
||||||
74 * {
|
* {
|
||||||
75 * // Do not call the built-in selectFuntion.
|
* // Do not call the built-in selectFuntion.
|
||||||
76 * // return false;
|
* // return false;
|
||||||
77 * }
|
* }
|
||||||
78 * },
|
* },
|
||||||
79 * 'for' : [ 'tab1', 'myFile' ]
|
* 'for' : [ 'tab1', 'myFile' ]
|
||||||
80 * }
|
* }
|
||||||
81 * </pre>
|
* </pre>
|
||||||
82 *
|
*
|
||||||
83 * Suppose you have a file element with an ID of <code>myFile</code>, a text
|
* Suppose you have a file element with an ID of <code>myFile</code>, a text
|
||||||
84 * field with an ID of <code>elementId</code> and a <code>fileButton</code>.
|
* field with an ID of <code>elementId</code> and a <code>fileButton</code>.
|
||||||
85 * If the <code>filebowser.url</code> attribute is not specified explicitly,
|
* If the <code>filebowser.url</code> attribute is not specified explicitly,
|
||||||
86 * the form action will be set to <code>filebrowser[<em>DialogWindowName</em>]UploadUrl</code>
|
* the form action will be set to <code>filebrowser[<em>DialogWindowName</em>]UploadUrl</code>
|
||||||
87 * or, if not specified, to <code>filebrowserUploadUrl</code>. Additional parameters
|
* or, if not specified, to <code>filebrowserUploadUrl</code>. Additional parameters
|
||||||
88 * from the <code>params</code> object will be added to the query string. It is
|
* from the <code>params</code> object will be added to the query string. It is
|
||||||
89 * possible to create your own <code>uploadHandler</code> and cancel the built-in
|
* possible to create your own <code>uploadHandler</code> and cancel the built-in
|
||||||
90 * <code>updateTargetElement</code> command.<br /><br />
|
* <code>updateTargetElement</code> command.<br /><br />
|
||||||
91 *
|
*
|
||||||
92 * <strong>Example 4: (Browse)</strong>
|
* <strong>Example 4: (Browse)</strong>
|
||||||
93 *
|
*
|
||||||
94 * <pre>
|
* <pre>
|
||||||
95 * {
|
* {
|
||||||
96 * type : 'button',
|
* type : 'button',
|
||||||
97 * id : 'buttonId',
|
* id : 'buttonId',
|
||||||
98 * label : editor.lang.common.browseServer,
|
* label : editor.lang.common.browseServer,
|
||||||
99 * filebrowser :
|
* filebrowser :
|
||||||
100 * {
|
* {
|
||||||
101 * action : 'Browse',
|
* action : 'Browse',
|
||||||
102 * url : '/ckfinder/ckfinder.html&type=Images',
|
* url : '/ckfinder/ckfinder.html&type=Images',
|
||||||
103 * target : 'tab1:elementId'
|
* target : 'tab1:elementId'
|
||||||
104 * }
|
* }
|
||||||
105 * }
|
* }
|
||||||
106 * </pre>
|
* </pre>
|
||||||
107 *
|
*
|
||||||
108 * In this example, when the button is pressed, the file browser will be opened in a
|
* In this example, when the button is pressed, the file browser will be opened in a
|
||||||
109 * popup window. If you do not specify the <code>filebrowser.url</code> attribute,
|
* popup window. If you do not specify the <code>filebrowser.url</code> attribute,
|
||||||
110 * <code>filebrowser[<em>DialogName</em>]BrowseUrl</code> or
|
* <code>filebrowser[<em>DialogName</em>]BrowseUrl</code> or
|
||||||
111 * <code>filebrowserBrowseUrl</code> will be used. After selecting a file in the file
|
* <code>filebrowserBrowseUrl</code> will be used. After selecting a file in the file
|
||||||
112 * browser, an element with an ID of <code>elementId</code> will be updated. Just
|
* browser, an element with an ID of <code>elementId</code> will be updated. Just
|
||||||
113 * like in the third example, a custom <code>onSelect</code> function may be defined.
|
* like in the third example, a custom <code>onSelect</code> function may be defined.
|
||||||
114 */
|
*/
|
||||||
( function()
|
|
||||||
{
|
( function() {
|
||||||
/*
|
// Default input element name for CSRF protection token.
|
||||||
118 * Adds (additional) arguments to given url.
|
var TOKEN_INPUT_NAME = 'ckCsrfToken';
|
||||||
119 *
|
|
||||||
120 * @param {String}
|
// Adds (additional) arguments to given url.
|
||||||
121 * url The url.
|
//
|
||||||
122 * @param {Object}
|
// @param {String}
|
||||||
123 * params Additional parameters.
|
// url The url.
|
||||||
124 */
|
// @param {Object}
|
||||||
function addQueryString( url, params )
|
// params Additional parameters.
|
||||||
{
|
function addQueryString( url, params ) {
|
||||||
var queryString = [];
|
var queryString = [];
|
||||||
|
|
||||||
if ( !params )
|
if ( !params )
|
||||||
return url;
|
return url;
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
for ( var i in params )
|
for ( var i in params )
|
||||||
queryString.push( i + "=" + encodeURIComponent( params[ i ] ) );
|
queryString.push( i + '=' + encodeURIComponent( params[ i ] ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return url + ( ( url.indexOf( "?" ) != -1 ) ? "&" : "?" ) + queryString.join( "&" );
|
return url + ( ( url.indexOf( '?' ) != -1 ) ? '&' : '?' ) + queryString.join( '&' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Make a string's first character uppercase.
|
||||||
141 * Make a string's first character uppercase.
|
//
|
||||||
142 *
|
// @param {String}
|
||||||
143 * @param {String}
|
// str String.
|
||||||
144 * str String.
|
function ucFirst( str ) {
|
||||||
145 */
|
|
||||||
function ucFirst( str )
|
|
||||||
{
|
|
||||||
str += '';
|
str += '';
|
||||||
var f = str.charAt( 0 ).toUpperCase();
|
var f = str.charAt( 0 ).toUpperCase();
|
||||||
return f + str.substr( 1 );
|
return f + str.substr( 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// The onlick function assigned to the 'Browse Server' button. Opens the
|
||||||
154 * The onlick function assigned to the 'Browse Server' button. Opens the
|
// file browser and updates target field when file is selected.
|
||||||
155 * file browser and updates target field when file is selected.
|
//
|
||||||
156 *
|
// @param {CKEDITOR.event}
|
||||||
157 * @param {CKEDITOR.event}
|
// evt The event object.
|
||||||
158 * evt The event object.
|
function browseServer() {
|
||||||
159 */
|
|
||||||
function browseServer( evt )
|
|
||||||
{
|
|
||||||
var dialog = this.getDialog();
|
var dialog = this.getDialog();
|
||||||
var editor = dialog.getParentEditor();
|
var editor = dialog.getParentEditor();
|
||||||
|
|
||||||
editor._.filebrowserSe = this;
|
editor._.filebrowserSe = this;
|
||||||
|
|
||||||
var width = editor.config[ 'filebrowser' + ucFirst( dialog.getName() ) + 'WindowWidth' ]
|
var width = editor.config[ 'filebrowser' + ucFirst( dialog.getName() ) + 'WindowWidth' ] || editor.config.filebrowserWindowWidth || '80%';
|
||||||
|| editor.config.filebrowserWindowWidth || '80%';
|
var height = editor.config[ 'filebrowser' + ucFirst( dialog.getName() ) + 'WindowHeight' ] || editor.config.filebrowserWindowHeight || '70%';
|
||||||
var height = editor.config[ 'filebrowser' + ucFirst( dialog.getName() ) + 'WindowHeight' ]
|
|
||||||
|| editor.config.filebrowserWindowHeight || '70%';
|
|
||||||
|
|
||||||
var params = this.filebrowser.params || {};
|
var params = this.filebrowser.params || {};
|
||||||
params.CKEditor = editor.name;
|
params.CKEditor = editor.name;
|
||||||
@@ -180,16 +171,42 @@
|
|||||||
editor.popup( url, width, height, editor.config.filebrowserWindowFeatures || editor.config.fileBrowserWindowFeatures );
|
editor.popup( url, width, height, editor.config.filebrowserWindowFeatures || editor.config.fileBrowserWindowFeatures );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Appends token preventing CSRF attacks to the form of provided file input.
|
||||||
184 * The onlick function assigned to the 'Upload' button. Makes the final
|
//
|
||||||
185 * decision whether form is really submitted and updates target field when
|
// @since 4.5.6
|
||||||
186 * file is uploaded.
|
// @param {CKEDITOR.dom.element} fileInput
|
||||||
187 *
|
function appendToken( fileInput ) {
|
||||||
188 * @param {CKEDITOR.event}
|
var tokenElement;
|
||||||
189 * evt The event object.
|
var form = new CKEDITOR.dom.element( fileInput.$.form );
|
||||||
190 */
|
|
||||||
function uploadFile( evt )
|
if ( form ) {
|
||||||
{
|
// Check if token input element already exists.
|
||||||
|
tokenElement = form.$.elements[ TOKEN_INPUT_NAME ];
|
||||||
|
|
||||||
|
// Create new if needed.
|
||||||
|
if ( !tokenElement ) {
|
||||||
|
tokenElement = new CKEDITOR.dom.element( 'input' );
|
||||||
|
tokenElement.setAttributes( {
|
||||||
|
name: TOKEN_INPUT_NAME,
|
||||||
|
type: 'hidden'
|
||||||
|
} );
|
||||||
|
|
||||||
|
form.append( tokenElement );
|
||||||
|
} else {
|
||||||
|
tokenElement = new CKEDITOR.dom.element( tokenElement );
|
||||||
|
}
|
||||||
|
|
||||||
|
tokenElement.setAttribute( 'value', CKEDITOR.tools.getCsrfToken() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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.
|
||||||
|
//
|
||||||
|
// @param {CKEDITOR.event}
|
||||||
|
// evt The event object.
|
||||||
|
function uploadFile() {
|
||||||
var dialog = this.getDialog();
|
var dialog = this.getDialog();
|
||||||
var editor = dialog.getParentEditor();
|
var editor = dialog.getParentEditor();
|
||||||
|
|
||||||
@@ -205,17 +222,14 @@
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Setups the file element.
|
||||||
209 * Setups the file element.
|
//
|
||||||
210 *
|
// @param {CKEDITOR.ui.dialog.file}
|
||||||
211 * @param {CKEDITOR.ui.dialog.file}
|
// fileInput The file element used during file upload.
|
||||||
212 * fileInput The file element used during file upload.
|
// @param {Object}
|
||||||
213 * @param {Object}
|
// filebrowser Object containing filebrowser settings assigned to
|
||||||
214 * filebrowser Object containing filebrowser settings assigned to
|
// the fileButton associated with this file element.
|
||||||
215 * the fileButton associated with this file element.
|
function setupFileElement( editor, fileInput, filebrowser ) {
|
||||||
216 */
|
|
||||||
function setupFileElement( editor, fileInput, filebrowser )
|
|
||||||
{
|
|
||||||
var params = filebrowser.params || {};
|
var params = filebrowser.params || {};
|
||||||
params.CKEditor = editor.name;
|
params.CKEditor = editor.name;
|
||||||
params.CKEditorFuncNum = editor._.filebrowserFn;
|
params.CKEditorFuncNum = editor._.filebrowserFn;
|
||||||
@@ -226,24 +240,23 @@
|
|||||||
fileInput.filebrowser = filebrowser;
|
fileInput.filebrowser = filebrowser;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Traverse through the content definition and attach filebrowser to
|
||||||
230 * Traverse through the content definition and attach filebrowser to
|
// elements with 'filebrowser' attribute.
|
||||||
231 * elements with 'filebrowser' attribute.
|
//
|
||||||
232 *
|
// @param String
|
||||||
233 * @param String
|
// dialogName Dialog name.
|
||||||
234 * dialogName Dialog name.
|
// @param {CKEDITOR.dialog.definitionObject}
|
||||||
235 * @param {CKEDITOR.dialog.definitionObject}
|
// definition Dialog definition.
|
||||||
236 * definition Dialog definition.
|
// @param {Array}
|
||||||
237 * @param {Array}
|
// elements Array of {@link CKEDITOR.dialog.definition.content}
|
||||||
238 * elements Array of {@link CKEDITOR.dialog.definition.content}
|
// objects.
|
||||||
239 * objects.
|
function attachFileBrowser( editor, dialogName, definition, elements ) {
|
||||||
240 */
|
if ( !elements || !elements.length )
|
||||||
function attachFileBrowser( editor, dialogName, definition, elements )
|
return;
|
||||||
{
|
|
||||||
var element, fileInput;
|
|
||||||
|
|
||||||
for ( var i in elements )
|
var element;
|
||||||
{
|
|
||||||
|
for ( var i = elements.length; i--; ) {
|
||||||
element = elements[ i ];
|
element = elements[ i ];
|
||||||
|
|
||||||
if ( element.type == 'hbox' || element.type == 'vbox' || element.type == 'fieldset' )
|
if ( element.type == 'hbox' || element.type == 'vbox' || element.type == 'fieldset' )
|
||||||
@@ -252,55 +265,54 @@
|
|||||||
if ( !element.filebrowser )
|
if ( !element.filebrowser )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ( typeof element.filebrowser == 'string' )
|
if ( typeof element.filebrowser == 'string' ) {
|
||||||
{
|
var fb = {
|
||||||
var fb =
|
|
||||||
{
|
|
||||||
action: ( element.type == 'fileButton' ) ? 'QuickUpload' : 'Browse',
|
action: ( element.type == 'fileButton' ) ? 'QuickUpload' : 'Browse',
|
||||||
target: element.filebrowser
|
target: element.filebrowser
|
||||||
};
|
};
|
||||||
element.filebrowser = fb;
|
element.filebrowser = fb;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( element.filebrowser.action == 'Browse' )
|
if ( element.filebrowser.action == 'Browse' ) {
|
||||||
{
|
|
||||||
var url = element.filebrowser.url;
|
var url = element.filebrowser.url;
|
||||||
if ( url === undefined )
|
if ( url === undefined ) {
|
||||||
{
|
|
||||||
url = editor.config[ 'filebrowser' + ucFirst( dialogName ) + 'BrowseUrl' ];
|
url = editor.config[ 'filebrowser' + ucFirst( dialogName ) + 'BrowseUrl' ];
|
||||||
if ( url === undefined )
|
if ( url === undefined )
|
||||||
url = editor.config.filebrowserBrowseUrl;
|
url = editor.config.filebrowserBrowseUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( url )
|
if ( url ) {
|
||||||
{
|
|
||||||
element.onClick = browseServer;
|
element.onClick = browseServer;
|
||||||
element.filebrowser.url = url;
|
element.filebrowser.url = url;
|
||||||
element.hidden = false;
|
element.hidden = false;
|
||||||
}
|
}
|
||||||
}
|
} else if ( element.filebrowser.action == 'QuickUpload' && element[ 'for' ] ) {
|
||||||
else if ( element.filebrowser.action == 'QuickUpload' && element[ 'for' ] )
|
|
||||||
{
|
|
||||||
url = element.filebrowser.url;
|
url = element.filebrowser.url;
|
||||||
if ( url === undefined )
|
if ( url === undefined ) {
|
||||||
{
|
|
||||||
url = editor.config[ 'filebrowser' + ucFirst( dialogName ) + 'UploadUrl' ];
|
url = editor.config[ 'filebrowser' + ucFirst( dialogName ) + 'UploadUrl' ];
|
||||||
if ( url === undefined )
|
if ( url === undefined )
|
||||||
url = editor.config.filebrowserUploadUrl;
|
url = editor.config.filebrowserUploadUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( url )
|
if ( url ) {
|
||||||
{
|
|
||||||
var onClick = element.onClick;
|
var onClick = element.onClick;
|
||||||
element.onClick = function( evt )
|
element.onClick = function( evt ) {
|
||||||
{
|
|
||||||
// "element" here means the definition object, so we need to find the correct
|
// "element" here means the definition object, so we need to find the correct
|
||||||
// button to scope the event call
|
// button to scope the event call
|
||||||
var sender = evt.sender;
|
var sender = evt.sender;
|
||||||
if ( onClick && onClick.call( sender, evt ) === false )
|
if ( onClick && onClick.call( sender, evt ) === false )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return uploadFile.call( sender, evt );
|
if ( uploadFile.call( sender, evt ) ) {
|
||||||
|
var fileInput = sender.getDialog().getContentElement( this[ 'for' ][ 0 ], this[ 'for' ][ 1 ] ).getInputElement();
|
||||||
|
|
||||||
|
// Append token preventing CSRF attacks.
|
||||||
|
appendToken( fileInput );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
element.filebrowser.url = url;
|
element.filebrowser.url = url;
|
||||||
@@ -311,46 +323,37 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Updates the target element with the url of uploaded/selected file.
|
||||||
315 * Updates the target element with the url of uploaded/selected file.
|
//
|
||||||
316 *
|
// @param {String}
|
||||||
317 * @param {String}
|
// url The url of a file.
|
||||||
318 * url The url of a file.
|
function updateTargetElement( url, sourceElement ) {
|
||||||
319 */
|
|
||||||
function updateTargetElement( url, sourceElement )
|
|
||||||
{
|
|
||||||
var dialog = sourceElement.getDialog();
|
var dialog = sourceElement.getDialog();
|
||||||
var targetElement = sourceElement.filebrowser.target || null;
|
var targetElement = sourceElement.filebrowser.target || null;
|
||||||
|
|
||||||
// If there is a reference to targetElement, update it.
|
// If there is a reference to targetElement, update it.
|
||||||
if ( targetElement )
|
if ( targetElement ) {
|
||||||
{
|
|
||||||
var target = targetElement.split( ':' );
|
var target = targetElement.split( ':' );
|
||||||
var element = dialog.getContentElement( target[ 0 ], target[ 1 ] );
|
var element = dialog.getContentElement( target[ 0 ], target[ 1 ] );
|
||||||
if ( element )
|
if ( element ) {
|
||||||
{
|
|
||||||
element.setValue( url );
|
element.setValue( url );
|
||||||
dialog.selectPage( target[ 0 ] );
|
dialog.selectPage( target[ 0 ] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Returns true if filebrowser is configured in one of the elements.
|
||||||
339 * Returns true if filebrowser is configured in one of the elements.
|
//
|
||||||
340 *
|
// @param {CKEDITOR.dialog.definitionObject}
|
||||||
341 * @param {CKEDITOR.dialog.definitionObject}
|
// definition Dialog definition.
|
||||||
342 * definition Dialog definition.
|
// @param String
|
||||||
343 * @param Stri344 * tabId The tab id where element(s) can be found.
|
// tabId The tab id where element(s) can be found.
|
||||||
345 * @param String
|
// @param String
|
||||||
346 * elementId The element id (or ids, separated with a semicolon) to check.
|
// elementId The element id (or ids, separated with a semicolon) to check.
|
||||||
347 */
|
function isConfigured( definition, tabId, elementId ) {
|
||||||
function isConfigured( definition, tabId, elementId )
|
if ( elementId.indexOf( ';' ) !== -1 ) {
|
||||||
{
|
var ids = elementId.split( ';' );
|
||||||
if ( elementId.indexOf( ";" ) !== -1 )
|
for ( var i = 0; i < ids.length; i++ ) {
|
||||||
{
|
|
||||||
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 true;
|
||||||
}
|
}
|
||||||
@@ -361,8 +364,7 @@
|
|||||||
return ( elementFileBrowser && elementFileBrowser.url );
|
return ( elementFileBrowser && elementFileBrowser.url );
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUrl( fileUrl, data )
|
function setUrl( fileUrl, data ) {
|
||||||
{
|
|
||||||
var dialog = this._.filebrowserSe.getDialog(),
|
var dialog = this._.filebrowserSe.getDialog(),
|
||||||
targetInput = this._.filebrowserSe[ 'for' ],
|
targetInput = this._.filebrowserSe[ 'for' ],
|
||||||
onSelect = this._.filebrowserSe.filebrowser.onSelect;
|
onSelect = this._.filebrowserSe.filebrowser.onSelect;
|
||||||
@@ -378,35 +380,36 @@
|
|||||||
|
|
||||||
// The "data" argument may be used to pass the error message to the editor.
|
// The "data" argument may be used to pass the error message to the editor.
|
||||||
if ( typeof data == 'string' && data )
|
if ( typeof data == 'string' && data )
|
||||||
alert( data );
|
alert( data ); // jshint ignore:line
|
||||||
|
|
||||||
if ( fileUrl )
|
if ( fileUrl )
|
||||||
updateTargetElement( fileUrl, this._.filebrowserSe );
|
updateTargetElement( fileUrl, this._.filebrowserSe );
|
||||||
}
|
}
|
||||||
|
|
||||||
CKEDITOR.plugins.add( 'filebrowser',
|
CKEDITOR.plugins.add( 'filebrowser', {
|
||||||
{
|
requires: 'popup',
|
||||||
init : function( editor, pluginPath )
|
init: function( editor ) {
|
||||||
{
|
|
||||||
editor._.filebrowserFn = CKEDITOR.tools.addFunction( setUrl, editor );
|
editor._.filebrowserFn = CKEDITOR.tools.addFunction( setUrl, editor );
|
||||||
editor.on( 'destroy', function () { CKEDITOR.tools.removeFunction( this._.filebrowserFn ); } );
|
editor.on( 'destroy', function() {
|
||||||
|
CKEDITOR.tools.removeFunction( this._.filebrowserFn );
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
CKEDITOR.on( 'dialogDefinition', function( evt )
|
CKEDITOR.on( 'dialogDefinition', function( evt ) {
|
||||||
{
|
// We require filebrowser plugin to be loaded.
|
||||||
|
if ( !evt.editor.plugins.filebrowser )
|
||||||
|
return;
|
||||||
|
|
||||||
var definition = evt.data.definition,
|
var definition = evt.data.definition,
|
||||||
element;
|
element;
|
||||||
// Associate filebrowser to elements with 'filebrowser' attribute.
|
// Associate filebrowser to elements with 'filebrowser' attribute.
|
||||||
for ( var i in definition.contents )
|
for ( var i = 0; i < definition.contents.length; ++i ) {
|
||||||
{
|
if ( ( element = definition.contents[ i ] ) ) {
|
||||||
if ( ( element = definition.contents[ i ] ) )
|
|
||||||
{
|
|
||||||
attachFileBrowser( evt.editor, evt.data.name, definition, element.elements );
|
attachFileBrowser( evt.editor, evt.data.name, definition, element.elements );
|
||||||
if ( element.hidden && element.filebrowser )
|
if ( element.hidden && element.filebrowser )
|
||||||
{
|
element.hidden = !isConfigured( definition, element.id, element.filebrowser );
|
||||||
element.hidden = !isConfigured( definition, element[ 'id' ], element.filebrowser );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
@@ -414,120 +417,157 @@
|
|||||||
} )();
|
} )();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
418 * The location of an external file browser that should be launched when the <strong>Browse Server</strong>
|
* The location of an external file manager that should be launched when the **Browse Server**
|
||||||
419 * button is pressed. If configured, the <strong>Browse Server</strong> button will appear in the
|
* button is pressed. If configured, the **Browse Server** button will appear in the
|
||||||
420 * <strong>Link</strong>, <strong>Image</strong>, and <strong>Flash</strong> dialog windows.
|
* **Link**, **Image**, and **Flash** dialog windows.
|
||||||
421 * @see The <a href="http://docs.cksource.com/CKEditor_3.x/Developers_Guide/File_Browser_(Uploader)">File Browser/Uploader</a> documentation.
|
*
|
||||||
422 * @name CKEDITOR.config.filebrowserBrowseUrl
|
* Read more in the [documentation](#!/guide/dev_file_browse_upload)
|
||||||
423 * @since 3.0
|
* and see the [SDK sample](http://sdk.ckeditor.com/samples/fileupload.html).
|
||||||
424 * @type String
|
*
|
||||||
425 * @default <code>''</code> (empty string = disabled)
|
* config.filebrowserBrowseUrl = '/browser/browse.php';
|
||||||
426 * @example
|
*
|
||||||
427 * config.filebrowserBrowseUrl = '/browser/browse.php';
|
* @since 3.0
|
||||||
428 */
|
* @cfg {String} [filebrowserBrowseUrl='' (empty string = disabled)]
|
||||||
|
* @member CKEDITOR.config
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
431 * The location of the script that handles file uploads.
|
* The location of the script that handles file uploads.
|
||||||
432 * If set, the <strong>Upload</strong> tab will appear in the <strong>Link</strong>, <strong>Image</strong>,
|
* If set, the **Upload** tab will appear in the **Link**, **Image**,
|
||||||
433 * and <strong>Flash</strong> dialog windows.
|
* and **Flash** dialog windows.
|
||||||
434 * @name CKEDITOR.config.filebrowserUploadUrl
|
*
|
||||||
435 * @see The <a href="http://docs.cksource.com/CKEditor_3.x/Developers_Guide/File_Browser_(Uploader)">File Browser/Uploader</a> documentation.
|
* Read more in the [documentation](#!/guide/dev_file_browse_upload)
|
||||||
436 * @since 3.0
|
* and see the [SDK sample](http://sdk.ckeditor.com/samples/fileupload.html).
|
||||||
437 * @type String
|
*
|
||||||
438 * @default <code>''</code> (empty string = disabled)
|
* config.filebrowserUploadUrl = '/uploader/upload.php';
|
||||||
439 * @example
|
*
|
||||||
440 * config.filebrowserUploadUrl = '/uploader/upload.php';
|
* **Note:** This is a configuration setting for a [file browser/uploader](#!/guide/dev_file_browse_upload).
|
||||||
441 */
|
* To configure [uploading dropped or pasted files](#!/guide/dev_file_upload) use the {@link CKEDITOR.config#uploadUrl}
|
||||||
|
* configuration option.
|
||||||
|
*
|
||||||
|
* @since 3.0
|
||||||
|
* @cfg {String} [filebrowserUploadUrl='' (empty string = disabled)]
|
||||||
|
* @member CKEDITOR.config
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
444 * The location of an external file browser that should be launched when the <strong>Browse Server</strong>
|
* The location of an external file manager that should be launched when the **Browse Server**
|
||||||
445 * button is pressed in the <strong>Image</strong> dialog window.
|
* button is pressed in the **Image** dialog window.
|
||||||
446 * If not set, CKEditor will use <code>{@link CKEDITOR.config.filebrowserBrowseUrl}</code>.
|
*
|
||||||
447 * @name CKEDITOR.config.filebrowserImageBrowseUrl
|
* If not set, CKEditor will use {@link CKEDITOR.config#filebrowserBrowseUrl}.
|
||||||
448 * @since 3.0
|
*
|
||||||
449 * @type String
|
* Read more in the [documentation](#!/guide/dev_file_manager_configuration-section-adding-file-manager-scripts-for-selected-dialog-windows)
|
||||||
450 * @default <code>''</code> (empty string = disabled)
|
* and see the [SDK sample](http://sdk.ckeditor.com/samples/fileupload.html).
|
||||||
451 * @example
|
*
|
||||||
452 * config.filebrowserImageBrowseUrl = '/browser/browse.php?type=Images';
|
* config.filebrowserImageBrowseUrl = '/browser/browse.php?type=Images';
|
||||||
453 */
|
*
|
||||||
|
* @since 3.0
|
||||||
|
* @cfg {String} [filebrowserImageBrowseUrl='' (empty string = disabled)]
|
||||||
|
* @member CKEDITOR.config
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
456 * The location of an external file browser that should be launched when the <strong>Browse Server</strong>
|
* The location of an external file browser that should be launched when the **Browse Server**
|
||||||
457 * button is pressed in the <strong>Flash</strong> dialog window.
|
* button is pressed in the **Flash** dialog window.
|
||||||
458 * If not set, CKEditor will use <code>{@link CKEDITOR.config.filebrowserBrowseUrl}</code>.
|
*
|
||||||
459 * @name CKEDITOR.config.filebrowserFlashBrowseUrl
|
* If not set, CKEditor will use {@link CKEDITOR.config#filebrowserBrowseUrl}.
|
||||||
460 * @since 3.0
|
*
|
||||||
461 * @type String
|
* Read more in the [documentation](#!/guide/dev_file_manager_configuration-section-adding-file-manager-scripts-for-selected-dialog-windows)
|
||||||
462 * @default <code>''</code> (empty string = disabled)
|
* and see the [SDK sample](http://sdk.ckeditor.com/samples/fileupload.html).
|
||||||
463 * @example
|
*
|
||||||
464 * config.filebrowserFlashBrowseUrl = '/browser/browse.php?type=Flash';
|
* config.filebrowserFlashBrowseUrl = '/browser/browse.php?type=Flash';
|
||||||
465 */
|
*
|
||||||
|
* @since 3.0
|
||||||
|
* @cfg {String} [filebrowserFlashBrowseUrl='' (empty string = disabled)]
|
||||||
|
* @member CKEDITOR.config
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
468 * The location of the script that handles file uploads in the <strong>Image</strong> dialog window.
|
* The location of the script that handles file uploads in the **Image** dialog window.
|
||||||
469 * If not set, CKEditor will use <code>{@link CKEDITOR.config.filebrowserUploadUrl}</code>.
|
*
|
||||||
470 * @name CKEDITOR.config.filebrowserImageUploadUrl
|
* If not set, CKEditor will use {@link CKEDITOR.config#filebrowserUploadUrl}.
|
||||||
471 * @since 3.0
|
*
|
||||||
472 * @type String
|
* Read more in the [documentation](#!/guide/dev_file_manager_configuration-section-adding-file-manager-scripts-for-selected-dialog-windows)
|
||||||
473 * @default <code>''</code> (empty string = disabled)
|
* and see the [SDK sample](http://sdk.ckeditor.com/samples/fileupload.html).
|
||||||
474 * @example
|
*
|
||||||
475 * config.filebrowserImageUploadUrl = '/uploader/upload.php?type=Images';
|
* config.filebrowserImageUploadUrl = '/uploader/upload.php?type=Images';
|
||||||
476 */
|
*
|
||||||
|
* **Note:** This is a configuration setting for a [file browser/uploader](#!/guide/dev_file_browse_upload).
|
||||||
|
* To configure [uploading dropped or pasted files](#!/guide/dev_file_upload) use the {@link CKEDITOR.config#uploadUrl}
|
||||||
|
* or {@link CKEDITOR.config#imageUploadUrl} configuration option.
|
||||||
|
*
|
||||||
|
* @since 3.0
|
||||||
|
* @cfg {String} [filebrowserImageUploadUrl='' (empty string = disabled)]
|
||||||
|
* @member CKEDITOR.config
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
479 * The location of the script that handles file uploads in the <strong>Flash</strong> dialog window.
|
* The location of the script that handles file uploads in the **Flash** dialog window.
|
||||||
480 * If not set, CKEditor will use <code>{@link CKEDITOR.config.filebrowserUploadUrl}</code>.
|
*
|
||||||
481 * @name CKEDITOR.config.filebrowserFlashUploadUrl
|
* If not set, CKEditor will use {@link CKEDITOR.config#filebrowserUploadUrl}.
|
||||||
482 * @since 3.0
|
*
|
||||||
483 * @type String
|
* Read more in the [documentation](#!/guide/dev_file_manager_configuration-section-adding-file-manager-scripts-for-selected-dialog-windows)
|
||||||
484 * @default <code>''</code> (empty string = disabled)
|
* and see the [SDK sample](http://sdk.ckeditor.com/samples/fileupload.html).
|
||||||
485 * @example
|
*
|
||||||
486 * config.filebrowserFlashUploadUrl = '/uploader/upload.php?type=Flash';
|
* config.filebrowserFlashUploadUrl = '/uploader/upload.php?type=Flash';
|
||||||
487 */
|
*
|
||||||
|
* @since 3.0
|
||||||
|
* @cfg {String} filebrowserFlashUploadUrl='' (empty string = disabled)]
|
||||||
|
* @member CKEDITOR.config
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
490 * The location of an external file browser that should be launched when the <strong>Browse Server</strong>
|
* The location of an external file manager that should be launched when the **Browse Server**
|
||||||
491 * button is pressed in the <strong>Link</strong> tab of the <strong>Image</strong> dialog window.
|
* button is pressed in the **Link** tab of the **Image** dialog window.
|
||||||
492 * If not set, CKEditor will use <code>{@link CKEDITOR.config.filebrowserBrowseUrl}</code>.
|
*
|
||||||
493 * @name CKEDITOR.config.filebrowserImageBrowseLinkUrl
|
* If not set, CKEditor will use {@link CKEDITOR.config#filebrowserBrowseUrl}.
|
||||||
494 * @since 3.2
|
*
|
||||||
495 * @type String
|
* Read more in the [documentation](#!/guide/dev_file_manager_configuration-section-adding-file-manager-scripts-for-selected-dialog-windows)
|
||||||
496 * @default <code>''</code> (empty string = disabled)
|
* and see the [SDK sample](http://sdk.ckeditor.com/samples/fileupload.html).
|
||||||
497 * @example
|
*
|
||||||
498 * config.filebrowserImageBrowseLinkUrl = '/browser/browse.php';
|
* config.filebrowserImageBrowseLinkUrl = '/browser/browse.php';
|
||||||
499 */
|
*
|
||||||
|
* @since 3.2
|
||||||
|
* @cfg {String} [filebrowserImageBrowseLinkUrl='' (empty string = disabled)]
|
||||||
|
* @member CKEDITOR.config
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
502 * The features to use in the file browser popup window.
|
* The features to use in the file manager popup window.
|
||||||
503 * @name CKEDITOR.config.filebrowserWindowFeatures
|
*
|
||||||
504 * @since 3.4.1
|
* config.filebrowserWindowFeatures = 'resizable=yes,scrollbars=no';
|
||||||
505 * @type String
|
*
|
||||||
506 * @default <code>'location=no,menubar=no,toolbar=no,dependent=yes,minimizable=no,modal=yes,alwaysRaised=yes,resizable=yes,scrollbars=yes'</code>
|
* @since 3.4.1
|
||||||
507 * @example
|
* @cfg {String} [filebrowserWindowFeatures='location=no,menubar=no,toolbar=no,dependent=yes,minimizable=no,modal=yes,alwaysRaised=yes,resizable=yes,scrollbars=yes']
|
||||||
508 * config.filebrowserWindowFeatures = 'resizable=yes,scrollbars=no';
|
* @member CKEDITOR.config
|
||||||
509 */
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
512 * The width of the file browser popup window. It can be a number denoting a value in
|
* The width of the file manager popup window. It can be a number denoting a value in
|
||||||
513 * pixels or a percent string.
|
* pixels or a percent string.
|
||||||
514 * @name CKEDITOR.config.filebrowserWindowWidth
|
*
|
||||||
515 * @type Number|String
|
* Read more in the [documentation](#!/guide/dev_file_manager_configuration-section-file-manager-window-size)
|
||||||
516 * @default <code>'80%'</code>
|
* and see the [SDK sample](http://sdk.ckeditor.com/samples/fileupload.html).
|
||||||
517 * @example
|
*
|
||||||
518 * config.filebrowserWindowWidth = 750;
|
* config.filebrowserWindowWidth = 750;
|
||||||
519 * @example
|
*
|
||||||
520 * config.filebrowserWindowWidth = '50%';
|
* config.filebrowserWindowWidth = '50%';
|
||||||
521 */
|
*
|
||||||
|
* @cfg {Number/String} [filebrowserWindowWidth='80%']
|
||||||
|
* @member CKEDITOR.config
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
524 * The height of the file browser popup window. It can be a number denoting a value in
|
* The height of the file manager popup window. It can be a number denoting a value in
|
||||||
525 * pixels or a percent string.
|
* pixels or a percent string.
|
||||||
526 * @name CKEDITOR.config.filebrowserWindowHeight
|
*
|
||||||
527 * @type Number|String
|
* Read more in the [documentation](#!/guide/dev_file_manager_configuration-section-file-manager-window-size)
|
||||||
528 * @default <code>'70%'</code>
|
* and see the [SDK sample](http://sdk.ckeditor.com/samples/fileupload.html).
|
||||||
529 * @example
|
*
|
||||||
530 * config.filebrowserWindowHeight = 580;
|
* config.filebrowserWindowHeight = 580;
|
||||||
531 * @example
|
*
|
||||||
532 * config.filebrowserWindowHeight = '50%';
|
* config.filebrowserWindowHeight = '50%';
|
||||||
533 */
|
*
|
||||||
|
* @cfg {Number/String} [filebrowserWindowHeight='70%']
|
||||||
|
* @member CKEDITOR.config
|
||||||
|
*/
|
||||||
|
Reference in New Issue
Block a user