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.

git-svn-id: https://develop.svn.wordpress.org/trunk@28868 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2014-06-27 16:05:07 +00:00
parent 0ff197f471
commit d2d985ffeb
1 changed files with 4 additions and 12 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;
},