modx.panel.resource.tv.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /**
  2. * Loads the Resource TV Panel
  3. *
  4. * @class MODx.panel.ResourceTV
  5. * @extends MODx.Panel
  6. * @param {Object} config
  7. * @xtype panel-resource-tv
  8. */
  9. MODx.panel.ResourceTV = function(config) {
  10. config = config || {};
  11. Ext.applyIf(config,{
  12. id: 'modx-panel-resource-tv'
  13. ,title: _('template_variables')
  14. ,class_key: ''
  15. ,resource: ''
  16. ,cls: MODx.config.tvs_below_content == 1 ? 'x-panel-body tvs-wrapper below-content' : 'tvs-wrapper x-panel-body'
  17. ,autoHeight: true
  18. ,applyTo: 'modx-resource-tvs-div'
  19. ,header: false
  20. ,templateField: 'modx-resource-template'
  21. });
  22. MODx.panel.ResourceTV.superclass.constructor.call(this,config);
  23. this.addEvents({ load: true });
  24. };
  25. Ext.extend(MODx.panel.ResourceTV,MODx.Panel,{
  26. autoload: function() {
  27. return false;
  28. }
  29. ,refreshTVs: function() {
  30. return false;
  31. var t = Ext.getCmp(this.config.templateField);
  32. if (!t && !this.config.template) { return false; }
  33. var template = this.config.template ? this.config.template : t.getValue();
  34. this.getUpdater().update({
  35. url: MODx.config.manager_url+'?a=resource/tvs'
  36. ,method: 'GET'
  37. ,params: {
  38. 'class_key': this.config.class_key
  39. ,'template': template
  40. ,'resource': this.config.resource
  41. }
  42. ,scripts: true
  43. ,callback: function() {
  44. this.fireEvent('load');
  45. if (MODx.afterTVLoad) { MODx.afterTVLoad(); }
  46. }
  47. ,scope: this
  48. });
  49. }
  50. });
  51. Ext.reg('modx-panel-resource-tv',MODx.panel.ResourceTV);