Avoid duplication of callbacks in theme browser sidebar each time the Next or Previous button is clicked.

This makes the collapse/expand button work as expected.

fixes #28581.
Built from https://develop.svn.wordpress.org/trunk@28868


git-svn-id: http://core.svn.wordpress.org/trunk@28668 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2014-06-27 16:06:15 +00:00
parent 819d4f972c
commit 08332b50cb
2 changed files with 5 additions and 13 deletions

View File

@ -362,7 +362,6 @@ themes.view.Theme = wp.Backbone.View.extend({
events: {
'click': themes.isInstall ? 'preview': 'expand',
'click .preview': 'preview',
'keydown': themes.isInstall ? 'preview': 'expand',
'touchend': themes.isInstall ? 'preview': 'expand',
'keyup': 'addFocus',
@ -487,7 +486,7 @@ themes.view.Theme = wp.Backbone.View.extend({
preview.$el.removeClass( 'no-navigation' );
}
// Apend preview
// Append preview
$( 'div.wrap' ).append( preview.el );
// Listen to our preview object
@ -511,15 +510,11 @@ themes.view.Theme = wp.Backbone.View.extend({
return self.current = current;
}
// Construct a new Preview view.
preview = new themes.view.Preview({
model: self.current
});
preview.model = self.current;
// Render and append.
preview.render();
this.setNavButtonsState();
$( 'div.wrap' ).append( preview.el );
$( '.next-theme' ).focus();
})
.listenTo( preview, 'theme:previous', function() {
@ -545,15 +540,11 @@ themes.view.Theme = wp.Backbone.View.extend({
return;
}
// Construct a new Preview view.
preview = new themes.view.Preview({
model: self.current
});
preview.model = self.current;
// Render and append.
preview.render();
this.setNavButtonsState();
$( 'div.wrap' ).append( preview.el );
$( '.previous-theme' ).focus();
});
@ -786,6 +777,7 @@ themes.view.Preview = themes.view.Details.extend({
themes.router.navigate( themes.router.baseUrl( '' ) );
this.trigger( 'preview:close' );
this.undelegateEvents();
this.unbind();
return false;
},

File diff suppressed because one or more lines are too long