checkbox.html 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. <tr>
  36. <th><span>控件名称</span><span class="label label-important">*</span></th>
  37. <th><span>选中状态</span></th>
  38. </tr>
  39. <tr>
  40. <td><input id="orgname" placeholder="必填项" type="text"/></td>
  41. <td>
  42. <label class="radio"><input id="orgchecked0" checked="checked" name="checked" type="radio"> 不选中 </label>
  43. <label class="radio"><input id="orgchecked1" name="checked" type="radio"> 选中 </label>
  44. </td>
  45. </tr>
  46. </table>
  47. </div>
  48. <script type="text/javascript">
  49. var oNode = null, thePlugins = 'checkbox';
  50. window.onload = function () {
  51. if (UE.plugins[thePlugins].editdom) {
  52. oNode = UE.plugins[thePlugins].editdom;
  53. var gTitle = oNode.getAttribute('title').replace(/&quot;/g, "\"");
  54. $G('orgname').value = gTitle;
  55. var checked = oNode.getAttribute('checked');
  56. checked ? $G('orgchecked1').checked = true : $G('orgchecked0').checked = true;
  57. }
  58. }
  59. dialog.oncancel = function () {
  60. if (UE.plugins[thePlugins].editdom) {
  61. delete UE.plugins[thePlugins].editdom;
  62. }
  63. };
  64. dialog.onok = function () {
  65. if ($G('orgname').value == '') {
  66. alert('控件名称不能为空');
  67. return false;
  68. }
  69. var gTitle = $G('orgname').value.replace(/\"/g, "&quot;");
  70. if (!oNode) {
  71. try {
  72. oNode = createElement('input', 'leipiNewField');
  73. oNode.setAttribute('title', gTitle);
  74. oNode.setAttribute('leipiPlugins', thePlugins);
  75. oNode.setAttribute('type', 'checkbox');
  76. if ($G('orgchecked1').checked) {
  77. oNode.setAttribute('checked', 'checked');
  78. } else {
  79. oNode.checked = false;
  80. }
  81. editor.execCommand('insertHtml', oNode.outerHTML);
  82. return true;
  83. } catch (e) {
  84. try {
  85. editor.execCommand('error');
  86. } catch (e) {
  87. alert('控件异常,请到 [雷劈网] 反馈或寻求帮助!');
  88. }
  89. return false;
  90. }
  91. } else {
  92. oNode.setAttribute('title', gTitle);
  93. if ($G('orgchecked1').checked) {
  94. oNode.setAttribute('checked', 'checked');
  95. } else {
  96. oNode.removeAttribute('checked');
  97. }
  98. delete UE.plugins[thePlugins].editdom;
  99. return true;
  100. }
  101. };
  102. </script>
  103. </body>
  104. </html>