Skip to content
Permalink
Browse files

Merge branch 't/13398' into major

  • Loading branch information...
Reinmar committed Jun 15, 2015
2 parents 5c2bd9c + 6e6da99 commit 83f365a6c238fed2ea938e221cc5c29df3f030eb
@@ -48,6 +48,7 @@ Other Changes:
* [#13147](http://dev.ckeditor.com/ticket/13147): Add buttons to the sticky toolbar.
* [#13207](http://dev.ckeditor.com/ticket/13207): Use modal window to display help in toolbar configurator.
* [#13316](http://dev.ckeditor.com/ticket/13316): Made [`CKEDITOR.env.isCompatible`](http://docs.ckeditor.com/#!/api/CKEDITOR.env-property-isCompatible) a blacklist rather than a whitelist. More about the change in the [Browser Compatibility](http://docs.ckeditor.com/#!/guide/dev_browsers) guide.
* [#13398](http://dev.ckeditor.com/ticket/13398): Renamed `CKEDITOR.fileTools.UploadsRepository` to [`CKEDITOR.fileTools.UploadRepository`](http://docs.ckeditor.com/#!/api/CKEDITOR.fileTools.uploadRepository) and changed all related properties.

## CKEditor 4.5 Beta

@@ -11,18 +11,18 @@

beforeInit: function( editor ) {
/**
* An instance of {@link CKEDITOR.fileTools.uploadsRepository upload repository}.
* An instance of {@link CKEDITOR.fileTools.uploadRepository upload repository}.
* It allows you to create and get {@link CKEDITOR.fileTools.fileLoader file loaders}.
*
* var loader = editor.uploadsRepository.create( file );
* var loader = editor.uploadRepository.create( file );
* loader.loadAndUpload( 'http://foo/bar' );
*
* @since 4.5
* @readonly
* @property {CKEDITOR.fileTools.uploadsRepository} uploadsRepository
* @property {CKEDITOR.fileTools.uploadRepository} uploadRepository
* @member CKEDITOR.editor
*/
editor.uploadsRepository = new UploadsRepository( editor );
editor.uploadRepository = new UploadRepository( editor );

/**
* This event if fired when {@link CKEDITOR.fileTools.fileLoader FileLoader} should send XHR. If event will not be
@@ -190,31 +190,31 @@
/**
* File loaders repository. It allows you to create and get {@link CKEDITOR.fileTools.fileLoader file loaders}.
*
* An instance of the repository is available as a {@link CKEDITOR.editor#uploadsRepository}.
* An instance of the repository is available as a {@link CKEDITOR.editor#uploadRepository}.
*
* var loader = editor.uploadsRepository.create( file );
* var loader = editor.uploadRepository.create( file );
* loader.loadAndUpload( 'http://foo/bar' );
*
* To find more information about handling files see the {@link CKEDITOR.fileTools.fileLoader} class.
*
* @since 4.5
* @class CKEDITOR.fileTools.uploadsRepository
* @class CKEDITOR.fileTools.uploadRepository
* @mixins CKEDITOR.event
* @constructor Creates an instance of the repository.
* @param {CKEDITOR.editor} editor Editor instance. Used only to get the language data.
*/
function UploadsRepository( editor ) {
function UploadRepository( editor ) {
this.editor = editor;

this.loaders = [];
}

UploadsRepository.prototype = {
UploadRepository.prototype = {
/**
* Creates a {@link CKEDITOR.fileTools.fileLoader file loader} instance with a unique id.
* The instance can be later retrieved from the repository using the {@link #loaders} array.
*
* Fires {@link CKEDITOR.fileTools.uploadsRepository#instanceCreated instanceCreated} event.
* Fires {@link CKEDITOR.fileTools.uploadRepository#instanceCreated instanceCreated} event.
*
* @param {Blob/String} fileOrData See {@link CKEDITOR.fileTools.fileLoader}.
* @param {String} fileName See {@link CKEDITOR.fileTools.fileLoader}.
@@ -293,7 +293,7 @@
* or response handling you need to overwrite default behavior using the {@link CKEDITOR.editor#fileUploadRequest} and
* {@link CKEDITOR.editor#fileUploadResponse} events. For more information see their documentation.
*
* To create a `FileLoader` instance use the {@link CKEDITOR.fileTools.uploadsRepository} class.
* To create a `FileLoader` instance use the {@link CKEDITOR.fileTools.uploadRepository} class.
*
* Here is a simple usage of `FileLoader`:
*
@@ -302,7 +302,7 @@
* var file = evt.data.dataTransfer.getFile( i );
*
* if ( CKEDITOR.fileTools.isTypeSupported( file, /image\/png/ ) ) {
* var loader = editor.uploadsRepository.create( file );
* var loader = editor.uploadRepository.create( file );
*
* loader.on( 'update', function() {
* document.getElementById( 'uploadProgress' ).innerHTML = loader.status;
@@ -463,7 +463,7 @@
*/

/**
* If `FileLoader` was created using {@link CKEDITOR.fileTools.uploadsRepository}
* If `FileLoader` was created using {@link CKEDITOR.fileTools.uploadRepository}
* it gets an identifier which is stored in this property.
*
* @readonly
@@ -731,7 +731,7 @@
*/
};

CKEDITOR.event.implementOn( UploadsRepository.prototype );
CKEDITOR.event.implementOn( UploadRepository.prototype );
CKEDITOR.event.implementOn( FileLoader.prototype );

var base64HeaderRegExp = /^data:(\S*?);base64,/;
@@ -782,7 +782,7 @@
}

CKEDITOR.tools.extend( CKEDITOR.fileTools, {
uploadsRepository: UploadsRepository,
uploadRepository: UploadRepository,
fileLoader: FileLoader,

/**
@@ -85,7 +85,7 @@

// We are not uploading images in non-editable blocs and fake objects (#13003).
if ( isDataInSrc && isRealObject && !img.data( 'cke-upload-id' ) && !img.isReadOnly( 1 ) ) {
var loader = editor.uploadsRepository.create( img.getAttribute( 'src' ) );
var loader = editor.uploadRepository.create( img.getAttribute( 'src' ) );
loader.upload( uploadUrl );

fileTools.markElement( img, 'uploadimage', loader.id );
@@ -36,7 +36,7 @@

if ( fileTools.isTypeSupported( file, /text\/(plain|html)/ ) ) {
var el = new CKEDITOR.dom.element( 'span' ),
loader = editor.uploadsRepository.create( file );
loader = editor.uploadRepository.create( file );

el.setText( '...' );

@@ -95,7 +95,7 @@
*
* if ( CKEDITOR.fileTools.isTypeSupported( file, /text\/(plain|html)/ ) ) {
* el = new CKEDITOR.dom.element( 'span' ),
* loader = editor.uploadsRepository.create( file );
* loader = editor.uploadRepository.create( file );
*
* el.setText( '...' );
*
@@ -121,7 +121,7 @@
*
* if ( CKEDITOR.fileTools.isTypeSupported( file, /text\/pdf/ ) ) {
* el = new CKEDITOR.dom.element( 'span' ),
* loader = editor.uploadsRepository.create( file );
* loader = editor.uploadRepository.create( file );
*
* el.setText( '...' );
*
@@ -143,7 +143,7 @@
*/
function addUploadWidget( editor, name, def ) {
var fileTools = CKEDITOR.fileTools,
uploads = editor.uploadsRepository,
uploads = editor.uploadRepository,
// Plugins which support all file type has lower priority than plugins which support specific types.
priority = def.supportedTypes ? 10 : 20;

@@ -498,4 +498,4 @@
markElement: markElement,
bindNotifications: bindNotifications
} );
} )();
} )();
@@ -22,8 +22,8 @@
isTypeSupported = CKEDITOR.fileTools.isTypeSupported;
getExtention = CKEDITOR.fileTools.getExtention;

// Reset uploadsRepository.
this.editor.uploadsRepository.loaders = [];
// Reset uploadRepository.
this.editor.uploadRepository.loaders = [];
},

'test getUploadUrl 1': function() {
@@ -110,8 +110,8 @@
assert.isFalse( isTypeSupported( { type: 'image/jpeg' }, /image\/(png|gif)/ ) );
},

'test UploadsRepository': function() {
var repository = this.editor.uploadsRepository;
'test UploadRepository': function() {
var repository = this.editor.uploadRepository;

assert.areSame( 0, repository.loaders.length );
assert.isUndefined( repository.loaders[ 0 ] );
@@ -137,8 +137,8 @@
},


'test UploadsRepository instanceCreated event': function() {
var repository = this.editor.uploadsRepository,
'test UploadRepository instanceCreated event': function() {
var repository = this.editor.uploadRepository,
listener = sinon.spy();

repository.on( 'instanceCreated', listener );
@@ -149,8 +149,8 @@
assert.areSame( loader, listener.firstCall.args[ 0 ].data, 'Should be called with loader.' );
},

'test UploadsRepository isFinished': function() {
var repository = this.editor.uploadsRepository;
'test UploadRepository isFinished': function() {
var repository = this.editor.uploadRepository;


repository.create( { name: 'foo1' } );
@@ -76,8 +76,8 @@
loadAndUploadCount = 0;

for ( editorName in this.editors ) {
// Clear uploads repository.
this.editors[ editorName ].uploadsRepository.loaders = [];
// Clear upload repository.
this.editors[ editorName ].uploadRepository.loaders = [];
}

if ( CKEDITOR.fileTools.bindNotifications.reset ) {
@@ -93,7 +93,7 @@
assertUploadingWidgets( editor, LOADING_IMG );
assert.areSame( '', editor.getData(), 'getData on loading.' );

var loader = editor.uploadsRepository.loaders[ 0 ];
var loader = editor.uploadRepository.loaders[ 0 ];

loader.data = bender.tools.pngBase64;
loader.changeStatus( 'uploading' );
@@ -120,7 +120,7 @@

pasteFiles( editor, [ bender.tools.getTestPngFile() ] );

var loader = editor.uploadsRepository.loaders[ 0 ];
var loader = editor.uploadRepository.loaders[ 0 ];

loader.data = bender.tools.pngBase64;
loader.changeStatus( 'uploading' );
@@ -150,7 +150,7 @@
assertUploadingWidgets( editor, LOADING_IMG );
assert.areSame( '', editor.getData(), 'getData on loading.' );

var loader = editor.uploadsRepository.loaders[ 0 ];
var loader = editor.uploadRepository.loaders[ 0 ];

loader.data = bender.tools.pngBase64;
loader.changeStatus( 'uploading' );
@@ -182,7 +182,7 @@
assertUploadingWidgets( editor, LOADED_IMG );
assert.areSame( '<p>xx</p>', editor.getData(), 'getData on loading.' );

var loader = editor.uploadsRepository.loaders[ 0 ];
var loader = editor.uploadRepository.loaders[ 0 ];

loader.data = bender.tools.pngBase64;
loader.changeStatus( 'uploading' );
@@ -341,7 +341,7 @@

'test paste image already marked': function() {
var editor = this.editors.classic,
uploads = editor.uploadsRepository;
uploads = editor.uploadRepository;

resumeAfter( editor, 'paste', function( evt ) {
var img = CKEDITOR.dom.element.createFromHtml( evt.data.dataValue );
@@ -475,7 +475,7 @@

'test prevent upload fake elements (#13003)': function() {
var editor = this.editors.inline,
createspy = sinon.spy( editor.uploadsRepository, 'create' );
createspy = sinon.spy( editor.uploadRepository, 'create' );

editor.fire( 'paste', {
dataValue: '<img src="data:image/gif;base64,aw==" alt="nothing" data-cke-realelement="some" />'
Oops, something went wrong.

0 comments on commit 83f365a

Please sign in to comment.
You can’t perform that action at this time.