Ticket #27055: 27055.39.diff
| File 27055.39.diff, 7.6 KB (added by , 12 years ago) |
|---|
-
wp-admin/css/themes.css
216 216 * Displays a theme update notice 217 217 * when an update is available. 218 218 */ 219 .theme-browser .theme .theme-update { 219 .theme-browser .theme .theme-update, 220 .theme-browser .theme .theme-installed { 220 221 background: #d54e21; 221 222 background: rgba(213, 78, 33, 0.95); 222 223 color: #fff; … … 234 235 overflow: hidden; 235 236 } 236 237 237 .theme-browser .theme .theme-update:before { 238 .theme-browser .theme .theme-update:before, 239 .theme-browser .theme .theme-installed:before { 238 240 content: '\f463'; 239 241 display: inline-block; 240 242 font: normal 20px/1 'dashicons'; … … 1074 1076 16.2 - Install Themes 1075 1077 ------------------------------------------------------------------------------*/ 1076 1078 1079 /* Already installed theme */ 1080 .theme-browser .theme.is-installed { 1081 cursor: default; 1082 } 1083 .theme-browser .theme .theme-installed { 1084 background: #0074a2; 1085 } 1086 .theme-browser .theme .theme-installed:before { 1087 content: '\f147'; 1088 } 1089 .theme-browser .theme.is-installed .theme-actions, 1090 .theme-browser.rendered .theme.is-installed .more-details { 1091 display: none !important; 1092 } 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 1077 1098 .theme-navigation { 1078 1099 background: #fff; 1079 1100 -webkit-box-shadow: 0 1px 1px 0 rgba(0,0,0,.1); -
wp-admin/js/theme.js
22 22 // Adds attributes to the default data coming through the .org themes api 23 23 // Map `id` to `slug` for shared code 24 24 initialize: function() { 25 var install, preview;25 var install, installed; 26 26 27 27 // Install url for the theme 28 28 // using the install nonce … … 35 35 // Build the url query 36 36 install = themes.data.settings.updateURI + '?' + $.param( install ); 37 37 38 // Preview url for the theme 39 preview = { 40 tab: 'theme-information', 41 theme: this.get( 'slug' ) 42 }; 38 // If theme is already installed, set an attribute. 39 if ( _.indexOf( themes.data.installedThemes, this.get( 'slug' ) ) !== -1 ) { 40 this.set({ installed: true }); 41 } 43 42 44 preview = themes.data.settings.installURI + '?' + $.param( preview );45 46 43 // Set the attributes 47 44 this.set({ 48 installURI: install, 49 previewURI: preview, 45 installURI: ( this.get( 'slug' ) ) ? install : false, 50 46 // slug is for installation, id is for existing. 51 47 id: this.get( 'slug' ) || this.get( 'id' ) 52 48 }); … … 391 387 if ( this.model.get( 'displayAuthor' ) ) { 392 388 this.$el.addClass( 'display-author' ); 393 389 } 390 391 if ( this.model.get( 'installed' ) ) { 392 this.$el.addClass( 'is-installed' ); 393 this.$el.unbind(); 394 } 394 395 }, 395 396 396 397 // Adds a class to the currently active theme … … 451 452 return this.touchDrag = false; 452 453 } 453 454 455 // Allow direct link path to installing a theme. 456 if ( $( event.target ).hasClass( 'button-primary' ) ) { 457 return; 458 } 459 454 460 // 'enter' and 'space' keys expand the details view when a theme is :focused 455 461 if ( event.type === 'keydown' && ( event.which !== 13 && event.which !== 32 ) ) { 456 462 return; … … 494 500 495 501 // If we have no more themes, bail. 496 502 if ( _.isUndefined( self.current ) ) { 503 self.options.parent.parent.trigger( 'theme:end' ); 497 504 return self.current = current; 498 505 } 499 506 … … 505 512 // Render and append. 506 513 preview.render(); 507 514 $( 'div.wrap' ).append( preview.el ); 515 $( '.next-theme' ).focus(); 508 516 }) 509 517 .listenTo( preview, 'theme:previous', function() { 510 518 … … 532 540 // Render and append. 533 541 preview.render(); 534 542 $( 'div.wrap' ).append( preview.el ); 543 $( '.previous-theme' ).focus(); 535 544 }); 536 545 } 537 546 }); … … 882 891 // Loop through the themes and setup each theme view 883 892 self.instance.each( function( theme ) { 884 893 self.theme = new themes.view.Theme({ 885 model: theme 894 model: theme, 895 parent: self 886 896 }); 887 897 888 898 // Render the views... … … 1158 1168 1159 1169 // Handles search route event 1160 1170 themes.router.on( 'route:search', function( query ) { 1161 self.view.trigger( 'theme:close' ); 1162 self.themes.doSearch( query ); 1171 $( '.theme-search' ).trigger( 'keyup' ); 1163 1172 }); 1164 1173 1165 1174 this.extraRoutes(); … … 1224 1233 // Get the themes by sending Ajax POST request to api.wordpress.org/themes 1225 1234 // or searching the local cache 1226 1235 this.collection.query( request ); 1236 1237 // Set route 1238 themes.router.navigate( themes.router.baseUrl( '?search=' + value ), { replace: true } ); 1227 1239 }, 300 ) 1228 1240 }); 1229 1241 … … 1329 1341 }, 1330 1342 1331 1343 sort: function( sort ) { 1332 $( '#theme-search-input' ).val( '');1344 this.clearSearch(); 1333 1345 1334 1346 $( '.theme-section, .theme-filter' ).removeClass( this.activeClass ); 1335 1347 $( '[data-sort="' + sort + '"]' ).addClass( this.activeClass ); … … 1450 1462 return this.addFilter(); 1451 1463 } 1452 1464 1465 this.clearSearch(); 1466 1467 themes.router.navigate( themes.router.baseUrl( '' ) ); 1453 1468 $( 'body' ).toggleClass( 'more-filters-opened' ); 1454 1469 }, 1455 1470 … … 1474 1489 1475 1490 backToFilters: function() { 1476 1491 $( 'body' ).removeClass( 'filters-applied' ); 1492 }, 1493 1494 clearSearch: function() { 1495 $( '#theme-search-input').val( '' ); 1477 1496 } 1478 1497 }); 1479 1498 … … 1482 1501 'theme-install.php?theme=:slug': 'preview', 1483 1502 'theme-install.php?sort=:sort': 'sort', 1484 1503 'theme-install.php?upload': 'upload', 1504 'theme-install.php?search=:query': 'search', 1485 1505 '': 'sort' 1486 1506 }, 1487 1507 1488 1508 baseUrl: function( url ) { 1489 1509 return 'theme-install.php' + url; 1490 } 1510 }, 1511 1512 search: function( query ) { 1513 $( '.theme-search' ).val( query ); 1514 }, 1491 1515 }); 1492 1516 1493 1517 … … 1542 1566 $( 'a.upload' ).trigger( 'click' ); 1543 1567 }); 1544 1568 1569 // Handles search route event 1570 themes.router.on( 'route:search', function( query ) { 1571 $( '.theme-search' ).focus().trigger( 'keyup' ); 1572 }); 1573 1545 1574 this.extraRoutes(); 1546 1575 }, 1547 1576 -
wp-admin/theme-install.php
33 33 'new' => __( 'Newest Themes' ), 34 34 ); 35 35 36 $installed_themes = search_theme_directories(); 37 foreach ( $installed_themes as $k => $v ) { 38 if ( false !== strpos( $k, '/' ) ) { 39 unset( $installed_themes[ $k ] ); 40 } 41 } 42 36 43 wp_localize_script( 'theme', '_wpThemeSettings', array( 37 44 'themes' => false, 38 45 'settings' => array( … … 51 58 'back' => __( 'Back' ), 52 59 'error' => ( 'There was a problem trying to load the themes. Please, try again.' ), // @todo improve 53 60 ), 61 'installedThemes' => array_keys( $installed_themes ), 54 62 'browse' => array( 55 63 'sections' => $sections, 56 64 ), … … 190 198 <a class="button button-primary" href="{{ data.installURI }}"><?php esc_html_e( 'Install' ); ?></a> 191 199 <a class="button button-secondary preview install-theme-preview" href="#"><?php esc_html_e( 'Preview' ); ?></a> 192 200 </div> 201 202 <# if ( data.installed ) { #> 203 <div class="theme-installed"><?php _e( 'Already Installed' ); ?></div> 204 <# } #> 193 205 </script> 194 206 195 207 <script id="tmpl-theme-preview" type="text/template"> 196 208 <div class="wp-full-overlay-sidebar"> 197 209 <div class="wp-full-overlay-header"> 198 210 <a href="#" class="close-full-overlay button-secondary"><?php _e( 'Close' ); ?></a> 211 <# if ( data.installed ) { #> 212 <a href="#" class="button button-primary theme-install disabled"><?php _e( 'Installed' ); ?></a> 213 <# } else { #> 199 214 <a href="{{ data.installURI }}" class="button button-primary theme-install"><?php _e( 'Install' ); ?></a> 215 <# } #> 200 216 </div> 201 217 <div class="wp-full-overlay-sidebar-content"> 202 218 <div class="install-theme-info">