form_builder.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>H+ 后台主题UI框架 - Bootstrap3 表单构建器</title>
  7. <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
  8. <meta name="description" content="H+是一个完全响应式,基于Bootstrap3最新版本开发的扁平化主题,她采用了主流的左右两栏式布局,使用了Html5+CSS3等现代技术">
  9. <link rel="shortcut icon" href="favicon.ico"> <link href="../css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
  10. <link href="../css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
  11. <link href="../css/animate.min.css" rel="stylesheet">
  12. <link href="../css/plugins/summernote/summernote.css" rel="stylesheet">
  13. <link href="../css/plugins/summernote/summernote-bs3.css" rel="stylesheet">
  14. <link href="../css/style.min.css?v=4.1.0" rel="stylesheet">
  15. <style>
  16. .droppable-active{background-color:#ffe!important}.tools a{cursor:pointer;font-size:80%}.form-body .col-md-6,.form-body .col-md-12{min-height:400px}.draggable{cursor:move}
  17. </style>
  18. </head>
  19. <body class="gray-bg">
  20. <div class="wrapper wrapper-content">
  21. <div class="row">
  22. <div class="col-sm-5">
  23. <div class="ibox float-e-margins">
  24. <div class="ibox-title">
  25. <h5>元素</h5>
  26. <div class="ibox-tools">
  27. <a class="collapse-link">
  28. <i class="fa fa-chevron-up"></i>
  29. </a>
  30. <a class="dropdown-toggle" data-toggle="dropdown" href="form_editors.html#">
  31. <i class="fa fa-wrench"></i>
  32. </a>
  33. <ul class="dropdown-menu dropdown-user">
  34. <li><a href="form_editors.html#">选项1</a>
  35. </li>
  36. <li><a href="form_editors.html#">选项2</a>
  37. </li>
  38. </ul>
  39. <a class="close-link">
  40. <i class="fa fa-times"></i>
  41. </a>
  42. </div>
  43. </div>
  44. <div class="ibox-content">
  45. <div class="alert alert-info">
  46. 拖拽左侧的表单元素到右侧区域,即可生成相应的HTML代码,表单代码,轻松搞定!
  47. </div>
  48. <form role="form" class="form-horizontal m-t">
  49. <div class="form-group draggable">
  50. <label class="col-sm-3 control-label">文本框:</label>
  51. <div class="col-sm-9">
  52. <input type="text" name="" class="form-control" placeholder="请输入文本">
  53. <span class="help-block m-b-none">说明文字</span>
  54. </div>
  55. </div>
  56. <div class="form-group draggable">
  57. <label class="col-sm-3 control-label">密码框:</label>
  58. <div class="col-sm-9">
  59. <input type="password" class="form-control" name="password" placeholder="请输入密码">
  60. </div>
  61. </div>
  62. <div class="form-group draggable">
  63. <label class="col-sm-3 control-label">下拉列表:</label>
  64. <div class="col-sm-9">
  65. <select class="form-control" name="">
  66. <option>选项 1</option>
  67. <option>选项 2</option>
  68. <option>选项 3</option>
  69. <option>选项 4</option>
  70. </select>
  71. </div>
  72. </div>
  73. <div class="form-group draggable">
  74. <label class="col-sm-3 control-label">文件域:</label>
  75. <div class="col-sm-9">
  76. <input type="file" name="" class="form-control">
  77. </div>
  78. </div>
  79. <div class="form-group draggable">
  80. <label class="col-sm-3 control-label">纯文本:</label>
  81. <div class="col-sm-9">
  82. <p class="form-control-static">这里是纯文字信息</p>
  83. </div>
  84. </div>
  85. <div class="form-group draggable">
  86. <label class="col-sm-3 control-label">单选框:
  87. </label>
  88. <div class="col-sm-9">
  89. <label class="radio-inline">
  90. <input type="radio" checked="" value="option1" id="optionsRadios1" name="optionsRadios">选项1</label>
  91. <label class="radio-inline">
  92. <input type="radio" value="option2" id="optionsRadios2" name="optionsRadios">选项2</label>
  93. </div>
  94. </div>
  95. <div class="form-group draggable">
  96. <label class="col-sm-3 control-label">复选框:</label>
  97. <div class="col-sm-9">
  98. <label class="checkbox-inline">
  99. <input type="checkbox" value="option1" id="inlineCheckbox1">选项1</label>
  100. <label class="checkbox-inline">
  101. <input type="checkbox" value="option2" id="inlineCheckbox2">选项2</label>
  102. <label class="checkbox-inline">
  103. <input type="checkbox" value="option3" id="inlineCheckbox3">选项3</label>
  104. </div>
  105. </div>
  106. <div class="hr-line-dashed"></div>
  107. <div class="form-group draggable">
  108. <div class="col-sm-12 col-sm-offset-3">
  109. <button class="btn btn-primary" type="submit">保存内容</button>
  110. <button class="btn btn-white" type="submit">取消</button>
  111. </div>
  112. </div>
  113. </form>
  114. <div class="clearfix"></div>
  115. </div>
  116. </div>
  117. </div>
  118. <div class="col-sm-7">
  119. <div class="ibox float-e-margins">
  120. <div class="ibox-title">
  121. <h5>拖拽左侧表单元素到此区域</h5>
  122. <div class="ibox-tools">
  123. 请选择显示的列数:
  124. <select id="n-columns">
  125. <option value="1">显示1列</option>
  126. <option value="2">显示2列</option>
  127. </select>
  128. </div>
  129. </div>
  130. <div class="ibox-content">
  131. <div class="row form-body form-horizontal m-t">
  132. <div class="col-md-12 droppable sortable">
  133. </div>
  134. <div class="col-md-6 droppable sortable" style="display: none;">
  135. </div>
  136. <div class="col-md-6 droppable sortable" style="display: none;">
  137. </div>
  138. </div>
  139. <button type="submit" class="btn btn-warning" data-clipboard-text="testing" id="copy-to-clipboard">复制代码</button>
  140. </div>
  141. </div>
  142. </div>
  143. </div>
  144. </div>
  145. <script src="../js/jquery.min.js?v=2.1.4"></script>
  146. <script src="../js/bootstrap.min.js?v=3.3.6"></script>
  147. <script src="../js/content.min.js?v=1.0.0"></script>
  148. <script src="../js/jquery-ui-1.10.4.min.js"></script>
  149. <script src="../js/plugins/beautifyhtml/beautifyhtml.js"></script>
  150. <script>
  151. $(document).ready(function(){setup_draggable();$("#n-columns").on("change",function(){var v=$(this).val();if(v==="1"){var $col=$(".form-body .col-md-12").toggle(true);$(".form-body .col-md-6 .draggable").each(function(i,el){$(this).remove().appendTo($col)});$(".form-body .col-md-6").toggle(false)}else{var $col=$(".form-body .col-md-6").toggle(true);$(".form-body .col-md-12 .draggable").each(function(i,el){$(this).remove().appendTo(i%2?$col[1]:$col[0])});$(".form-body .col-md-12").toggle(false)}});$("#copy-to-clipboard").on("click",function(){var $copy=$(".form-body").clone().appendTo(document.body);$copy.find(".tools, :hidden").remove();$.each(["draggable","droppable","sortable","dropped","ui-sortable","ui-draggable","ui-droppable","form-body"],function(i,c){$copy.find("."+c).removeClass(c).removeAttr("style")});var html=html_beautify($copy.html());$copy.remove();$modal=get_modal(html).modal("show");$modal.find(".btn").remove();$modal.find(".modal-title").html("复制HTML代码");$modal.find(":input:first").select().focus();return false})});var setup_draggable=function(){$(".draggable").draggable({appendTo:"body",helper:"clone"});$(".droppable").droppable({accept:".draggable",helper:"clone",hoverClass:"droppable-active",drop:function(event,ui){$(".empty-form").remove();var $orig=$(ui.draggable);if(!$(ui.draggable).hasClass("dropped")){var $el=$orig.clone().addClass("dropped").css({"position":"static","left":null,"right":null}).appendTo(this);var id=$orig.find(":input").attr("id");if(id){id=id.split("-").slice(0,-1).join("-")+"-"+(parseInt(id.split("-").slice(-1)[0])+1);$orig.find(":input").attr("id",id);$orig.find("label").attr("for",id)}$('<p class="tools col-sm-12 col-sm-offset-3"> <a class="edit-link">编辑HTML<a> | <a class="remove-link">移除</a></p>').appendTo($el)}else{if($(this)[0]!=$orig.parent()[0]){var $el=$orig.clone().css({"position":"static","left":null,"right":null}).appendTo(this);$orig.remove()}}}}).sortable()};var get_modal=function(content){var modal=$('<div class="modal" style="overflow: auto;" tabindex="-1"> <div class="modal-dialog"><div class="modal-content"><div class="modal-header"><a type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</a><h4 class="modal-title">编辑HTML</h4></div><div class="modal-body ui-front"> <textarea class="form-control" style="min-height: 200px; margin-bottom: 10px;font-family: Monaco, Fixed">'+content+'</textarea><button class="btn btn-success">更新HTML</button></div> </div></div></div>').appendTo(document.body);return modal};$(document).on("click",".edit-link",function(ev){var $el=$(this).parent().parent();var $el_copy=$el.clone();var $edit_btn=$el_copy.find(".edit-link").parent().remove();var $modal=get_modal(html_beautify($el_copy.html())).modal("show");$modal.find(":input:first").focus();$modal.find(".btn-success").click(function(ev2){var html=$modal.find("textarea").val();if(!html){$el.remove()}else{$el.html(html);$edit_btn.appendTo($el)}$modal.modal("hide");return false})});$(document).on("click",".remove-link",function(ev){$(this).parent().parent().remove()});
  152. </script>
  153. </body>
  154. </html>