Skip to content

Instantly share code, notes, and snippets.

@aulizko
Created January 5, 2011 10:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aulizko/766135 to your computer and use it in GitHub Desktop.
Save aulizko/766135 to your computer and use it in GitHub Desktop.
PageFlow (outdated)
/**
* Page Flow controller - load hash-specific data, show appropriate container and all that
* @Class PageFlow
*/
var PageFlow = function () {
/**
* show whole list of goods
* @method loadListOfGoods
* @private
*/
loadListOfGoods = function () {
$('#goodsItemDetails').css('display', 'none');
$('#listOfGoodsWorkArea').css('display', 'block');
},
/**
* show detailed goods item view
* @method loadGoodsItemDetails
* @private
*/
loadGoodsItemDetails = function (id) {
var item = M.ListOfGoods.getGoodsItemById(id);
if (item.pluralizedProfit.length == 0) {
item.pluralizedProfit = item.pluralizedPrice;
}
// fill container with appropriate data
M.Renderer.renderGoodsItemDetails([item]);
// show goodsItemDetails
$('#goodsItemDetails').css('display', 'block');
$('#listOfGoodsWorkArea').css('display', 'none');
},
return {
/**
* decide what page to load
* @method loadPage
* @param pageName {String|Number} location.hash with stripped `#` sign
* @public
*/
loadPage : function (pageName) {
if (L.isUndefined(pageName)) {
if (M.ClientURI.isMainPage()) {
loadListOfGoods();
}
}
// if pageName is number
if (L.isNumber(pageName) || pageName.replace(/\d+/, '').length == 0) {
// need to load goods item details page with provided id
loadGoodsItemDetails(pageName);
} else {
switch (pageName) {
case 'all':
loadListOfGoods();
break;
}
}
}
};
}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment