suggested articles / email is now sent

This commit is contained in:
Senad Uka
2015-09-21 06:31:52 +02:00
parent 2a4800fdab
commit 56f9c7b72b
10 changed files with 158 additions and 30 deletions

View File

@@ -0,0 +1,50 @@
var React = require('react');
var ItemList = require('./itemList');
var ItemStore = require('../../stores/itemStore.js');
var ItemActions = require('../../actions/itemActions.js');
var ItemCollection = require('../../models/itemCollection');
var RandomItems = React.createClass({
render: function() {
return (
<ItemList items={this.state.items} />
);
},
// Add change listeners to stores
componentDidMount: function() {
ItemActions.loadFrontPageItems();
ItemStore.addChangeListener(this._onChange);
},
componentWillUnmount: function () {
ItemStore.removeChangeListener(this._onChange);
},
getInitialState: function() {
return {
items: this.getRandomItems()
}
},
getRandomItems: function() {
var NUMBER_OF_SUGGESTED_ITEMS = 8;
var allItems = ItemStore.getItems();
var randomIndexStart = Math.floor(Math.random() * ((allItems.models.length - NUMBER_OF_SUGGESTED_ITEMS + 1)));
allItems.models = allItems.models.slice(randomIndexStart, randomIndexStart + NUMBER_OF_SUGGESTED_ITEMS);
return allItems;
},
_onChange: function () {
this.setState({
items: this.getRandomItems()
});
},
});
module.exports = RandomItems;

View File

@@ -2,6 +2,7 @@ var React = require('react'),
Router = require('react-router'),
RouteHandler = Router.RouteHandler,
AllItems = require('../items/allItems'),
RandomItems = require('../items/randomItems'),
LinkBanner = require('../linkBanner/linkBanner'),
AllItemsInGroup = require('../items/allItemsInGroup');
@@ -16,7 +17,9 @@ var StartPage = React.createClass({
<div className='col-md-12'>
<LinkBanner locationName="startPage" />
<AllItemsInGroup />
<RouteHandler />
<h2>Preporučeno</h2>
<RandomItems />
</div>
<GAInitiailizer />
</div>

View File

@@ -529,3 +529,7 @@ text-decoration: none;
font-size: 29px;
color: #06c3c3;
}
.footer {
text-align: center;
}

File diff suppressed because one or more lines are too long

View File

@@ -21,6 +21,9 @@
<img height={50} src="https://res.cloudinary.com/du5pdibul/image/upload/v1434870249/progress_bar_idgtad.gif" />
</div>
<script src='/ribica.js' type='text/javascript'></script>
<div class="footer">
© Ribica.ba 2015.
</div>
<script type='text/javascript'>
RIBICA.App.bootstrap();
</script>