textfield.html.ajax.bak 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <title>插入文本框</title>
  7. <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
  8. <link rel="stylesheet" href="leipi.style.css">
  9. <script type="text/javascript" src="../dialogs/internal.js"></script>
  10. <style>
  11. </style>
  12. </head>
  13. <body>
  14. <div class="content">
  15. <table class="table table-bordered table-striped table-hover">
  16. <tr>
  17. <th><span>控件名称</span><span class="label label-danger">*</span></th>
  18. <th><span>默认值</span> </th>
  19. </tr>
  20. <tr>
  21. <td><input type="text" class="form-control input-sm" id="txtName" placeholder="必填项"></td>
  22. <td><input type="text" class="form-control input-sm" id="txtValue" placeholder="无则不填"></td>
  23. </tr>
  24. <tr>
  25. <th><span>输入框样式</span> </th>
  26. <th><span>可见性</span> </th>
  27. </tr>
  28. <tr>
  29. <td>
  30. 宽 <input id="txtWidth" type="text" value="150" size="5"/> px
  31. &nbsp;&nbsp;
  32. 高 <input id="txtHeight" type="text" value="20" size="5"/> px
  33. </td>
  34. <td> <label><input id="txtHidden" type="checkbox" /> 隐藏 </label> </td>
  35. </tr>
  36. <tr>
  37. <th><span>字体大小</span> </th>
  38. <th><span>对齐方式</span> </th>
  39. </tr>
  40. <tr>
  41. <td> <input id="txtFontSize" type="text" size="5" value="12" /> px</td>
  42. <td>
  43. <select id="txtAlign" class="form-control">
  44. <option value="left" >左对齐</option>
  45. <option value="center">居中对齐</option>
  46. <option value="right">右对齐</option>
  47. </select>
  48. </td>
  49. </tr>
  50. </table>
  51. </div>
  52. <script type="text/javascript">
  53. var oNode = null;
  54. window.onload = function() {
  55. //弹出窗口初始化函数,这里主要是判断是编辑文本框还是新增
  56. //以下这个对象定义在editor.all.js第13259行。
  57. if( UE.plugins['textfield'].editdom ){
  58. oNode = UE.plugins['textfield'].editdom;
  59. $G('txtName').value = oNode.getAttribute('title');
  60. $G('txtValue').value = oNode.getAttribute('value');
  61. var nHidden = oNode.getAttribute('hide');
  62. if ( nHidden == '1' ) {
  63. $G('txtHidden').checked = true ;
  64. } else {
  65. nHidden = '0';
  66. }
  67. var sItemId = oNode.getAttribute('name').substr(5);
  68. var sFontSize = oNode.style.fontSize;
  69. $G('txtFontSize').value = sFontSize.substr(0, sFontSize.length - 2);//这里的substr是为了去掉末尾的'px'
  70. var sSizeWidth = oNode.style.width;
  71. $G('txtWidth').value = sSizeWidth.substr(0, sSizeWidth.length - 2);
  72. var sSizeHeight = oNode.style.height;
  73. $G('txtHeight').value = sSizeHeight.substr(0, sSizeHeight.length - 2);
  74. $G('txtAlign').value = oNode.style.textAlign;
  75. }
  76. }
  77. dialog.oncancel = function () {
  78. if( UE.plugins['textfield'].editdom ) {
  79. delete UE.plugins['textfield'].editdom;
  80. }
  81. };
  82. dialog.onok = function (){
  83. if($G('txtName').value==''){
  84. alert('请输入控件名称');
  85. return false;
  86. }
  87. if( !oNode ) {
  88. var sUrl = '/itemid.html'// parent.getItemUrl;
  89. var nItemId = 0;
  90. ajax.request(sUrl, {method: 'GET',timeout:60000,async: false,onsuccess:function (xhr) {
  91. try {
  92. nItemId = xhr.responseText;
  93. var html = '<input type="text"';
  94. html += ' title = "' + $G('txtName').value + '"';
  95. html += ' name = "data_' + nItemId + '"';
  96. html += ' value = "' + $G('txtValue').value + '"';
  97. if ( $G('txtHidden').checked ) {
  98. html += ' hide = "1"';
  99. } else {
  100. html += ' hide = "0"';
  101. }
  102. html += ' style = "';
  103. if( $G('txtFontSize').value != '' ) {
  104. html += 'font-size:' + $G('txtFontSize').value + 'px;';
  105. }
  106. if( $G('txtAlign').value != '' ) {
  107. html += 'text-align:' + $G('txtAlign').value + ';';
  108. }
  109. if( $G('txtWidth').value != '' ) {
  110. html += 'width:' + $G('txtWidth').value + 'px;';
  111. }
  112. if( $G('txtHeight').value != '' ) {
  113. html += 'height:' + $G('txtHeight').value + 'px;';
  114. }
  115. html += '" />';
  116. editor.execCommand('insertHtml',html);
  117. } catch (e) {
  118. return;
  119. }
  120. },
  121. error:function () {
  122. alert('Request TimeOut');
  123. }
  124. })
  125. } else {
  126. oNode.setAttribute('title', $G('txtName').value);
  127. oNode.setAttribute('value', $G('txtValue').value);
  128. if( $G('txtHidden').checked ) {
  129. oNode.setAttribute('hide', 1);
  130. } else {
  131. oNode.setAttribute('hide', 0);
  132. }
  133. var style = '';
  134. if( $G('txtFontSize').value != '' ) {
  135. style += 'font-size:' + $G('txtFontSize').value + 'px;';
  136. }
  137. if( $G('txtAlign').value != '' ) {
  138. style += 'text-align:' + $G('txtAlign').value + ';';
  139. }
  140. if( $G('txtWidth').value != '' ) {
  141. style += 'width:' + $G('txtWidth').value + 'px;';
  142. }
  143. if( $G('txtHeight').value != '' ) {
  144. style += 'height:' + $G('txtHeight').value + 'px;';
  145. }
  146. oNode.setAttribute('style',style );
  147. delete UE.plugins['textfield'].editdom; //使用后清空这个对象,变回新增模式
  148. }
  149. };
  150. </script>
  151. </body>
  152. </html>