Created
January 5, 2011 10:26
-
-
Save aulizko/766135 to your computer and use it in GitHub Desktop.
PageFlow (outdated)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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