Global.renderList (collection, funcOrSkin, itemsPerPage, pageIdx)
generic list render function. if the argument "itemsPerPage" is given it renders a pagelist, otherwise the *whole* collection will be rendered

  • Parameter Object:
    collection to work on
  • Parameter Object:
    either a string which is interpreted as name of a skin or a function to call for each item (the item is passed as argument)
  • Parameter Int:
    Number of items per page
  • Parameter Object:
    String or Integer representing the currently viewed page
  • Returns
    String rendered list
Sourcecode in Global/renderFunctions.js:
1:   function renderList(collection, funcOrSkin, itemsPerPage, pageIdx) {
2:      var currIdx = 0;
3:      var isArray = collection instanceof Array;
4:      var stop = size = isArray ? collection.length : collection.size();
5:   
6:      if (itemsPerPage) {
7:         var totalPages = Math.ceil(size/itemsPerPage);
8:         if (isNaN(pageIdx) || pageIdx > totalPages || pageIdx < 0)
9:            pageIdx = 0;
10:        currIdx = pageIdx * itemsPerPage;
11:        stop = Math.min(currIdx + itemsPerPage, size);
12:     }
13:     var isFunction = (funcOrSkin instanceof Function) ? true : false;
14:     res.push();
15:     while (currIdx < stop) {
16:        var item = isArray ? collection[currIdx] : collection.get(currIdx);
17:        isFunction ? funcOrSkin(item) : item.renderSkin(funcOrSkin);
18:        currIdx++;
19:     }
20:     return res.pop();
21:  }