indexLayout.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790
  1. /*******************************************************************************
  2. *
  3. * 系统首页布局设计js
  4. *
  5. * <pre>
  6. *
  7. * 作者:hugh zhuang
  8. * 邮箱:zhuangxh@jee-soft.cn
  9. * 日期:2015-01-8-上午11:10:52
  10. * 版权:广州宏天软件有限公司版权所有
  11. * </pre>
  12. *
  13. ******************************************************************************/
  14. var indexLayoutPlugin = null;
  15. ;(function($, window, document, undefined) {
  16. var pluginName = "indexLayout",
  17. defaults = {
  18. templateAliasKey:"template-alias"//模版别名
  19. },
  20. contenthandle = null,
  21. layouthistory=null,
  22. layoutClass= ".index-layout",
  23. STORAGE_KEY ="indexLayoutData",
  24. downloadLayout="#download-layout",
  25. currentDocument = null,
  26. timerSave = 1000, stopsave = 0, startdrag = 0,
  27. indexHtml = $(layoutClass).html();
  28. //currenteditor = null
  29. function Plugin(element, options) {
  30. this.settings = $.extend({}, defaults, options);
  31. this._defaults = defaults;
  32. this._name = pluginName;
  33. this.init();
  34. }
  35. Plugin.prototype = {
  36. init : function() {
  37. indexLayoutPlugin = this;
  38. //this.initCkeditor();
  39. this.restoreData();
  40. this.initData();
  41. setInterval(function() {
  42. indexLayoutPlugin.handleSaveLayout();
  43. }, timerSave);
  44. },
  45. initData:function(){
  46. this.initSetting();
  47. this.initDraggable();
  48. // 初始化容器
  49. this.initContainer();
  50. //初始化操作
  51. this.initOperation();
  52. this.removeElm();
  53. this.gridSystemGenerator();
  54. },
  55. // //初始化Ckeditor
  56. // initCkeditor : function() {
  57. // CKEDITOR.disableAutoInline = true;
  58. // contenthandle = CKEDITOR.replace('contenteditor', {
  59. // language : 'zh-cn',
  60. // contentsCss : [ __ctx
  61. // + '/styles/common/css/bootstrap/bootstrap-combined.min.css' ],
  62. // allowedContent : true
  63. // });
  64. // },
  65. //初始化恢复数据
  66. restoreData:function(){
  67. // if (this.supportstorage()) {
  68. // layouthistory = JSON.parse(localStorage.getItem(STORAGE_KEY));
  69. // if (!layouthistory)
  70. // return false;
  71. // window.indexHtml = layouthistory.list[layouthistory.count - 1];
  72. // if (window.indexHtml)
  73. // $(layoutClass).html(window.indexHtml);
  74. // }
  75. $(layoutClass).html( $('#html').val());
  76. },
  77. initSetting:function(){
  78. // 设置最小高度
  79. $("body").css("min-height", $(window).height() - 20);
  80. // 设置布局最小高度
  81. $(layoutClass).css("min-height", $(window).height() - 45);
  82. $('.sidebar-nav').css("height", $(window).height()-10);
  83. $('.sidebar-scroller').each(function() {
  84. $(this).slimScroll({
  85. size : '7px',
  86. color : '#a1b2bd',
  87. width:180,
  88. height : $(window).height() - 40,
  89. alwaysVisible : ($(this).attr("data-always-visible") == "1" ? true: false),
  90. railVisible : ($(this).attr("data-rail-visible") == "1" ? true: false),
  91. railOpacity : 0.1,
  92. disableFadeOut : true
  93. });
  94. });
  95. },
  96. initDraggable:function(){
  97. var me = this;
  98. // 可以拖动 允许 添加的布局
  99. $(".sidebar-nav .lyrow").draggable({
  100. connectToSortable : layoutClass,
  101. helper : "clone",
  102. handle : ".drag",
  103. start : function(e, t) {
  104. if (!startdrag)
  105. stopsave++;
  106. startdrag = 1;
  107. },
  108. drag : function(e, t) {
  109. t.helper.width(400);
  110. },
  111. stop : function(e, t) {
  112. me.initSortable();
  113. if (stopsave > 0)
  114. stopsave--;
  115. startdrag = 0;
  116. }
  117. });
  118. //允许 添加的栏目
  119. $(".sidebar-nav .box").draggable({
  120. connectToSortable : ".column",
  121. helper : "clone",
  122. handle : ".drag",
  123. start : function(e, t) {
  124. if (!startdrag)
  125. stopsave++;
  126. startdrag = 1;
  127. },
  128. drag : function(e, t) {
  129. t.helper.width(400);
  130. },
  131. stop : function() {
  132. me.handleJsIds();
  133. if (stopsave > 0)
  134. stopsave--;
  135. startdrag = 0;
  136. }
  137. });
  138. },
  139. /**
  140. * 初始化排序
  141. */
  142. initSortable:function(){
  143. $(layoutClass+", "+layoutClass+" .column").sortable({
  144. connectWith : ".column",
  145. opacity : .35,
  146. start : function(e, t) {
  147. if (!startdrag)
  148. stopsave++;
  149. startdrag = 1;
  150. },
  151. stop : function(e, t) {
  152. if (stopsave > 0)
  153. stopsave--;
  154. startdrag = 0;
  155. }
  156. });
  157. },
  158. /**
  159. * 初始化容器
  160. */
  161. initContainer :function () {
  162. this.initSortable();
  163. this.configurationElm();
  164. },
  165. /**
  166. * 处理编辑、下拉菜单配置
  167. */
  168. configurationElm :function (e, t) {
  169. //可以编辑
  170. $(layoutClass).delegate(".configuration > button", "click", function(e) {
  171. e.preventDefault();
  172. var t = $(this).parent().next().next().children();
  173. $(this).toggleClass("active");
  174. t.toggleClass($(this).attr("rel"));
  175. });
  176. //处理下拉菜单
  177. $(layoutClass).delegate(".configuration .dropdown-menu a", "click",
  178. function(e) {
  179. e.preventDefault();
  180. var t = $(this).parent().parent();
  181. var n = t.parent().parent().next().next().children();
  182. t.find("li").removeClass("active");
  183. $(this).parent().addClass("active");
  184. var r = "";
  185. t.find("a").each(function() {
  186. r += $(this).attr("rel") + " ";
  187. });
  188. t.parent().removeClass("open");
  189. n.removeClass(r);
  190. n.addClass($(this).attr("rel"));
  191. });
  192. },
  193. /**
  194. * 下载布局html
  195. */
  196. downloadLayoutSrc:function () {
  197. var formatSrc = this.saveLayoutSrc();
  198. $("#downloadModal textarea").empty();
  199. $("#downloadModal textarea").val(formatSrc);
  200. },
  201. getLyrow:function (lyrow,len){
  202. var rtn = "";
  203. for (var i = 0; i < len; i++) {
  204. rtn += lyrow+" ";
  205. }
  206. return rtn;
  207. },
  208. /**
  209. * 保存布局的源码
  210. * @returns {}
  211. */
  212. saveLayoutSrc:function (){
  213. var me = this;
  214. $(downloadLayout).children().html($(layoutClass).html());
  215. var t = $(downloadLayout).children();
  216. t.find(".preview, .configuration, .drag, .remove").remove();
  217. t.find(".lyrow").addClass("removeClean");
  218. t.find(".box-element").addClass("removeClean");
  219. var lyrow = ".lyrow";
  220. for (var i = 6; i >=0; i--) {
  221. var l = me.getLyrow(lyrow,i);
  222. t.find(l +".removeClean").each(function() {
  223. me.cleanHtml(this);
  224. });
  225. }
  226. t.find(".removeClean").remove();
  227. $(downloadLayout+" .column").removeClass("ui-sortable");
  228. $(downloadLayout+" .row-fluid").removeClass("clearfix").children()
  229. .removeClass("column");
  230. if ($(downloadLayout+" .container").length > 0) {
  231. me.changeStructure("row-fluid", "row");
  232. }
  233. formatSrc = $.htmlClean($(downloadLayout).html(), {
  234. format : true,
  235. allowedAttributes : [ [ "id" ], [ "class" ],["data-action"], [ "data-toggle" ],
  236. [ "data-target" ], [ "data-parent" ], [ "role" ],
  237. [ "data-dismiss" ], [ "aria-labelledby" ], [ "aria-hidden" ],
  238. [ "data-slide-to" ], [ "data-slide" ],
  239. [me._defaults.templateAliasKey]]
  240. });
  241. $(downloadLayout).html(formatSrc);
  242. return formatSrc;
  243. },
  244. /**
  245. * 处理保存管理布局
  246. */
  247. saveRemoteLayout:function () {
  248. var name = $('#name').val();
  249. if(name == ""){
  250. BootstrapDialog.alert("请输入名称!");
  251. return;
  252. }
  253. $("#saveRemoteLayout").attr("disabled","disabled");
  254. //需要保存2套,一套是展示的模版,一套是设计的模版
  255. var formatSrc = this.saveLayoutSrc(),
  256. html = $(formatSrc).clone(true),
  257. designHtml = $(layoutClass).clone(true);
  258. this.changeHtml(html);
  259. this.changeHtml(designHtml);
  260. var isDef =$("input[name='isDef']:checked").val();
  261. $.ajax({
  262. type : "POST",
  263. url : __ctx+"/platform/system/sysIndexLayoutManage/saveLayout.ht",
  264. data : {
  265. id:$('#id').val(),
  266. name:$('#name').val(),
  267. memo:$('#memo').val(),
  268. orgId:$('#orgId').val(),
  269. isDef:isDef,
  270. html : html.html(),
  271. designHtml: designHtml.html()
  272. },
  273. success : function(data) {
  274. var obj = eval('(' + data + ')');
  275. if (obj.result == 1) {
  276. BootstrapDialog.confirm("保存成功,是否继续操作?", function(rtn){
  277. if(rtn){
  278. window.location.href=__ctx+"/platform/system/sysIndexLayoutManage/design.ht?id="+obj.message;
  279. }else{
  280. if(window.opener){
  281. try{
  282. window.opener.location.href=window.opener.location.href.getNewUrl();
  283. }catch(e){}
  284. }
  285. window.close();
  286. }
  287. });
  288. } else {
  289. BootstrapDialog.error(obj.message,"提示信息");
  290. }
  291. }
  292. });
  293. },
  294. /**
  295. * 保存我的布局
  296. */
  297. saveRemoteMyLayout:function(){
  298. $("#button-my-save-modal").attr("disabled","disabled");
  299. //需要保存2套,一套是展示的模版,一套是设计的模版
  300. var formatSrc = this.saveLayoutSrc(),
  301. html = $(formatSrc).clone(true),
  302. designHtml = $(layoutClass).clone(true);
  303. this.changeHtml(html);
  304. this.changeHtml(designHtml);
  305. $.ajax({
  306. type : "POST",
  307. url : __ctx+"/platform/system/sysIndexMyLayout/saveLayout.ht",
  308. data : {
  309. html : html.html(),
  310. designHtml: designHtml.html()
  311. },
  312. success : function(data) {
  313. var obj = eval('(' + data + ')');
  314. if (obj.result == 1) {
  315. BootstrapDialog.confirm("保存成功,是否继续操作?", function(rtn){
  316. if(rtn){
  317. window.location.href=__ctx+"/platform/system/sysIndexMyLayout/design.ht";
  318. }else{
  319. if(window.opener){
  320. try{
  321. window.opener.location.href=window.opener.location.href.getNewUrl();
  322. }catch(e){}
  323. }
  324. window.close();
  325. }
  326. });
  327. } else {
  328. $("#button-my-save-modal").attr("disabled","");
  329. BootstrapDialog.error(obj.message,"提示信息");
  330. }
  331. }
  332. });
  333. },
  334. cleanHtml:function (e) {
  335. $(e).parent().append($(e).children().html());
  336. },
  337. changeHtml :function (html){
  338. var me = this, templateAliasKey= me._defaults.templateAliasKey;
  339. html.find("["+templateAliasKey+"]").each(function(){
  340. var self = $(this),
  341. alias = self.attr(templateAliasKey),
  342. div = $("<div></div>").attr(templateAliasKey,alias);
  343. self.after(div);
  344. self.remove();
  345. });
  346. },
  347. /**
  348. * 是否支持保存数据 localStorage
  349. *
  350. * @returns {Boolean}
  351. */
  352. supportstorage:function () {
  353. if (typeof window.localStorage == 'object')
  354. return true;
  355. else
  356. return false;
  357. },
  358. /**
  359. * 处理保存布局
  360. */
  361. handleSaveLayout:function () {
  362. var e = $(layoutClass).html();
  363. if (!stopsave && e != window.indexHtml) {
  364. stopsave++;
  365. window.indexHtml = e;
  366. this.saveLayout();
  367. stopsave--;
  368. }
  369. },
  370. /**
  371. * 保存布局
  372. */
  373. saveLayout:function () {
  374. var data = layouthistory;
  375. if (!data) {
  376. data = {};
  377. data.count = 0;
  378. data.list = [];
  379. }
  380. if (data.list.length > data.count) {
  381. for (var i = data.count; i < data.list.length; i++)
  382. data.list[i] = null;
  383. }
  384. data.list[data.count] = window.indexHtml;
  385. data.count++;
  386. if (this.supportstorage()) {
  387. localStorage.setItem(STORAGE_KEY, JSON.stringify(data));
  388. } else {// 不支持本地保存可以考虑保存服务器
  389. /*
  390. * $.ajax({ type: "POST", url: "/build/saveLayout", data: { layout:
  391. * $(layoutClass).html() }, success: function(data) {
  392. * //updateButtonsVisibility(); } });
  393. */
  394. }
  395. layouthistory = data;
  396. //console.info(data);
  397. },
  398. /**
  399. * 清除布局
  400. */
  401. clearIndex: function () {
  402. $(layoutClass).empty();
  403. layouthistory = null;
  404. if (this.supportstorage())
  405. localStorage.removeItem(STORAGE_KEY);
  406. },
  407. /**
  408. * 删除按钮激活样式
  409. */
  410. removeMenuClasses:function () {
  411. $("#menu-layoutit li button").removeClass("active");
  412. },
  413. changeStructure:function (e, t) {
  414. $(downloadLayout+" ." + e).removeClass(e).addClass(t);
  415. },
  416. /**
  417. * 清除布局
  418. */
  419. removeElm :function () {
  420. var me =this;
  421. $(layoutClass).delegate(".remove", "click", function(e) {
  422. e.preventDefault();
  423. $(this).parent().remove();
  424. if (!$(layoutClass+" .lyrow").length > 0) {
  425. me.clearIndex();
  426. }
  427. });
  428. },
  429. /**
  430. * 撤销布局
  431. * @returns {Boolean}
  432. */
  433. undoLayout:function () {
  434. var data = layouthistory;
  435. // console.log(data);
  436. if (data) {
  437. if (data.count < 2)
  438. return false;
  439. window.indexHtml = data.list[data.count - 2];
  440. data.count--;
  441. $(layoutClass).html(window.indexHtml);
  442. if (this.supportstorage()) {
  443. localStorage.setItem(STORAGE_KEY, JSON.stringify(data));
  444. }
  445. return true;
  446. }
  447. return false;
  448. /*
  449. * $.ajax({ type: "POST", url: "/build/getPreviousLayout", data: { },
  450. * success: function(data) { undoOperation(data); } });
  451. */
  452. },
  453. /**
  454. * 重做布局
  455. * @returns {Boolean}
  456. */
  457. redoLayout:function () {
  458. var data = layouthistory;
  459. if (data) {
  460. if (data.list[data.count]) {
  461. window.indexHtml = data.list[data.count];
  462. data.count++;
  463. $(layoutClass).html(window.indexHtml);
  464. if (this.supportstorage()) {
  465. localStorage.setItem(STORAGE_KEY, JSON.stringify(data));
  466. }
  467. return true;
  468. }
  469. }
  470. return false;
  471. /*
  472. * $.ajax({ type: "POST", url: "/build/getPreviousLayout", data: { },
  473. * success: function(data) { redoOperation(data); } });
  474. */
  475. },
  476. /**
  477. * 处理js的ID
  478. */
  479. handleJsIds:function () {
  480. this.handleModalIds();
  481. this.handleAccordionIds();
  482. this.handleCarouselIds();
  483. this.handleTabsIds();
  484. },
  485. handleAccordionIds:function () {
  486. var me = this,
  487. e = $(layoutClass+" #myAccordion"),
  488. t = me.randomNumber(),
  489. n = "accordion-" + t,
  490. r;
  491. e.attr("id", n);
  492. e.find(".accordion-group").each(function(e, t) {
  493. r = "accordion-element-" + me.randomNumber();
  494. $(t).find(".accordion-toggle").each(function(e, t) {
  495. $(t).attr("data-parent", "#" + n);
  496. $(t).attr("href", "#" + r);
  497. });
  498. $(t).find(".accordion-body").each(function(e, t) {
  499. $(t).attr("id", r);
  500. });
  501. });
  502. },
  503. handleCarouselIds:function () {
  504. var e = $(layoutClass +" #myCarousel"),
  505. t = this.randomNumber(),
  506. n = "carousel-" + t;
  507. e.attr("id", n);
  508. e.find(".carousel-indicators li").each(function(e, t) {
  509. $(t).attr("data-target", "#" + n);
  510. });
  511. e.find(".left").attr("href", "#" + n);
  512. e.find(".right").attr("href", "#" + n);
  513. },
  514. handleModalIds:function () {
  515. var me = this,
  516. e = $(layoutClass+" #myModalLink"),
  517. t = me.randomNumber(),
  518. n = "modal-container-" + t,
  519. r = "modal-" + t;
  520. e.attr("id", r);
  521. e.attr("href", "#" + n);
  522. e.next().attr("id", n);
  523. },
  524. handleTabsIds:function () {
  525. var me = this,
  526. e = $(layoutClass+" #myTabs"),
  527. t = me.randomNumber(),
  528. n = "tabs-" + t;
  529. e.attr("id", n);
  530. e.find(".tab-pane").each(function(e, t) {
  531. var n = $(t).attr("id");
  532. var r = "panel-" + me.randomNumber();
  533. $(t).attr("id", r);
  534. $(t).parent().parent().find("a[href=#" + n + "]").attr("href",
  535. "#" + r);
  536. });
  537. },
  538. // 随机一个1到
  539. randomNumber:function () {
  540. return this.randomFromInterval(1, 1e6);
  541. },
  542. randomFromInterval: function (e, t) {
  543. return Math.floor(Math.random() * (t - e + 1) + e);
  544. },
  545. gridSystemGenerator:function () {
  546. $(".lyrow .preview input").bind("keyup", function() {
  547. var e = 0,
  548. t = "",
  549. n = $(this).val().split(" ", 12);
  550. $.each(n, function(n, r) {
  551. e = e + parseInt(r);
  552. t += '<div class="span' + r + ' column"></div>';
  553. });
  554. if (e == 12) {
  555. $(this).parent().next().children().html(t);
  556. $(this).parent().prev().show();
  557. } else {
  558. $(this).parent().prev().hide();
  559. }
  560. });
  561. },
  562. selectTemplate:function(){
  563. var me = this;
  564. BootstrapDialog.show({
  565. title : '选择模版',
  566. size: BootstrapDialog.SIZE_WIDE,
  567. url:__ctx+"/platform/system/sysIndexLayoutManage/selectTemplate.ht",
  568. //回调函数
  569. sucCall:function(rtn){
  570. $(layoutClass).html(rtn);
  571. me.initData();
  572. indexPagePlugin.initUIEvent();
  573. }
  574. });
  575. },
  576. //删除布局
  577. deleteLayout:function(id){
  578. BootstrapDialog.confirm("该操作是删除自己的布局,首页的布局取默认的布局。是否删除当前设计的布局?", function(rtn){
  579. if(rtn){
  580. $.ajax({
  581. type : "POST",
  582. url : __ctx+"/platform/system/sysIndexMyLayout/deleteLayout.ht",
  583. data : {
  584. id : id
  585. },
  586. success : function(data) {
  587. var obj = eval('(' + data + ')');
  588. if (obj.result == 1) {
  589. BootstrapDialog.alert("删除成功!", function(){
  590. window.location.href=__ctx+"/platform/system/sysIndexMyLayout/design.ht";
  591. });
  592. } else {
  593. BootstrapDialog.error(obj.message,"提示信息");
  594. }
  595. }
  596. });
  597. }
  598. })
  599. },
  600. /**
  601. * 初始化相关按钮操作
  602. */
  603. initOperation:function(){
  604. var me = this;
  605. //保存编辑器内容
  606. $("#savecontent").unbind("click").bind("click",function(e) {
  607. e.preventDefault();
  608. //currenteditor.html(contenthandle.getData());
  609. });
  610. //下载(预览)
  611. $("[data-target=#downloadModal]").unbind("click").bind("click",function(e) {
  612. e.preventDefault();
  613. me.downloadLayoutSrc();
  614. });
  615. $("[data-target=#saveMyModal]").unbind("click").bind("click",function(e) {
  616. e.preventDefault();
  617. me.saveRemoteMyLayout();
  618. });
  619. //保存内容
  620. $("#saveRemoteLayout").unbind("click").bind("click",function(e) {
  621. e.preventDefault();
  622. me.saveRemoteLayout();
  623. });
  624. //下载
  625. $("#download").unbind("click").bind("click",function() {
  626. me.downloadLayout();
  627. return false;
  628. });
  629. $("#downloadhtml").unbind("click").bind("click",function() {
  630. me.downloadHtmlLayout();
  631. return false;
  632. });
  633. //编辑
  634. $("#edit").unbind("click").bind("click",function() {
  635. $("body").removeClass("devpreview sourcepreview");
  636. $("body").addClass("edit");
  637. me.removeMenuClasses();
  638. $(this).addClass("active");
  639. return false;
  640. });
  641. $("#clear").unbind("click").bind("click",function(e) {
  642. e.preventDefault();
  643. BootstrapDialog.confirm("是否清空布局?", function(rtn){
  644. if(rtn)
  645. me.clearIndex();
  646. });
  647. });
  648. $("#devpreview").unbind("click").bind("click",function() {
  649. $("body").removeClass("edit sourcepreview");
  650. $("body").addClass("devpreview");
  651. me.removeMenuClasses();
  652. $(this).addClass("active");
  653. return false;
  654. });
  655. $("#sourcepreview").unbind("click").bind("click",function() {
  656. $("body").removeClass("edit");
  657. $("body").addClass("devpreview sourcepreview");
  658. me.removeMenuClasses();
  659. $(this).addClass("active");
  660. return false;
  661. });
  662. //自适应宽度
  663. $("#fluidPage").unbind("click").bind("click",function(e) {
  664. e.preventDefault();
  665. me.changeStructure("container", "container-fluid");
  666. $("#fixedPage").removeClass("active");
  667. $(this).addClass("active");
  668. me.downloadLayoutSrc();
  669. });
  670. //固定宽度
  671. $("#fixedPage").unbind("click").bind("click",function(e) {
  672. e.preventDefault();
  673. me.changeStructure("container-fluid", "container");
  674. $("#fluidPage").removeClass("active");
  675. $(this).addClass("active");
  676. me.downloadLayoutSrc();
  677. });
  678. $(".nav-header").unbind("click").bind("click",function() {
  679. $(".sidebar-nav .boxes, .sidebar-nav .rows").hide();
  680. $(this).next().slideDown();
  681. });
  682. //撤销
  683. $('#undo').unbind("click").bind("click",function() {
  684. stopsave++;
  685. if (me.undoLayout())
  686. me.initContainer();
  687. stopsave--;
  688. });
  689. //重做
  690. $('#redo').unbind("click").bind("click",function() {
  691. stopsave++;
  692. if (me.redoLayout())
  693. me.initContainer();
  694. stopsave--;
  695. });
  696. //设计模式的编辑
  697. $('body.edit '+layoutClass).unbind("click").bind("click","[data-target=#editorModal]",function(e) {
  698. e.preventDefault();
  699. //currenteditor = $(this).parent().parent().find('.view');
  700. //var eText = currenteditor.html();
  701. //contenthandle.setData(eText);
  702. });
  703. $("#template").unbind("click").bind("click",function() {
  704. me.selectTemplate();
  705. });
  706. //删除我设计的布局
  707. $('#button-delete-modal').unbind("click").bind("click",function() {
  708. me.deleteLayout($(this).attr('var'));
  709. });
  710. }
  711. };
  712. $.fn[pluginName] = function(options) {
  713. return this
  714. .each(function() {
  715. if (!$.data(this, "plugin_" + pluginName)) {
  716. $.data(this, "plugin_" + pluginName, new Plugin(this,
  717. options));
  718. }
  719. });
  720. };
  721. })(jQuery, window, document);
  722. $(document).ready(function() {
  723. $('body').indexLayout();
  724. });
  725. /**
  726. * 调整
  727. */
  728. $(window).resize(function() {
  729. indexLayoutPlugin.initSetting();
  730. });
  731. function selectOrg(){
  732. var conf ={
  733. isSingle:true,
  734. callback:function(orgId,orgName){
  735. $('#orgId').val(orgId);
  736. $('#orgName').val(orgName);
  737. }
  738. };
  739. if(!conf.isSingle)conf.isSingle=false;
  740. var scope={};
  741. if(conf.scope) scope = (conf.scope).replace(/\'/g, '"');
  742. var url=__ctx + '/platform/system/sysOrg/dialog.ht?isSingle=' + conf.isSingle;
  743. url=url.getNewUrl();
  744. var that =this;
  745. BootstrapDialog.show({
  746. title : '组织选择器',
  747. size: BootstrapDialog.SIZE_WIDE,
  748. url:url,
  749. scope : scope,
  750. //回调函数
  751. sucCall:function(rtn){
  752. conf.callback.call(that,rtn.orgId,rtn.orgName);
  753. }
  754. });
  755. }