| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- Trex.MarkupTemplate = {};
- (function() {
- var __TEMPLATES = {};
- Trex.define(Trex.MarkupTemplate, {
- add: function(name, template) {
- __TEMPLATES[name] = template;
- },
- get: function(name) {
- if(!__TEMPLATES[name]) {
- return {
- evaluate: function() { return ""; },
- evaluateToDom: function() { return ""; }
- };
- }
- if(typeof(__TEMPLATES[name]) == 'string') {
- var _template = __TEMPLATES[name].replace(/@[\w\.]+/g, function(full) {
- return TXMSG(full);
- });
- __TEMPLATES[name] = new Template(_template);
- }
- return __TEMPLATES[name];
- },
- splitList: function(rows, cols, items){
- var _matrix = { 'row': [] };
- var _total = items.length;
- var _matrix_row = _matrix.row;
- for(var row=0; row<rows; row++) {
- _matrix_row.push({ 'col': [] });
- var _matrix_col = _matrix_row.last().col;
- for(var col=0; col<cols; col++) {
- var _item = {
- 'image': '',
- 'data': ' ',
- 'klass': ''
- };
- if(row * cols + col < _total) {
- if(typeof(items[row * cols + col]) == 'string') {
- _item.data = items[row * cols + col];
- } else {
- _item = Object.extend(_item ,items[row * cols + col]);
- }
- }
- _matrix_col.push(_item);
- }
- }
- return _matrix;
- }
- });
- })();
|