modx.panel.resource.static.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /**
  2. * @class MODx.panel.Static
  3. * @extends MODx.FormPanel
  4. * @param {Object} config An object of config properties
  5. * @xtype modx-panel-static
  6. */
  7. MODx.panel.Static = function(config) {
  8. config = config || {record:{}};
  9. config.record = config.record || {};
  10. Ext.applyIf(config,{
  11. id: 'modx-panel-resource'
  12. ,class_key: 'modStaticResource'
  13. ,items: this.getFields(config)
  14. });
  15. MODx.panel.Static.superclass.constructor.call(this,config);
  16. };
  17. Ext.extend(MODx.panel.Static,MODx.panel.Resource,{
  18. defaultClassKey: 'modStaticResource'
  19. ,classLexiconKey: 'static_resource'
  20. ,rteElements: false
  21. ,getPageHeader: function(config) {
  22. config = config || {record:{}};
  23. return {
  24. html: _('static_resource_new')
  25. ,id: 'modx-resource-header'
  26. ,xtype: 'modx-header'
  27. };
  28. }
  29. ,getMainFields: function(config) {
  30. var its = MODx.panel.Static.superclass.getMainFields.call(this,config);
  31. its.push({
  32. xtype: 'modx-combo-browser'
  33. ,browserEl: 'modx-browser'
  34. ,prependPath: false
  35. ,prependUrl: false
  36. // ,hideFiles: true
  37. ,fieldLabel: _('static_resource')
  38. ,description: '<b>[[*content]]</b>'
  39. ,name: 'content'
  40. ,id: 'modx-resource-content-static' // changed id to not have to usual box-shadow around the content field
  41. ,maxLength: 255
  42. ,anchor: '100%'
  43. ,value: (config.record.content || config.record.ta) || ''
  44. ,openTo: config.record.openTo
  45. ,listeners: {
  46. 'select':{fn:function(data) {
  47. var str = data.fullRelativeUrl;
  48. if (MODx.config.base_url != '/') {
  49. str = str.replace(MODx.config.base_url,'');
  50. }
  51. if (str.substring(0,1) == '/') { str = str.substring(1); }
  52. Ext.getCmp('modx-resource-content-static').setValue(str);
  53. this.markDirty();
  54. },scope:this}
  55. }
  56. });
  57. return its;
  58. }
  59. ,getContentField: function(config) {
  60. return null;
  61. }
  62. });
  63. Ext.reg('modx-panel-static',MODx.panel.Static);