macros.html 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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. function createElement(type, name) {
  19. var element = null;
  20. try {
  21. element = document.createElement('<' + type + ' name="' + name + '">');
  22. } catch (e) {
  23. }
  24. if (element == null) {
  25. element = document.createElement(type);
  26. element.name = name;
  27. }
  28. return element;
  29. }
  30. </script>
  31. </head>
  32. <body>
  33. <div class="content">
  34. <table class="table table-bordered table-striped table-hover">
  35. <thead>
  36. <tr>
  37. <th><span>控件名称</span><span class="label label-important">*</span></th>
  38. <th><span>类型</span></th>
  39. </tr>
  40. <tr>
  41. <td>
  42. <input id="orgname" type="text" placeholder="必填项"/>
  43. </td>
  44. <td>
  45. <select id="orgtype" class="span7">
  46. <optgroup label="----常用日期宏控件----">
  47. <option value="sys_datetime">当前日期+时间 [ 1997-01-01 12:30 ]</option>
  48. <option value="sys_date">当前日期 [ 1997-01-01 ]</option>
  49. <option value="sys_date_cn">当前日期 [ 1997年1月1日 ]</option>
  50. <option value="sys_date_cn_short1">当前日期 [ 1997年1月 ]</option>
  51. <option value="sys_date_cn_short4">当前年份 [ 1997 ]</option>
  52. <option value="sys_date_cn_short3">当前年份 [ 1997年 ]</option>
  53. <option value="sys_date_cn_short2">当前日期 [ 1月1日 ]</option>
  54. <option value="sys_time">当前时间 [ 12:30 ]</option>
  55. <option value="sys_week">当前星期 [ 星期一 ]</option>
  56. </optgroup>
  57. <optgroup label="----扩展定义----">
  58. <option value="sys_userid">当前用户ID,如 9527</option>
  59. <option value="sys_realname">当前用户姓名,如 唐伯虎</option>
  60. <option value="sys_dept">当前用户部门,如 华府</option>
  61. </optgroup>
  62. </select>
  63. </td>
  64. </tr>
  65. </thead>
  66. <tbody id='itemAttr'>
  67. <tr>
  68. <th><span>控件样式</span></th>
  69. <th><span>可见性</span></th>
  70. </tr>
  71. <tr>
  72. <td>
  73. 宽 <input id="orgwidth" type="text" value="150" class="input-small span1" placeholder="auto"/> px
  74. &nbsp;&nbsp;
  75. 字体大小 <input id="orgfontsize" type="text" value="" class="input-small span1" placeholder="auto"/> px
  76. </td>
  77. <td>
  78. <label class="checkbox"> <input id="orghide" type="checkbox"> 隐藏 </label>
  79. </td>
  80. </tr>
  81. </tbody>
  82. </table>
  83. </div>
  84. <script type="text/javascript">
  85. var oNode = null, thePlugins = 'macros';
  86. window.onload = function () {
  87. if (UE.plugins[thePlugins].editdom) {
  88. oNode = UE.plugins[thePlugins].editdom;
  89. var gTitle = oNode.getAttribute('title').replace(/&quot;/g, "\""), gHidden = oNode.getAttribute('orghide'),
  90. gFontSize = oNode.getAttribute('orgfontsize'), gWidth = oNode.getAttribute('orgwidth'),
  91. gType = oNode.getAttribute('orgtype');
  92. gTitle = gTitle == null ? '' : gTitle;
  93. $G('orgname').value = gTitle;
  94. //if( oNode.tagName == 'INPUT' ) {}
  95. if (oNode.getAttribute('orghide') == '1') {
  96. $G('orghide').checked = true;
  97. }
  98. $G('orgname').value = gTitle;
  99. $G('orgtype').value = gType;
  100. $G('orgwidth').value = gWidth;
  101. $G('orgfontsize').value = gFontSize;
  102. }
  103. }
  104. dialog.oncancel = function () {
  105. if (UE.plugins[thePlugins].editdom) {
  106. delete UE.plugins[thePlugins].editdom;
  107. }
  108. };
  109. dialog.onok = function () {
  110. if ($G('orgname').value == '') {
  111. alert('控件名称不能为空');
  112. return false;
  113. }
  114. var gTitle = $G('orgname').value.replace(/\"/g, "&quot;"), gFontSize = $G('orgfontsize').value,
  115. gWidth = $G('orgwidth').value, gType = $G('orgtype').value;
  116. if (!oNode) {
  117. try {
  118. /*
  119. if ( $G('orgtype').value.indexOf('sys_list')>0 ) {
  120. oNode = document.createElement("select");
  121. var objOption = new Option('{macros}', '');
  122. oNode.options[oNode.options.length] = objOption;
  123. } else {
  124. //input
  125. }*/
  126. oNode = createElement('input', 'leipiNewField');
  127. oNode.setAttribute('type', 'text');
  128. oNode.setAttribute('value', '{macros}');
  129. oNode.setAttribute('title', gTitle);
  130. oNode.setAttribute('name', 'leipiNewField');
  131. oNode.setAttribute('leipiPlugins', thePlugins);
  132. oNode.setAttribute('orgtype', gType);
  133. if ($G('orghide').checked) {
  134. oNode.setAttribute('orghide', '1');
  135. } else {
  136. oNode.setAttribute('orghide', '0');
  137. }
  138. if (gFontSize != '') {
  139. oNode.style.fontSize = gFontSize + 'px';
  140. oNode.setAttribute('orgfontsize', gFontSize);
  141. }
  142. if (gWidth != '') {
  143. oNode.style.width = gWidth + 'px';
  144. oNode.setAttribute('orgwidth', gWidth);
  145. }
  146. editor.execCommand('insertHtml', oNode.outerHTML);
  147. return true;
  148. } catch (e) {
  149. try {
  150. editor.execCommand('error');
  151. } catch (e) {
  152. alert('控件异常,请到 [雷劈网] 反馈或寻求帮助!');
  153. }
  154. return false;
  155. }
  156. } else {
  157. var norgname = oNode.getAttribute('name').replace(/\"/g, "&quot;");
  158. var oNewNode = null;
  159. domUtils.remove(oNode, false); //删除当前控件,再创建一个新的
  160. /*
  161. if ( $G('orgtype').value.indexOf('sys_list') > 0 ) {
  162. oNewNode = document.createElement("select");
  163. var objOption = new Option('{macros}', '');
  164. oNewNode.options[oNewNode.options.length] = objOption;
  165. }*/
  166. oNewNode = createElement('input', 'leipiNewField');
  167. oNewNode.setAttribute('type', 'text');
  168. oNewNode.setAttribute('value', '{macros}');
  169. oNewNode.setAttribute('title', gTitle);
  170. oNewNode.setAttribute('name', norgname);
  171. oNewNode.setAttribute('leipiPlugins', thePlugins);
  172. oNewNode.setAttribute('orgtype', gType);
  173. if ($G('orghide').checked) {
  174. oNewNode.setAttribute('orghide', '1');
  175. } else {
  176. oNewNode.setAttribute('orghide', '0');
  177. }
  178. if (gFontSize != '') {
  179. oNewNode.style.fontSize = gFontSize + 'px';
  180. oNewNode.setAttribute('orgfontsize', gFontSize);
  181. } else {
  182. oNewNode.setAttribute('orgfontsize', '');
  183. }
  184. if (gWidth != '') {
  185. oNewNode.style.width = gWidth + 'px';
  186. oNewNode.setAttribute('orgwidth', gWidth);
  187. } else {
  188. oNewNode.setAttribute('orgwidth', '');
  189. }
  190. editor.execCommand('insertHtml', oNewNode.outerHTML);
  191. delete UE.plugins[thePlugins].editdom;
  192. }
  193. };
  194. </script>
  195. </body>
  196. </html>