UNPKG

nyx_server

Version:

Node内容发布

361 lines (290 loc) 10.7 kB
(function ($, lib, topic) { 'use strict'; // 初始化页面即页面配置 topic.page.init(); // 页面蒙层初始化 topic.mask.init(); // postMessage,与表单交互监听部分初始化 topic.postMessage.init(); // 初始化碎片设计 // topic.fragmentDesign.init(); // 初始化通栏 // topic.bannerGroup.createAll(); // topic.bannerBlank.init(); // 初始碎片 topic.fragmentGroup.createAll(); // 创建通栏排序工具 // var sortBannerTool = new topic.module.BannerSortTool(); // 创建通栏侧边列表 // var bannerList = new topic.module.BannerList(); // 创建碎片侧边列表 var fragmentList = new topic.module.FragmentList(); var uploaderBox = new topic.module.UploaderBox(); // 创建侧边导航 var nav = new topic.module.Nav(); // 在所有处理完成后,将蒙层隐藏。 topic.mask.hide(); /*************状态自定义事件*************/ // 通栏排序状态改变时触发自定义事件 // topic.state.on('isSortBannerChange', function (oldValue, newValue) { // if (newValue === true) { // topic.state.set('bodyList', lib.creatBodyList()); // sortBannerTool.show(); // } else { // sortBannerTool.hide(); // } // }); // 侧边列表状态改变触发自定义事件 topic.state.on('isListShowChange', function (oldValue, newValue) { var pageModel = topic.state.get('pageModel'); var isUploadShow = topic.state.get('isUploadShow'); if (newValue === true) { // if (pageModel === 'bannerEdit') { // bannerList.show(); // bannerList.render(); // } else { fragmentList.show(); fragmentList.render(); // } if (isUploadShow === true) { uploaderBox.hide(); topic.state.set('isUploadShow', false); } } else { // if (pageModel === 'bannerEdit') { // bannerList.hide(); // } else { fragmentList.hide(); // } } }); topic.state.on('isUploadShowChange', function (oldValue, newValue) { var isListShow = topic.state.get('isListShow'); if (newValue === true) { uploaderBox.show(); if (isListShow === true) { // bannerList.hide(); fragmentList.hide(); topic.state.set('isListShow', false); } } else { uploaderBox.hide(); } }); // // 页面模式改变触发自定义事件 // topic.state.on('pageModelChange', function (oldValue, newValue) { // topic.page.changeModel(newValue); // listReset(newValue); // }); // var listReset = function (pageModel) { // if (!bannerList.isShow && !fragmentList.isShow) { // return; // } // if (pageModel === 'bannerEdit') { // if (fragmentList.isShow) { // fragmentList.hide(); // setTimeout(function () { // bannerList.show(); // bannerList.render(); // }, 600); // } // } else { // if (bannerList.isShow) { // bannerList.hide(); // setTimeout(function () { // fragmentList.show(); // fragmentList.render(); // }, 600); // } // } // }; // // 打开关闭碎片的设计模式状态触发的自定义事件 // topic.state.on('isDesignChange', function (oldValue, newValue) { // if (newValue === true) { // nav.designSwitchEnable(); // } else { // topic.fragmentDesign.hide(); // nav.designSwitchDisable(); // } // }); /*******************通栏列表自定义事件*******************/ // // 点击列表时的自定义事件 // bannerList.on('listClick', function (uid) { // var banner = topic.bannerGroup.banners[uid]; // if (banner.visible === false && !topic.state.get('isSortBanner')) { // banner.edit(); // return; // } // banner.focus(); // }); // // 点击列表的编辑选项时的自定义事件 // bannerList.on('editClick', function (uid, x, y) { // var banner = topic.bannerGroup.banners[uid]; // if (!topic.state.get('isSortBanner')) { // if (typeof banner.menu === 'undefined') { // banner.menu = new topic.module.BannerMenu(banner); // } // banner.menu.show(x, y); // // banner.edit(); // } // }); // // 点击列表的编辑选项时的自定义事件 // bannerList.on('hideClick', function (uid, isHide) { // var banner = topic.bannerGroup.banners[uid]; // if (!isHide) { // banner.isHide = true; // banner.hide(); // } else { // banner.isHide = false; // banner.show(); // } // }); // // 移入列表时候的自定义事件 // bannerList.on('mouseenter', function (uid) { // var banner = topic.bannerGroup.banners[uid]; // banner.active(); // }); // // 移出列表时候的自定义事件 // bannerList.on('mouseenter', function (uid) { // var banner = topic.bannerGroup.banners[uid]; // banner.unActive(); // }); // // 拖动结束时候的自定义事件 // bannerList.on('dragEnd', function (moveUid, overUid, direct) { // var banner = topic.bannerGroup.banners[moveUid]; // banner.moveTo(overUid, direct); // }); /*******************通栏对象自定义事件******************/ // topic.bannerEvent.on('move', function () { // topic.bannerGroup.layoutResetAll(); // topic.page.pageInfoUpdate(); // bannerList.render(); // }); // topic.bannerEvent.on('del', function (uid) { // topic.bannerGroup.remove(uid); // topic.page.pageInfoUpdate(); // bannerList.render(); // if (!lib.hasBanner()) { // topic.bannerBlank.init(); // } // }); // topic.bannerEvent.on('insert', function () { // bannerList.render(); // topic.bannerGroup.createAll(); // topic.fragmentGroup.createAll(); // topic.bannerGroup.layoutResetAll(); // topic.fragmentGroup.layoutResetAll(); // topic.page.pageInfoUpdate(); // }); // topic.bannerEvent.on('refresh', function () { // topic.bannerGroup.createAll(); // topic.fragmentGroup.createAll(); // topic.bannerGroup.layoutResetAll(); // topic.fragmentGroup.layoutResetAll(); // topic.fragmentDesign.hide(); // bannerList.render(); // }); // topic.bannerEvent.on('replace', function (uid) { // topic.bannerGroup.remove(uid); // topic.bannerGroup.createAll(); // topic.fragmentGroup.createAll(); // topic.bannerGroup.layoutResetAll(); // topic.fragmentGroup.layoutResetAll(); // topic.page.pageInfoUpdate(); // bannerList.render(); // }); /************创建通栏块自定义事件************/ // topic.bannerBlank.on('create', function () { // bannerList.render(); // topic.bannerGroup.createAll(); // topic.fragmentGroup.createAll(); // topic.bannerGroup.layoutResetAll(); // topic.fragmentGroup.layoutResetAll(); // topic.page.pageInfoUpdate(); // }); /************碎片列表自定义事件**************/ // 点击列表时的自定义事件 fragmentList.on('listClick', function (uid) { var fragment = topic.fragmentGroup.fragments[uid]; if (fragment.visible === false) { fragment.edit(); return; } fragment.focus(); }); // 点击列表的编辑选项时的自定义事件 fragmentList.on('editClick', function (uid, x, y) { var fragment = topic.fragmentGroup.fragments[uid]; // if (typeof fragment.menu === 'undefined') { // fragment.menu = new topic.module.FragmentMenu(fragment); // } // fragment.menu.show(x, y); fragment.edit(); }); // 点击列表的编辑选项时的自定义事件 fragmentList.on('hideClick', function (uid, isHide) { var fragment = topic.fragmentGroup.fragments[uid]; if (!isHide) { fragment.isHide = true; fragment.hide(); } else { fragment.isHide = false; fragment.show(); } }); // 移入列表时候的自定义事件 fragmentList.on('mouseenter', function (uid) { var fragment = topic.fragmentGroup.fragments[uid]; fragment.active(); }); // 移出列表时候的自定义事件 fragmentList.on('mouseenter', function (uid) { var fragment = topic.fragmentGroup.fragments[uid]; fragment.unActive(); }); /*******************碎片对象自定义事件******************/ topic.fragmentEvent.on('refresh', function () { // topic.bannerGroup.createAll(); topic.fragmentGroup.createAll(); // topic.bannerGroup.layoutResetAll(); topic.fragmentGroup.layoutResetAll(); fragmentList.render(); }); // topic.fragmentEvent.on('restore', function (banner) { // banner.refresh(); // }); /*******************页面对象自定义事件*****************/ topic.page.on('resize', function (pageModel) { // if (pageModel === 'bannerEdit') { // topic.bannerGroup.layoutResetAll(); // } else { topic.fragmentGroup.layoutResetAll(); // } // @todo 这种处理方式导致弹出的菜单定位不准确,需要采用其他方法: // a.最简单的方法,改变页面大小,直接隐藏 // b.在选取的时候,记录位置与窗口大小,改变的时候,根据改变后的窗口大小, // 算出差值,对相关菜单显示位置进行修正 // c.将菜单生成在蒙层中,使用相对绝对定位,这样菜单会跟随蒙层改变位置,这样折腾改变挺大的。 // if (pageModel === 'fragmentDesign' && topic.fragmentDesign.isLocked()) { // topic.fragmentDesign.maskSelector.mask(topic.fragmentDesign.maskSelector.lockeElm); // } }); /*******************碎片创建自定义事件*****************/ // topic.fragmentDesign.on('create', function (bannerUid) { // var banner = topic.bannerGroup.banners[bannerUid]; // banner.refresh(); // }); /*******************碎片创建自定义事件*****************/ nav.on('refresh', function () { // topic.bannerGroup.layoutResetAll(); topic.fragmentGroup.layoutResetAll(); }); /*******************弹出窗口自定义事件*****************/ // 当弹出窗口创建时,将窗口弹出状态设置为true topic.dialogEvent.on('open', function () { topic.state.set('isDialogOpen', true); }); topic.dialogEvent.on('destroy', function () { topic.state.set('isDialogOpen', false); }); }(topicJquery, topic.utils, topic));