Bind `this` at calltime instead of letting `self` spill down into closures.
See #28510. Built from https://develop.svn.wordpress.org/trunk@31380 git-svn-id: http://core.svn.wordpress.org/trunk@31361 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
308ae4c887
commit
ef12a2cc8c
|
@ -130,7 +130,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
shortcode : function( model ) {
|
shortcode : function( model ) {
|
||||||
var self = this, content;
|
var content;
|
||||||
|
|
||||||
_.each( this.defaults, function( value, key ) {
|
_.each( this.defaults, function( value, key ) {
|
||||||
model[ key ] = self.coerce( model, key );
|
model[ key ] = self.coerce( model, key );
|
||||||
|
@ -138,7 +138,7 @@
|
||||||
if ( value === model[ key ] ) {
|
if ( value === model[ key ] ) {
|
||||||
delete model[ key ];
|
delete model[ key ];
|
||||||
}
|
}
|
||||||
});
|
}, this );
|
||||||
|
|
||||||
content = model.content;
|
content = model.content;
|
||||||
delete model.content;
|
delete model.content;
|
||||||
|
@ -191,15 +191,15 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
shortcode : function( model ) {
|
shortcode : function( model ) {
|
||||||
var self = this, content;
|
var content;
|
||||||
|
|
||||||
_.each( this.defaults, function( value, key ) {
|
_.each( this.defaults, function( value, key ) {
|
||||||
model[ key ] = self.coerce( model, key );
|
model[ key ] = this.coerce( model, key );
|
||||||
|
|
||||||
if ( value === model[ key ] ) {
|
if ( value === model[ key ] ) {
|
||||||
delete model[ key ];
|
delete model[ key ];
|
||||||
}
|
}
|
||||||
});
|
}, this );
|
||||||
|
|
||||||
content = model.content;
|
content = model.content;
|
||||||
delete model.content;
|
delete model.content;
|
||||||
|
@ -1189,14 +1189,12 @@ var PostMedia = Backbone.Model.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
changeAttachment: function( attachment ) {
|
changeAttachment: function( attachment ) {
|
||||||
var self = this;
|
|
||||||
|
|
||||||
this.setSource( attachment );
|
this.setSource( attachment );
|
||||||
|
|
||||||
this.unset( 'src' );
|
this.unset( 'src' );
|
||||||
_.each( _.without( wp.media.view.settings.embedExts, this.extension ), function( ext ) {
|
_.each( _.without( wp.media.view.settings.embedExts, this.extension ), function( ext ) {
|
||||||
self.unset( ext );
|
this.unset( ext );
|
||||||
} );
|
}, this );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -2831,7 +2829,7 @@ AttachmentsBrowser = View.extend({
|
||||||
controller: this.controller,
|
controller: this.controller,
|
||||||
priority: -60,
|
priority: -60,
|
||||||
click: function() {
|
click: function() {
|
||||||
var changed = [], removed = [], self = this,
|
var changed = [], removed = [],
|
||||||
selection = this.controller.state().get( 'selection' ),
|
selection = this.controller.state().get( 'selection' ),
|
||||||
library = this.controller.state().get( 'library' );
|
library = this.controller.state().get( 'library' );
|
||||||
|
|
||||||
|
@ -2872,10 +2870,10 @@ AttachmentsBrowser = View.extend({
|
||||||
if ( changed.length ) {
|
if ( changed.length ) {
|
||||||
selection.remove( removed );
|
selection.remove( removed );
|
||||||
|
|
||||||
$.when.apply( null, changed ).then( function() {
|
$.when.apply( null, changed ).then( _.bind( function() {
|
||||||
library._requery( true );
|
library._requery( true );
|
||||||
self.controller.trigger( 'selection:action:done' );
|
this.controller.trigger( 'selection:action:done' );
|
||||||
} );
|
}, this ) );
|
||||||
} else {
|
} else {
|
||||||
this.controller.trigger( 'selection:action:done' );
|
this.controller.trigger( 'selection:action:done' );
|
||||||
}
|
}
|
||||||
|
@ -4145,10 +4143,11 @@ MediaDetails = AttachmentDisplay.extend({
|
||||||
* @returns {media.view.MediaDetails} Returns itself to allow chaining
|
* @returns {media.view.MediaDetails} Returns itself to allow chaining
|
||||||
*/
|
*/
|
||||||
render: function() {
|
render: function() {
|
||||||
var self = this;
|
|
||||||
|
|
||||||
AttachmentDisplay.prototype.render.apply( this, arguments );
|
AttachmentDisplay.prototype.render.apply( this, arguments );
|
||||||
setTimeout( function() { self.resetFocus(); }, 10 );
|
|
||||||
|
setTimeout( _.bind( function() {
|
||||||
|
this.resetFocus();
|
||||||
|
}, this ), 10 );
|
||||||
|
|
||||||
this.settings = _.defaults( {
|
this.settings = _.defaults( {
|
||||||
success : this.success
|
success : this.success
|
||||||
|
|
|
@ -129,7 +129,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
shortcode : function( model ) {
|
shortcode : function( model ) {
|
||||||
var self = this, content;
|
var content;
|
||||||
|
|
||||||
_.each( this.defaults, function( value, key ) {
|
_.each( this.defaults, function( value, key ) {
|
||||||
model[ key ] = self.coerce( model, key );
|
model[ key ] = self.coerce( model, key );
|
||||||
|
@ -137,7 +137,7 @@
|
||||||
if ( value === model[ key ] ) {
|
if ( value === model[ key ] ) {
|
||||||
delete model[ key ];
|
delete model[ key ];
|
||||||
}
|
}
|
||||||
});
|
}, this );
|
||||||
|
|
||||||
content = model.content;
|
content = model.content;
|
||||||
delete model.content;
|
delete model.content;
|
||||||
|
@ -190,15 +190,15 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
shortcode : function( model ) {
|
shortcode : function( model ) {
|
||||||
var self = this, content;
|
var content;
|
||||||
|
|
||||||
_.each( this.defaults, function( value, key ) {
|
_.each( this.defaults, function( value, key ) {
|
||||||
model[ key ] = self.coerce( model, key );
|
model[ key ] = this.coerce( model, key );
|
||||||
|
|
||||||
if ( value === model[ key ] ) {
|
if ( value === model[ key ] ) {
|
||||||
delete model[ key ];
|
delete model[ key ];
|
||||||
}
|
}
|
||||||
});
|
}, this );
|
||||||
|
|
||||||
content = model.content;
|
content = model.content;
|
||||||
delete model.content;
|
delete model.content;
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -67,18 +67,20 @@ Cropper = State.extend({
|
||||||
requires: { library: false, selection: false },
|
requires: { library: false, selection: false },
|
||||||
|
|
||||||
click: function() {
|
click: function() {
|
||||||
var self = this,
|
var controller = this.controller,
|
||||||
selection = this.controller.state().get('selection').first();
|
selection;
|
||||||
|
|
||||||
selection.set({cropDetails: this.controller.state().imgSelect.getSelection()});
|
selection = controller.state().get('selection').first();
|
||||||
|
selection.set({cropDetails: controller.state().imgSelect.getSelection()});
|
||||||
|
|
||||||
this.$el.text(l10n.cropping);
|
this.$el.text(l10n.cropping);
|
||||||
this.$el.attr('disabled', true);
|
this.$el.attr('disabled', true);
|
||||||
this.controller.state().doCrop( selection ).done( function( croppedImage ) {
|
|
||||||
self.controller.trigger('cropped', croppedImage );
|
controller.state().doCrop( selection ).done( function( croppedImage ) {
|
||||||
self.controller.close();
|
controller.trigger('cropped', croppedImage );
|
||||||
|
controller.close();
|
||||||
}).fail( function() {
|
}).fail( function() {
|
||||||
self.controller.trigger('content:error:crop');
|
controller.trigger('content:error:crop');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2663,7 +2663,7 @@ AttachmentsBrowser = View.extend({
|
||||||
controller: this.controller,
|
controller: this.controller,
|
||||||
priority: -60,
|
priority: -60,
|
||||||
click: function() {
|
click: function() {
|
||||||
var changed = [], removed = [], self = this,
|
var changed = [], removed = [],
|
||||||
selection = this.controller.state().get( 'selection' ),
|
selection = this.controller.state().get( 'selection' ),
|
||||||
library = this.controller.state().get( 'library' );
|
library = this.controller.state().get( 'library' );
|
||||||
|
|
||||||
|
@ -2704,10 +2704,10 @@ AttachmentsBrowser = View.extend({
|
||||||
if ( changed.length ) {
|
if ( changed.length ) {
|
||||||
selection.remove( removed );
|
selection.remove( removed );
|
||||||
|
|
||||||
$.when.apply( null, changed ).then( function() {
|
$.when.apply( null, changed ).then( _.bind( function() {
|
||||||
library._requery( true );
|
library._requery( true );
|
||||||
self.controller.trigger( 'selection:action:done' );
|
this.controller.trigger( 'selection:action:done' );
|
||||||
} );
|
}, this ) );
|
||||||
} else {
|
} else {
|
||||||
this.controller.trigger( 'selection:action:done' );
|
this.controller.trigger( 'selection:action:done' );
|
||||||
}
|
}
|
||||||
|
@ -3198,11 +3198,9 @@ Details = EditImage.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
save: function() {
|
save: function() {
|
||||||
var self = this;
|
this.model.fetch().done( _.bind( function() {
|
||||||
|
this.frame.content.mode( 'edit-metadata' );
|
||||||
this.model.fetch().done( function() {
|
}, this ) );
|
||||||
self.frame.content.mode( 'edit-metadata' );
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -3251,12 +3249,11 @@ EditImage = View.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
save: function() {
|
save: function() {
|
||||||
var self = this,
|
var lastState = this.controller.lastState();
|
||||||
lastState = this.controller.lastState();
|
|
||||||
|
|
||||||
this.model.fetch().done( function() {
|
this.model.fetch().done( _.bind( function() {
|
||||||
self.controller.setState( lastState );
|
this.controller.setState( lastState );
|
||||||
});
|
}, this ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -3560,8 +3557,6 @@ EditAttachments = MediaFrame.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
createModal: function() {
|
createModal: function() {
|
||||||
var self = this;
|
|
||||||
|
|
||||||
// Initialize modal container view.
|
// Initialize modal container view.
|
||||||
if ( this.options.modal ) {
|
if ( this.options.modal ) {
|
||||||
this.modal = new Modal({
|
this.modal = new Modal({
|
||||||
|
@ -3569,18 +3564,18 @@ EditAttachments = MediaFrame.extend({
|
||||||
title: this.options.title
|
title: this.options.title
|
||||||
});
|
});
|
||||||
|
|
||||||
this.modal.on( 'open', function () {
|
this.modal.on( 'open', _.bind( function () {
|
||||||
$( 'body' ).on( 'keydown.media-modal', _.bind( self.keyEvent, self ) );
|
$( 'body' ).on( 'keydown.media-modal', _.bind( this.keyEvent, this ) );
|
||||||
} );
|
}, this ) );
|
||||||
|
|
||||||
// Completely destroy the modal DOM element when closing it.
|
// Completely destroy the modal DOM element when closing it.
|
||||||
this.modal.on( 'close', function() {
|
this.modal.on( 'close', _.bind( function() {
|
||||||
self.modal.remove();
|
this.modal.remove();
|
||||||
$( 'body' ).off( 'keydown.media-modal' ); /* remove the keydown event */
|
$( 'body' ).off( 'keydown.media-modal' ); /* remove the keydown event */
|
||||||
// Restore the original focus item if possible
|
// Restore the original focus item if possible
|
||||||
$( 'li.attachment[data-id="' + self.model.get( 'id' ) +'"]' ).focus();
|
$( 'li.attachment[data-id="' + this.model.get( 'id' ) +'"]' ).focus();
|
||||||
self.resetRoute();
|
this.resetRoute();
|
||||||
} );
|
}, this ) );
|
||||||
|
|
||||||
// Set this frame as the modal's content.
|
// Set this frame as the modal's content.
|
||||||
this.modal.content( this );
|
this.modal.content( this );
|
||||||
|
@ -4145,10 +4140,11 @@ MediaDetails = AttachmentDisplay.extend({
|
||||||
* @returns {media.view.MediaDetails} Returns itself to allow chaining
|
* @returns {media.view.MediaDetails} Returns itself to allow chaining
|
||||||
*/
|
*/
|
||||||
render: function() {
|
render: function() {
|
||||||
var self = this;
|
|
||||||
|
|
||||||
AttachmentDisplay.prototype.render.apply( this, arguments );
|
AttachmentDisplay.prototype.render.apply( this, arguments );
|
||||||
setTimeout( function() { self.resetFocus(); }, 10 );
|
|
||||||
|
setTimeout( _.bind( function() {
|
||||||
|
this.resetFocus();
|
||||||
|
}, this ), 10 );
|
||||||
|
|
||||||
this.settings = _.defaults( {
|
this.settings = _.defaults( {
|
||||||
success : this.success
|
success : this.success
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -28,14 +28,12 @@ var PostMedia = Backbone.Model.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
changeAttachment: function( attachment ) {
|
changeAttachment: function( attachment ) {
|
||||||
var self = this;
|
|
||||||
|
|
||||||
this.setSource( attachment );
|
this.setSource( attachment );
|
||||||
|
|
||||||
this.unset( 'src' );
|
this.unset( 'src' );
|
||||||
_.each( _.without( wp.media.view.settings.embedExts, this.extension ), function( ext ) {
|
_.each( _.without( wp.media.view.settings.embedExts, this.extension ), function( ext ) {
|
||||||
self.unset( ext );
|
this.unset( ext );
|
||||||
} );
|
}, this );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -333,18 +333,20 @@ Cropper = State.extend({
|
||||||
requires: { library: false, selection: false },
|
requires: { library: false, selection: false },
|
||||||
|
|
||||||
click: function() {
|
click: function() {
|
||||||
var self = this,
|
var controller = this.controller,
|
||||||
selection = this.controller.state().get('selection').first();
|
selection;
|
||||||
|
|
||||||
selection.set({cropDetails: this.controller.state().imgSelect.getSelection()});
|
selection = controller.state().get('selection').first();
|
||||||
|
selection.set({cropDetails: controller.state().imgSelect.getSelection()});
|
||||||
|
|
||||||
this.$el.text(l10n.cropping);
|
this.$el.text(l10n.cropping);
|
||||||
this.$el.attr('disabled', true);
|
this.$el.attr('disabled', true);
|
||||||
this.controller.state().doCrop( selection ).done( function( croppedImage ) {
|
|
||||||
self.controller.trigger('cropped', croppedImage );
|
controller.state().doCrop( selection ).done( function( croppedImage ) {
|
||||||
self.controller.close();
|
controller.trigger('cropped', croppedImage );
|
||||||
|
controller.close();
|
||||||
}).fail( function() {
|
}).fail( function() {
|
||||||
self.controller.trigger('content:error:crop');
|
controller.trigger('content:error:crop');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3836,7 +3838,7 @@ AttachmentsBrowser = View.extend({
|
||||||
controller: this.controller,
|
controller: this.controller,
|
||||||
priority: -60,
|
priority: -60,
|
||||||
click: function() {
|
click: function() {
|
||||||
var changed = [], removed = [], self = this,
|
var changed = [], removed = [],
|
||||||
selection = this.controller.state().get( 'selection' ),
|
selection = this.controller.state().get( 'selection' ),
|
||||||
library = this.controller.state().get( 'library' );
|
library = this.controller.state().get( 'library' );
|
||||||
|
|
||||||
|
@ -3877,10 +3879,10 @@ AttachmentsBrowser = View.extend({
|
||||||
if ( changed.length ) {
|
if ( changed.length ) {
|
||||||
selection.remove( removed );
|
selection.remove( removed );
|
||||||
|
|
||||||
$.when.apply( null, changed ).then( function() {
|
$.when.apply( null, changed ).then( _.bind( function() {
|
||||||
library._requery( true );
|
library._requery( true );
|
||||||
self.controller.trigger( 'selection:action:done' );
|
this.controller.trigger( 'selection:action:done' );
|
||||||
} );
|
}, this ) );
|
||||||
} else {
|
} else {
|
||||||
this.controller.trigger( 'selection:action:done' );
|
this.controller.trigger( 'selection:action:done' );
|
||||||
}
|
}
|
||||||
|
@ -4395,12 +4397,11 @@ EditImage = View.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
save: function() {
|
save: function() {
|
||||||
var self = this,
|
var lastState = this.controller.lastState();
|
||||||
lastState = this.controller.lastState();
|
|
||||||
|
|
||||||
this.model.fetch().done( function() {
|
this.model.fetch().done( _.bind( function() {
|
||||||
self.controller.setState( lastState );
|
this.controller.setState( lastState );
|
||||||
});
|
}, this ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -4603,8 +4604,6 @@ EmbedUrl = View.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
var self = this;
|
|
||||||
|
|
||||||
this.$input = $('<input id="embed-url-field" type="url" />').val( this.model.get('url') );
|
this.$input = $('<input id="embed-url-field" type="url" />').val( this.model.get('url') );
|
||||||
this.input = this.$input[0];
|
this.input = this.$input[0];
|
||||||
|
|
||||||
|
@ -4614,9 +4613,9 @@ EmbedUrl = View.extend({
|
||||||
this.listenTo( this.model, 'change:url', this.render );
|
this.listenTo( this.model, 'change:url', this.render );
|
||||||
|
|
||||||
if ( this.model.get( 'url' ) ) {
|
if ( this.model.get( 'url' ) ) {
|
||||||
_.delay( function () {
|
_.delay( _.bind( function () {
|
||||||
self.model.trigger( 'change:url' );
|
this.model.trigger( 'change:url' );
|
||||||
}, 500 );
|
}, this ), 500 );
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
@ -6069,18 +6068,19 @@ ImageDetails = AttachmentDisplay.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
var self = this,
|
var args = arguments;
|
||||||
args = arguments;
|
|
||||||
|
|
||||||
if ( this.model.attachment && 'pending' === this.model.dfd.state() ) {
|
if ( this.model.attachment && 'pending' === this.model.dfd.state() ) {
|
||||||
this.model.dfd.done( function() {
|
this.model.dfd
|
||||||
AttachmentDisplay.prototype.render.apply( self, args );
|
.done( _.bind( function() {
|
||||||
self.postRender();
|
AttachmentDisplay.prototype.render.apply( this, args );
|
||||||
} ).fail( function() {
|
this.postRender();
|
||||||
self.model.attachment = false;
|
}, this ) )
|
||||||
AttachmentDisplay.prototype.render.apply( self, args );
|
.fail( _.bind( function() {
|
||||||
self.postRender();
|
this.model.attachment = false;
|
||||||
} );
|
AttachmentDisplay.prototype.render.apply( this, args );
|
||||||
|
this.postRender();
|
||||||
|
}, this ) );
|
||||||
} else {
|
} else {
|
||||||
AttachmentDisplay.prototype.render.apply( this, arguments );
|
AttachmentDisplay.prototype.render.apply( this, arguments );
|
||||||
this.postRender();
|
this.postRender();
|
||||||
|
@ -7793,8 +7793,6 @@ EditorUploader = View.extend({
|
||||||
* Bind drag'n'drop events to callbacks.
|
* Bind drag'n'drop events to callbacks.
|
||||||
*/
|
*/
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
var self = this;
|
|
||||||
|
|
||||||
this.initialized = false;
|
this.initialized = false;
|
||||||
|
|
||||||
// Bail if not enabled or UA does not support drag'n'drop or File API.
|
// Bail if not enabled or UA does not support drag'n'drop or File API.
|
||||||
|
@ -7814,9 +7812,9 @@ EditorUploader = View.extend({
|
||||||
this.$document.on( 'dragover', _.bind( this.containerDragover, this ) );
|
this.$document.on( 'dragover', _.bind( this.containerDragover, this ) );
|
||||||
this.$document.on( 'dragleave', _.bind( this.containerDragleave, this ) );
|
this.$document.on( 'dragleave', _.bind( this.containerDragleave, this ) );
|
||||||
|
|
||||||
this.$document.on( 'dragstart dragend drop', function( event ) {
|
this.$document.on( 'dragstart dragend drop', _.bind( function( event ) {
|
||||||
self.localDrag = event.type === 'dragstart';
|
this.localDrag = event.type === 'dragstart';
|
||||||
});
|
}, this ) );
|
||||||
|
|
||||||
this.initialized = true;
|
this.initialized = true;
|
||||||
return this;
|
return this;
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -182,7 +182,7 @@ AttachmentsBrowser = View.extend({
|
||||||
controller: this.controller,
|
controller: this.controller,
|
||||||
priority: -60,
|
priority: -60,
|
||||||
click: function() {
|
click: function() {
|
||||||
var changed = [], removed = [], self = this,
|
var changed = [], removed = [],
|
||||||
selection = this.controller.state().get( 'selection' ),
|
selection = this.controller.state().get( 'selection' ),
|
||||||
library = this.controller.state().get( 'library' );
|
library = this.controller.state().get( 'library' );
|
||||||
|
|
||||||
|
@ -223,10 +223,10 @@ AttachmentsBrowser = View.extend({
|
||||||
if ( changed.length ) {
|
if ( changed.length ) {
|
||||||
selection.remove( removed );
|
selection.remove( removed );
|
||||||
|
|
||||||
$.when.apply( null, changed ).then( function() {
|
$.when.apply( null, changed ).then( _.bind( function() {
|
||||||
library._requery( true );
|
library._requery( true );
|
||||||
self.controller.trigger( 'selection:action:done' );
|
this.controller.trigger( 'selection:action:done' );
|
||||||
} );
|
}, this ) );
|
||||||
} else {
|
} else {
|
||||||
this.controller.trigger( 'selection:action:done' );
|
this.controller.trigger( 'selection:action:done' );
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,11 +15,9 @@ Details = EditImage.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
save: function() {
|
save: function() {
|
||||||
var self = this;
|
this.model.fetch().done( _.bind( function() {
|
||||||
|
this.frame.content.mode( 'edit-metadata' );
|
||||||
this.model.fetch().done( function() {
|
}, this ) );
|
||||||
self.frame.content.mode( 'edit-metadata' );
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -41,12 +41,11 @@ EditImage = View.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
save: function() {
|
save: function() {
|
||||||
var self = this,
|
var lastState = this.controller.lastState();
|
||||||
lastState = this.controller.lastState();
|
|
||||||
|
|
||||||
this.model.fetch().done( function() {
|
this.model.fetch().done( _.bind( function() {
|
||||||
self.controller.setState( lastState );
|
this.controller.setState( lastState );
|
||||||
});
|
}, this ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -23,8 +23,6 @@ EmbedUrl = View.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
var self = this;
|
|
||||||
|
|
||||||
this.$input = $('<input id="embed-url-field" type="url" />').val( this.model.get('url') );
|
this.$input = $('<input id="embed-url-field" type="url" />').val( this.model.get('url') );
|
||||||
this.input = this.$input[0];
|
this.input = this.$input[0];
|
||||||
|
|
||||||
|
@ -34,9 +32,9 @@ EmbedUrl = View.extend({
|
||||||
this.listenTo( this.model, 'change:url', this.render );
|
this.listenTo( this.model, 'change:url', this.render );
|
||||||
|
|
||||||
if ( this.model.get( 'url' ) ) {
|
if ( this.model.get( 'url' ) ) {
|
||||||
_.delay( function () {
|
_.delay( _.bind( function () {
|
||||||
self.model.trigger( 'change:url' );
|
this.model.trigger( 'change:url' );
|
||||||
}, 500 );
|
}, this ), 500 );
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -74,8 +74,6 @@ EditAttachments = MediaFrame.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
createModal: function() {
|
createModal: function() {
|
||||||
var self = this;
|
|
||||||
|
|
||||||
// Initialize modal container view.
|
// Initialize modal container view.
|
||||||
if ( this.options.modal ) {
|
if ( this.options.modal ) {
|
||||||
this.modal = new Modal({
|
this.modal = new Modal({
|
||||||
|
@ -83,18 +81,18 @@ EditAttachments = MediaFrame.extend({
|
||||||
title: this.options.title
|
title: this.options.title
|
||||||
});
|
});
|
||||||
|
|
||||||
this.modal.on( 'open', function () {
|
this.modal.on( 'open', _.bind( function () {
|
||||||
$( 'body' ).on( 'keydown.media-modal', _.bind( self.keyEvent, self ) );
|
$( 'body' ).on( 'keydown.media-modal', _.bind( this.keyEvent, this ) );
|
||||||
} );
|
}, this ) );
|
||||||
|
|
||||||
// Completely destroy the modal DOM element when closing it.
|
// Completely destroy the modal DOM element when closing it.
|
||||||
this.modal.on( 'close', function() {
|
this.modal.on( 'close', _.bind( function() {
|
||||||
self.modal.remove();
|
this.modal.remove();
|
||||||
$( 'body' ).off( 'keydown.media-modal' ); /* remove the keydown event */
|
$( 'body' ).off( 'keydown.media-modal' ); /* remove the keydown event */
|
||||||
// Restore the original focus item if possible
|
// Restore the original focus item if possible
|
||||||
$( 'li.attachment[data-id="' + self.model.get( 'id' ) +'"]' ).focus();
|
$( 'li.attachment[data-id="' + this.model.get( 'id' ) +'"]' ).focus();
|
||||||
self.resetRoute();
|
this.resetRoute();
|
||||||
} );
|
}, this ) );
|
||||||
|
|
||||||
// Set this frame as the modal's content.
|
// Set this frame as the modal's content.
|
||||||
this.modal.content( this );
|
this.modal.content( this );
|
||||||
|
|
|
@ -49,18 +49,19 @@ ImageDetails = AttachmentDisplay.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
var self = this,
|
var args = arguments;
|
||||||
args = arguments;
|
|
||||||
|
|
||||||
if ( this.model.attachment && 'pending' === this.model.dfd.state() ) {
|
if ( this.model.attachment && 'pending' === this.model.dfd.state() ) {
|
||||||
this.model.dfd.done( function() {
|
this.model.dfd
|
||||||
AttachmentDisplay.prototype.render.apply( self, args );
|
.done( _.bind( function() {
|
||||||
self.postRender();
|
AttachmentDisplay.prototype.render.apply( this, args );
|
||||||
} ).fail( function() {
|
this.postRender();
|
||||||
self.model.attachment = false;
|
}, this ) )
|
||||||
AttachmentDisplay.prototype.render.apply( self, args );
|
.fail( _.bind( function() {
|
||||||
self.postRender();
|
this.model.attachment = false;
|
||||||
} );
|
AttachmentDisplay.prototype.render.apply( this, args );
|
||||||
|
this.postRender();
|
||||||
|
}, this ) );
|
||||||
} else {
|
} else {
|
||||||
AttachmentDisplay.prototype.render.apply( this, arguments );
|
AttachmentDisplay.prototype.render.apply( this, arguments );
|
||||||
this.postRender();
|
this.postRender();
|
||||||
|
|
|
@ -110,10 +110,11 @@ MediaDetails = AttachmentDisplay.extend({
|
||||||
* @returns {media.view.MediaDetails} Returns itself to allow chaining
|
* @returns {media.view.MediaDetails} Returns itself to allow chaining
|
||||||
*/
|
*/
|
||||||
render: function() {
|
render: function() {
|
||||||
var self = this;
|
|
||||||
|
|
||||||
AttachmentDisplay.prototype.render.apply( this, arguments );
|
AttachmentDisplay.prototype.render.apply( this, arguments );
|
||||||
setTimeout( function() { self.resetFocus(); }, 10 );
|
|
||||||
|
setTimeout( _.bind( function() {
|
||||||
|
this.resetFocus();
|
||||||
|
}, this ), 10 );
|
||||||
|
|
||||||
this.settings = _.defaults( {
|
this.settings = _.defaults( {
|
||||||
success : this.success
|
success : this.success
|
||||||
|
|
|
@ -30,8 +30,6 @@ EditorUploader = View.extend({
|
||||||
* Bind drag'n'drop events to callbacks.
|
* Bind drag'n'drop events to callbacks.
|
||||||
*/
|
*/
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
var self = this;
|
|
||||||
|
|
||||||
this.initialized = false;
|
this.initialized = false;
|
||||||
|
|
||||||
// Bail if not enabled or UA does not support drag'n'drop or File API.
|
// Bail if not enabled or UA does not support drag'n'drop or File API.
|
||||||
|
@ -51,9 +49,9 @@ EditorUploader = View.extend({
|
||||||
this.$document.on( 'dragover', _.bind( this.containerDragover, this ) );
|
this.$document.on( 'dragover', _.bind( this.containerDragover, this ) );
|
||||||
this.$document.on( 'dragleave', _.bind( this.containerDragleave, this ) );
|
this.$document.on( 'dragleave', _.bind( this.containerDragleave, this ) );
|
||||||
|
|
||||||
this.$document.on( 'dragstart dragend drop', function( event ) {
|
this.$document.on( 'dragstart dragend drop', _.bind( function( event ) {
|
||||||
self.localDrag = event.type === 'dragstart';
|
this.localDrag = event.type === 'dragstart';
|
||||||
});
|
}, this ) );
|
||||||
|
|
||||||
this.initialized = true;
|
this.initialized = true;
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.2-alpha-31379';
|
$wp_version = '4.2-alpha-31380';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue