leipi.form.build.plugins.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. /*e.preventDefault();//阻止元素发生默认的行为(例如,当点击提交按钮时阻止对表单的提交*/
  2. /* 文本框控件 text
  3. acc 是 class="component" 的DIV
  4. e 是 class="leipiplugins" 的控件
  5. */
  6. LPB.plugins['text'] = function (active_component,leipiplugins) {
  7. var plugins = 'text',popover = $(".popover");
  8. //右弹form 初始化值
  9. $(popover).find("#orgname").val($(leipiplugins).attr("title"));
  10. $(popover).find("#orgvalue").val($(leipiplugins).val());
  11. //右弹form 取消控件
  12. $(popover).delegate(".btn-danger", "click", function(e){
  13. active_component.popover("hide");
  14. });
  15. //右弹form 确定控件
  16. $(popover).delegate(".btn-info", "click", function(e){
  17. var inputs = $(popover).find("input");
  18. if($(popover).find("textarea").length>0)
  19. {
  20. inputs.push($(popover).find("textarea")[0]);
  21. }
  22. $.each(inputs, function(i,e){
  23. var attr_name = $(e).attr("id");//属性名称
  24. var attr_val = $(e).val();
  25. switch(attr_name)
  26. {
  27. //要break
  28. case 'orgvalue':
  29. //$(leipiplugins).val(attr_val);
  30. $(leipiplugins).attr("value", attr_val);
  31. break;
  32. //没有break
  33. case 'orgname':
  34. $(leipiplugins).attr("title",attr_val);
  35. active_component.find(".leipiplugins-orgname").text(attr_val);
  36. break;
  37. default:
  38. $(leipiplugins).attr(attr_name, attr_val);
  39. }
  40. active_component.popover("hide");
  41. LPB.genSource();//重置源代码
  42. });
  43. });
  44. }
  45. /* 多行文本框控件 textarea
  46. acc 是 class="component" 的DIV
  47. e 是 class="leipiplugins" 的控件
  48. */
  49. LPB.plugins['textarea'] = function (active_component,leipiplugins) {
  50. var plugins = 'textarea',popover = $(".popover");
  51. //右弹form 初始化值
  52. $(popover).find("#orgname").val($(leipiplugins).attr("title"));
  53. $(popover).find("#orgvalue").val($(leipiplugins).val());
  54. //右弹form 取消控件
  55. $(popover).delegate(".btn-danger", "click", function(e){
  56. active_component.popover("hide");
  57. });
  58. //右弹form 确定控件
  59. $(popover).delegate(".btn-info", "click", function(e){
  60. var inputs = $(popover).find("input");
  61. if($(popover).find("textarea").length>0)
  62. {
  63. inputs.push($(popover).find("textarea")[0]);
  64. }
  65. $.each(inputs, function(i,e){
  66. var attr_name = $(e).attr("id");//属性名称
  67. var attr_val = $(e).val();
  68. switch(attr_name)
  69. {
  70. //要break
  71. case 'orgvalue':
  72. //$(leipiplugins).val(attr_val);
  73. $(leipiplugins).text(attr_val);
  74. break;
  75. //没有break
  76. case 'orgname':
  77. $(leipiplugins).attr("title",attr_val);
  78. active_component.find(".leipiplugins-orgname").text(attr_val);
  79. default:
  80. $(leipiplugins).attr(attr_name, attr_val);
  81. }
  82. active_component.popover("hide");
  83. LPB.genSource();//重置源代码
  84. });
  85. });
  86. }
  87. /* 下拉框控件 select
  88. acc 是 class="component" 的DIV
  89. e 是 class="leipiplugins" 的控件
  90. */
  91. LPB.plugins['select'] = function (active_component,leipiplugins) {
  92. var plugins = 'select',popover = $(".popover");
  93. //右弹form 初始化值
  94. $(popover).find("#orgname").val($(leipiplugins).attr("title"));
  95. var val = $.map($(leipiplugins).find("option"), function(e,i){return $(e).text()});
  96. val = val.join("\r");
  97. $(popover).find("#orgvalue").text(val);
  98. //右弹form 取消控件
  99. $(popover).delegate(".btn-danger", "click", function(e){
  100. active_component.popover("hide");
  101. });
  102. //右弹form 确定控件
  103. $(popover).delegate(".btn-info", "click", function(e){
  104. var inputs = $(popover).find("input");
  105. if($(popover).find("textarea").length>0)
  106. {
  107. inputs.push($(popover).find("textarea")[0]);
  108. }
  109. $.each(inputs, function(i,e){
  110. var attr_name = $(e).attr("id");//属性名称
  111. var attr_val = $(e).val();
  112. switch(attr_name)
  113. {
  114. //要break
  115. case 'orgvalue':
  116. var options = attr_val.split("\n");
  117. $(leipiplugins).html("");
  118. $.each(options, function(i,e){
  119. $(leipiplugins).append("\n ");
  120. $(leipiplugins).append($("<option>").text(e));
  121. });
  122. //$(leipiplugins).text(attr_val);
  123. break;
  124. case 'orgname':
  125. $(leipiplugins).attr("title",attr_val);
  126. active_component.find(".leipiplugins-orgname").text(attr_val);
  127. break;
  128. default:
  129. $(leipiplugins).attr(attr_name, attr_val);
  130. }
  131. active_component.popover("hide");
  132. LPB.genSource();//重置源代码
  133. });
  134. });
  135. }
  136. /* 复选控件 checkbox
  137. acc 是 class="component" 的DIV
  138. e 是 class="leipiplugins" 的控件
  139. */
  140. LPB.plugins['checkbox'] = function (active_component,leipiplugins) {
  141. var plugins = 'checkbox',popover = $(".popover");
  142. //右弹form 初始化值
  143. $(popover).find("#orgname").val($(leipiplugins).attr("title"));
  144. val = $.map($(leipiplugins), function(e,i){return $(e).val().trim()});
  145. val = val.join("\r");
  146. $(popover).find("#orgvalue").text(val);
  147. //右弹form 取消控件
  148. $(popover).delegate(".btn-danger", "click", function(e){
  149. active_component.popover("hide");
  150. });
  151. //右弹form 确定控件
  152. $(popover).delegate(".btn-info", "click", function(e){
  153. var inputs = $(popover).find("input");
  154. if($(popover).find("textarea").length>0)
  155. {
  156. inputs.push($(popover).find("textarea")[0]);
  157. }
  158. $.each(inputs, function(i,e){
  159. var attr_name = $(e).attr("id");//属性名称
  160. var attr_val = $(e).val();
  161. switch(attr_name)
  162. {
  163. //要break
  164. case 'orgvalue':
  165. var checkboxes = attr_val.split("\n");
  166. var html = "<!-- Multiple Checkboxes -->\n";
  167. $.each(checkboxes, function(i,e){
  168. if(e.length > 0){
  169. var vName = $(leipiplugins).eq(i).attr("name"),vTitle = $(leipiplugins).eq(i).attr("title"),orginline = $(leipiplugins).eq(i).attr("orginline");
  170. if(!vName) vName = ''; if(!vTitle) vTitle = ''; if(!orginline) orginline = '';
  171. html += '<label class="checkbox '+orginline+'">\n<input type="checkbox" name="'+vName+'" title="'+vTitle+'" value="'+e+'" orginline="'+orginline+'" class="leipiplugins" leipiplugins="checkbox" >'+e+'\n</label>';
  172. }
  173. $(active_component).find(".leipiplugins-orgvalue").html(html);
  174. });
  175. break;
  176. case 'orgname':
  177. $(leipiplugins).attr("title",attr_val);
  178. active_component.find(".leipiplugins-orgname").text(attr_val);
  179. break;
  180. default:
  181. $(leipiplugins).attr(attr_name, attr_val);
  182. }
  183. active_component.popover("hide");
  184. LPB.genSource();//重置源代码
  185. });
  186. });
  187. }
  188. /* 复选控件 radio
  189. acc 是 class="component" 的DIV
  190. e 是 class="leipiplugins" 的控件
  191. */
  192. LPB.plugins['radio'] = function (active_component,leipiplugins) {
  193. var plugins = 'radio',popover = $(".popover");
  194. //右弹form 初始化值
  195. $(popover).find("#orgname").val($(leipiplugins).attr("title"));
  196. val = $.map($(leipiplugins), function(e,i){return $(e).val().trim()});
  197. val = val.join("\r");
  198. $(popover).find("#orgvalue").text(val);
  199. //右弹form 取消控件
  200. $(popover).delegate(".btn-danger", "click", function(e){
  201. active_component.popover("hide");
  202. });
  203. //右弹form 确定控件
  204. $(popover).delegate(".btn-info", "click", function(e){
  205. var inputs = $(popover).find("input");
  206. if($(popover).find("textarea").length>0)
  207. {
  208. inputs.push($(popover).find("textarea")[0]);
  209. }
  210. $.each(inputs, function(i,e){
  211. var attr_name = $(e).attr("id");//属性名称
  212. var attr_val = $(e).val();
  213. switch(attr_name)
  214. {
  215. //要break
  216. case 'orgvalue':
  217. var checkboxes = attr_val.split("\n");
  218. var html = "<!-- Multiple Checkboxes -->\n";
  219. $.each(checkboxes, function(i,e){
  220. if(e.length > 0){
  221. var vName = $(leipiplugins).eq(i).attr("name"),vTitle = $(leipiplugins).eq(i).attr("title"),orginline = $(leipiplugins).eq(i).attr("orginline");
  222. if(!vName) vName = ''; if(!vTitle) vTitle = ''; if(!orginline) orginline = '';
  223. html += '<label class="radio '+orginline+'">\n<input type="radio" name="'+vName+'" title="'+vTitle+'" value="'+e+'" orginline="'+orginline+'" class="leipiplugins" leipiplugins="radio" >'+e+'\n</label>';
  224. }
  225. $(active_component).find(".leipiplugins-orgvalue").html(html);
  226. });
  227. break;
  228. case 'orgname':
  229. $(leipiplugins).attr("title",attr_val);
  230. active_component.find(".leipiplugins-orgname").text(attr_val);
  231. break;
  232. default:
  233. $(leipiplugins).attr(attr_name, attr_val);
  234. }
  235. active_component.popover("hide");
  236. LPB.genSource();//重置源代码
  237. });
  238. });
  239. }
  240. /* 上传控件 uploadfile
  241. acc 是 class="component" 的DIV
  242. e 是 class="leipiplugins" 的控件
  243. */
  244. LPB.plugins['uploadfile'] = function (active_component,leipiplugins) {
  245. var plugins = 'uploadfile',popover = $(".popover");
  246. //右弹form 初始化值
  247. $(popover).find("#orgname").val($(leipiplugins).attr("title"));
  248. //右弹form 取消控件
  249. $(popover).delegate(".btn-danger", "click", function(e){
  250. active_component.popover("hide");
  251. });
  252. //右弹form 确定控件
  253. $(popover).delegate(".btn-info", "click", function(e){
  254. var inputs = $(popover).find("input");
  255. if($(popover).find("textarea").length>0)
  256. {
  257. inputs.push($(popover).find("textarea")[0]);
  258. }
  259. $.each(inputs, function(i,e){
  260. var attr_name = $(e).attr("id");//属性名称
  261. var attr_val = $(e).val();
  262. switch(attr_name)
  263. {
  264. case 'orgname':
  265. $(leipiplugins).attr("title",attr_val);
  266. active_component.find(".leipiplugins-orgname").text(attr_val);
  267. break;
  268. default:
  269. $(leipiplugins).attr(attr_name, attr_val);
  270. }
  271. active_component.popover("hide");
  272. LPB.genSource();//重置源代码
  273. });
  274. });
  275. }