<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[27937] trunk/src/wp-admin: Theme Installer: Fix sorting, counts, keyboard navigation; add prev/next to previews.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/27937">27937</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2014-04-03 23:52:45 +0000 (Thu, 03 Apr 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Theme Installer: Fix sorting, counts, keyboard navigation; add prev/next to previews.
props matveb.
see <a href="http://core.trac.wordpress.org/ticket/27055">#27055</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadmincssthemescss">trunk/src/wp-admin/css/themes.css</a></li>
<li><a href="#trunksrcwpadminjsthemejs">trunk/src/wp-admin/js/theme.js</a></li>
<li><a href="#trunksrcwpadminthemeinstallphp">trunk/src/wp-admin/theme-install.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadmincssthemescss"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-admin/css/themes.css (27936 => 27937)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-admin/css/themes.css 2014-04-03 23:05:01 UTC (rev 27936)
+++ trunk/src/wp-admin/css/themes.css 2014-04-03 23:52:45 UTC (rev 27937)
</span><span class="lines">@@ -1289,8 +1289,11 @@
</span><span class="cx"> margin: 0 5px;
</span><span class="cx"> padding: 4px 8px;
</span><span class="cx"> }
</span><ins>+.more-filters-container .filtering-by a {
+ margin-left: 10px;
+}
</ins><span class="cx"> body.filters-applied .more-filters-container .filters-group,
</span><del>-body.filters-applied .more-filters-container a,
</del><ins>+body.filters-applied .more-filters-container a.button,
</ins><span class="cx"> body.filters-applied .more-filters-container br {
</span><span class="cx"> display: none !important;
</span><span class="cx"> }
</span><span class="lines">@@ -1509,7 +1512,7 @@
</span><span class="cx"> margin: 0;
</span><span class="cx"> z-index: 10;
</span><span class="cx"> overflow: auto;
</span><del>- background: transparent;
</del><ins>+ background: #eee;
</ins><span class="cx"> border-right: none;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1672,6 +1675,16 @@
</span><span class="cx"> display: none;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+.wp-full-overlay .theme-navigation {
+ padding: 10px 20px;
+ position: absolute;
+ bottom: 10px;
+ text-align: left;
+}
+.wp-full-overlay .theme-navigation .next-theme {
+ float: right;
+}
+
</ins><span class="cx"> /* Animations */
</span><span class="cx"> .wp-full-overlay,
</span><span class="cx"> .wp-full-overlay-sidebar,
</span><span class="lines">@@ -1750,7 +1763,7 @@
</span><span class="cx">
</span><span class="cx"> .install-theme-info {
</span><span class="cx"> display: none;
</span><del>- padding: 10px 20px 20px;
</del><ins>+ padding: 10px 20px 60px;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> .single-theme .install-theme-info {
</span></span></pre></div>
<a id="trunksrcwpadminjsthemejs"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-admin/js/theme.js (27936 => 27937)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-admin/js/theme.js 2014-04-03 23:05:01 UTC (rev 27936)
+++ trunk/src/wp-admin/js/theme.js 2014-04-03 23:52:45 UTC (rev 27937)
</span><span class="lines">@@ -215,6 +215,8 @@
</span><span class="cx"> return collection;
</span><span class="cx"> },
</span><span class="cx">
</span><ins>+ count: false,
+
</ins><span class="cx"> // Handles requests for more themes
</span><span class="cx"> // and caches results
</span><span class="cx"> //
</span><span class="lines">@@ -229,6 +231,10 @@
</span><span class="cx"> self = this,
</span><span class="cx"> query, isPaginated, count;
</span><span class="cx">
</span><ins>+ // Store current query request args
+ // for later use with the event `theme:end`
+ this.currentQuery.request = request;
+
</ins><span class="cx"> // Search the query cache for matches.
</span><span class="cx"> query = _.find( queries, function( query ) {
</span><span class="cx"> return _.isEqual( query.request, request );
</span><span class="lines">@@ -244,7 +250,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Otherwise, send a new API call and add it to the cache.
</span><del>- if ( ! query ) {
</del><ins>+ if ( ! query && ! isPaginated ) {
</ins><span class="cx"> query = this.apiCall( request ).done( function( data ) {
</span><span class="cx"> // Update the collection with the queried data.
</span><span class="cx"> self.reset( data.themes );
</span><span class="lines">@@ -260,7 +266,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Store the results and the query request
</span><del>- queries.push( { themes: data.themes, request: request } );
</del><ins>+ queries.push( { themes: data.themes, request: request, total: count } );
</ins><span class="cx"> }).fail( function() {
</span><span class="cx"> self.trigger( 'query:fail' );
</span><span class="cx"> });
</span><span class="lines">@@ -289,6 +295,14 @@
</span><span class="cx">
</span><span class="cx"> // Only trigger an update event since we already have the themes
</span><span class="cx"> // on our cached object
</span><ins>+ if ( _.isNumber( query.total ) ) {
+ this.count = query.total;
+ }
+
+ if ( ! query.total ) {
+ this.count = this.length;
+ }
+
</ins><span class="cx"> this.reset( query.themes );
</span><span class="cx"> this.trigger( 'update' );
</span><span class="cx"> }
</span><span class="lines">@@ -305,9 +319,6 @@
</span><span class="cx">
</span><span class="cx"> // Send Ajax POST request to api.wordpress.org/themes
</span><span class="cx"> apiCall: function( request, paginated ) {
</span><del>- // Store current query request args
- // for later use with the event `theme:end`
- this.currentQuery.request = request;
</del><span class="cx">
</span><span class="cx"> // Ajax request to .org API
</span><span class="cx"> return $.ajax({
</span><span class="lines">@@ -441,6 +452,9 @@
</span><span class="cx"> },
</span><span class="cx">
</span><span class="cx"> preview: function( event ) {
</span><ins>+ var self = this,
+ current;
+
</ins><span class="cx"> // Bail if the user scrolled on a touch device
</span><span class="cx"> if ( this.touchDrag === true ) {
</span><span class="cx"> return this.touchDrag = false;
</span><span class="lines">@@ -460,12 +474,74 @@
</span><span class="cx">
</span><span class="cx"> event = event || window.event;
</span><span class="cx">
</span><ins>+ // Set focus to current theme.
+ themes.focusedTheme = this.$el;
+
+ // Construct a new Preview view.
</ins><span class="cx"> var preview = new themes.view.Preview({
</span><span class="cx"> model: this.model
</span><span class="cx"> });
</span><span class="cx">
</span><ins>+ // Render the view and append it.
</ins><span class="cx"> preview.render();
</span><span class="cx"> $( 'div.wrap' ).append( preview.el );
</span><ins>+
+ // Listen to our preview object
+ // for `theme:next` and `theme:previous` events.
+ this.listenTo( preview, 'theme:next', function() {
+
+ // Keep local track of current theme model.
+ current = self.model;
+
+ // If we have ventured away from current model update the current model position.
+ if ( ! _.isUndefined( self.current ) ) {
+ current = self.current;
+ }
+
+ // Get previous theme model.
+ self.current = self.model.collection.at( self.model.collection.indexOf( current ) + 1 );
+
+ // If we have no more themes, bail.
+ if ( _.isUndefined( self.current ) ) {
+ return self.current = current;
+ }
+
+ // Construct a new Preview view.
+ preview = new themes.view.Preview({
+ model: self.current
+ });
+
+ // Render and append.
+ preview.render();
+ $( 'div.wrap' ).append( preview.el );
+ })
+ .listenTo( preview, 'theme:previous', function() {
+
+ // Keep track of current theme model.
+ current = self.model;
+
+ // If we have ventured away from current model update the current model position.
+ if ( ! _.isUndefined( self.current ) ) {
+ current = self.current;
+ }
+
+ // Get previous theme model.
+ self.current = self.model.collection.at( self.model.collection.indexOf( current ) - 1 );
+
+ // If we have no more themes, bail.
+ if ( _.isUndefined( self.current ) ) {
+ return;
+ }
+
+ // Construct a new Preview view.
+ preview = new themes.view.Preview({
+ model: self.current
+ });
+
+ // Render and append.
+ preview.render();
+ $( 'div.wrap' ).append( preview.el );
+ });
</ins><span class="cx"> }
</span><span class="cx"> });
</span><span class="cx">
</span><span class="lines">@@ -633,14 +709,16 @@
</span><span class="cx">
</span><span class="cx"> // Theme Preview view
</span><span class="cx"> // Set ups a modal overlay with the expanded theme data
</span><del>-themes.view.Preview = wp.Backbone.View.extend({
</del><ins>+themes.view.Preview = themes.view.Details.extend({
</ins><span class="cx">
</span><span class="cx"> className: 'wp-full-overlay expanded',
</span><span class="cx"> el: '#theme-installer',
</span><span class="cx">
</span><span class="cx"> events: {
</span><span class="cx"> 'click .close-full-overlay': 'close',
</span><del>- 'click .collapse-sidebar': 'collapse'
</del><ins>+ 'click .collapse-sidebar': 'collapse',
+ 'click .previous-theme': 'previousTheme',
+ 'click .next-theme': 'nextTheme'
</ins><span class="cx"> },
</span><span class="cx">
</span><span class="cx"> // The HTML template for the theme preview
</span><span class="lines">@@ -654,12 +732,18 @@
</span><span class="cx">
</span><span class="cx"> this.$el.fadeIn( 200, function() {
</span><span class="cx"> $( 'body' ).addClass( 'theme-installer-active full-overlay-active' );
</span><ins>+ $( '.close-full-overlay' ).focus();
</ins><span class="cx"> });
</span><span class="cx"> },
</span><span class="cx">
</span><span class="cx"> close: function() {
</span><span class="cx"> this.$el.fadeOut( 200, function() {
</span><span class="cx"> $( 'body' ).removeClass( 'theme-installer-active full-overlay-active' );
</span><ins>+
+ // Return focus to the theme div
+ if ( themes.focusedTheme ) {
+ themes.focusedTheme.focus();
+ }
</ins><span class="cx"> });
</span><span class="cx">
</span><span class="cx"> themes.router.navigate( themes.router.baseUrl( '' ) );
</span><span class="lines">@@ -782,7 +866,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Display a live theme count for the collection
</span><del>- this.count.text( this.collection.length );
</del><ins>+ this.count.text( this.collection.count ? this.collection.count : this.collection.length );
</ins><span class="cx"> },
</span><span class="cx">
</span><span class="cx"> // Iterates through each instance of the collection
</span><span class="lines">@@ -1143,6 +1227,9 @@
</span><span class="cx"> request.tag = [ value.slice( 4 ) ];
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ $( '.theme-section.current' ).removeClass( 'current' );
+ $( 'body' ).removeClass( 'more-filters-opened filters-applied' );
+
</ins><span class="cx"> // Get the themes by sending Ajax POST request to api.wordpress.org/themes
</span><span class="cx"> // or searching the local cache
</span><span class="cx"> this.collection.query( request );
</span><span class="lines">@@ -1161,7 +1248,8 @@
</span><span class="cx"> 'click .apply-filters': 'addFilter',
</span><span class="cx"> 'click [type="checkbox"]': 'filtersChecked',
</span><span class="cx"> 'click .clear-filters': 'clearFilters',
</span><del>- 'click .feature-name': 'filterSection'
</del><ins>+ 'click .feature-name': 'filterSection',
+ 'click .filtering-by a': 'backToFilters'
</ins><span class="cx"> },
</span><span class="cx">
</span><span class="cx"> // Handles all the rendering of the public theme directory
</span><span class="lines">@@ -1297,6 +1385,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> $( 'body' ).addClass( 'filters-applied' );
</span><ins>+ $( '.theme-section.current' ).removeClass( 'current' );
</ins><span class="cx"> filteringBy.empty();
</span><span class="cx">
</span><span class="cx"> _.each( tags, function( tag ) {
</span><span class="lines">@@ -1355,7 +1444,7 @@
</span><span class="cx"> event.preventDefault();
</span><span class="cx">
</span><span class="cx"> if ( $( 'body' ).hasClass( 'filters-applied' ) ) {
</span><del>- return $( 'body' ).removeClass( 'filters-applied' );
</del><ins>+ return this.backToFilters();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // If the filters section is opened and filters are checked
</span><span class="lines">@@ -1384,6 +1473,10 @@
</span><span class="cx"> $( item ).prop( 'checked', false );
</span><span class="cx"> return self.filtersChecked();
</span><span class="cx"> });
</span><ins>+ },
+
+ backToFilters: function() {
+ $( 'body' ).removeClass( 'filters-applied' );
</ins><span class="cx"> }
</span><span class="cx"> });
</span><span class="cx">
</span></span></pre></div>
<a id="trunksrcwpadminthemeinstallphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-admin/theme-install.php (27936 => 27937)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-admin/theme-install.php 2014-04-03 23:05:01 UTC (rev 27936)
+++ trunk/src/wp-admin/theme-install.php 2014-04-03 23:52:45 UTC (rev 27937)
</span><span class="lines">@@ -145,11 +145,11 @@
</span><span class="cx"> <div class="filtering-by">
</span><span class="cx"> <span><?php _e( 'Filtering by:' ); ?></span>
</span><span class="cx"> <div class="tags"></div>
</span><ins>+ <a href="#"><?php _e( 'Edit' ); ?></a>
</ins><span class="cx"> </div>
</span><span class="cx"> </div>
</span><span class="cx"> </div>
</span><span class="cx"> <div class="theme-browser"></div>
</span><del>- <div class="theme-overlay"></div>
</del><span class="cx"> <div id="theme-installer" class="wp-full-overlay expanded"></div>
</span><span class="cx">
</span><span class="cx"> <p class="no-themes"><?php _e( 'No themes found. Try a different search.' ); ?></p>
</span><span class="lines">@@ -224,6 +224,10 @@
</span><span class="cx"> <span class="collapse-sidebar-label"><?php _e( 'Collapse' ); ?></span>
</span><span class="cx"> <span class="collapse-sidebar-arrow"></span>
</span><span class="cx"> </a>
</span><ins>+ <div class="theme-navigation">
+ <a class="previous-theme button" href="#"><?php _e( 'Previous' ); ?></a>
+ <a class="next-theme button" href="#"><?php _e( 'Next' ); ?></a>
+ </div>
</ins><span class="cx"> </div>
</span><span class="cx"> </div>
</span><span class="cx"> <div class="wp-full-overlay-main">
</span></span></pre>
</div>
</div>
</body>
</html>