data.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /**
  2. * Loads the resource data page
  3. *
  4. * @class MODx.page.ResourceData
  5. * @extends MODx.Component
  6. * @param {Object} config An object of config properties
  7. * @xtype modx-page-resource-data
  8. */
  9. MODx.page.ResourceData = function(config) {
  10. config = config || {};
  11. var btns = [];
  12. if (config.canEdit == 1) {
  13. btns.push({
  14. text: _('edit')
  15. ,id: 'modx-abtn-edit'
  16. ,cls: 'primary-button'
  17. ,hidden: config.canEdit == 1 ? false : true
  18. ,handler: this.editResource
  19. ,scope: this
  20. });
  21. }
  22. btns.push({
  23. text: _('view')
  24. ,id: 'modx-abtn-preview'
  25. ,handler: this.preview
  26. ,scope: this
  27. });
  28. btns.push({
  29. text: _('cancel')
  30. ,id: 'modx-abtn-cancel'
  31. ,handler: this.cancel
  32. ,scope: this
  33. });
  34. Ext.applyIf(config,{
  35. form: 'modx-resource-data'
  36. ,buttons: btns
  37. ,components: [{
  38. xtype: 'modx-panel-resource-data'
  39. ,resource: config.record.id
  40. ,context: config.record.context_key
  41. ,class_key: config.record.class_key
  42. ,pagetitle: config.record.pagetitle
  43. ,border: false
  44. ,url: config.url
  45. }]
  46. });
  47. MODx.page.ResourceData.superclass.constructor.call(this,config);
  48. };
  49. Ext.extend(MODx.page.ResourceData,MODx.Component,{
  50. preview: function() {
  51. window.open(this.config.record.preview_url);
  52. return false;
  53. }
  54. ,editResource: function() {
  55. MODx.loadPage('resource/update', 'id='+this.config.record.id);
  56. }
  57. ,cancel: function() {
  58. MODx.loadPage('?');
  59. }
  60. });
  61. Ext.reg('modx-page-resource-data',MODx.page.ResourceData);