collections.renderers.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. var iconClass = {
  2. "edit": "icon-pencil",
  3. "quickupdate": "icon-edit",
  4. "delete": "icon-trash-o",
  5. "duplicate": "icon-files-o",
  6. "publish": "icon-thumbs-o-up",
  7. "unpublish": "icon-thumbs-down",
  8. "view": "icon-eye",
  9. "open": "icon-folder-open-o",
  10. "remove": "icon-ban",
  11. "undelete": "icon-undo",
  12. "unlink": "icon-chain-broken"
  13. };
  14. var pagetitleWithButtons = new Ext.XTemplate('<tpl for="."><div class="collections-title-column">'
  15. +'<span class="collections-children-icon x-tree-node-collapsed"><i class="{icons}"></i></span><h3 class="main-column buttons"><a href="{[ parent.self.getEditChildUrl(parent) ]}" title="Edit {pagetitle}">{pagetitle}</a></h3>'
  16. +'<ul class="actions">'
  17. +'<tpl for="actions">'
  18. +'<tpl if="values.urlFunction">'
  19. +'<li><a href="{[ parent.self[values.urlFunction](parent) ]}" class="{className}">{text}</a></li>'
  20. +'</tpl>'
  21. +'<tpl if="!values.urlFunction">'
  22. +'<li><a href="javascript:void(0);" class="controlBtn {className}">{text}</a></li>'
  23. +'</tpl>'
  24. +'</tpl>'
  25. +'</ul>'
  26. +'</div></tpl>',{
  27. compiled: true
  28. });
  29. var pagetitle = new Ext.XTemplate('<tpl for="."><div class="collections-title-column">'
  30. + '<span class="collections-children-icon x-tree-node-collapsed"><i class="{icons}"></i></span><h3 class="main-column buttons"><a href="{[ parent.self.getEditChildUrl(parent) ]}" title="Edit {pagetitle}">{pagetitle}</a></h3>'
  31. + '</div></tpl>', {
  32. compiled: true
  33. });
  34. var pagetitleLink = new Ext.XTemplate('<tpl for="."><div class="collections-title-column">'
  35. + '<a href="{[ parent.self.getEditChildUrl(parent) ]}" title="Edit {pagetitle}">{pagetitle}</a>'
  36. + '</div></tpl>', {
  37. compiled: true
  38. });
  39. var pagetitleWithIcons = new Ext.XTemplate('<tpl for="."><div class="collections-title-column">'
  40. +'<span class="collections-children-icon x-tree-node-collapsed"><i class="{icons}"></i></span><h3 class="main-column buttons"><a href="{[ parent.self.getEditChildUrl(parent) ]}" title="Edit {pagetitle}">{pagetitle}</a></h3>'
  41. +'<ul class="actions">'
  42. +'<tpl for="actions">'
  43. +'<tpl if="values.urlFunction">'
  44. +'<li><a href="{[ parent.self[values.urlFunction](parent) ]}" class="{className}" title="{text}">'
  45. +'<i class="icon icon-fw icon {[ iconClass[values.key] ]}"></i>{[ iconClass[values.key] ? "":values.text ]}'
  46. +'</a></li>'
  47. +'</tpl>'
  48. +'<tpl if="!values.urlFunction">'
  49. +'<li><a href="javascript:void(0);" class="controlBtn {className}" title="{text}">'
  50. +'<i class="icon icon-fw icon {[ iconClass[values.key] ]}" data-id="{parent.id}" data-action="{values.key}"></i>{[ iconClass[values.key] ? "":values.text ]}'
  51. +'</a></li>'
  52. +'</tpl>'
  53. +'</tpl>'
  54. +'</ul>'
  55. +'</div></tpl>',{
  56. compiled: true
  57. });
  58. var icons = new Ext.XTemplate('<tpl for=".">'
  59. +'<ul class="actions solo">'
  60. +'<tpl for="actions">'
  61. +'<tpl if="values.urlFunction">'
  62. +'<li><a href="{[ parent.self[values.urlFunction](parent) ]}" class="{className}" title="{text}">'
  63. +'<i class="icon icon-fw icon {[ iconClass[values.key] ]}"></i>{[ iconClass[values.key] ? "":values.text ]}'
  64. +'</a></li>'
  65. +'</tpl>'
  66. +'<tpl if="!values.urlFunction">'
  67. +'<li><a href="javascript:void(0);" class="controlBtn {className}" title="{text}">'
  68. +'<i class="icon icon-fw icon {[ iconClass[values.key] ]}" data-id="{parent.id}" data-action="{values.key}"></i>{[ iconClass[values.key] ? "":values.text ]}'
  69. +'</a></li>'
  70. +'</tpl>'
  71. +'</tpl>'
  72. +'</ul>'
  73. +'</tpl>',{
  74. compiled: true
  75. });
  76. collections.renderer.buttons = function(value, metaData, record, rowIndex, colIndex, store) {
  77. return icons.apply(record.data);
  78. };
  79. collections.renderer.qtip = function(value, metaData, record, rowIndex, colIndex, store) {
  80. metaData.attr = 'ext:qtip="' + value + '"';
  81. return value;
  82. };
  83. collections.renderer.pagetitleWithButtons = function(value, metaData, record, rowIndex, colIndex, store) {
  84. return pagetitleWithButtons.apply(record.data);
  85. };
  86. collections.renderer.pagetitleWithIcons = function(value, metaData, record, rowIndex, colIndex, store) {
  87. return pagetitleWithIcons.apply(record.data);
  88. };
  89. collections.renderer.pagetitle = function(value, metaData, record, rowIndex, colIndex, store) {
  90. return pagetitle.apply(record.data);
  91. };
  92. collections.renderer.pagetitleLink = function(value, metaData, record, rowIndex, colIndex, store) {
  93. return pagetitleLink.apply(record.data);
  94. };
  95. collections.renderer.datetimeTwoLines = function(value, metaData, record, rowIndex, colIndex, store) {
  96. if (value == 0) return '';
  97. var d = Date.parseDate(value, 'Y-m-d H:i:s');
  98. var date = Ext.util.Format.date(d, MODx.config['collections.mgr_date_format']);
  99. var time = Ext.util.Format.date(d, MODx.config['collections.mgr_time_format']);
  100. return '<div class="collections-grid-date">' + date + '<span class="collections-grid-time">' + time + '</span></div>';
  101. };
  102. collections.renderer.datetime = function(value, metaData, record, rowIndex, colIndex, store) {
  103. if (value == 0) return '';
  104. var d = Date.parseDate(value, 'Y-m-d H:i:s');
  105. return Ext.util.Format.date(d,MODx.config['collections.mgr_datetime_format']);
  106. };
  107. collections.renderer.timestampToDatetime = function(value, metaData, record, rowIndex, colIndex, store) {
  108. if (value == 0 || value == null) return '';
  109. return Ext.util.Format.date(new Date(parseInt(value)),MODx.config['collections.mgr_datetime_format']);
  110. };
  111. collections.renderer.image = function(value, metaData, record, rowIndex, colIndex, store) {
  112. if (value != '' && value != null) {
  113. var imgPath = MODx.config['collections.renderer_image_path'];
  114. return '<img src="' + MODx.config.base_url + imgPath + value + '" width="64">';
  115. }
  116. };
  117. collections.renderer.boolean = function(value, metaData, record, rowIndex, colIndex, store) {
  118. var iconclass = (value) ? 'icon-check' : 'icon-times';
  119. return '<div style="text-align:center;"><i class="icon ' + iconclass + '"></i></div>';
  120. };
  121. // Backwards compatibility
  122. Collections.renderer = {
  123. buttons: collections.renderer.buttons,
  124. qtip: collections.renderer.qtip,
  125. pagetitleWithButtons: collections.renderer.pagetitleWithButtons,
  126. pagetitleWithIcons: collections.renderer.pagetitleWithIcons,
  127. pagetitle: collections.renderer.pagetitle,
  128. pagetitleLink: collections.renderer.pagetitleLink,
  129. datetimeTwoLines: collections.renderer.datetimeTwoLines,
  130. datetime: collections.renderer.datetime,
  131. timestampToDatetime: collections.renderer.timestampToDatetime,
  132. image: collections.renderer.image,
  133. boolean: collections.renderer.boolean
  134. };