removed redundant ribica name from subfolders

This commit is contained in:
Edin Dazdarevic
2015-01-22 22:20:34 +01:00
parent 13296062f4
commit 335e954bce
150 changed files with 18 additions and 18 deletions

14
front-ui/app/app.js Normal file
View File

@@ -0,0 +1,14 @@
var Router = require('./router'),
Backbone = require('backbone');
var App = function() {
this.bootstrap = function() {
// here goes all app initialization and bootstraping logic
this.router = new Router();
Backbone.history.start();
};
};
var app = new App();
module.exports = app;

View File

@@ -0,0 +1,30 @@
var React = require('react');
var SingleItem = require('./singleItem');
var ItemCollection = require('../models/itemCollection.js');
var ItemList = React.createClass({
render: function() {
var items = this.props.items.models.map( function(item) {
return (
<SingleItem item={item} />
);
});
return (
<div className="row-fluid">
<div className="span10">
<ul className="item_list">
{items}
</ul>
</div>
</div>
);
},
});
module.exports = ItemList;

View File

@@ -0,0 +1,61 @@
var React = require('react'),
SectionCollection = require('../models/sectionCollection'),
Section = require('../models/section');
var SectionItem = React.createClass({
subCatClicked: function() {
alert('you clicked on subcategory');
},
render: function() {
var catStyle = {
paddingLeft: '20px'
};
var subStyle = {
paddingLeft: '20px'
};
var style = {
paddingLeft: '30px'
};
var self = this;
return (
<li className="active" role='presentation'>
<a href="#">{this.props.data.get('name')}</a>
<div>
{
this.props.data.get('categories').map(function(cat) {
return (<div style={style}> {cat.name}
{ cat.sub_categories.map(function(sc) {
return <div style={subStyle} onClick={self.subCatClicked}> {sc.name} </div>
}) }
</div>)
})
}
</div>
</li>
);
}
});
var SectionsListComponent = React.createClass({
render: function() {
return (
<div className= "sections-list-component">
<ul className="nav nav-pills">
{this.props.sections.models.map(function(s){
return <SectionItem data={s}></SectionItem>
})}
</ul>
</div>
);
}
});
module.exports = SectionsListComponent;

View File

@@ -0,0 +1,23 @@
var React = require('react');
var SingleItem = React.createClass({
render: function() {
var firstImage = this.state.item.get('multi_media_descriptions')[0];
firstImage = firstImage || { url: "http://res.cloudinary.com/lfvt7ps2n/image/upload/c_crop,g_center,w_300/v1421732950/http_www.asms.ru_bitrix_templates_main_images_nophoto_irnofq.png" } ;
return (
<div className="single_item">
<img src={firstImage.url} />
<h1> { this.state.item.get('name') }</h1>
<div> { this.state.item.get('list_price') } KM </div>
</div>
);
},
getInitialState: function () {
return { item: this.props.item };
},
});
module.exports = SingleItem;

View File

@@ -0,0 +1,13 @@
var StartPageSectionsView = require('../views/startPageSectionsView'),
StartPageItemsView = require('../views/startPageItemsView');
function HomeController() {
console.log('HomeController');
var sectionsView = new StartPageSectionsView();
sectionsView.render();
var itemsView = new StartPageItemsView();
itemsView.render();
}
module.exports = HomeController;

View File

@@ -0,0 +1,22 @@
.single_item {
text-align: center;
vertical-align: center;
display: inline-block;
}
.single_item img {
padding: 5px;
}
.single_item div {
width: 315px;
}
.single_item h1 {
font-size: 15px;
text-decoration: bold;
}

3
front-ui/app/globals.js Normal file
View File

@@ -0,0 +1,3 @@
module.exports = {
ApiUrl: 'http://localhost:4567'
};

View File

@@ -0,0 +1,9 @@
var Backbone = require('backbone');
var Globals = require('../globals');
var Item = Backbone.Model.extend({
urlRoot : Globals.ApiUrl + '/item'
});
module.exports = Item;

View File

@@ -0,0 +1,38 @@
var Backbone = require('backbone'),
Item = require('./item'),
Globals = require('../globals');
var ItemCollection = Backbone.Collection.extend({
setLimit: function(limit) {
this.queryLimit = limit;
},
setOffset: function(offset) {
this.offset = offset;
},
classificationTypeUrlParts: ['','section','category','sub_category'],
setClassificationType: function(type) {
this.classificationType = type;
} ,
setClassificatonId: function(id) {
this.classificationId = id;
},
model: Item,
url: function() {
var path = '/item'
if(this.classificationType > 0) {
// eg. http://localhost:4567/item/section/1/offset/0/limit/10
var urlPart = this.classificationTypeUrlParts[this.classificationType];
path += "/" + urlPart + "/" + this.classificationId
} // else eg. http://localhost:4567/item/offset/0/limit/10
path += "/offset/" + this.offset + "/limit/" + this.queryLimit;
return Globals.ApiUrl + path;
}
});
module.exports = ItemCollection;

View File

@@ -0,0 +1,12 @@
var Backbone = require('backbone');
var Globals = require('../globals');
var Section = Backbone.Model.extend({
urlRoot : Globals.ApiUrl + '/section',
defaults : {
name: ''
}
});
module.exports = Section;

View File

@@ -0,0 +1,10 @@
var Backbone = require('backbone'),
Section = require('./section'),
Globals = require('../globals');
var SectionCollection = Backbone.Collection.extend({
model: Section,
url: Globals.ApiUrl + '/section'
});
module.exports = SectionCollection;

7
front-ui/app/ribica.js Normal file
View File

@@ -0,0 +1,7 @@
var Backbone = require('backbone');
var app = require('./app');
Backbone.$ = $;
module.exports = {
App : app
}

11
front-ui/app/router.js Normal file
View File

@@ -0,0 +1,11 @@
var Backbone = require('backbone'),
HomeController = require('./controllers/homeController');
var Router = Backbone.Router.extend({
routes : {
"home" : HomeController,
"*default": HomeController
}
});
module.exports = Router;

View File

@@ -0,0 +1,34 @@
var Backbone = require('backbone'),
React = require('react'),
ItemList = require('../components/itemList'),
ItemCollection = require('../models/itemCollection'),
Item = require('../models/item');
var StartPageItemsView = Backbone.View.extend({
el: '#content',
template: '<div class="item-list-container"></div>',
initialize: function() {
//alert('StartPageItemsView init');
},
render: function() {
this.$el.append(this.template);
var items = new ItemCollection();
items.setClassificationType(0);
items.setLimit(30);
items.setOffset(0);
var self = this;
items.fetch({success: function() {
// var resultItems = items.map(function (a) { return a.attributes });
React.render(new ItemList({
items: items
}),
self.$('.item-list-container').get(0));
}});
return this;
}
});
module.exports = StartPageItemsView;

View File

@@ -0,0 +1,35 @@
var Backbone = require('backbone'),
React = require('react'),
SectionsViewComponent = require('../components/sectionsListComponent'),
SectionCollection = require('../models/sectionCollection'),
Section = require('../models/section');
var StartPageSectionsView = Backbone.View.extend({
el: '#content',
template: '<div class="section-list-container"></div>',
initialize: function() {
//alert('StartPageSectionsView init');
},
render: function() {
this.$el.append(this.template);
var sections = new SectionCollection();
var self = this;
sections.fetch({success: function() {
console.log(sections);
React.render(new SectionsViewComponent({
handleClick: self.clickHandler.bind(self),
sections: sections
}),
self.$('.section-list-container').get(0));
}});
return this;
},
clickHandler : function() {
alert('the item was clicked!');
}
});
module.exports = StartPageSectionsView;