Ticket #27521: 27521.19.diff
File 27521.19.diff, 5.3 KB (added by , 11 years ago) |
---|
-
wp-admin/css/themes.css
1077 1077 ------------------------------------------------------------------------------*/ 1078 1078 1079 1079 /* Already installed theme */ 1080 .theme-browser .theme.is-installed {1081 cursor: default;1082 }1083 1080 .theme-browser .theme .theme-installed { 1084 1081 background: #0074a2; 1085 1082 } 1086 1083 .theme-browser .theme .theme-installed:before { 1087 1084 content: '\f147'; 1088 1085 } 1089 .theme-browser .theme.is-installed .theme-actions .button-primary, 1090 .theme-browser.rendered .theme.is-installed .more-details { 1086 .theme-browser .theme.is-installed .theme-actions .button-primary { 1091 1087 display: none !important; 1092 1088 } 1093 .theme-browser.rendered .theme.is-installed:hover .theme-screenshot img,1094 .theme-browser.rendered .theme.is-installed:focus .theme-screenshot img {1095 opacity: 1 !important;1096 }1097 1089 1098 1090 .theme-navigation { 1099 1091 background: #fff; -
wp-admin/js/theme.js
442 442 this.touchDrag = true; 443 443 }, 444 444 445 // Handles .disabled classes for previous/next buttons in theme installer preview446 setNavButtonsState: function() {447 var $themeInstaller = $( '.theme-install-overlay' ),448 current = _.isUndefined( this.current ) ? this.model : this.current;449 450 // Disable previous at the zero position451 if ( 0 === this.model.collection.indexOf( current ) ) {452 $themeInstaller.find( '.previous-theme' ).addClass( 'disabled' );453 }454 455 // Disable next if the next model is undefined456 if ( _.isUndefined( this.model.collection.at( this.model.collection.indexOf( current ) + 1 ) ) ) {457 $themeInstaller.find( '.next-theme' ).addClass( 'disabled' );458 }459 },460 461 445 preview: function( event ) { 462 446 var self = this, 463 447 current, preview; … … 496 480 497 481 // Render the view and append it. 498 482 preview.render(); 483 this.setNavButtonsState(); 499 484 $( 'div.wrap' ).append( preview.el ); 500 485 501 486 // Listen to our preview object … … 535 520 // Keep track of current theme model. 536 521 current = self.model; 537 522 523 // Bail early if we are at the beginning of the collection 524 if ( self.model.collection.indexOf( self.current ) === 0 ) { 525 return; 526 } 527 538 528 // If we have ventured away from current model update the current model position. 539 529 if ( ! _.isUndefined( self.current ) ) { 540 530 current = self.current; … … 559 549 $( 'div.wrap' ).append( preview.el ); 560 550 $( '.previous-theme' ).focus(); 561 551 }); 562 self.setNavButtonsState(); 552 553 this.listenTo( preview, 'preview:close', function() { 554 self.current = self.model 555 }); 556 }, 557 558 // Handles .disabled classes for previous/next buttons in theme installer preview 559 setNavButtonsState: function() { 560 var $themeInstaller = $( '.theme-install-overlay' ), 561 current = _.isUndefined( this.current ) ? this.model : this.current; 562 563 // Disable previous at the zero position 564 if ( 0 === this.model.collection.indexOf( current ) ) { 565 $themeInstaller.find( '.previous-theme' ).addClass( 'disabled' ); 566 } 567 568 // Disable next if the next model is undefined 569 if ( _.isUndefined( this.model.collection.at( this.model.collection.indexOf( current ) + 1 ) ) ) { 570 $themeInstaller.find( '.next-theme' ).addClass( 'disabled' ); 571 } 563 572 } 564 573 }); 565 574 … … 738 747 'click .close-full-overlay': 'close', 739 748 'click .collapse-sidebar': 'collapse', 740 749 'click .previous-theme': 'previousTheme', 741 'click .next-theme': 'nextTheme' 750 'click .next-theme': 'nextTheme', 751 'keyup': 'keyEvent' 742 752 }, 743 753 744 754 // The HTML template for the theme preview … … 752 762 themes.router.navigate( themes.router.baseUrl( '?theme=' + this.model.get( 'id' ) ), { replace: true } ); 753 763 754 764 this.$el.fadeIn( 200, function() { 755 $( 'body' ) 756 .addClass( 'theme-installer-active full-overlay-active' ) 757 .on( 'keyup.overlay', function( event ) { 758 // The escape key closes the preview 759 if ( event.keyCode === 27 ) { 760 self.close(); 761 } 762 // The right arrow key, next theme 763 if ( event.keyCode === 39 ) { 764 self.nextTheme(); 765 } 766 767 // The left arrow key, previous theme 768 if ( event.keyCode === 37 ) { 769 self.previousTheme(); 770 } 771 }); 765 $( 'body' ).addClass( 'theme-installer-active full-overlay-active' ); 772 766 $( '.close-full-overlay' ).focus(); 773 767 }); 774 768 }, 775 769 776 770 close: function() { 777 771 this.$el.fadeOut( 200, function() { 778 $( 'body' ).removeClass( 'theme-installer-active full-overlay-active' ) .off( 'keyup.overlay' );772 $( 'body' ).removeClass( 'theme-installer-active full-overlay-active' ); 779 773 780 774 // Return focus to the theme div 781 775 if ( themes.focusedTheme ) { … … 784 778 }); 785 779 786 780 themes.router.navigate( themes.router.baseUrl( '' ) ); 781 this.trigger( 'preview:close' ); 787 782 return false; 788 783 }, 789 784 … … 791 786 792 787 this.$el.toggleClass( 'collapsed' ).toggleClass( 'expanded' ); 793 788 return false; 789 }, 790 791 keyEvent: function( event ) { 792 // The escape key closes the preview 793 if ( event.keyCode === 27 ) { 794 this.undelegateEvents(); 795 this.close(); 796 } 797 // The right arrow key, next theme 798 if ( event.keyCode === 39 ) { 799 _.once( this.nextTheme() ); 800 } 801 802 // The left arrow key, previous theme 803 if ( event.keyCode === 37 ) { 804 this.previousTheme(); 805 } 794 806 } 795 807 }); 796 808