CKEDITOR.plugins.cloudservices.cloudServicesLoader
A dedicated uploader type for CKEditor Cloud Services.
Note that this type is defined in the plugin.onLoad method, thus is guaranteed to be available in dependent plugin's beforeInit, init and CKEDITOR.pluginDefinition.afterInit methods.
Filtering
Properties
-
customToken : StringCKEDITOR.plugins.cloudservices.cloudServicesLoader#customTokenCustom CKEditor Cloud Services token.
-
String data encoded with Base64. If the
FileLoaderis created with a Base64 string, thedatais that string. If a file was passed to the constructor, the data isnulluntil loading is completed. -
File object which represents the handled file. This property is set for both constructor options (file or data).
-
The name of the file. If there is no file name, it is created by using the CKEDITOR.config.fileTools_defaultFileName option.
-
If
FileLoaderwas created using CKEDITOR.fileTools.uploadRepository, it gets an identifier which is stored in this property. -
The number of loaded bytes. If the
FileLoaderwas created with a data string, the loaded value equals the total value. -
The error message or additional information received from the server.
-
Native
FileReaderreference used to load the file. -
All data received in the response from the server. If the server returns additional data, it will be available in this property.
It contains all data set in the CKEDITOR.editor.fileUploadResponse event listener.
-
status : StringCKEDITOR.plugins.cloudservices.cloudServicesLoader#statusThe loader status. Possible values:
created– The loader was created, but neither load nor upload started.loading– The file is being loaded from the user's storage.loaded– The file was loaded, the process is finished.uploading– The file is being uploaded to the server.uploaded– The file was uploaded, the process is finished.error– The process stops because of an error, more details are available in the message property.abort– The process was stopped by the user.
-
The total file size in bytes.
-
The total size of upload data in bytes. If the
xhr.uploadobject is present, this value will indicate the total size of the request payload, not only the file size itself. If thexhr.uploadobject is not available and the real upload size cannot be obtained, this value will be equal to total. It has anullvalue until the upload size is known.loader.on( 'update', function() { // Wait till uploadTotal is present. if ( loader.uploadTotal ) { console.log( 'uploadTotal: ' + loader.uploadTotal ); } }); -
The target of the upload.
-
The number of uploaded bytes.
-
The URL to the file when it is uploaded or received from the server.
-
Native
XMLHttpRequestreference used to upload the file.
Static properties
Methods
-
inherited
constructor( editor, fileOrData, [ fileName ] ) → fileLoaderCKEDITOR.plugins.cloudservices.cloudServicesLoader#constructorCreates an instance of the class and sets initial values for all properties.
Parameters
editor : editorThe editor instance. Used only to get language data.
fileOrData : Blob | StringA blob object or a data string encoded with Base64.
[ fileName ] : StringThe file name. If not set and the second parameter is a file, then its name will be used. If not set and the second parameter is a Base64 data string, then the file name will be created based on the CKEDITOR.config.fileTools_defaultFileName option.
Returns
fileLoader
-
abort()CKEDITOR.plugins.cloudservices.cloudServicesLoader#abortAborts the process.
This method has a different behavior depending on the current status.
-
Register event handler under the capturing stage on supported target.
-
Predefine some intrinsic properties on a specific event name.
Parameters
name : StringThe event name
meta : Object
-
inherited
fire( eventName, [ data ], [ editor ] ) → Boolean | ObjectCKEDITOR.plugins.cloudservices.cloudServicesLoader#fireFires an specific event in the object. All registered listeners are called at this point.
someObject.on( 'someEvent', function() { ... } ); someObject.on( 'someEvent', function() { ... } ); someObject.fire( 'someEvent' ); // Both listeners are called. someObject.on( 'someEvent', function( event ) { alert( event.data ); // 'Example' } ); someObject.fire( 'someEvent', 'Example' );Parameters
eventName : StringThe event name to fire.
[ data ] : ObjectData to be sent as the CKEDITOR.eventInfo.data when calling the listeners.
[ editor ] : editorThe editor instance to send as the CKEDITOR.eventInfo.editor when calling the listener.
Returns
Boolean | ObjectA boolean indicating that the event is to be canceled, or data returned by one of the listeners.
-
inherited
fireOnce( eventName, [ data ], [ editor ] ) → Boolean | ObjectCKEDITOR.plugins.cloudservices.cloudServicesLoader#fireOnceFires an specific event in the object, releasing all listeners registered to that event. The same listeners are not called again on successive calls of it or of fire.
someObject.on( 'someEvent', function() { ... } ); someObject.fire( 'someEvent' ); // Above listener called. someObject.fireOnce( 'someEvent' ); // Above listener called. someObject.fire( 'someEvent' ); // No listeners called.Parameters
eventName : StringThe event name to fire.
[ data ] : ObjectData to be sent as the CKEDITOR.eventInfo.data when calling the listeners.
[ editor ] : editorThe editor instance to send as the CKEDITOR.eventInfo.editor when calling the listener.
Returns
Boolean | ObjectA booloan indicating that the event is to be canceled, or data returned by one of the listeners.
-
inherited
hasListeners( eventName ) → BooleanCKEDITOR.plugins.cloudservices.cloudServicesLoader#hasListenersChecks if there is any listener registered to a given event.
var myListener = function() { ... }; someObject.on( 'someEvent', myListener ); alert( someObject.hasListeners( 'someEvent' ) ); // true alert( someObject.hasListeners( 'noEvent' ) ); // falseParameters
eventName : StringThe event name.
Returns
Boolean
-
Returns
trueif the loading and uploading finished (successfully or not), so the status isloaded,uploaded,errororabort.Returns
Booleantrueif the loading and uploading finished.
-
Loads a file from the storage on the user's device to the
dataattribute.The order of the statuses for a successful load is:
created,loading,loaded.
-
inherited
loadAndUpload( url, [ additionalRequestParameters ] )CKEDITOR.plugins.cloudservices.cloudServicesLoader#loadAndUploadLoads a file from the storage on the user's device to the
dataattribute and uploads it to the server.The order of statuses for a successful load and upload is:
created,loading,uploading,uploaded.
Parameters
url : StringThe upload URL.
[ additionalRequestParameters ] : ObjectAdditional parameters that would be passed to the CKEDITOR.editor.fileUploadRequest event.
-
inherited
on( eventName, listenerFunction, [ scopeObj ], [ listenerData ], [ priority ] ) → ObjectCKEDITOR.plugins.cloudservices.cloudServicesLoader#onRegisters a listener to a specific event in the current object.
someObject.on( 'someEvent', function() { alert( this == someObject ); // true } ); someObject.on( 'someEvent', function() { alert( this == anotherObject ); // true }, anotherObject ); someObject.on( 'someEvent', function( event ) { alert( event.listenerData ); // 'Example' }, null, 'Example' ); someObject.on( 'someEvent', function() { ... } ); // 2nd called someObject.on( 'someEvent', function() { ... }, null, null, 100 ); // 3rd called someObject.on( 'someEvent', function() { ... }, null, null, 1 ); // 1st calledNote: CKEditor's event system has a limitation that one function cannot be used as a listener for the same event more than once. Hence, to reuse it with multiple listeners, it should be wrapped into additional wrapper function:
function listener( evt ) { ... }; someObject.on( 'someEvent', function() { listener(); } ); someObject.on( 'someEvent', function( evt ) { listener( evt ); } );Parameters
eventName : StringThe event name to which listen.
listenerFunction : FunctionThe function listening to the event. A single CKEDITOR.eventInfo object instanced is passed to this function containing all the event data.
[ scopeObj ] : ObjectThe object used to scope the listener call (the
thisobject). If omitted, the current object is used.[ listenerData ] : ObjectData to be sent as the CKEDITOR.eventInfo.listenerData when calling the listener.
[ priority ] : NumberThe listener priority. Lower priority listeners are called first. Listeners with the same priority value are called in registration order.
Defaults to
10
Returns
ObjectAn object containing the
removeListenerfunction, which can be used to remove the listener at any time.
-
Similiar with on but the listener will be called only once upon the next event firing.
-
Remove all existing listeners on this object, for cleanup purpose.
-
inherited
removeListener( eventName, listenerFunction )CKEDITOR.plugins.cloudservices.cloudServicesLoader#removeListenerUnregisters a listener function from being called at the specified event. No errors are thrown if the listener has not been registered previously.
var myListener = function() { ... }; someObject.on( 'someEvent', myListener ); someObject.fire( 'someEvent' ); // myListener called. someObject.removeListener( 'someEvent', myListener ); someObject.fire( 'someEvent' ); // myListener not called.Parameters
eventName : StringThe event name.
listenerFunction : FunctionThe listener function to unregister.
-
Updates the state of the
FileLoaderlisteners. This method should be called if the state of the visual representation of the upload process is out of synchronization and needs to be refreshed (e.g. because of an undo operation or because the dialog window with the upload is closed and reopened). Fires the update event. -
inherited
upload( url, [ additionalRequestParameters ] )CKEDITOR.plugins.cloudservices.cloudServicesLoader#uploadUploads a file to the server.
The order of the statuses for a successful upload is:
created,uploading,uploaded.
Parameters
url : StringThe upload URL.
[ additionalRequestParameters ] : ObjectAdditional data that would be passed to the CKEDITOR.editor.fileUploadRequest event.
-
private inherited
attachRequestListeners( xhr )CKEDITOR.plugins.cloudservices.cloudServicesLoader#attachRequestListenersAttaches listeners to the XML HTTP request object.
Parameters
xhr : XMLHttpRequestXML HTTP request object.
-
private inherited
changeStatus( newStatus )CKEDITOR.plugins.cloudservices.cloudServicesLoader#changeStatus
Static methods
-
mixed static
implementOn( targetObject )CKEDITOR.plugins.cloudservices.cloudServicesLoader#implementOnImplements the CKEDITOR.event features in an object.
var myObject = { message: 'Example' }; CKEDITOR.event.implementOn( myObject ); myObject.on( 'testEvent', function() { alert( this.message ); } ); myObject.fire( 'testEvent' ); // 'Example'Parameters
targetObject : ObjectThe object into which implement the features.
Events
-
abort( evt )CKEDITOR.plugins.cloudservices.cloudServicesLoader#abortEvent fired when the status changes to
abort. It will be fired once for theFileLoader.Parameters
evt : eventInfo
-
error( evt )CKEDITOR.plugins.cloudservices.cloudServicesLoader#errorEvent fired when the status changes to
error. It will be fired once for theFileLoader.Parameters
evt : eventInfo
-
loaded( evt )CKEDITOR.plugins.cloudservices.cloudServicesLoader#loadedEvent fired when the status changes to
loaded. It will be fired once for theFileLoader.Parameters
evt : eventInfo
-
loading( evt )CKEDITOR.plugins.cloudservices.cloudServicesLoader#loadingEvent fired when the status changes to
loading. It will be fired once for theFileLoader.Parameters
evt : eventInfo
-
uploaded( evt )CKEDITOR.plugins.cloudservices.cloudServicesLoader#uploadedEvent fired when the status changes to
uploaded. It will be fired once for theFileLoader.Parameters
evt : eventInfo
-
uploading( evt )CKEDITOR.plugins.cloudservices.cloudServicesLoader#uploadingEvent fired when the status changes to
uploading. It will be fired once for theFileLoader.Parameters
evt : eventInfo