您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

147 行
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 Dialog = wn.ui.Dialog.extend({
  27. init: function(w, h, title, content) {
  28. this._super({
  29. width: w,
  30. title: title
  31. });
  32. if(content)this.make_body(content);
  33. this.onshow = '';
  34. this.oncancel = '';
  35. this.no_cancel_flag = 0; // allow to cancel
  36. this.display = false;
  37. this.first_button = false;
  38. },
  39. make_body: function(content) {
  40. this.rows = {}; this.widgets = {};
  41. for(var i in content) this.make_row(content[i]);
  42. },
  43. clear_inputs: function(d) {
  44. for(var wid in this.widgets) {
  45. var w = this.widgets[wid];
  46. var tn = w.tagName ? w.tagName.toLowerCase() : '';
  47. if(tn=='input' || tn=='textarea') {
  48. w.value = '';
  49. } else if(tn=='select') {
  50. sel_val(w.options[0].value);
  51. } else if(w.txt) {
  52. w.txt.value = '';
  53. } else if(w.input) {
  54. w.input.value = '';
  55. }
  56. }
  57. },
  58. make_row: function(d) {
  59. var me = this;
  60. this.rows[d[1]] = $a(this.body, 'div', 'dialog_row');
  61. var row = this.rows[d[1]];
  62. if(d[0]!='HTML') {
  63. var t = make_table(row,1,2,'100%',['30%','70%']);
  64. row.tab = t;
  65. var c1 = $td(t,0,0);
  66. var c2 = $td(t,0,1);
  67. if(d[0]!='Check' && d[0]!='Button')
  68. $(c1).text(d[1]);
  69. }
  70. if(d[0]=='HTML') {
  71. if(d[2])row.innerHTML = d[2];
  72. this.widgets[d[1]]=row;
  73. }
  74. else if(d[0]=='Check') {
  75. var i = $a_input(c2, 'checkbox','',{width:'20px'});
  76. c1.innerHTML = d[1];
  77. this.widgets[d[1]] = i;
  78. }
  79. else if(d[0]=='Data') {
  80. c1.innerHTML = d[1];
  81. c2.style.overflow = 'auto';
  82. this.widgets[d[1]] = $a_input(c2, 'text');
  83. if(d[2])$a(c2, 'div', 'field_description').innerHTML = d[2];
  84. }
  85. else if(d[0]=='Link') {
  86. c1.innerHTML = d[1];
  87. var f = make_field({fieldtype:'Link', 'label':d[1], 'options':d[2]}, '', c2, this, 0, 1);
  88. f.not_in_form = 1;
  89. f.dialog = this;
  90. f.refresh();
  91. this.widgets[d[1]] = f.input;
  92. }
  93. else if(d[0]=='Date') {
  94. c1.innerHTML = d[1];
  95. var f = make_field({fieldtype:'Date', 'label':d[1], 'options':d[2]}, '', c2, this, 0, 1);
  96. f.not_in_form = 1;
  97. f.refresh();
  98. f.dialog = this;
  99. this.widgets[d[1]] = f.input;
  100. }
  101. else if(d[0]=='Password') {
  102. c1.innerHTML = d[1];
  103. c2.style.overflow = 'auto';
  104. this.widgets[d[1]] = $a_input(c2, 'password');
  105. if(d[3])$a(c2, 'div', 'field_description').innerHTML = d[3];
  106. }
  107. else if(d[0]=='Select') {
  108. c1.innerHTML = d[1];
  109. this.widgets[d[1]] = $a(c2, 'select', '', {width:'160px'})
  110. if(d[2])$a(c2, 'div', 'field_description').innerHTML = d[2];
  111. if(d[3])add_sel_options(this.widgets[d[1]], d[3], d[3][0]);
  112. }
  113. else if(d[0]=='Text') {
  114. c1.innerHTML = d[1];
  115. c2.style.overflow = 'auto';
  116. this.widgets[d[1]] = $a(c2, 'textarea');
  117. if(d[2])$a(c2, 'div', 'field_description').innerHTML = d[2];
  118. }
  119. else if(d[0]=='Button') {
  120. c2.style.height = '32px';
  121. var b = $btn(c2, d[1], function(btn) {
  122. if(btn._onclick) btn._onclick(me) }, null, null, 1);
  123. b.dialog = me;
  124. if(!this.first_button) {
  125. $(b).addClass('btn-info');
  126. this.first_button = true;
  127. }
  128. if(d[2]) {
  129. b._onclick = d[2];
  130. }
  131. this.widgets[d[1]] = b;
  132. }
  133. }
  134. });