modx.panel.tv.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  1. /**
  2. * Loads the TV panel
  3. *
  4. * @class MODx.panel.TV
  5. * @extends MODx.FormPanel
  6. * @param {Object} config An object of configuration properties
  7. * @xtype modx-panel-tv
  8. */
  9. MODx.panel.TV = function(config) {
  10. config = config || {};
  11. config.record = config.record || {};
  12. config = MODx.setStaticElementsConfig(config, 'tv');
  13. Ext.applyIf(config,{
  14. url: MODx.config.connector_url
  15. ,baseParams: {
  16. action: 'element/tv/get'
  17. }
  18. ,id: 'modx-panel-tv'
  19. ,cls: 'container form-with-labels'
  20. ,class_key: 'modTemplateVar'
  21. ,tv: ''
  22. ,bodyStyle: ''
  23. ,items: [{
  24. html: _('tv_new')
  25. ,id: 'modx-tv-header'
  26. ,xtype: 'modx-header'
  27. },MODx.getPageStructure([{
  28. title: _('general_information')
  29. ,defaults: {border: false ,msgTarget: 'side', layout: 'form'}
  30. ,layout: 'form'
  31. ,id: 'modx-tv-form'
  32. ,itemId: 'form-tv'
  33. ,labelWidth: 150
  34. ,forceLayout: true
  35. ,items: [{
  36. html: '<p>'+_('tv_msg')+'</p>'
  37. ,id: 'modx-tv-msg'
  38. ,xtype: 'modx-description'
  39. },{
  40. layout: 'column'
  41. ,border: false
  42. ,defaults: {
  43. layout: 'form'
  44. ,labelAlign: 'top'
  45. ,anchor: '100%'
  46. ,border: false
  47. ,cls:'main-wrapper'
  48. ,labelSeparator: ''
  49. }
  50. ,items: [{
  51. columnWidth: .6
  52. ,items: [{
  53. xtype: 'hidden'
  54. ,name: 'id'
  55. ,id: 'modx-tv-id'
  56. ,value: config.record.id || MODx.request.id
  57. },{
  58. xtype: 'hidden'
  59. ,name: 'props'
  60. ,id: 'modx-tv-props'
  61. ,value: config.record.props || null
  62. },{
  63. xtype: 'textfield'
  64. ,fieldLabel: _('name')+'<span class="required">*</span>'
  65. ,description: MODx.expandHelp ? '' : _('tv_desc_name')
  66. ,name: 'name'
  67. ,id: 'modx-tv-name'
  68. ,anchor: '100%'
  69. ,maxLength: 100
  70. ,enableKeyEvents: true
  71. ,allowBlank: false
  72. ,value: config.record.name
  73. ,listeners: {
  74. 'keyup': {scope:this,fn:function(f,e) {
  75. var title = Ext.util.Format.stripTags(f.getValue());
  76. title = _('tv')+': '+Ext.util.Format.htmlEncode(title);
  77. if (MODx.request.a !== 'element/tv/create' && MODx.perm.tree_show_element_ids === 1) {
  78. title = title+ ' <small>('+this.config.record.id+')</small>';
  79. }
  80. Ext.getCmp('modx-tv-header').getEl().update(title);
  81. MODx.setStaticElementPath('tv');
  82. }}
  83. }
  84. },{
  85. xtype: MODx.expandHelp ? 'label' : 'hidden'
  86. ,forId: 'modx-tv-name'
  87. ,html: _('tv_desc_name')
  88. ,cls: 'desc-under'
  89. },{
  90. xtype: 'textfield'
  91. ,fieldLabel: _('tv_caption')
  92. ,description: MODx.expandHelp ? '' : _('tv_desc_caption')
  93. ,name: 'caption'
  94. ,id: 'modx-tv-caption'
  95. ,anchor: '100%'
  96. ,value: config.record.caption
  97. },{
  98. xtype: MODx.expandHelp ? 'label' : 'hidden'
  99. ,forId: 'modx-tv-caption'
  100. ,html: _('tv_desc_caption')
  101. ,cls: 'desc-under'
  102. },{
  103. xtype: 'textarea'
  104. ,fieldLabel: _('description')
  105. ,description: MODx.expandHelp ? '' : _('tv_desc_description')
  106. ,name: 'description'
  107. ,id: 'modx-tv-description'
  108. ,anchor: '100%'
  109. ,maxLength: 255
  110. ,value: config.record.description || ''
  111. },{
  112. xtype: MODx.expandHelp ? 'label' : 'hidden'
  113. ,forId: 'modx-tv-description'
  114. ,html: _('tv_desc_description')
  115. ,cls: 'desc-under'
  116. },{
  117. xtype: 'modx-combo-browser'
  118. ,browserEl: 'modx-browser'
  119. ,fieldLabel: _('static_file')
  120. ,description: MODx.expandHelp ? '' : _('static_file_msg')
  121. ,name: 'static_file'
  122. // ,hideFiles: true
  123. ,openTo: config.record.openTo || ''
  124. ,id: 'modx-tv-static-file'
  125. ,triggerClass: 'x-form-code-trigger'
  126. ,anchor: '100%'
  127. ,maxLength: 255
  128. ,value: config.record.static_file || ''
  129. ,hidden: !config.record['static']
  130. ,hideMode: 'offsets'
  131. },{
  132. xtype: MODx.expandHelp ? 'label' : 'hidden'
  133. ,forId: 'modx-tv-static-file'
  134. ,id: 'modx-tv-static-file-help'
  135. ,html: _('static_file_msg')
  136. ,cls: 'desc-under'
  137. ,hidden: !config.record['static']
  138. ,hideMode: 'offsets'
  139. },{
  140. html: MODx.onTVFormRender
  141. ,border: false
  142. }]
  143. },{
  144. columnWidth: .4
  145. ,items: [{
  146. xtype: 'modx-combo-category'
  147. ,fieldLabel: _('category')
  148. ,name: 'category'
  149. ,id: 'modx-tv-category'
  150. ,anchor: '100%'
  151. ,value: config.record.category || 0
  152. ,listeners: {
  153. 'afterrender': {scope:this,fn:function(f,e) {
  154. setTimeout(function(){
  155. MODx.setStaticElementPath('tv');
  156. }, 200);
  157. }}
  158. ,'change': {scope:this,fn:function(f,e) {
  159. MODx.setStaticElementPath('tv');
  160. }}
  161. }
  162. },{
  163. xtype: MODx.expandHelp ? 'label' : 'hidden'
  164. ,forId: 'modx-tv-category'
  165. ,html: _('tv_desc_category')
  166. ,cls: 'desc-under'
  167. },{
  168. xtype: 'numberfield'
  169. ,fieldLabel: _('tv_rank')
  170. ,name: 'rank'
  171. ,id: 'modx-tv-rank'
  172. ,width: 50
  173. ,maxLength: 4
  174. ,allowNegative: false
  175. ,allowBlank: false
  176. ,value: config.record.rank || 0
  177. },{
  178. xtype: 'xcheckbox'
  179. ,boxLabel: _('tv_lock')
  180. ,description: _('tv_lock_msg')
  181. ,name: 'locked'
  182. ,id: 'modx-tv-locked'
  183. ,inputValue: 1
  184. ,checked: config.record.locked || false
  185. },{
  186. xtype: 'xcheckbox'
  187. ,boxLabel: _('clear_cache_on_save')
  188. ,description: _('clear_cache_on_save_msg')
  189. ,hideLabel: true
  190. ,name: 'clearCache'
  191. ,id: 'modx-tv-clear-cache'
  192. ,inputValue: 1
  193. ,checked: Ext.isDefined(config.record.clearCache) || true
  194. },{border: false, html: '<br style="line-height: 25px;"/>'},{
  195. xtype: 'xcheckbox'
  196. ,hideLabel: true
  197. ,boxLabel: _('is_static')
  198. ,description: MODx.expandHelp ? '' : _('is_static_msg')
  199. ,name: 'static'
  200. ,id: 'modx-tv-static'
  201. ,inputValue: 1
  202. ,checked: config.record['static'] || false
  203. },{
  204. xtype: MODx.expandHelp ? 'label' : 'hidden'
  205. ,forId: 'modx-tv-static'
  206. ,id: 'modx-tv-static-help'
  207. ,html: _('is_static_msg')
  208. ,cls: 'desc-under'
  209. },{
  210. xtype: 'modx-combo-source'
  211. ,fieldLabel: _('static_source')
  212. ,description: MODx.expandHelp ? '' : _('static_source_msg')
  213. ,name: 'source'
  214. ,id: 'modx-tv-static-source'
  215. ,anchor: '100%'
  216. ,maxLength: 255
  217. ,value: config.record.source != null ? config.record.source : MODx.config.default_media_source
  218. ,hidden: !config.record['static']
  219. ,hideMode: 'offsets'
  220. ,baseParams: {
  221. action: 'source/getList'
  222. ,showNone: true
  223. ,streamsOnly: true
  224. }
  225. ,listeners: {
  226. select: {
  227. fn: this.changeSource
  228. ,scope: this
  229. }
  230. }
  231. },{
  232. xtype: MODx.expandHelp ? 'label' : 'hidden'
  233. ,forId: 'modx-tv-static-source'
  234. ,id: 'modx-tv-static-source-help'
  235. ,html: _('static_source_msg')
  236. ,cls: 'desc-under'
  237. ,hidden: !config.record['static']
  238. ,hideMode: 'offsets'
  239. }]
  240. }]
  241. }]
  242. },{
  243. xtype: 'modx-panel-element-properties'
  244. ,itemId: 'panel-properties'
  245. ,elementPanel: 'modx-panel-tv'
  246. ,elementId: config.tv
  247. ,elementType: 'modTemplateVar'
  248. ,record: config.record
  249. },{
  250. xtype: 'modx-panel-tv-input-properties'
  251. ,record: config.record
  252. },{
  253. xtype: 'modx-panel-tv-output-properties'
  254. ,record: config.record
  255. },{
  256. title: _('tv_tmpl_access')
  257. ,itemId: 'form-template'
  258. ,hideMode: 'offsets'
  259. ,defaults: {autoHeight: true}
  260. ,layout: 'form'
  261. ,items: [{
  262. html: '<p>'+_('tv_tmpl_access_msg')+'</p>'
  263. ,xtype: 'modx-description'
  264. },{
  265. xtype: 'modx-grid-tv-template'
  266. ,itemId: 'grid-template'
  267. ,cls:'main-wrapper'
  268. ,tv: config.tv
  269. ,preventRender: true
  270. ,anchor: '100%'
  271. ,listeners: {
  272. 'rowclick': {fn:this.markDirty,scope:this}
  273. ,'afteredit': {fn:this.markDirty,scope:this}
  274. ,'afterRemoveRow': {fn:this.markDirty,scope:this}
  275. }
  276. }]
  277. },{
  278. title: _('access_permissions')
  279. ,id: 'modx-tv-access-form'
  280. ,itemId: 'form-access'
  281. ,forceLayout: true
  282. ,hideMode: 'offsets'
  283. ,defaults: {autoHeight: true}
  284. ,layout: 'form'
  285. ,items: [{
  286. html: '<p>'+_('tv_access_msg')+'</p>'
  287. ,id: 'modx-tv-access-msg'
  288. ,xtype: 'modx-description'
  289. },{
  290. xtype: 'modx-grid-tv-security'
  291. ,itemId: 'grid-access'
  292. ,cls:'main-wrapper'
  293. ,tv: config.tv
  294. ,preventRender: true
  295. ,anchor: '100%'
  296. ,listeners: {
  297. 'rowclick': {fn:this.markDirty,scope:this}
  298. ,'afteredit': {fn:this.markDirty,scope:this}
  299. ,'afterRemoveRow': {fn:this.markDirty,scope:this}
  300. }
  301. }]
  302. },{
  303. title: _('sources')
  304. ,id: 'modx-tv-sources-form'
  305. ,itemId: 'form-sources'
  306. ,defaults: {autoHeight: true}
  307. ,layout: 'form'
  308. ,hideMode: 'offsets'
  309. ,items: [{
  310. html: '<p>'+_('tv_sources.intro_msg')+'</p>'
  311. ,id: 'modx-tv-sources-msg'
  312. ,xtype: 'modx-description'
  313. },{
  314. xtype: 'modx-grid-element-sources'
  315. ,itemId: 'grid-sources'
  316. ,cls:'main-wrapper'
  317. ,id: 'modx-grid-element-sources'
  318. ,tv: config.tv
  319. ,preventRender: true
  320. ,listeners: {
  321. 'rowclick': {fn:this.markDirty,scope:this}
  322. ,'afteredit': {fn:this.markDirty,scope:this}
  323. ,'afterRemoveRow': {fn:this.markDirty,scope:this}
  324. }
  325. }]
  326. }],{
  327. id: 'modx-tv-tabs'
  328. ,forceLayout: true
  329. ,deferredRender: false
  330. ,stateful: true
  331. ,stateId: 'modx-tv-tabpanel-'+config.tv
  332. ,stateEvents: ['tabchange']
  333. ,hideMode: 'offsets'
  334. ,anchor: '100%'
  335. ,getState:function() {
  336. return {activeTab:this.items.indexOf(this.getActiveTab())};
  337. }
  338. })]
  339. ,useLoadingMask: true
  340. ,listeners: {
  341. 'setup': {fn:this.setup,scope:this}
  342. ,'success': {fn:this.success,scope:this}
  343. ,'beforeSubmit': {fn:this.beforeSubmit,scope:this}
  344. ,'failureSubmit': {
  345. fn: function () {
  346. this.showErroredTab(['modx-tv-form'], 'modx-tv-tabs')
  347. },
  348. scope: this
  349. }
  350. }
  351. });
  352. MODx.panel.TV.superclass.constructor.call(this,config);
  353. var isStatic = Ext.getCmp('modx-tv-static');
  354. if (isStatic) { isStatic.on('check',this.toggleStaticFile); }
  355. };
  356. Ext.extend(MODx.panel.TV,MODx.FormPanel,{
  357. initialized: false
  358. ,setup: function() {
  359. if (this.initialized) { this.clearDirty(); return true; }
  360. this.getForm().setValues(this.config.record);
  361. if (!Ext.isEmpty(this.config.record.name)) {
  362. var title = _('tv')+': '+this.config.record.name;
  363. if (MODx.perm.tree_show_element_ids === 1) {
  364. title = title+ ' <small>('+this.config.record.id+')</small>';
  365. }
  366. Ext.getCmp('modx-tv-header').getEl().update(title);
  367. }
  368. var d;
  369. if (!Ext.isEmpty(this.config.record.properties)) {
  370. d = this.config.record.properties;
  371. var g = Ext.getCmp('modx-grid-element-properties');
  372. if (g) {
  373. g.defaultProperties = d;
  374. g.getStore().loadData(d);
  375. }
  376. }
  377. if (!Ext.isEmpty(this.config.record.sources) && !this.initialized) {
  378. Ext.getCmp('modx-grid-element-sources').getStore().loadData(this.config.record.sources);
  379. }
  380. Ext.getCmp('modx-panel-tv-output-properties').showOutputProperties(Ext.getCmp('modx-tv-display'));
  381. Ext.getCmp('modx-panel-tv-input-properties').showInputProperties(Ext.getCmp('modx-tv-type'));
  382. this.fireEvent('ready',this.config.record);
  383. if (MODx.onLoadEditor) {MODx.onLoadEditor(this);}
  384. this.clearDirty();
  385. this.initialized = true;
  386. MODx.fireEvent('ready');
  387. return true;
  388. }
  389. /**
  390. * Set the browser window "media source" source
  391. */
  392. ,changeSource: function() {
  393. var browser = Ext.getCmp('modx-tv-static-file')
  394. ,source = Ext.getCmp('modx-tv-static-source').getValue();
  395. browser.config.source = source;
  396. }
  397. ,beforeSubmit: function(o) {
  398. var g = Ext.getCmp('modx-grid-tv-template');
  399. var rg = Ext.getCmp('modx-grid-tv-security');
  400. var sg = Ext.getCmp('modx-grid-element-sources');
  401. Ext.apply(o.form.baseParams,{
  402. templates: g.encodeModified()
  403. ,resource_groups: rg.encodeModified()
  404. ,sources: sg.encode()
  405. ,propdata: Ext.getCmp('modx-grid-element-properties').encode()
  406. });
  407. this.cleanupEditor();
  408. return this.fireEvent('save',{
  409. values: this.getForm().getValues()
  410. ,stay: MODx.config.stay
  411. });
  412. }
  413. ,success: function(r) {
  414. Ext.getCmp('modx-grid-tv-template').getStore().commitChanges();
  415. Ext.getCmp('modx-grid-tv-security').getStore().commitChanges();
  416. Ext.getCmp('modx-grid-element-sources').getStore().commitChanges();
  417. if (MODx.request.id) Ext.getCmp('modx-grid-element-properties').save();
  418. this.getForm().setValues(r.result.object);
  419. var t = Ext.getCmp('modx-tree-element');
  420. if (t) {
  421. var c = Ext.getCmp('modx-tv-category').getValue();
  422. var u = c != '' && c != null && c != 0 ? 'n_tv_category_'+c : 'n_type_tv';
  423. var node = t.getNodeById('n_tv_element_' + Ext.getCmp('modx-tv-id').getValue() + '_' + r.result.object.previous_category);
  424. if (node) node.destroy();
  425. t.refreshNode(u,true);
  426. }
  427. }
  428. ,changeEditor: function() {
  429. this.cleanupEditor();
  430. this.submit();
  431. }
  432. ,cleanupEditor: function() {
  433. if (MODx.onSaveEditor) {
  434. var fld = Ext.getCmp('modx-tv-default-text');
  435. MODx.onSaveEditor(fld);
  436. }
  437. }
  438. ,toggleStaticFile: function(cb) {
  439. var flds = ['modx-tv-static-file','modx-tv-static-file-help','modx-tv-static-source','modx-tv-static-source-help'];
  440. var fld,i;
  441. if (cb.checked) {
  442. for (i in flds) {
  443. fld = Ext.getCmp(flds[i]);
  444. if (fld) { fld.show(); }
  445. }
  446. } else {
  447. for (i in flds) {
  448. fld = Ext.getCmp(flds[i]);
  449. if (fld) { fld.hide(); }
  450. }
  451. }
  452. }
  453. });
  454. Ext.reg('modx-panel-tv',MODx.panel.TV);
  455. MODx.panel.TVInputProperties = function(config) {
  456. config = config || {};
  457. Ext.applyIf(config,{
  458. id: 'modx-panel-tv-input-properties'
  459. ,title: _('tv_input_options')
  460. ,header: false
  461. ,border: false
  462. ,defaults: { border: false }
  463. ,cls: 'form-with-labels'
  464. ,items: [{
  465. html: _('tv_input_options_msg')
  466. ,itemId: 'desc-tv-input-properties'
  467. ,xtype: 'modx-description'
  468. },{
  469. layout: 'form'
  470. ,border: false
  471. ,cls:'main-wrapper'
  472. ,labelAlign: 'top'
  473. ,labelSeparator: ''
  474. ,items: [{
  475. xtype: 'modx-combo-tv-input-type'
  476. ,fieldLabel: _('tv_type')
  477. ,description: MODx.expandHelp ? '' : _('tv_type_desc')
  478. ,name: 'type'
  479. ,id: 'modx-tv-type'
  480. ,itemid: 'fld-type'
  481. ,anchor: '100%'
  482. ,value: config.record.type || 'text'
  483. ,listeners: {
  484. 'select': {fn:this.showInputProperties,scope:this}
  485. }
  486. },{
  487. xtype: 'label'
  488. ,forId: 'modx-tv-type'
  489. ,html: _('tv_type_desc')
  490. ,cls: 'desc-under'
  491. },{
  492. xtype: 'textarea'
  493. ,fieldLabel: _('tv_elements')
  494. ,description: MODx.expandHelp ? '' : _('tv_elements_desc')
  495. ,name: 'els'
  496. ,id: 'modx-tv-elements'
  497. ,itemId: 'fld-els'
  498. ,anchor: '100%'
  499. ,grow: true
  500. ,maxHeight: 160
  501. ,value: config.record.elements || ''
  502. ,listeners: {
  503. 'change': {fn:this.markPanelDirty,scope:this}
  504. }
  505. },{
  506. xtype: MODx.expandHelp ? 'label' : 'hidden'
  507. ,forId: 'modx-tv-elements'
  508. ,html: _('tv_elements_desc')
  509. ,cls: 'desc-under'
  510. },{
  511. xtype: 'textarea'
  512. ,fieldLabel: _('tv_default')
  513. ,description: MODx.expandHelp ? '' : _('tv_default_desc')
  514. ,name: 'default_text'
  515. ,id: 'modx-tv-default-text'
  516. ,itemId: 'fld-default_text'
  517. ,anchor: '100%'
  518. ,grow: true
  519. ,maxHeight: 250
  520. ,value: config.record.default_text || ''
  521. ,listeners: {
  522. 'change': {fn:this.markPanelDirty,scope:this}
  523. }
  524. },{
  525. xtype: MODx.expandHelp ? 'label' : 'hidden'
  526. ,forId: 'modx-tv-default-text'
  527. ,html: _('tv_default_desc')
  528. ,cls: 'desc-under'
  529. },{
  530. id: 'modx-input-props'
  531. ,autoHeight: true
  532. }]
  533. }]
  534. });
  535. MODx.panel.TVInputProperties.superclass.constructor.call(this,config);
  536. };
  537. Ext.extend(MODx.panel.TVInputProperties,MODx.Panel,{
  538. markPanelDirty: function() {
  539. Ext.getCmp('modx-panel-tv').markDirty();
  540. }
  541. ,showInputProperties: function(cb,rc,i) {
  542. var element = Ext.getCmp('modx-tv-elements');
  543. if (element) {
  544. element.show();
  545. }
  546. this.markPanelDirty();
  547. var pu = Ext.get('modx-input-props').getUpdater();
  548. pu.loadScripts = true;
  549. try {
  550. pu.update({
  551. url: MODx.config.connector_url
  552. ,method: 'GET'
  553. ,params: {
  554. 'action': 'element/tv/renders/getInputProperties'
  555. ,'context': 'mgr'
  556. ,'tv': this.config.record.id
  557. ,'type': cb.getValue() || 'default'
  558. }
  559. ,scripts: true
  560. });
  561. } catch(e) {MODx.debug(e);}
  562. }
  563. });
  564. Ext.reg('modx-panel-tv-input-properties',MODx.panel.TVInputProperties);
  565. MODx.panel.TVOutputProperties = function(config) {
  566. config = config || {};
  567. Ext.applyIf(config,{
  568. id: 'modx-panel-tv-output-properties'
  569. ,title: _('tv_output_options')
  570. ,header: false
  571. ,layout: 'form'
  572. ,cls: 'form-with-labels'
  573. ,defaults: {border: false}
  574. ,items: [{
  575. html: _('tv_output_options_msg')
  576. ,itemId: 'desc-tv-output-properties'
  577. ,xtype: 'modx-description'
  578. },{
  579. layout: 'form'
  580. ,border: false
  581. ,cls:'main-wrapper'
  582. ,labelAlign: 'top'
  583. ,items: [{
  584. xtype: 'modx-combo-tv-widget'
  585. ,fieldLabel: _('tv_output_type')
  586. ,name: 'display'
  587. ,hiddenName: 'display'
  588. ,id: 'modx-tv-display'
  589. ,itemId: 'fld-display'
  590. ,value: config.record.display || 'default'
  591. ,anchor: '100%'
  592. ,listeners: {
  593. 'select': {fn:this.showOutputProperties,scope:this}
  594. }
  595. },{
  596. xtype: MODx.expandHelp ? 'label' : 'hidden'
  597. ,labelSeparator: ''
  598. ,forId: 'modx-tv-display'
  599. ,html: _('tv_output_type_desc')
  600. ,cls: 'desc-under'
  601. },{
  602. id: 'modx-widget-props'
  603. ,autoHeight: true
  604. }]
  605. }]
  606. });
  607. MODx.panel.TVOutputProperties.superclass.constructor.call(this,config);
  608. };
  609. Ext.extend(MODx.panel.TVOutputProperties,MODx.Panel,{
  610. showOutputProperties: function(cb,rc,i) {
  611. Ext.getCmp('modx-panel-tv').markDirty();
  612. var pu = Ext.get('modx-widget-props').getUpdater();
  613. pu.loadScripts = true;
  614. try {
  615. pu.update({
  616. url: MODx.config.connector_url
  617. ,method: 'GET'
  618. ,params: {
  619. 'action': 'element/tv/renders/getProperties'
  620. ,'context': 'mgr'
  621. ,'tv': this.config.record.id
  622. ,'type': cb.getValue() || 'default'
  623. }
  624. ,scripts: true
  625. });
  626. } catch(e) {MODx.debug(e);}
  627. }
  628. });
  629. Ext.reg('modx-panel-tv-output-properties',MODx.panel.TVOutputProperties);
  630. MODx.grid.ElementSources = function(config) {
  631. var src = new MODx.combo.MediaSource();
  632. src.getStore().load();
  633. config = config || {};
  634. Ext.applyIf(config,{
  635. id: 'modx-grid-element-sources'
  636. ,fields: ['context_key','source','name']
  637. ,autoHeight: true
  638. ,primaryKey: 'id'
  639. ,columns: [{
  640. header: _('context')
  641. ,dataIndex: 'context_key'
  642. },{
  643. header: _('source')
  644. ,dataIndex: 'source'
  645. ,xtype: 'combocolumn'
  646. ,editor: src
  647. ,gridId: 'modx-grid-element-sources'
  648. }]
  649. });
  650. MODx.grid.ElementSources.superclass.constructor.call(this,config);
  651. this.propRecord = Ext.data.Record.create(['context_key','source']);
  652. };
  653. Ext.extend(MODx.grid.ElementSources,MODx.grid.LocalGrid,{
  654. getMenu: function() {
  655. return [];
  656. }
  657. });
  658. Ext.reg('modx-grid-element-sources',MODx.grid.ElementSources);