diff --git a/src/views/explore/explore.jsx b/src/views/explore/explore.jsx index 2812063e8..3a17a8ae5 100644 --- a/src/views/explore/explore.jsx +++ b/src/views/explore/explore.jsx @@ -9,6 +9,9 @@ var api = require('../../lib/api'); var Page = require('../../components/page/www/page.jsx'); var Tabs = require('../../components/tabs/tabs.jsx'); var TitleBanner = require('../../components/title-banner/title-banner.jsx'); +var Button = require('../../components/forms/button.jsx'); +var Form = require('../../components/forms/form.jsx'); +var Select = require('../../components/forms/select.jsx'); var SubNavigation = require('../../components/subnavigation/subnavigation.jsx'); var Grid = require('../../components/grid/grid.jsx'); @@ -27,16 +30,19 @@ var Explore = injectIntl(React.createClass({ stories: 'stories' }; var typeOptions = ['projects','studios']; + var modeOptions = ['trending', 'popular', 'recent', '']; var pathname = window.location.pathname.toLowerCase(); if (pathname[pathname.length - 1] === '/') { pathname = pathname.substring(0, pathname.length - 1); } - var slash = pathname.lastIndexOf('/'); - var currentCategory = pathname.substring(slash + 1,pathname.length); - var typeStart = pathname.indexOf('explore/'); - var type = pathname.substring(typeStart + 8,slash); - if (Object.keys(categoryOptions).indexOf(currentCategory) === -1 || typeOptions.indexOf(type) === -1) { + var options = pathname.split('/'); + var type = options[2]; + var currentCategory = options[3]; + var currentMode = options.length > 4 ? options[4] : ''; + if (Object.keys(categoryOptions).indexOf(currentCategory) === -1 || + typeOptions.indexOf(type) === -1 || + modeOptions.indexOf(currentMode) === -1){ window.location = window.location.origin + '/explore/projects/all/'; } @@ -44,7 +50,9 @@ var Explore = injectIntl(React.createClass({ category: currentCategory, acceptableTabs: categoryOptions, acceptableTypes: typeOptions, + acceptableModes: modeOptions, itemType: type, + mode: currentMode, loadNumber: 16 }; }, @@ -65,6 +73,7 @@ var Explore = injectIntl(React.createClass({ '?limit=' + this.props.loadNumber + '&offset=' + this.state.offset + '&language=' + this.props.intl.locale + + '&mode=' + (this.props.mode ? this.props.mode : 'trending') + qText }, function (err, body) { if (!err) { @@ -84,14 +93,20 @@ var Explore = injectIntl(React.createClass({ break; } } - window.location = window.location.origin + '/explore/' + newType + '/' + this.props.tab; + window.location = window.location.origin + '/explore/' + newType + '/' + this.props.tab + '/' + this.props.mode; + }, + changeSortMode: function (name, value) { + if (this.props.acceptableModes.indexOf(value) !== -1) { + window.location = window.location.origin + '/explore/' + + this.props.itemType + '/' + this.props.category + '/' + value; + } }, getBubble: function (type) { var classes = classNames({ active: (this.props.category === type) }); return ( - +
  • @@ -100,15 +115,16 @@ var Explore = injectIntl(React.createClass({ }, getTab: function (type) { var classes = classNames({ - active: (this.props.itemType === type) + active: (this.props.itemType === type), + inactive: (this.props.itemType !== type) }); return ( -
    +
  • {this.props.itemType === type ? [ - + ] : [ - + ]}
  • @@ -130,29 +146,37 @@ var Explore = injectIntl(React.createClass({ {this.getTab('projects')} {this.getTab('studios')} - - {this.getBubble('all')} - {this.getBubble('animations')} - {this.getBubble('art')} - {this.getBubble('games')} - {this.getBubble('music')} - {this.getBubble('stories')} - +
    + + {this.getBubble('all')} + {this.getBubble('animations')} + {this.getBubble('art')} + {this.getBubble('games')} + {this.getBubble('music')} + {this.getBubble('stories')} + +
    +