Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

123 řádky
2.9 KiB

  1. //
  2. // Dialog - old style dialog - deprecated
  3. //
  4. var cur_dialog;
  5. var top_index=91;
  6. function Dialog(w, h, title, content) {
  7. this.make({width:w, title:title});
  8. if(content)this.make_body(content);
  9. this.onshow = '';
  10. this.oncancel = '';
  11. this.no_cancel_flag = 0; // allow to cancel
  12. this.display = false;
  13. var me = this;
  14. }
  15. Dialog.prototype = new wn.widgets.Dialog()
  16. Dialog.prototype.make_body = function(content) {
  17. this.rows = {}; this.widgets = {};
  18. for(var i in content) this.make_row(content[i]);
  19. }
  20. Dialog.prototype.clear_inputs = function(d) {
  21. for(var wid in this.widgets) {
  22. var w = this.widgets[wid];
  23. var tn = w.tagName ? w.tagName.toLowerCase() : '';
  24. if(tn=='input' || tn=='textarea') {
  25. w.value = '';
  26. } else if(tn=='select') {
  27. sel_val(w.options[0].value);
  28. } else if(w.txt) {
  29. w.txt.value = '';
  30. } else if(w.input) {
  31. w.input.value = '';
  32. }
  33. }
  34. }
  35. Dialog.prototype.make_row = function(d) {
  36. var me = this;
  37. this.rows[d[1]] = $a(this.body, 'div', 'dialog_row');
  38. var row = this.rows[d[1]];
  39. if(d[0]!='HTML') {
  40. var t = make_table(row,1,2,'100%',['30%','70%']);
  41. row.tab = t;
  42. var c1 = $td(t,0,0);
  43. var c2 = $td(t,0,1);
  44. if(d[0]!='Check' && d[0]!='Button')
  45. $t(c1, d[1]);
  46. }
  47. if(d[0]=='HTML') {
  48. if(d[2])row.innerHTML = d[2];
  49. this.widgets[d[1]]=row;
  50. }
  51. else if(d[0]=='Check') {
  52. var i = $a_input(c2, 'checkbox','',{width:'20px'});
  53. c1.innerHTML = d[1];
  54. this.widgets[d[1]] = i;
  55. }
  56. else if(d[0]=='Data') {
  57. c1.innerHTML = d[1];
  58. c2.style.overflow = 'auto';
  59. this.widgets[d[1]] = $a_input(c2, 'text');
  60. if(d[2])$a(c2, 'div', 'comment').innerHTML = d[2];
  61. }
  62. else if(d[0]=='Link') {
  63. c1.innerHTML = d[1];
  64. var f = make_field({fieldtype:'Link', 'label':d[1], 'options':d[2]}, '', c2, this, 0, 1);
  65. f.not_in_form = 1;
  66. f.dialog = this;
  67. f.refresh();
  68. this.widgets[d[1]] = f.input;
  69. }
  70. else if(d[0]=='Date') {
  71. c1.innerHTML = d[1];
  72. var f = make_field({fieldtype:'Date', 'label':d[1], 'options':d[2]}, '', c2, this, 0, 1);
  73. f.not_in_form = 1;
  74. f.refresh();
  75. f.dialog = this;
  76. this.widgets[d[1]] = f.input;
  77. }
  78. else if(d[0]=='Password') {
  79. c1.innerHTML = d[1];
  80. c2.style.overflow = 'auto';
  81. this.widgets[d[1]] = $a_input(c2, 'password');
  82. if(d[3])$a(c2, 'div', 'comment').innerHTML = d[3];
  83. }
  84. else if(d[0]=='Select') {
  85. c1.innerHTML = d[1];
  86. this.widgets[d[1]] = $a(c2, 'select', '', {width:'160px'})
  87. if(d[2])$a(c2, 'div', 'comment').innerHTML = d[2];
  88. if(d[3])add_sel_options(this.widgets[d[1]], d[3], d[3][0]);
  89. }
  90. else if(d[0]=='Text') {
  91. c1.innerHTML = d[1];
  92. c2.style.overflow = 'auto';
  93. this.widgets[d[1]] = $a(c2, 'textarea');
  94. if(d[2])$a(c2, 'div', 'comment').innerHTML = d[2];
  95. }
  96. else if(d[0]=='Button') {
  97. c2.style.height = '32px';
  98. c2.style.textAlign = 'right';
  99. var b = $btn(c2, d[1], function(btn) { if(btn._onclick) btn._onclick(me) }, null, null, 1);
  100. b.dialog = me;
  101. if(d[2]) {
  102. b._onclick = d[2];
  103. }
  104. this.widgets[d[1]] = b;
  105. }
  106. }