X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/849f15aeed7a5e39314057bdc0064d8edd60dd7d..refs/tags/wordpress-4.4-scripts:/wp-admin/js/theme.js
diff --git a/wp-admin/js/theme.js b/wp-admin/js/theme.js
index 344a8178..1a91279b 100644
--- a/wp-admin/js/theme.js
+++ b/wp-admin/js/theme.js
@@ -79,12 +79,12 @@ themes.view.Appearance = wp.Backbone.View.extend({
// Render and append
this.view.render();
- this.$el.empty().append( this.view.el ).addClass('rendered');
+ this.$el.empty().append( this.view.el ).addClass( 'rendered' );
this.$el.append( '
' );
},
// Defines search element container
- searchContainer: $( '#wpbody h2:first' ),
+ searchContainer: $( '#wpbody h1:first' ),
// Search input and view
// for current theme collection
@@ -156,6 +156,7 @@ themes.Collection = Backbone.Collection.extend({
// Useful for resetting the views when you clean the input
if ( this.terms === '' ) {
this.reset( themes.data.themes );
+ $( 'body' ).removeClass( 'no-results' );
}
// Trigger an 'update' event
@@ -165,7 +166,7 @@ themes.Collection = Backbone.Collection.extend({
// Performs a search within the collection
// @uses RegExp
search: function( term ) {
- var match, results, haystack;
+ var match, results, haystack, name, description, author;
// Start with a full collection
this.reset( themes.data.themes, { silent: true } );
@@ -181,7 +182,11 @@ themes.Collection = Backbone.Collection.extend({
// Find results
// _.filter and .test
results = this.filter( function( data ) {
- haystack = _.union( data.get( 'name' ), data.get( 'id' ), data.get( 'description' ), data.get( 'author' ), data.get( 'tags' ) );
+ name = data.get( 'name' ).replace( /(<([^>]+)>)/ig, '' );
+ description = data.get( 'description' ).replace( /(<([^>]+)>)/ig, '' );
+ author = data.get( 'author' ).replace( /(<([^>]+)>)/ig, '' );
+
+ haystack = _.union( name, data.get( 'id' ), description, author, data.get( 'tags' ) );
if ( match.test( data.get( 'author' ) ) && term.length > 2 ) {
data.set( 'displayAuthor', true );
@@ -449,6 +454,8 @@ themes.view.Theme = wp.Backbone.View.extend({
var self = this,
current, preview;
+ event = event || window.event;
+
// Bail if the user scrolled on a touch device
if ( this.touchDrag === true ) {
return this.touchDrag = false;
@@ -759,9 +766,10 @@ themes.view.Preview = themes.view.Details.extend({
html: themes.template( 'theme-preview' ),
render: function() {
- var data = this.model.toJSON();
+ var self = this,
+ data = this.model.toJSON();
- this.$el.html( this.html( data ) );
+ this.$el.removeClass( 'iframe-ready' ).html( this.html( data ) );
themes.router.navigate( themes.router.baseUrl( themes.router.themePath + this.model.get( 'id' ) ), { replace: true } );
@@ -769,6 +777,14 @@ themes.view.Preview = themes.view.Details.extend({
$( 'body' ).addClass( 'theme-installer-active full-overlay-active' );
$( '.close-full-overlay' ).focus();
});
+
+ this.$el.find( 'iframe' ).one( 'load', function() {
+ self.iframeLoaded();
+ });
+ },
+
+ iframeLoaded: function() {
+ this.$el.addClass( 'iframe-ready' );
},
close: function() {
@@ -779,7 +795,7 @@ themes.view.Preview = themes.view.Details.extend({
if ( themes.focusedTheme ) {
themes.focusedTheme.focus();
}
- });
+ }).removeClass( 'iframe-ready' );
themes.router.navigate( themes.router.baseUrl( '' ) );
this.trigger( 'preview:close' );
@@ -788,7 +804,13 @@ themes.view.Preview = themes.view.Details.extend({
return false;
},
- collapse: function() {
+ collapse: function( event ) {
+ var $button = $( event.currentTarget );
+ if ( 'true' === $button.attr( 'aria-expanded' ) ) {
+ $button.attr({ 'aria-expanded': 'false', 'aria-label': l10n.expandSidebar });
+ } else {
+ $button.attr({ 'aria-expanded': 'true', 'aria-label': l10n.collapseSidebar });
+ }
this.$el.toggleClass( 'collapsed' ).toggleClass( 'expanded' );
return false;
@@ -824,7 +846,10 @@ themes.view.Themes = wp.Backbone.View.extend({
index: 0,
// The theme count element
- count: $( '.wp-filter .theme-count' ),
+ count: $( '.wp-core-ui .theme-count' ),
+
+ // The live themes count
+ liveThemeCount: 0,
initialize: function( options ) {
var self = this;
@@ -849,8 +874,10 @@ themes.view.Themes = wp.Backbone.View.extend({
this.listenTo( self.collection, 'query:success', function( count ) {
if ( _.isNumber( count ) ) {
self.count.text( count );
+ self.announceSearchResults( count );
} else {
self.count.text( self.collection.length );
+ self.announceSearchResults( self.collection.length );
}
});
@@ -895,7 +922,7 @@ themes.view.Themes = wp.Backbone.View.extend({
// and keeping theme count in sync
render: function() {
// Clear the DOM, please
- this.$el.html( '' );
+ this.$el.empty();
// If the user doesn't have switch capabilities
// or there is only one theme in the collection
@@ -921,7 +948,10 @@ themes.view.Themes = wp.Backbone.View.extend({
}
// Display a live theme count for the collection
- this.count.text( this.collection.count ? this.collection.count : this.collection.length );
+ this.liveThemeCount = this.collection.count ? this.collection.count : this.collection.length;
+ this.count.text( this.liveThemeCount );
+
+ this.announceSearchResults( this.liveThemeCount );
},
// Iterates through each instance of the collection
@@ -939,7 +969,7 @@ themes.view.Themes = wp.Backbone.View.extend({
}
// Make sure the add-new stays at the end
- if ( page >= 1 ) {
+ if ( ! themes.isInstall && page >= 1 ) {
$( '.add-new-theme' ).remove();
}
@@ -961,8 +991,8 @@ themes.view.Themes = wp.Backbone.View.extend({
});
// 'Add new theme' element shown at the end of the grid
- if ( themes.data.settings.canInstall ) {
- this.$el.append( '