themed_template.window.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. fred.window.ThemedTemplate = function (config) {
  2. config = config || {};
  3. Ext.applyIf(config, {
  4. title: _('fred.themed_templates.create'),
  5. closeAction: 'close',
  6. isUpdate: false,
  7. url: fred.config.connectorUrl,
  8. action: 'mgr/themed_templates/create',
  9. modal: true,
  10. autoHeight: true,
  11. buttonAlign: 'left',
  12. buttons: [
  13. {
  14. xtype: 'fred-button-help',
  15. path: 'cmp/themed_templates/'
  16. },
  17. '->',
  18. {
  19. text: config.cancelBtnText || _('cancel'),
  20. scope: this,
  21. handler: function() { config.closeAction !== 'close' ? this.hide() : this.close(); }
  22. },
  23. {
  24. text: config.saveBtnText || _('save'),
  25. cls: 'primary-button',
  26. scope: this,
  27. handler: this.submit
  28. }
  29. ],
  30. fields: this.getFields(config)
  31. });
  32. fred.window.ThemedTemplate.superclass.constructor.call(this, config);
  33. };
  34. Ext.extend(fred.window.ThemedTemplate, MODx.Window, {
  35. getFields: function (config) {
  36. var fields = [];
  37. if (config.isUpdate) {
  38. fields.push({
  39. xtype: 'hidden',
  40. name: 'template'
  41. });
  42. }
  43. fields.push([
  44. {
  45. xtype: config.isUpdate ? 'modx-combo-template' : 'fred-combo-template',
  46. fieldLabel: _('fred.themed_templates.template'),
  47. name: config.isUpdate ? 'template_value' : 'templates',
  48. hiddenName: config.isUpdate ? 'template_value' : 'templates[]',
  49. anchor: '100%',
  50. allowBlank: false,
  51. disabled: config.isUpdate
  52. },
  53. {
  54. xtype: 'fred-combo-themes',
  55. fieldLabel: _('fred.themed_templates.theme'),
  56. name: 'theme',
  57. anchor: '100%',
  58. allowBlank: true,
  59. isUpdate: config.isUpdate
  60. }
  61. ]);
  62. return fields;
  63. }
  64. });
  65. Ext.reg('fred-window-themed-template', fred.window.ThemedTemplate);