Changeset 1435
- Timestamp:
- 03/20/2015 04:08:38 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/js/theme.js
r1434 r1435 573 573 }); 574 574 575 // Theme Details view576 // Set ups a modal overlay with the expanded theme data575 // Theme Details view 576 // Set ups a modal overlay with the expanded theme data 577 577 themes.view.Details = wp.Backbone.View.extend({ 578 578 // Wrap theme data on a div.theme element … … 1298 1298 1299 1299 events: { 1300 'input': 'search',1301 1300 'keyup': 'search', 1302 'change': 'search', 1303 'search': 'search', 1304 'blur': 'pushState' 1301 'search': 'search' 1305 1302 }, 1306 1303 … … 1313 1310 } ); 1314 1311 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 enter1327 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 return1334 if ( this.searching && event.which !== 13 ) {1335 options.replace = true;1336 } else {1337 this.searching = true;1338 }1339 1340 // Update the URL hash1341 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 queries1362 // Listens to [theme] and [search] params1363 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 view1397 themes.view.InstallerSearch = themes.view.Search.extend({1398 1399 events: {1400 'keyup': 'search',1401 'search': 'search'1402 1312 }, 1403 1313 … … 1720 1630 }); 1721 1631 1722 themes. InstallerRouter = Backbone.Router.extend({1632 themes.Router = Backbone.Router.extend({ 1723 1633 routes: { 1724 1634 'browse/:sort/' : 'sort', … … 1753 1663 }); 1754 1664 1755 themes.Run Installer= {1665 themes.Run = { 1756 1666 init: function() { 1757 1667 // Set up the view … … 1759 1669 this.view = new themes.view.Installer({ 1760 1670 section: 'featured', 1761 SearchView: themes.view. InstallerSearch1671 SearchView: themes.view.Search 1762 1672 }); 1763 1673 … … 1785 1695 // Bind to our global `themes` object 1786 1696 // so that the router is available to sub-views 1787 themes.router = new themes. InstallerRouter();1697 themes.router = new themes.Router(); 1788 1698 1789 1699 // Handles `theme` route event … … 1841 1751 // Ready... 1842 1752 $( function() { 1843 themes.Run Installer.init();1753 themes.Run.init(); 1844 1754 }); 1845 1755
Note: See TracChangeset
for help on using the changeset viewer.