leipi.formdesign.v4.js 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074
  1. /*
  2. * 设计器私有的配置说明
  3. * 一
  4. * UE.leipiFormDesignUrl 插件路径
  5. *
  6. * 二
  7. *UE.getEditor('myFormDesign',{
  8. * toolleipi:true,//是否显示,设计器的清单 tool
  9. */
  10. UE.leipiFormDesignUrl = 'formdesign';
  11. /**
  12. * 文本框
  13. * @command textfield
  14. * @method execCommand
  15. * @param { String } cmd 命令字符串
  16. * @example
  17. * ```javascript
  18. * editor.execCommand( 'textfield');
  19. * ```
  20. */
  21. UE.plugins['text'] = function () {
  22. var me = this, thePlugins = 'text';
  23. me.commands[thePlugins] = {
  24. execCommand: function () {
  25. var dialog = new UE.ui.Dialog({
  26. iframeUrl: this.options.UEDITOR_HOME_URL + UE.leipiFormDesignUrl + '/text.html',
  27. name: thePlugins,
  28. editor: this,
  29. title: '文本框',
  30. cssRules: "width:600px;height:310px;",
  31. buttons: [
  32. {
  33. className: 'edui-okbutton',
  34. label: '确定',
  35. onclick: function () {
  36. dialog.close(true);
  37. }
  38. },
  39. {
  40. className: 'edui-cancelbutton',
  41. label: '取消',
  42. onclick: function () {
  43. dialog.close(false);
  44. }
  45. }]
  46. });
  47. dialog.render();
  48. dialog.open();
  49. }
  50. };
  51. var popup = new baidu.editor.ui.Popup({
  52. editor: this,
  53. content: '',
  54. className: 'edui-bubble',
  55. _edittext: function () {
  56. baidu.editor.plugins[thePlugins].editdom = popup.anchorEl;
  57. me.execCommand(thePlugins);
  58. this.hide();
  59. },
  60. _delete: function () {
  61. if (window.confirm('确认删除该控件吗?')) {
  62. baidu.editor.dom.domUtils.remove(this.anchorEl, false);
  63. }
  64. this.hide();
  65. }
  66. });
  67. popup.render();
  68. me.addListener('mouseover', function (t, evt) {
  69. evt = evt || window.event;
  70. var el = evt.target || evt.srcElement;
  71. var leipiPlugins = el.getAttribute('leipiplugins');
  72. if (/input/ig.test(el.tagName) && leipiPlugins == thePlugins) {
  73. var html = popup.formatHtml(
  74. '<nobr>文本框: <span onclick=$$._edittext() class="edui-clickable">编辑</span>&nbsp;&nbsp;<span onclick=$$._delete() class="edui-clickable">删除</span></nobr>');
  75. if (html) {
  76. popup.getDom('content').innerHTML = html;
  77. popup.anchorEl = el;
  78. popup.showAnchor(popup.anchorEl);
  79. } else {
  80. popup.hide();
  81. }
  82. }
  83. });
  84. };
  85. /**
  86. * 宏控件
  87. * @command macros
  88. * @method execCommand
  89. * @param { String } cmd 命令字符串
  90. * @example
  91. * ```javascript
  92. * editor.execCommand( 'macros');
  93. * ```
  94. */
  95. UE.plugins['macros'] = function () {
  96. var me = this, thePlugins = 'macros';
  97. me.commands[thePlugins] = {
  98. execCommand: function () {
  99. var dialog = new UE.ui.Dialog({
  100. iframeUrl: this.options.UEDITOR_HOME_URL + UE.leipiFormDesignUrl + '/macros.html',
  101. name: thePlugins,
  102. editor: this,
  103. title: '宏控件',
  104. cssRules: "width:600px;height:270px;",
  105. buttons: [
  106. {
  107. className: 'edui-okbutton',
  108. label: '确定',
  109. onclick: function () {
  110. dialog.close(true);
  111. }
  112. },
  113. {
  114. className: 'edui-cancelbutton',
  115. label: '取消',
  116. onclick: function () {
  117. dialog.close(false);
  118. }
  119. }]
  120. });
  121. dialog.render();
  122. dialog.open();
  123. }
  124. };
  125. var popup = new baidu.editor.ui.Popup({
  126. editor: this,
  127. content: '',
  128. className: 'edui-bubble',
  129. _edittext: function () {
  130. baidu.editor.plugins[thePlugins].editdom = popup.anchorEl;
  131. me.execCommand(thePlugins);
  132. this.hide();
  133. },
  134. _delete: function () {
  135. if (window.confirm('确认删除该控件吗?')) {
  136. baidu.editor.dom.domUtils.remove(this.anchorEl, false);
  137. }
  138. this.hide();
  139. }
  140. });
  141. popup.render();
  142. me.addListener('mouseover', function (t, evt) {
  143. evt = evt || window.event;
  144. var el = evt.target || evt.srcElement;
  145. var leipiPlugins = el.getAttribute('leipiplugins');
  146. if (/input/ig.test(el.tagName) && leipiPlugins == thePlugins) {
  147. var html = popup.formatHtml(
  148. '<nobr>宏控件: <span onclick=$$._edittext() class="edui-clickable">编辑</span>&nbsp;&nbsp;<span onclick=$$._delete() class="edui-clickable">删除</span></nobr>');
  149. if (html) {
  150. popup.getDom('content').innerHTML = html;
  151. popup.anchorEl = el;
  152. popup.showAnchor(popup.anchorEl);
  153. } else {
  154. popup.hide();
  155. }
  156. }
  157. });
  158. };
  159. /**
  160. * 单选框
  161. * @command radio
  162. * @method execCommand
  163. * @param { String } cmd 命令字符串
  164. * @example
  165. * ```javascript
  166. * editor.execCommand( 'radio');
  167. * ```
  168. UE.plugins['radio'] = function () {
  169. var me = this,thePlugins = 'radio';
  170. me.commands[thePlugins] = {
  171. execCommand:function () {
  172. var dialog = new UE.ui.Dialog({
  173. iframeUrl:this.options.UEDITOR_HOME_URL + UE.leipiFormDesignUrl+'/radio.html',
  174. name:thePlugins,
  175. editor:this,
  176. title: '单选框',
  177. cssRules:"width:590px;height:370px;",
  178. buttons:[
  179. {
  180. className:'edui-okbutton',
  181. label:'确定',
  182. onclick:function () {
  183. dialog.close(true);
  184. }
  185. },
  186. {
  187. className:'edui-cancelbutton',
  188. label:'取消',
  189. onclick:function () {
  190. dialog.close(false);
  191. }
  192. }]
  193. });
  194. dialog.render();
  195. dialog.open();
  196. }
  197. };
  198. var popup = new baidu.editor.ui.Popup( {
  199. editor:this,
  200. content: '',
  201. className: 'edui-bubble',
  202. _edittext: function () {
  203. baidu.editor.plugins[thePlugins].editdom = popup.anchorEl;
  204. me.execCommand(thePlugins);
  205. this.hide();
  206. },
  207. _delete:function(){
  208. if( window.confirm('确认删除该控件吗?') ) {
  209. baidu.editor.dom.domUtils.remove(this.anchorEl,false);
  210. }
  211. this.hide();
  212. }
  213. } );
  214. popup.render();
  215. me.addListener( 'mouseover', function( t, evt ) {
  216. evt = evt || window.event;
  217. var el = evt.target || evt.srcElement;
  218. var leipiPlugins = el.getAttribute('leipiplugins');
  219. if ( /input/ig.test( el.tagName ) && leipiPlugins==thePlugins) {
  220. var html = popup.formatHtml(
  221. '<nobr>单选框: <span onclick=$$._edittext() class="edui-clickable">编辑</span>&nbsp;&nbsp;<span onclick=$$._delete() class="edui-clickable">删除</span></nobr>' );
  222. if ( html ) {
  223. popup.getDom( 'content' ).innerHTML = html;
  224. popup.anchorEl = el;
  225. popup.showAnchor( popup.anchorEl );
  226. } else {
  227. popup.hide();
  228. }
  229. }
  230. });
  231. };
  232. */
  233. /**
  234. * 复选框
  235. * @command checkbox
  236. * @method execCommand
  237. * @param { String } cmd 命令字符串
  238. * @example
  239. * ```javascript
  240. * editor.execCommand( 'checkbox');
  241. * ```
  242. */
  243. /*
  244. UE.plugins['checkbox'] = function () {
  245. var me = this,thePlugins = 'checkbox';
  246. me.commands[thePlugins] = {
  247. execCommand:function () {
  248. var dialog = new UE.ui.Dialog({
  249. iframeUrl:this.options.UEDITOR_HOME_URL + UE.leipiFormDesignUrl+'/checkbox.html',
  250. name:thePlugins,
  251. editor:this,
  252. title: '复选框',
  253. cssRules:"width:600px;height:200px;",
  254. buttons:[
  255. {
  256. className:'edui-okbutton',
  257. label:'确定',
  258. onclick:function () {
  259. dialog.close(true);
  260. }
  261. },
  262. {
  263. className:'edui-cancelbutton',
  264. label:'取消',
  265. onclick:function () {
  266. dialog.close(false);
  267. }
  268. }]
  269. });
  270. dialog.render();
  271. dialog.open();
  272. }
  273. };
  274. var popup = new baidu.editor.ui.Popup( {
  275. editor:this,
  276. content: '',
  277. className: 'edui-bubble',
  278. _edittext: function () {
  279. baidu.editor.plugins[thePlugins].editdom = popup.anchorEl;
  280. me.execCommand(thePlugins);
  281. this.hide();
  282. },
  283. _delete:function(){
  284. if( window.confirm('确认删除该控件吗?') ) {
  285. baidu.editor.dom.domUtils.remove(this.anchorEl,false);
  286. }
  287. this.hide();
  288. }
  289. } );
  290. popup.render();
  291. me.addListener( 'mouseover', function( t, evt ) {
  292. evt = evt || window.event;
  293. var el = evt.target || evt.srcElement;
  294. var leipiPlugins = el.getAttribute('leipiplugins');
  295. if ( /input/ig.test( el.tagName ) && leipiPlugins==thePlugins) {
  296. var html = popup.formatHtml(
  297. '<nobr>复选框: <span onclick=$$._edittext() class="edui-clickable">编辑</span>&nbsp;&nbsp;<span onclick=$$._delete() class="edui-clickable">删除</span></nobr>' );
  298. if ( html ) {
  299. popup.getDom( 'content' ).innerHTML = html;
  300. popup.anchorEl = el;
  301. popup.showAnchor( popup.anchorEl );
  302. } else {
  303. popup.hide();
  304. }
  305. }
  306. });
  307. };
  308. */
  309. /**
  310. * 单选框组
  311. * @command radios
  312. * @method execCommand
  313. * @param { String } cmd 命令字符串
  314. * @example
  315. * ```javascript
  316. * editor.execCommand( 'radio');
  317. * ```
  318. */
  319. UE.plugins['radios'] = function () {
  320. var me = this, thePlugins = 'radios';
  321. me.commands[thePlugins] = {
  322. execCommand: function () {
  323. var dialog = new UE.ui.Dialog({
  324. iframeUrl: this.options.UEDITOR_HOME_URL + UE.leipiFormDesignUrl + '/radios.html',
  325. name: thePlugins,
  326. editor: this,
  327. title: '单选框组',
  328. cssRules: "width:590px;height:370px;",
  329. buttons: [
  330. {
  331. className: 'edui-okbutton',
  332. label: '确定',
  333. onclick: function () {
  334. dialog.close(true);
  335. }
  336. },
  337. {
  338. className: 'edui-cancelbutton',
  339. label: '取消',
  340. onclick: function () {
  341. dialog.close(false);
  342. }
  343. }]
  344. });
  345. dialog.render();
  346. dialog.open();
  347. }
  348. };
  349. var popup = new baidu.editor.ui.Popup({
  350. editor: this,
  351. content: '',
  352. className: 'edui-bubble',
  353. _edittext: function () {
  354. baidu.editor.plugins[thePlugins].editdom = popup.anchorEl;
  355. me.execCommand(thePlugins);
  356. this.hide();
  357. },
  358. _delete: function () {
  359. if (window.confirm('确认删除该控件吗?')) {
  360. baidu.editor.dom.domUtils.remove(this.anchorEl, false);
  361. }
  362. this.hide();
  363. }
  364. });
  365. popup.render();
  366. me.addListener('mouseover', function (t, evt) {
  367. evt = evt || window.event;
  368. var el = evt.target || evt.srcElement;
  369. var leipiPlugins = el.getAttribute('leipiplugins');
  370. if (/span/ig.test(el.tagName) && leipiPlugins == thePlugins) {
  371. var html = popup.formatHtml(
  372. '<nobr>单选框组: <span onclick=$$._edittext() class="edui-clickable">编辑</span>&nbsp;&nbsp;<span onclick=$$._delete() class="edui-clickable">删除</span></nobr>');
  373. if (html) {
  374. var elInput = el.getElementsByTagName("input");
  375. var rEl = elInput.length > 0 ? elInput[0] : el;
  376. popup.getDom('content').innerHTML = html;
  377. popup.anchorEl = el;
  378. popup.showAnchor(rEl);
  379. } else {
  380. popup.hide();
  381. }
  382. }
  383. });
  384. };
  385. /**
  386. * 复选框组
  387. * @command checkboxs
  388. * @method execCommand
  389. * @param { String } cmd 命令字符串
  390. * @example
  391. * ```javascript
  392. * editor.execCommand( 'checkboxs');
  393. * ```
  394. */
  395. UE.plugins['checkboxs'] = function () {
  396. var me = this, thePlugins = 'checkboxs';
  397. me.commands[thePlugins] = {
  398. execCommand: function () {
  399. var dialog = new UE.ui.Dialog({
  400. iframeUrl: this.options.UEDITOR_HOME_URL + UE.leipiFormDesignUrl + '/checkboxs.html',
  401. name: thePlugins,
  402. editor: this,
  403. title: '复选框组',
  404. cssRules: "width:600px;height:400px;",
  405. buttons: [
  406. {
  407. className: 'edui-okbutton',
  408. label: '确定',
  409. onclick: function () {
  410. dialog.close(true);
  411. }
  412. },
  413. {
  414. className: 'edui-cancelbutton',
  415. label: '取消',
  416. onclick: function () {
  417. dialog.close(false);
  418. }
  419. }]
  420. });
  421. dialog.render();
  422. dialog.open();
  423. }
  424. };
  425. var popup = new baidu.editor.ui.Popup({
  426. editor: this,
  427. content: '',
  428. className: 'edui-bubble',
  429. _edittext: function () {
  430. baidu.editor.plugins[thePlugins].editdom = popup.anchorEl;
  431. me.execCommand(thePlugins);
  432. this.hide();
  433. },
  434. _delete: function () {
  435. if (window.confirm('确认删除该控件吗?')) {
  436. baidu.editor.dom.domUtils.remove(this.anchorEl, false);
  437. }
  438. this.hide();
  439. }
  440. });
  441. popup.render();
  442. me.addListener('mouseover', function (t, evt) {
  443. evt = evt || window.event;
  444. var el = evt.target || evt.srcElement;
  445. var leipiPlugins = el.getAttribute('leipiplugins');
  446. if (/span/ig.test(el.tagName) && leipiPlugins == thePlugins) {
  447. var html = popup.formatHtml(
  448. '<nobr>复选框组: <span onclick=$$._edittext() class="edui-clickable">编辑</span>&nbsp;&nbsp;<span onclick=$$._delete() class="edui-clickable">删除</span></nobr>');
  449. if (html) {
  450. var elInput = el.getElementsByTagName("input");
  451. var rEl = elInput.length > 0 ? elInput[0] : el;
  452. popup.getDom('content').innerHTML = html;
  453. popup.anchorEl = el;
  454. popup.showAnchor(rEl);
  455. } else {
  456. popup.hide();
  457. }
  458. }
  459. });
  460. };
  461. /**
  462. * 多行文本框
  463. * @command textarea
  464. * @method execCommand
  465. * @param { String } cmd 命令字符串
  466. * @example
  467. * ```javascript
  468. * editor.execCommand( 'textarea');
  469. * ```
  470. */
  471. UE.plugins['textarea'] = function () {
  472. var me = this, thePlugins = 'textarea';
  473. me.commands[thePlugins] = {
  474. execCommand: function () {
  475. var dialog = new UE.ui.Dialog({
  476. iframeUrl: this.options.UEDITOR_HOME_URL + UE.leipiFormDesignUrl + '/textarea.html',
  477. name: thePlugins,
  478. editor: this,
  479. title: '多行文本框',
  480. cssRules: "width:600px;height:330px;",
  481. buttons: [
  482. {
  483. className: 'edui-okbutton',
  484. label: '确定',
  485. onclick: function () {
  486. dialog.close(true);
  487. }
  488. },
  489. {
  490. className: 'edui-cancelbutton',
  491. label: '取消',
  492. onclick: function () {
  493. dialog.close(false);
  494. }
  495. }]
  496. });
  497. dialog.render();
  498. dialog.open();
  499. }
  500. };
  501. var popup = new baidu.editor.ui.Popup({
  502. editor: this,
  503. content: '',
  504. className: 'edui-bubble',
  505. _edittext: function () {
  506. baidu.editor.plugins[thePlugins].editdom = popup.anchorEl;
  507. me.execCommand(thePlugins);
  508. this.hide();
  509. },
  510. _delete: function () {
  511. if (window.confirm('确认删除该控件吗?')) {
  512. baidu.editor.dom.domUtils.remove(this.anchorEl, false);
  513. }
  514. this.hide();
  515. }
  516. });
  517. popup.render();
  518. me.addListener('mouseover', function (t, evt) {
  519. evt = evt || window.event;
  520. var el = evt.target || evt.srcElement;
  521. if (/textarea/ig.test(el.tagName)) {
  522. var html = popup.formatHtml(
  523. '<nobr>多行文本框: <span onclick=$$._edittext() class="edui-clickable">编辑</span>&nbsp;&nbsp;<span onclick=$$._delete() class="edui-clickable">删除</span></nobr>');
  524. if (html) {
  525. popup.getDom('content').innerHTML = html;
  526. popup.anchorEl = el;
  527. popup.showAnchor(popup.anchorEl);
  528. } else {
  529. popup.hide();
  530. }
  531. }
  532. });
  533. };
  534. /**
  535. * 下拉菜单
  536. * @command select
  537. * @method execCommand
  538. * @param { String } cmd 命令字符串
  539. * @example
  540. * ```javascript
  541. * editor.execCommand( 'select');
  542. * ```
  543. */
  544. UE.plugins['select'] = function () {
  545. var me = this, thePlugins = 'select';
  546. me.commands[thePlugins] = {
  547. execCommand: function () {
  548. var dialog = new UE.ui.Dialog({
  549. iframeUrl: this.options.UEDITOR_HOME_URL + UE.leipiFormDesignUrl + '/select.html',
  550. name: thePlugins,
  551. editor: this,
  552. title: '下拉菜单',
  553. cssRules: "width:590px;height:370px;",
  554. buttons: [
  555. {
  556. className: 'edui-okbutton',
  557. label: '确定',
  558. onclick: function () {
  559. dialog.close(true);
  560. }
  561. },
  562. {
  563. className: 'edui-cancelbutton',
  564. label: '取消',
  565. onclick: function () {
  566. dialog.close(false);
  567. }
  568. }]
  569. });
  570. dialog.render();
  571. dialog.open();
  572. }
  573. };
  574. var popup = new baidu.editor.ui.Popup({
  575. editor: this,
  576. content: '',
  577. className: 'edui-bubble',
  578. _edittext: function () {
  579. baidu.editor.plugins[thePlugins].editdom = popup.anchorEl;
  580. me.execCommand(thePlugins);
  581. this.hide();
  582. },
  583. _delete: function () {
  584. if (window.confirm('确认删除该控件吗?')) {
  585. baidu.editor.dom.domUtils.remove(this.anchorEl, false);
  586. }
  587. this.hide();
  588. }
  589. });
  590. popup.render();
  591. me.addListener('mouseover', function (t, evt) {
  592. evt = evt || window.event;
  593. var el = evt.target || evt.srcElement;
  594. var leipiPlugins = el.getAttribute('leipiplugins');
  595. if (/select|span/ig.test(el.tagName) && leipiPlugins == thePlugins) {
  596. var html = popup.formatHtml(
  597. '<nobr>下拉菜单: <span onclick=$$._edittext() class="edui-clickable">编辑</span>&nbsp;&nbsp;<span onclick=$$._delete() class="edui-clickable">删除</span></nobr>');
  598. if (html) {
  599. if (el.tagName == 'SPAN') {
  600. var elInput = el.getElementsByTagName("select");
  601. el = elInput.length > 0 ? elInput[0] : el;
  602. }
  603. popup.getDom('content').innerHTML = html;
  604. popup.anchorEl = el;
  605. popup.showAnchor(popup.anchorEl);
  606. } else {
  607. popup.hide();
  608. }
  609. }
  610. });
  611. };
  612. /**
  613. * 进度条
  614. * @command progressbar
  615. * @method execCommand
  616. * @param { String } cmd 命令字符串
  617. * @example
  618. * ```javascript
  619. * editor.execCommand( 'progressbar');
  620. * ```
  621. */
  622. UE.plugins['progressbar'] = function () {
  623. var me = this, thePlugins = 'progressbar';
  624. me.commands[thePlugins] = {
  625. execCommand: function () {
  626. var dialog = new UE.ui.Dialog({
  627. iframeUrl: this.options.UEDITOR_HOME_URL + UE.leipiFormDesignUrl + '/progressbar.html',
  628. name: thePlugins,
  629. editor: this,
  630. title: '进度条',
  631. cssRules: "width:600px;height:450px;",
  632. buttons: [
  633. {
  634. className: 'edui-okbutton',
  635. label: '确定',
  636. onclick: function () {
  637. dialog.close(true);
  638. }
  639. },
  640. {
  641. className: 'edui-cancelbutton',
  642. label: '取消',
  643. onclick: function () {
  644. dialog.close(false);
  645. }
  646. }]
  647. });
  648. dialog.render();
  649. dialog.open();
  650. }
  651. };
  652. var popup = new baidu.editor.ui.Popup({
  653. editor: this,
  654. content: '',
  655. className: 'edui-bubble',
  656. _edittext: function () {
  657. baidu.editor.plugins[thePlugins].editdom = popup.anchorEl;
  658. me.execCommand(thePlugins);
  659. this.hide();
  660. },
  661. _delete: function () {
  662. if (window.confirm('确认删除该控件吗?')) {
  663. baidu.editor.dom.domUtils.remove(this.anchorEl, false);
  664. }
  665. this.hide();
  666. }
  667. });
  668. popup.render();
  669. me.addListener('mouseover', function (t, evt) {
  670. evt = evt || window.event;
  671. var el = evt.target || evt.srcElement;
  672. var leipiPlugins = el.getAttribute('leipiplugins');
  673. if (/img/ig.test(el.tagName) && leipiPlugins == thePlugins) {
  674. var html = popup.formatHtml(
  675. '<nobr>进度条: <span onclick=$$._edittext() class="edui-clickable">编辑</span>&nbsp;&nbsp;<span onclick=$$._delete() class="edui-clickable">删除</span></nobr>');
  676. if (html) {
  677. popup.getDom('content').innerHTML = html;
  678. popup.anchorEl = el;
  679. popup.showAnchor(popup.anchorEl);
  680. } else {
  681. popup.hide();
  682. }
  683. }
  684. });
  685. };
  686. /**
  687. * 二维码
  688. * @command qrcode
  689. * @method execCommand
  690. * @param { String } cmd 命令字符串
  691. * @example
  692. * ```javascript
  693. * editor.execCommand( 'qrcode');
  694. * ```
  695. */
  696. UE.plugins['qrcode'] = function () {
  697. var me = this, thePlugins = 'qrcode';
  698. me.commands[thePlugins] = {
  699. execCommand: function () {
  700. var dialog = new UE.ui.Dialog({
  701. iframeUrl: this.options.UEDITOR_HOME_URL + UE.leipiFormDesignUrl + '/qrcodex.html',
  702. name: thePlugins,
  703. editor: this,
  704. title: '二维码',
  705. cssRules: "width:600px;height:370px;",
  706. buttons: [
  707. {
  708. className: 'edui-okbutton',
  709. label: '确定',
  710. onclick: function () {
  711. dialog.close(true);
  712. }
  713. },
  714. {
  715. className: 'edui-cancelbutton',
  716. label: '取消',
  717. onclick: function () {
  718. dialog.close(false);
  719. }
  720. }]
  721. });
  722. dialog.render();
  723. dialog.open();
  724. }
  725. };
  726. var popup = new baidu.editor.ui.Popup({
  727. editor: this,
  728. content: '',
  729. className: 'edui-bubble',
  730. _edittext: function () {
  731. baidu.editor.plugins[thePlugins].editdom = popup.anchorEl;
  732. me.execCommand(thePlugins);
  733. this.hide();
  734. },
  735. _delete: function () {
  736. if (window.confirm('确认删除该控件吗?')) {
  737. baidu.editor.dom.domUtils.remove(this.anchorEl, false);
  738. }
  739. this.hide();
  740. }
  741. });
  742. popup.render();
  743. me.addListener('mouseover', function (t, evt) {
  744. evt = evt || window.event;
  745. var el = evt.target || evt.srcElement;
  746. var leipiPlugins = el.getAttribute('leipiplugins');
  747. if (/img/ig.test(el.tagName) && leipiPlugins == thePlugins) {
  748. var html = popup.formatHtml(
  749. '<nobr>二维码: <span onclick=$$._edittext() class="edui-clickable">编辑</span>&nbsp;&nbsp;<span onclick=$$._delete() class="edui-clickable">删除</span></nobr>');
  750. if (html) {
  751. popup.getDom('content').innerHTML = html;
  752. popup.anchorEl = el;
  753. popup.showAnchor(popup.anchorEl);
  754. } else {
  755. popup.hide();
  756. }
  757. }
  758. });
  759. };
  760. /**
  761. * 列表控件
  762. * @command listctrl
  763. * @method execCommand
  764. * @param { String } cmd 命令字符串
  765. * @example
  766. * ```javascript
  767. * editor.execCommand( 'qrcode');
  768. * ```
  769. */
  770. UE.plugins['listctrl'] = function () {
  771. var me = this, thePlugins = 'listctrl';
  772. me.commands[thePlugins] = {
  773. execCommand: function () {
  774. var dialog = new UE.ui.Dialog({
  775. iframeUrl: this.options.UEDITOR_HOME_URL + UE.leipiFormDesignUrl + '/listctrl.html',
  776. name: thePlugins,
  777. editor: this,
  778. title: '列表控件',
  779. cssRules: "width:800px;height:400px;",
  780. buttons: [
  781. {
  782. className: 'edui-okbutton',
  783. label: '确定',
  784. onclick: function () {
  785. dialog.close(true);
  786. }
  787. },
  788. {
  789. className: 'edui-cancelbutton',
  790. label: '取消',
  791. onclick: function () {
  792. dialog.close(false);
  793. }
  794. }]
  795. });
  796. dialog.render();
  797. dialog.open();
  798. }
  799. };
  800. var popup = new baidu.editor.ui.Popup({
  801. editor: this,
  802. content: '',
  803. className: 'edui-bubble',
  804. _edittext: function () {
  805. baidu.editor.plugins[thePlugins].editdom = popup.anchorEl;
  806. me.execCommand(thePlugins);
  807. this.hide();
  808. },
  809. _delete: function () {
  810. if (window.confirm('确认删除该控件吗?')) {
  811. baidu.editor.dom.domUtils.remove(this.anchorEl, false);
  812. }
  813. this.hide();
  814. }
  815. });
  816. popup.render();
  817. me.addListener('mouseover', function (t, evt) {
  818. evt = evt || window.event;
  819. var el = evt.target || evt.srcElement;
  820. var leipiPlugins = el.getAttribute('leipiplugins');
  821. if (/input/ig.test(el.tagName) && leipiPlugins == thePlugins) {
  822. var html = popup.formatHtml(
  823. '<nobr>列表控件: <span onclick=$$._edittext() class="edui-clickable">编辑</span>&nbsp;&nbsp;<span onclick=$$._delete() class="edui-clickable">删除</span></nobr>');
  824. if (html) {
  825. popup.getDom('content').innerHTML = html;
  826. popup.anchorEl = el;
  827. popup.showAnchor(popup.anchorEl);
  828. } else {
  829. popup.hide();
  830. }
  831. }
  832. });
  833. };
  834. UE.plugins['more'] = function () {
  835. var me = this, thePlugins = 'more';
  836. me.commands[thePlugins] = {
  837. execCommand: function () {
  838. var dialog = new UE.ui.Dialog({
  839. iframeUrl: this.options.UEDITOR_HOME_URL + UE.leipiFormDesignUrl + '/more.html',
  840. name: thePlugins,
  841. editor: this,
  842. title: '玩转表单设计器,一起参与,帮助完善',
  843. cssRules: "width:600px;height:200px;",
  844. buttons: [
  845. {
  846. className: 'edui-okbutton',
  847. label: '确定',
  848. onclick: function () {
  849. dialog.close(true);
  850. }
  851. }]
  852. });
  853. dialog.render();
  854. dialog.open();
  855. }
  856. };
  857. };
  858. UE.plugins['error'] = function () {
  859. var me = this, thePlugins = 'error';
  860. me.commands[thePlugins] = {
  861. execCommand: function () {
  862. var dialog = new UE.ui.Dialog({
  863. iframeUrl: this.options.UEDITOR_HOME_URL + UE.leipiFormDesignUrl + '/error.html',
  864. name: thePlugins,
  865. editor: this,
  866. title: '异常提示',
  867. cssRules: "width:400px;height:130px;",
  868. buttons: [
  869. {
  870. className: 'edui-okbutton',
  871. label: '确定',
  872. onclick: function () {
  873. dialog.close(true);
  874. }
  875. }]
  876. });
  877. dialog.render();
  878. dialog.open();
  879. }
  880. };
  881. };
  882. UE.plugins['leipi'] = function () {
  883. var me = this, thePlugins = 'leipi';
  884. me.commands[thePlugins] = {
  885. execCommand: function () {
  886. var dialog = new UE.ui.Dialog({
  887. iframeUrl: this.options.UEDITOR_HOME_URL + UE.leipiFormDesignUrl + '/leipi.html',
  888. name: thePlugins,
  889. editor: this,
  890. title: '表单设计器 - 清单',
  891. cssRules: "width:620px;height:220px;",
  892. buttons: [
  893. {
  894. className: 'edui-okbutton',
  895. label: '确定',
  896. onclick: function () {
  897. dialog.close(true);
  898. }
  899. }]
  900. });
  901. dialog.render();
  902. dialog.open();
  903. }
  904. };
  905. };
  906. UE.plugins['leipi_template'] = function () {
  907. var me = this, thePlugins = 'leipi_template';
  908. me.commands[thePlugins] = {
  909. execCommand: function () {
  910. var dialog = new UE.ui.Dialog({
  911. iframeUrl: this.options.UEDITOR_HOME_URL + UE.leipiFormDesignUrl + '/template.html',
  912. name: thePlugins,
  913. editor: this,
  914. title: '表单模板',
  915. cssRules: "width:640px;height:380px;",
  916. buttons: [
  917. {
  918. className: 'edui-okbutton',
  919. label: '确定',
  920. onclick: function () {
  921. dialog.close(true);
  922. }
  923. }]
  924. });
  925. dialog.render();
  926. dialog.open();
  927. }
  928. };
  929. };
  930. UE.registerUI('button_leipi', function (editor, uiName) {
  931. if (!this.options.toolleipi) {
  932. return false;
  933. }
  934. //注册按钮执行时的command命令,使用命令默认就会带有回退操作
  935. editor.registerCommand(uiName, {
  936. execCommand: function () {
  937. editor.execCommand('leipi');
  938. }
  939. });
  940. //创建一个button
  941. var btn = new UE.ui.Button({
  942. //按钮的名字
  943. name: uiName,
  944. //提示
  945. title: "表单设计器",
  946. //需要添加的额外样式,指定icon图标,这里默认使用一个重复的icon
  947. cssRules: 'background-position: -401px -40px;',
  948. //点击时执行的命令
  949. onclick: function () {
  950. //这里可以不用执行命令,做你自己的操作也可
  951. editor.execCommand(uiName);
  952. }
  953. });
  954. /*
  955. //当点到编辑内容上时,按钮要做的状态反射
  956. editor.addListener('selectionchange', function () {
  957. var state = editor.queryCommandState(uiName);
  958. if (state == -1) {
  959. btn.setDisabled(true);
  960. btn.setChecked(false);
  961. } else {
  962. btn.setDisabled(false);
  963. btn.setChecked(state);
  964. }
  965. });
  966. */
  967. //因为你是添加button,所以需要返回这个button
  968. return btn;
  969. });
  970. UE.registerUI('button_template', function (editor, uiName) {
  971. if (!this.options.toolleipi) {
  972. return false;
  973. }
  974. //注册按钮执行时的command命令,使用命令默认就会带有回退操作
  975. editor.registerCommand(uiName, {
  976. execCommand: function () {
  977. try {
  978. leipiFormDesign.exec('leipi_template');
  979. //leipiFormDesign.fnCheckForm('save');
  980. } catch (e) {
  981. alert('打开模板异常');
  982. }
  983. }
  984. });
  985. //创建一个button
  986. var btn = new UE.ui.Button({
  987. //按钮的名字
  988. name: uiName,
  989. //提示
  990. title: "表单模板",
  991. //需要添加的额外样式,指定icon图标,这里默认使用一个重复的icon
  992. cssRules: 'background-position: -339px -40px;',
  993. //点击时执行的命令
  994. onclick: function () {
  995. //这里可以不用执行命令,做你自己的操作也可
  996. editor.execCommand(uiName);
  997. }
  998. });
  999. //因为你是添加button,所以需要返回这个button
  1000. return btn;
  1001. });
  1002. UE.registerUI('button_preview', function (editor, uiName) {
  1003. if (!this.options.toolleipi) {
  1004. return false;
  1005. }
  1006. //注册按钮执行时的command命令,使用命令默认就会带有回退操作
  1007. editor.registerCommand(uiName, {
  1008. execCommand: function () {
  1009. try {
  1010. leipiFormDesign.fnReview();
  1011. } catch (e) {
  1012. alert('leipiFormDesign.fnReview 预览异常');
  1013. }
  1014. }
  1015. });
  1016. //创建一个button
  1017. var btn = new UE.ui.Button({
  1018. //按钮的名字
  1019. name: uiName,
  1020. //提示
  1021. title: "预览",
  1022. //需要添加的额外样式,指定icon图标,这里默认使用一个重复的icon
  1023. cssRules: 'background-position: -420px -19px;',
  1024. //点击时执行的命令
  1025. onclick: function () {
  1026. //这里可以不用执行命令,做你自己的操作也可
  1027. editor.execCommand(uiName);
  1028. }
  1029. });
  1030. //因为你是添加button,所以需要返回这个button
  1031. return btn;
  1032. });
  1033. UE.registerUI('button_save', function (editor, uiName) {
  1034. if (!this.options.toolleipi) {
  1035. return false;
  1036. }
  1037. //注册按钮执行时的command命令,使用命令默认就会带有回退操作
  1038. editor.registerCommand(uiName, {
  1039. execCommand: function () {
  1040. try {
  1041. leipiFormDesign.fnCheckForm('save');
  1042. } catch (e) {
  1043. alert('leipiFormDesign.fnCheckForm("save") 保存异常');
  1044. }
  1045. }
  1046. });
  1047. //创建一个button
  1048. var btn = new UE.ui.Button({
  1049. //按钮的名字
  1050. name: uiName,
  1051. //提示
  1052. title: "保存表单",
  1053. //需要添加的额外样式,指定icon图标,这里默认使用一个重复的icon
  1054. cssRules: 'background-position: -481px -20px;',
  1055. //点击时执行的命令
  1056. onclick: function () {
  1057. //这里可以不用执行命令,做你自己的操作也可
  1058. editor.execCommand(uiName);
  1059. }
  1060. });
  1061. //因为你是添加button,所以需要返回这个button
  1062. return btn;
  1063. });