Ticket #31793: 31793.patch
File 31793.patch, 4.9 KB (added by , 10 years ago) |
---|
-
src/wp-admin/js/customize-controls.js
552 552 currentTheme: '', 553 553 overlay: '', 554 554 template: '', 555 screenshotQueue: null, 556 $window: $( window ), 557 $customizeSidebar: $( '.wp-full-overlay-sidebar-content:first' ), 555 558 556 559 /** 557 560 * @since 4.2.0 … … 582 585 section.closeDetails(); 583 586 } 584 587 }); 588 589 _.bindAll( this, 'renderScreenshots' ); 585 590 }, 586 591 587 592 /** … … 691 696 } 692 697 }); 693 698 api.panel.each( function ( otherPanel ) { 694 if ( panel !== otherPanel ) { 695 otherPanel.collapse( { duration: 0 } ); 696 } 699 otherPanel.collapse( { duration: 0 } ); 697 700 }); 698 701 699 702 content.show( 0, function() { … … 703 706 section.addClass( 'current-panel' ); 704 707 overlay.addClass( 'in-themes-panel' ); 705 708 container.scrollTop( 0 ); 709 _.delay( panel.renderScreenshots, 10 ); // Wait for controls 710 panel.$customizeSidebar.on( 'scroll.customize-themes-section', _.throttle( panel.renderScreenshots, 300 ) ); 706 711 if ( args.completeCallback ) { 707 712 args.completeCallback(); 708 713 } … … 713 718 siblings.removeClass( 'open' ); 714 719 section.removeClass( 'current-panel' ); 715 720 overlay.removeClass( 'in-themes-panel' ); 721 panel.$customizeSidebar.off( 'scroll.customize-themes-section' ); 716 722 content.delay( 180 ).hide( 0, function() { 717 723 content.css( 'margin-top', 'inherit' ); // Reset 718 724 if ( args.completeCallback ) { … … 726 732 }, 727 733 728 734 /** 735 * Render control's screenshot if the control comes into view. 736 * 737 * @since 4.2.0 738 */ 739 renderScreenshots: function( ) { 740 var section = this; 741 742 // Fill queue initially. 743 if ( section.screenshotQueue === null ) { 744 section.screenshotQueue = section.controls(); 745 } 746 747 // Are all screenshots rendered? 748 if ( ! section.screenshotQueue.length ) { 749 return; 750 } 751 752 section.screenshotQueue = _.filter( section.screenshotQueue, function( control ) { 753 var $image = control.container.find( '.theme-screenshot img' ); 754 755 if ( ! $image.length ) { 756 return false; 757 } 758 759 // Based on unveil.js. 760 var wt = section.$window.scrollTop(), 761 wb = wt + section.$window.height(), 762 et = $image.offset().top, 763 eb = et + $image.height(), 764 threshold = 50, 765 inView = eb >= wt - threshold && et <= wb + threshold; 766 767 if ( inView ) { 768 control.container.trigger( 'render-screenshot' ); 769 } 770 771 // If the image is in view return false so it's cleared from the queue. 772 return ! inView; 773 } ); 774 }, 775 776 /** 729 777 * Advance the modal to the next theme. 730 778 * 731 779 * @since 4.2.0 … … 815 863 callback = callback || function(){}; 816 864 section.currentTheme = theme.id; 817 865 section.overlay.html( section.template( theme ) ) 818 819 866 .fadeIn( 'fast' ) 867 .focus(); 820 868 $( 'body' ).addClass( 'modal-open' ); 821 869 section.containFocus( section.overlay ); 822 870 section.updateLimits(); … … 1480 1528 1481 1529 this.params.attachment = this.params.defaultAttachment; 1482 1530 this.setting( this.params.defaultAttachment.url ); 1483 1531 }, 1484 1532 1485 1533 /** 1486 1534 * Called when the "Remove" link is clicked. Empties the setting. … … 1899 1947 1900 1948 api.section( control.section() ).showDetails( control.params.theme ); 1901 1949 }); 1950 1951 control.container.on( 'render-screenshot', function() { 1952 var $screenshot = $( this ).find( 'img' ), 1953 source = $screenshot.data( 'src' ); 1954 1955 if ( source ) { 1956 $screenshot.attr( 'src', source ); 1957 } 1958 }); 1902 1959 }, 1903 1960 1904 1961 /** … … 1908 1965 */ 1909 1966 filter: function( term ) { 1910 1967 var control = this, 1911 1912 1913 1914 1968 haystack = control.params.theme.name + ' ' + 1969 control.params.theme.description + ' ' + 1970 control.params.theme.tags + ' ' + 1971 control.params.theme.author; 1915 1972 haystack = haystack.toLowerCase().replace( '-', ' ' ); 1916 1973 if ( -1 !== haystack.search( term ) ) { 1917 1974 control.activate(); -
src/wp-includes/class-wp-customize-control.php
1205 1205 <div class="theme" tabindex="0" data-preview-url="<?php echo esc_attr( $preview_url ); ?>" aria-describedby="{{ data.theme.id }}-action {{ data.theme.id }}-name"> 1206 1206 <# if ( data.theme.screenshot[0] ) { #> 1207 1207 <div class="theme-screenshot"> 1208 <img src="{{ data.theme.screenshot[0] }}" alt="" />1208 <img data-src="{{ data.theme.screenshot[0] }}" alt="" /> 1209 1209 </div> 1210 1210 <# } else { #> 1211 1211 <div class="theme-screenshot blank"></div>