diff --git src/wp-admin/js/theme.js src/wp-admin/js/theme.js
index edb9bb6..fbcd0d2 100644
|
|
|
themes.view.Theme = wp.Backbone.View.extend({ |
| 443 | 443 | this.touchDrag = true; |
| 444 | 444 | }, |
| 445 | 445 | |
| | 446 | // Handles .disabled classes for previous/next buttons in theme installer preview |
| | 447 | setNavButtonsState: function() { |
| | 448 | var $themeInstaller = $( '#theme-installer' ), |
| | 449 | current = _.isUndefined( this.current ) ? this.model : this.current; |
| | 450 | |
| | 451 | // Disable previous at the zero position |
| | 452 | if ( 0 === this.model.collection.indexOf( current ) ) { |
| | 453 | $themeInstaller.find( '.previous-theme' ).addClass( 'disabled' ); |
| | 454 | } |
| | 455 | |
| | 456 | // Disable next if the next model is undefined |
| | 457 | if ( _.isUndefined( this.model.collection.at( this.model.collection.indexOf( current ) + 1 ) ) ) { |
| | 458 | $themeInstaller.find( '.next-theme' ).addClass( 'disabled' ); |
| | 459 | } |
| | 460 | }, |
| | 461 | |
| 446 | 462 | preview: function( event ) { |
| 447 | 463 | var self = this, |
| 448 | 464 | current, preview; |
| … |
… |
themes.view.Theme = wp.Backbone.View.extend({ |
| 511 | 527 | |
| 512 | 528 | // Render and append. |
| 513 | 529 | preview.render(); |
| | 530 | this.setNavButtonsState(); |
| 514 | 531 | $( 'div.wrap' ).append( preview.el ); |
| 515 | 532 | $( '.next-theme' ).focus(); |
| 516 | 533 | }) |
| … |
… |
themes.view.Theme = wp.Backbone.View.extend({ |
| 539 | 556 | |
| 540 | 557 | // Render and append. |
| 541 | 558 | preview.render(); |
| | 559 | this.setNavButtonsState(); |
| 542 | 560 | $( 'div.wrap' ).append( preview.el ); |
| 543 | 561 | $( '.previous-theme' ).focus(); |
| 544 | 562 | }); |
| | 563 | self.setNavButtonsState(); |
| 545 | 564 | } |
| 546 | 565 | }); |
| 547 | 566 | |
| … |
… |
themes.view.Details = wp.Backbone.View.extend({ |
| 676 | 695 | this.trigger( 'theme:collapse' ); |
| 677 | 696 | }, |
| 678 | 697 | |
| 679 | | // Confirmation dialoge for deleting a theme |
| | 698 | // Confirmation dialog for deleting a theme |
| 680 | 699 | deleteTheme: function() { |
| 681 | 700 | return confirm( themes.data.settings.confirmDelete ); |
| 682 | 701 | }, |
| … |
… |
themes.view.Preview = themes.view.Details.extend({ |
| 725 | 744 | html: themes.template( 'theme-preview' ), |
| 726 | 745 | |
| 727 | 746 | render: function() { |
| 728 | | var data = this.model.toJSON(); |
| | 747 | var data = this.model.toJSON(), |
| | 748 | self = this; |
| 729 | 749 | this.$el.html( this.html( data ) ); |
| 730 | 750 | |
| 731 | 751 | themes.router.navigate( themes.router.baseUrl( '?theme=' + this.model.get( 'id' ) ), { replace: true } ); |
| 732 | 752 | |
| 733 | 753 | this.$el.fadeIn( 200, function() { |
| 734 | | $( 'body' ).addClass( 'theme-installer-active full-overlay-active' ); |
| | 754 | $( 'body' ) |
| | 755 | .addClass( 'theme-installer-active full-overlay-active' ) |
| | 756 | .on( 'keyup', function( event ) { |
| | 757 | // Pressing the escape key closes the preview |
| | 758 | if ( event.keyCode === 27 ) { |
| | 759 | self.close(); |
| | 760 | } |
| | 761 | }); |
| 735 | 762 | $( '.close-full-overlay' ).focus(); |
| 736 | 763 | }); |
| 737 | 764 | }, |
| 738 | 765 | |
| 739 | 766 | close: function() { |
| 740 | 767 | this.$el.fadeOut( 200, function() { |
| 741 | | $( 'body' ).removeClass( 'theme-installer-active full-overlay-active' ); |
| | 768 | $( 'body' ).removeClass( 'theme-installer-active full-overlay-active' ).unbind( 'keyup' ); |
| 742 | 769 | |
| 743 | 770 | // Return focus to the theme div |
| 744 | 771 | if ( themes.focusedTheme ) { |