Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 
 

148 строки
4.2 KiB

  1. // Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com)
  2. //
  3. // MIT License (MIT)
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a
  6. // copy of this software and associated documentation files (the "Software"),
  7. // to deal in the Software without restriction, including without limitation
  8. // the rights to use, copy, modify, merge, publish, distribute, sublicense,
  9. // and/or sell copies of the Software, and to permit persons to whom the
  10. // Software is furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  16. // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  17. // PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  18. // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
  19. // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
  20. // OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  21. //
  22. //
  23. // Dialog - old style dialog - deprecated
  24. //
  25. var cur_dialog;
  26. var top_index=91;
  27. var Dialog = wn.ui.Dialog.extend({
  28. init: function(w, h, title, content) {
  29. this._super({
  30. width: w,
  31. title: title
  32. });
  33. if(content)this.make_body(content);
  34. this.onshow = '';
  35. this.oncancel = '';
  36. this.no_cancel_flag = 0; // allow to cancel
  37. this.display = false;
  38. this.first_button = false;
  39. },
  40. make_body: function(content) {
  41. this.rows = {}; this.widgets = {};
  42. for(var i in content) this.make_row(content[i]);
  43. },
  44. clear_inputs: function(d) {
  45. for(var wid in this.widgets) {
  46. var w = this.widgets[wid];
  47. var tn = w.tagName ? w.tagName.toLowerCase() : '';
  48. if(tn=='input' || tn=='textarea') {
  49. w.value = '';
  50. } else if(tn=='select') {
  51. sel_val(w.options[0].value);
  52. } else if(w.txt) {
  53. w.txt.value = '';
  54. } else if(w.input) {
  55. w.input.value = '';
  56. }
  57. }
  58. },
  59. make_row: function(d) {
  60. var me = this;
  61. this.rows[d[1]] = $a(this.body, 'div', 'dialog_row');
  62. var row = this.rows[d[1]];
  63. if(d[0]!='HTML') {
  64. var t = make_table(row,1,2,'100%',['30%','70%']);
  65. row.tab = t;
  66. var c1 = $td(t,0,0);
  67. var c2 = $td(t,0,1);
  68. if(d[0]!='Check' && d[0]!='Button')
  69. $(c1).text(d[1]);
  70. }
  71. if(d[0]=='HTML') {
  72. if(d[2])row.innerHTML = d[2];
  73. this.widgets[d[1]]=row;
  74. }
  75. else if(d[0]=='Check') {
  76. var i = $a_input(c2, 'checkbox','',{width:'20px'});
  77. c1.innerHTML = d[1];
  78. this.widgets[d[1]] = i;
  79. }
  80. else if(d[0]=='Data') {
  81. c1.innerHTML = d[1];
  82. c2.style.overflow = 'auto';
  83. this.widgets[d[1]] = $a_input(c2, 'text');
  84. if(d[2])$a(c2, 'div', 'field_description').innerHTML = d[2];
  85. }
  86. else if(d[0]=='Link') {
  87. c1.innerHTML = d[1];
  88. var f = make_field({fieldtype:'Link', 'label':d[1], 'options':d[2]}, '', c2, this, 0, 1);
  89. f.not_in_form = 1;
  90. f.dialog = this;
  91. f.refresh();
  92. this.widgets[d[1]] = f.input;
  93. }
  94. else if(d[0]=='Date') {
  95. c1.innerHTML = d[1];
  96. var f = make_field({fieldtype:'Date', 'label':d[1], 'options':d[2]}, '', c2, this, 0, 1);
  97. f.not_in_form = 1;
  98. f.refresh();
  99. f.dialog = this;
  100. this.widgets[d[1]] = f.input;
  101. }
  102. else if(d[0]=='Password') {
  103. c1.innerHTML = d[1];
  104. c2.style.overflow = 'auto';
  105. this.widgets[d[1]] = $a_input(c2, 'password');
  106. if(d[3])$a(c2, 'div', 'field_description').innerHTML = d[3];
  107. }
  108. else if(d[0]=='Select') {
  109. c1.innerHTML = d[1];
  110. this.widgets[d[1]] = $a(c2, 'select', '', {width:'160px'})
  111. if(d[2])$a(c2, 'div', 'field_description').innerHTML = d[2];
  112. if(d[3])add_sel_options(this.widgets[d[1]], d[3], d[3][0]);
  113. }
  114. else if(d[0]=='Text') {
  115. c1.innerHTML = d[1];
  116. c2.style.overflow = 'auto';
  117. this.widgets[d[1]] = $a(c2, 'textarea');
  118. if(d[2])$a(c2, 'div', 'field_description').innerHTML = d[2];
  119. }
  120. else if(d[0]=='Button') {
  121. c2.style.height = '32px';
  122. var b = $btn(c2, d[1], function(btn) {
  123. if(btn._onclick) btn._onclick(me) }, null, null, 1);
  124. b.dialog = me;
  125. if(!this.first_button) {
  126. $(b).addClass('btn-info');
  127. this.first_button = true;
  128. }
  129. if(d[2]) {
  130. b._onclick = d[2];
  131. }
  132. this.widgets[d[1]] = b;
  133. }
  134. }
  135. });