tvs.tpl 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. {$OnResourceTVFormPrerender}
  2. <input type="hidden" name="tvs" value="1" />
  3. <div id="modx-tv-tabs" class="x-form-label-top">
  4. {foreach from=$categories item=category}
  5. {if count($category.tvs) > 0}
  6. <div id="modx-tv-tab{$category.id}" class="x-tab{if $category.hidden}-hidden{/if}" title="{$category.category}">
  7. {foreach from=$category.tvs item=tv name='tv'}
  8. {if $tv->type NEQ "hidden"}
  9. <div class="modx-tv-type-{$tv->type} x-form-item x-tab-item {cycle values=",alt"} modx-tv{if $smarty.foreach.tv.first} tv-first{/if}{if $smarty.foreach.tv.last} tv-last{/if}" id="tv{$tv->id}-tr">
  10. <label for="tv{$tv->id}" class="x-form-item-label modx-tv-label">
  11. <div class="modx-tv-label-title">
  12. {if $showCheckbox|default}<input type="checkbox" name="tv{$tv->id}-checkbox" class="modx-tv-checkbox" value="1" />{/if}
  13. <span class="modx-tv-caption" id="tv{$tv->id}-caption">{if $tv->caption}{$tv->caption}{else}{$tv->name}{/if}</span>
  14. </div>
  15. <a class="modx-tv-reset" id="modx-tv-reset-{$tv->id}" title="{$_lang.set_to_default}"></a>
  16. {if $tv->description}
  17. <span class="modx-tv-label-description">{$tv->description}</span>
  18. {/if}
  19. </label>
  20. {if $tv->inherited}<span class="modx-tv-inherited">{$_lang.tv_value_inherited}</span>{/if}
  21. <div class="x-form-element modx-tv-form-element">
  22. <input type="hidden" id="tvdef{$tv->id}" value="{$tv->default_text|escape}" />
  23. {$tv->get('formElement')}
  24. </div>
  25. </div>
  26. <script type="text/javascript">{literal}Ext.onReady(function() { new Ext.ToolTip({{/literal}target: 'tv{$tv->id}-caption',html: '[[*{$tv->name}]]'{literal}});});{/literal}</script>
  27. {else}
  28. <input type="hidden" id="tvdef{$tv->id}" value="{$tv->default_text|escape}" />
  29. {$tv->get('formElement')}
  30. {/if}
  31. {/foreach}
  32. <div class="clear"></div>
  33. </div>
  34. {/if}
  35. {/foreach}
  36. </div>
  37. {literal}
  38. <script type="text/javascript">
  39. // <![CDATA[
  40. Ext.onReady(function() {
  41. MODx.resetTV = function(id) {
  42. var i = Ext.get('tv'+id);
  43. var d = Ext.get('tvdef'+id);
  44. if (i) {
  45. i.dom.value = d.dom.value;
  46. i.dom.checked = d.dom.value ? true : false;
  47. }
  48. var c = Ext.getCmp('tv'+id);
  49. if (c) {
  50. if (c.xtype == 'checkboxgroup' || c.xtype == 'radiogroup') {
  51. var cbs = d.dom.value.split(',');
  52. for (var i=0;i<c.items.length;i++) {
  53. if (c.items.items[i]) {
  54. c.items.items[i].setValue(cbs.indexOf(c.items.items[i].id) != -1);
  55. }
  56. }
  57. } else {
  58. c.setValue(d.dom.value);
  59. }
  60. }
  61. var p = Ext.getCmp('modx-panel-resource');
  62. if (p) {
  63. p.markDirty();
  64. p.fireEvent('tv-reset',{id:id});
  65. }
  66. };
  67. Ext.select('.modx-tv-reset').on('click',function(e,t,o) {
  68. var id = t.id.split('-');
  69. id = id[3];
  70. MODx.resetTV(id);
  71. });
  72. MODx.refreshTVs = function() {
  73. if (MODx.unloadTVRTE) { MODx.unloadTVRTE(); }
  74. Ext.getCmp('modx-panel-resource-tv').refreshTVs();
  75. };
  76. {/literal}{if $tvcount GT 0}{literal}
  77. MODx.load({
  78. xtype: 'modx-vtabs'
  79. ,applyTo: 'modx-tv-tabs'
  80. ,autoTabs: true
  81. ,border: false
  82. ,plain: true
  83. ,deferredRender: false
  84. ,id: 'modx-resource-vtabs'
  85. ,headerCfg: {
  86. tag: 'div'
  87. ,cls: 'x-tab-panel-header vertical-tabs-header'
  88. ,id: 'modx-resource-vtabs-header'
  89. ,html: MODx.config.show_tv_categories_header === true ? '<h4 id="modx-resource-vtabs-header-title">'+_('categories')+'</h4>' : ''
  90. }
  91. ,listeners: {
  92. beforeadd: function (tabpanel, comp) {
  93. if (comp.contentEl && (Ext.get(comp.contentEl).child('.modx-tv') === null)) {
  94. return false;
  95. }
  96. }
  97. ,afterrender: function (tabpanel) {
  98. if (tabpanel.items.length === 0) {
  99. Ext.getCmp('modx-resource-tabs').hideTabStripItem('modx-panel-resource-tv');
  100. }
  101. }
  102. }
  103. });
  104. {/literal}{/if}
  105. MODx.tvCounts = {$tvCounts};
  106. MODx.tvMap = {$tvMap};
  107. {literal}
  108. });
  109. // ]]>
  110. </script>
  111. {/literal}
  112. {$OnResourceTVFormRender}
  113. <div class="clear"></div>