Making WordPress.org

Changeset 1435


Ignore:
Timestamp:
03/20/2015 04:08:38 AM (9 years ago)
Author:
obenland
Message:

WP.org Themes: Simplify app and remove some dead code.

See r1434.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/js/theme.js

    r1434 r1435  
    573573    });
    574574
    575 // Theme Details view
    576 // Set ups a modal overlay with the expanded theme data
     575    // Theme Details view
     576    // Set ups a modal overlay with the expanded theme data
    577577    themes.view.Details = wp.Backbone.View.extend({
    578578        // Wrap theme data on a div.theme element
     
    12981298
    12991299        events: {
    1300             'input':  'search',
    13011300            'keyup':  'search',
    1302             'change': 'search',
    1303             'search': 'search',
    1304             'blur':   'pushState'
     1301            'search': 'search'
    13051302        },
    13061303
     
    13131310            } );
    13141311
    1315         },
    1316 
    1317         // Runs a search on the theme collection.
    1318         search: function( event ) {
    1319             var options = {};
    1320 
    1321             // Clear on escape.
    1322             if ( event.type === 'keyup' && event.which === 27 ) {
    1323                 event.target.value = '';
    1324             }
    1325 
    1326             // Lose input focus when pressing enter
    1327             if ( event.which === 13 ) {
    1328                 this.$el.trigger( 'blur' );
    1329             }
    1330 
    1331             this.collection.doSearch( event.target.value );
    1332 
    1333             // if search is initiated and key is not return
    1334             if ( this.searching && event.which !== 13 ) {
    1335                 options.replace = true;
    1336             } else {
    1337                 this.searching = true;
    1338             }
    1339 
    1340             // Update the URL hash
    1341             if ( event.target.value ) {
    1342                 themes.router.navigate( themes.router.baseUrl( themes.router.searchPath + event.target.value ), options );
    1343             } else {
    1344                 themes.router.navigate( themes.router.baseUrl( '' ) );
    1345             }
    1346         },
    1347 
    1348         pushState: function( event ) {
    1349             var url = themes.router.baseUrl( '' );
    1350 
    1351             if ( event.target.value ) {
    1352                 url = themes.router.baseUrl( themes.router.searchPath + event.target.value );
    1353             }
    1354 
    1355             this.searching = false;
    1356             themes.router.navigate( url );
    1357 
    1358         }
    1359     });
    1360 
    1361     // Sets up the routes events for relevant url queries
    1362     // Listens to [theme] and [search] params
    1363     themes.Router = Backbone.Router.extend({
    1364 
    1365         routes: {
    1366             'themes.php?theme=:slug': 'theme',
    1367             'themes.php?search=:query': 'search',
    1368             'themes.php?s=:query': 'search',
    1369             'themes.php': 'themes',
    1370             '': 'themes'
    1371         },
    1372 
    1373         baseUrl: function( url ) {
    1374             return 'themes.php' + url;
    1375         },
    1376 
    1377         themePath: '?theme=',
    1378         searchPath: '?search=',
    1379 
    1380         search: function( query ) {
    1381             $( '.wp-filter-search' ).val( query );
    1382         },
    1383 
    1384         themes: function() {
    1385             $( '.wp-filter-search' ).val( '' );
    1386         },
    1387 
    1388         navigate: function() {
    1389             if ( Backbone.history._hasPushState ) {
    1390                 Backbone.Router.prototype.navigate.apply( this, arguments );
    1391             }
    1392         }
    1393 
    1394     });
    1395 
    1396     // Extend the main Search view
    1397     themes.view.InstallerSearch =  themes.view.Search.extend({
    1398 
    1399         events: {
    1400             'keyup':  'search',
    1401             'search': 'search'
    14021312        },
    14031313
     
    17201630    });
    17211631
    1722     themes.InstallerRouter = Backbone.Router.extend({
     1632    themes.Router = Backbone.Router.extend({
    17231633        routes: {
    17241634            'browse/:sort/'  : 'sort',
     
    17531663    });
    17541664
    1755     themes.RunInstaller = {
     1665    themes.Run = {
    17561666        init: function() {
    17571667            // Set up the view
     
    17591669            this.view = new themes.view.Installer({
    17601670                section: 'featured',
    1761                 SearchView: themes.view.InstallerSearch
     1671                SearchView: themes.view.Search
    17621672            });
    17631673
     
    17851695            // Bind to our global `themes` object
    17861696            // so that the router is available to sub-views
    1787             themes.router = new themes.InstallerRouter();
     1697            themes.router = new themes.Router();
    17881698
    17891699            // Handles `theme` route event
     
    18411751    // Ready...
    18421752    $( function() {
    1843         themes.RunInstaller.init();
     1753        themes.Run.init();
    18441754    });
    18451755
Note: See TracChangeset for help on using the changeset viewer.