text.html 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <head>
  4. <title>文本框</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  6. <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
  7. <meta name="generator" content="www.leipi.org"/>
  8. <link rel="stylesheet" href="bootstrap/css/bootstrap.css">
  9. <!--[if lte IE 6]>
  10. <link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap-ie6.css">
  11. <![endif]-->
  12. <!--[if lte IE 7]>
  13. <link rel="stylesheet" type="text/css" href="bootstrap/css/ie.css">
  14. <![endif]-->
  15. <link rel="stylesheet" href="leipi.style.css">
  16. <script type="text/javascript" src="../dialogs/internal.js"></script>
  17. <script type="text/javascript">
  18. /* Thank you by
  19. http://www.alt-tag.com/blog/2006/02/ie-dom-bugs/ */
  20. function createElement(type, name) {
  21. var element = null;
  22. try {
  23. element = document.createElement('<' + type + ' name="' + name + '">');
  24. } catch (e) {
  25. }
  26. if (element == null) {
  27. element = document.createElement(type);
  28. element.name = name;
  29. }
  30. return element;
  31. }
  32. </script>
  33. </head>
  34. <body>
  35. <div class="content">
  36. <table class="table table-bordered table-striped table-hover">
  37. <tr>
  38. <th><span>控件名称</span><span class="label label-important">*</span></th>
  39. <th><span>默认值</span></th>
  40. </tr>
  41. <tr>
  42. <td><input type="text" id="orgname" placeholder="必填项"></td>
  43. <td><input type="text" id="orgvalue" placeholder="无则不填"></td>
  44. </tr>
  45. <tr>
  46. <th><span>数据类型</span></th>
  47. <th><span>对齐方式</span></th>
  48. </tr>
  49. <tr>
  50. <td>
  51. <select id="orgtype">
  52. <option value="text">普通文本</option>
  53. <option value="email">邮箱地址</option>
  54. <option value="int">整数</option>
  55. <option value="float">小数</option>
  56. <option value="idcard">身份证号码</option>
  57. </select>
  58. </td>
  59. <td>
  60. <select id="orgalign">
  61. <option value="left">左对齐</option>
  62. <option value="center">居中对齐</option>
  63. <option value="right">右对齐</option>
  64. </select>
  65. </td>
  66. </tr>
  67. <tr>
  68. <th>
  69. <span>&nbsp;&nbsp;&nbsp;&nbsp;长&nbsp;&nbsp;X&nbsp;&nbsp;宽&nbsp;&nbsp;&nbsp;&&nbsp;&nbsp;&nbsp;字体大小</span>
  70. </th>
  71. <th><span>可见性</span></th>
  72. </tr>
  73. <tr>
  74. <td>
  75. <input id="orgwidth" type="text" value="150" class="input-small span1" placeholder="auto"/>
  76. X
  77. <input id="orgheight" type="text" value="" class="input-small span1" placeholder="auto"/>
  78. &
  79. <input id="orgfontsize" type="text" value="" class="input-small span1" placeholder="auto"/> px
  80. </td>
  81. <td>
  82. <label class="checkbox inline"><input id="orghide" type="checkbox"/> 隐藏 </label>
  83. </td>
  84. </tr>
  85. </table>
  86. </div>
  87. <script type="text/javascript">
  88. var oNode = null, thePlugins = 'text';
  89. window.onload = function () {
  90. if (UE.plugins[thePlugins].editdom) {
  91. oNode = UE.plugins[thePlugins].editdom;
  92. var gValue = '';
  93. if (oNode.getAttribute('value'))
  94. gValue = oNode.getAttribute('value').replace(/&quot;/g, "\"");
  95. var gTitle = oNode.getAttribute('title').replace(/&quot;/g, "\""), gHidden = oNode.getAttribute('orghide'),
  96. gFontSize = oNode.getAttribute('orgfontsize'), gAlign = oNode.getAttribute('orgalign'),
  97. gWidth = oNode.getAttribute('orgwidth'), gHeight = oNode.getAttribute('orgheight'),
  98. gType = oNode.getAttribute('orgtype');
  99. gValue = gValue == null ? '' : gValue;
  100. gTitle = gTitle == null ? '' : gTitle;
  101. $G('orgvalue').value = gValue;
  102. $G('orgname').value = gTitle;
  103. if (gHidden == '1') {
  104. $G('orghide').checked = true;
  105. }
  106. $G('orgfontsize').value = gFontSize;
  107. $G('orgwidth').value = gWidth;
  108. $G('orgheight').value = gHeight;
  109. $G('orgalign').value = gAlign;
  110. $G('orgtype').value = gType;
  111. }
  112. }
  113. dialog.oncancel = function () {
  114. if (UE.plugins[thePlugins].editdom) {
  115. delete UE.plugins[thePlugins].editdom;
  116. }
  117. };
  118. dialog.onok = function () {
  119. if ($G('orgname').value == '') {
  120. alert('请输入控件名称');
  121. return false;
  122. }
  123. var gValue = $G('orgvalue').value.replace(/\"/g, "&quot;"),
  124. gTitle = $G('orgname').value.replace(/\"/g, "&quot;"), gFontSize = $G('orgfontsize').value,
  125. gAlign = $G('orgalign').value, gWidth = $G('orgwidth').value, gHeight = $G('orgheight').value,
  126. gType = $G('orgtype').value;
  127. if (!oNode) {
  128. try {
  129. oNode = createElement('input', 'leipiNewField');
  130. oNode.setAttribute('type', 'text');
  131. oNode.setAttribute('title', gTitle);
  132. oNode.setAttribute('value', gValue);
  133. oNode.setAttribute('name', 'leipiNewField');
  134. oNode.setAttribute('leipiPlugins', thePlugins);
  135. if ($G('orghide').checked) {
  136. oNode.setAttribute('orghide', 1);
  137. } else {
  138. oNode.setAttribute('orghide', 0);
  139. }
  140. if (gFontSize != '') {
  141. oNode.style.fontSize = gFontSize + 'px';
  142. //style += 'font-size:' + gFontSize + 'px;';
  143. oNode.setAttribute('orgfontsize', gFontSize);
  144. }
  145. if (gAlign != '') {
  146. //style += 'text-align:' + gAlign + ';';
  147. oNode.style.textAlign = gAlign;
  148. oNode.setAttribute('orgalign', gAlign);
  149. }
  150. if (gWidth != '') {
  151. oNode.style.width = gWidth + 'px';
  152. //style += 'width:' + gWidth + 'px;';
  153. oNode.setAttribute('orgwidth', gWidth);
  154. }
  155. if (gHeight != '') {
  156. oNode.style.height = gHeight + 'px';
  157. //style += 'height:' + gHeight + 'px;';
  158. oNode.setAttribute('orgheight', gHeight);
  159. }
  160. if (gType != '') {
  161. oNode.setAttribute('orgtype', gType);
  162. }
  163. //oNode.setAttribute('style',style );
  164. //oNode.style.cssText=style;//ie7
  165. editor.execCommand('insertHtml', oNode.outerHTML);
  166. } catch (e) {
  167. try {
  168. editor.execCommand('error');
  169. } catch (e) {
  170. alert('控件异常,请到 [雷劈网] 反馈或寻求帮助!');
  171. }
  172. return false;
  173. }
  174. } else {
  175. oNode.setAttribute('title', gTitle);
  176. oNode.setAttribute('value', $G('orgvalue').value);
  177. if ($G('orghide').checked) {
  178. oNode.setAttribute('orghide', 1);
  179. } else {
  180. oNode.setAttribute('orghide', 0);
  181. }
  182. if (gFontSize != '') {
  183. oNode.style.fontSize = gFontSize + 'px';
  184. oNode.setAttribute('orgfontsize', gFontSize);
  185. } else {
  186. oNode.style.fontSize = '';
  187. oNode.setAttribute('orgfontsize', '');
  188. }
  189. if (gAlign != '') {
  190. oNode.style.textAlign = gAlign;
  191. oNode.setAttribute('orgalign', gAlign);
  192. } else {
  193. oNode.setAttribute('orgalign', '');
  194. }
  195. if (gWidth != '') {
  196. oNode.style.width = gWidth + 'px';
  197. oNode.setAttribute('orgwidth', gWidth);
  198. } else {
  199. oNode.style.width = '';
  200. oNode.setAttribute('orgwidth', '');
  201. }
  202. if (gHeight != '') {
  203. oNode.style.height = gHeight + 'px';
  204. oNode.setAttribute('orgheight', gHeight);
  205. } else {
  206. oNode.style.height = '';
  207. oNode.setAttribute('orgheight', '');
  208. }
  209. if (gType != '') {
  210. oNode.setAttribute('orgtype', gType);
  211. } else {
  212. oNode.setAttribute('orgtype', '');
  213. }
  214. delete UE.plugins[thePlugins].editdom;
  215. }
  216. };
  217. </script>
  218. </body>
  219. </html>