Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 
 

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