|
@@ -90,42 +90,14 @@ var data = {
|
|
|
productView: {
|
|
productView: {
|
|
|
list: true,
|
|
list: true,
|
|
|
description: false
|
|
description: false
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-var view = rivets.bind(app, {
|
|
|
|
|
- sections: sections,
|
|
|
|
|
- selectedSection: selectedSection_,
|
|
|
|
|
- productCategories: productCategories_,
|
|
|
|
|
- data: data,
|
|
|
|
|
- selectedCategory: selectedCategory_,
|
|
|
|
|
- selectSection: function(event, scope) {
|
|
|
|
|
- var newValue = event.target.text;
|
|
|
|
|
- window.history.pushState({}, newValue, '#' + newValue)
|
|
|
|
|
- chooseSection(newValue);
|
|
|
|
|
- event.target.className = 'selected';
|
|
|
|
|
- scope.getData[newValue]();
|
|
|
|
|
- },
|
|
|
|
|
- selectCategory: function(event, scope) {
|
|
|
|
|
- data.productView.list = true;
|
|
|
|
|
- data.productView.description = false;
|
|
|
|
|
- var category = productCategories_.find(R.propEq('name', event.target.text));
|
|
|
|
|
- var categoryList = getElement('ul#product-category-nav > li > a')
|
|
|
|
|
- data.selectedCategory = category;
|
|
|
|
|
- getProducts(category._id);
|
|
|
|
|
- addSelectedClass(categoryList, category.name);
|
|
|
|
|
},
|
|
},
|
|
|
- seeProduct: function(event, scope) {
|
|
|
|
|
- data.productView.list = false;
|
|
|
|
|
- data.productView.description = true;
|
|
|
|
|
- data.productDescription = data.products.find(R.propEq('name', event.target.text));
|
|
|
|
|
- },
|
|
|
|
|
- getData: {
|
|
|
|
|
|
|
+ getSectionData: {
|
|
|
productos: getCategories,
|
|
productos: getCategories,
|
|
|
- empresa: function() {},
|
|
|
|
|
- verMas: function() {}
|
|
|
|
|
|
|
+ empresa: function() {}
|
|
|
}
|
|
}
|
|
|
-});
|
|
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
|
|
|
function getElement(selector) {
|
|
function getElement(selector) {
|
|
|
return window.document.querySelectorAll(selector);
|
|
return window.document.querySelectorAll(selector);
|
|
@@ -133,7 +105,8 @@ function getElement(selector) {
|
|
|
|
|
|
|
|
function chooseSection(section) {
|
|
function chooseSection(section) {
|
|
|
var navbarList = getElement('ul.navbar-list > li > a');
|
|
var navbarList = getElement('ul.navbar-list > li > a');
|
|
|
- addSelectedClass(navbarList, section, selectedSection_)
|
|
|
|
|
|
|
+ addSelectedClass(navbarList, section, selectedSection_);
|
|
|
|
|
+ data.getSectionData[section]();
|
|
|
}
|
|
}
|
|
|
var elements = [];
|
|
var elements = [];
|
|
|
|
|
|
|
@@ -145,6 +118,11 @@ function addSelectedClass(elemList, x, opt) {
|
|
|
opt[el.text] = isSelected;
|
|
opt[el.text] = isSelected;
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
|
|
+ if (opt) {
|
|
|
|
|
+ sections.forEach(function (s) {
|
|
|
|
|
+ opt[s] = s === x;
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
window.onscroll = function() {
|
|
window.onscroll = function() {
|
|
@@ -172,5 +150,35 @@ function isInViewport(element) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
window.onload = function() {
|
|
window.onload = function() {
|
|
|
- chooseSection(window.location.hash.substr(1));
|
|
|
|
|
|
|
+ var section = window.location.hash.substr(1)
|
|
|
|
|
+ if (section !== '') {
|
|
|
|
|
+ chooseSection(section);
|
|
|
|
|
+ }
|
|
|
|
|
+ var view = rivets.bind(app, {
|
|
|
|
|
+ sections: sections,
|
|
|
|
|
+ selectedSection: selectedSection_,
|
|
|
|
|
+ productCategories: productCategories_,
|
|
|
|
|
+ data: data,
|
|
|
|
|
+ selectedCategory: selectedCategory_,
|
|
|
|
|
+ selectSection: function(event, scope) {
|
|
|
|
|
+ var newValue = event.target.text;
|
|
|
|
|
+ window.history.pushState({}, newValue, '#' + newValue)
|
|
|
|
|
+ chooseSection(newValue);
|
|
|
|
|
+ event.target.className = 'selected';
|
|
|
|
|
+ },
|
|
|
|
|
+ selectCategory: function(event, scope) {
|
|
|
|
|
+ data.productView.list = true;
|
|
|
|
|
+ data.productView.description = false;
|
|
|
|
|
+ var category = productCategories_.find(R.propEq('name', event.target.text));
|
|
|
|
|
+ var categoryList = getElement('ul#product-category-nav > li > a')
|
|
|
|
|
+ data.selectedCategory = category;
|
|
|
|
|
+ getProducts(category._id);
|
|
|
|
|
+ addSelectedClass(categoryList, category.name);
|
|
|
|
|
+ },
|
|
|
|
|
+ seeProduct: function(event, scope) {
|
|
|
|
|
+ data.productView.list = false;
|
|
|
|
|
+ data.productView.description = true;
|
|
|
|
|
+ data.productDescription = data.products.find(R.propEq('name', event.target.text));
|
|
|
|
|
+ }
|
|
|
|
|
+});
|
|
|
}
|
|
}
|