/** * [ONEMAP.M.menu] * @return {[object]} */ define([ 'modDir/menu/myLayer', 'html!templates/menu', 'modDir/menu/modelFly', // 'layoutDir/user', 'css!styles/menu', 'css!styles/tools/toolPublicPopup' ], function (layerController, tplLayout, modelFly, user) { /** * 模块状态,用于存储模块的状态 例如:收起,关闭 * @type {Object} */ var status = { showSideBar: false } function init() { setLayout(); bindEvent(); subscribe(); }; function setLayout() { $(tplLayout).appendTo($("#menu .cover-content")); //军综网关闭态势功能 if (map23DConfig.netType == 2) { // $("#menu .ts").hide(); // $("#menu .wxzy .dmz").hide(); // $("#menu .zhj").hide(); } // if(!ONEMAP.D.user.ticket){$("#menu .zhj").hide();} if (bowser.msie && !$('html').hasClass('websockets')) { $("#menu .ts").hide(); $("#menu .zhj").hide(); } // user.init(); ONEMAP.C.layerLength = 0; ONEMAP.C.zoomArr = []; ONEMAP.C.zoomArr2w = []; if (!map23DConfig.atlas) { $("#map-library").hide(); } if (!map23DConfig.sanweiMenu) { $(".menu-scroll .sanWei").remove(); } if (!map23DData.show3DAlert) { $(".menu-scroll .sanWei").hide(); var tdata = ONEMAP.D.globalSettingData.map3DModelSetting; if (tdata.length > 0) { $(".menu-scroll .sanWei").show() for (var i = 0; i < tdata.length; i++) { tdata[i].id '
  • ' + tdata[i].name + '

  • ' } } for (var i = 0; i < tdata.length; i++) { if (tdata[i].url.indexOf("v2.0") > -1) { $(".menu-scroll .sanWei").show() } } } if (ONEMAP.D.isLoad) { $("#map-library").show(); } else { $("#map-library").hide(); } $("#menu .mnsc").mCustomScrollbar({ scrollInertia: 500 }); // if(ONEMAP.D.user.ticket){ if (ONEMAP.D.globalSettingData.kuozhanLink) { var kz = ONEMAP.D.globalSettingData.kuozhanLink; for (var i = 0, l = kz.length; i < l; i++) { var title = kz[i].title; var link = kz[i].link; var liDom = $('
  • ' + title + '
  • '); liDom.appendTo($("#exKuozhan")); } } // } } /** * 窗口布局重置 * @type {Function} */ function layoutResize(options) { $("#menu .mnsc").mCustomScrollbar('update'); }; function bindEvent() { // if (ONEMAP.D.user.ticket.length <= 0) { // $(".sanWei").hide(); // } else { // if(map23DData.show3DAlert){ // $(".sanWei").show(); // }else{ // $(".sanWei").hide(); // } // } //收起 $("#menu .menu-title p").bind("click", function () { ONEMAP.C.publisher.publish('', 'layout::closeLeft'); }) layerController.init(); // 根目录 $("#menu .im-0").on('click', function () { if ($(this).parent().hasClass("active")) { $(this).parent().removeClass("active"); } else { $(".menu-base").removeClass("active"); $(this).parent().addClass("active"); } }) // 二三级目录 $("#menu .fu").off('click').on('click', function () { if ($(this).parent().hasClass('active')) { $(this).parent().removeClass('active'); // 关闭当前子目录 if ($(this).parent().hasClass('im-1')) { $(this).find(".im-2").removeClass('active'); } } else { $(this).parent().addClass('active'); } $("#menu .infoMenu .im-1 ul.menu-content").mCustomScrollbar('update');; }) $("#menu .meteo-twoLi").on('click', function () { if ($(this).hasClass('current')) { $(this).removeClass('current') } else { $(this).addClass('current') } }) //二级目录展开 $("#menu .current-menu2 .isExpend").off('click').on('click', function () { var o = $(this); if (o.parent().filter('li').hasClass('active')) { o.parent().filter('li').removeClass('active') } else { o.parent().filter('li').addClass('active'); } }) require(['modDir/menu/menuVue'], function () { }); // // 矢量 // $("#vector").unbind('click').bind('click', function () { // require(['modDir/menu/vector'], function (vector) { // vector.init(); // }); // }) // // 栅格 // $("#raster").unbind('click').bind('click', function () { // require(['modDir/menu/raster'], function (raster) { // raster.init(); // }); // }) // //三维数据 // $("#threeData").unbind('click').bind('click', function () { // require(['modDir/menu/getCollect3DData'], function (getCollect3DData) { // getCollect3DData.init(); // }); // }) require(['modDir/menu/modelFly'], function (modelFly) { if (ONEMAP.M.liuLanQi != "other") { modelFly.init(); } }); //重要目标与事件 $("#infoAndTrgt").unbind('click').bind('click', function () { if ($(this).parent().hasClass("info")) { $(this).parent().removeClass("info"); $("#userIGListInfo .item").hide(); //ONEMAP.C.publisher.publish('handHide', 'layout::sideBar'); } else { $(this).parent().addClass("info"); $("#userIGListInfo .item").show(); require(['modDir/gcms/gcmsNav'], function (gcmsNav) { gcmsNav.init(); }); } }) // 展开收起 $("#menu .switch").off('click').on('click', function () { var h = parseFloat($("#menu").css("height")) - 12; if ($(this).attr("switch") == "guan") { $("#menu").animate({ "margin-top": -h }, 200); $(this).attr("switch", "kai"); } else if ($(this).attr("switch") == "kai") { $("#menu").animate({ "margin-top": 0 }, 200); $(this).attr("switch", "guan"); } }) // 选择图层 $("#menu .test .im-3 input").off('change').on('change', function () { var that = $(this); require(['modDir/menu/testInfo'], function (testInfo) { testInfo.init(that); }) }) //卫星导航 $("#wxdh-meun").off("click").on("click", function () { require(['modDir/weixing/daohang'], function (daohang) { daohang.init($(this)); }); }); //定位经度 $("#wx-dwjd").off("click").on("click", function () { var isLoad = checkBoxStates("wx-dwjd"); var layerName = $(this).children().filter('p').text(); if (isLoad) { require(['modDir/weixing/statesDwjd'], function (statesDwjd) { statesDwjd.init(layerName); }); } else { if (ONEMAP.M.statesDwjd) { ONEMAP.M.statesDwjd.remove() } } }) //北斗用户态势 $("#bd-zhjMinor").off("click").on("click", function () { var isLoad = checkBoxStates("bd-zhjMinor"); var layerName = $(this).children().filter('p').text(); if (isLoad) { require(['modDir/weixing/zhjMinor'], function (zhjminor) { zhjminor.init(layerName); }); } else { if (ONEMAP.M.zhjMinor) { ONEMAP.M.zhjMinor.remove() } } }) // 专题一张图 $("#heaven .im-0").off("click").on("click", function () { require(['modDir/menu/getCollect2DData'], function (getCollect2DData) { getCollect2DData.init(); }); }) //通信卫星 $(".menu-title-tongxin").bind("click", function () { //ONEMAP.M.sideNav.show3dMap(); // ONEMAP.C.publisher.publish("modalChange","topBarEvent"); var layerName = $(this).text(); if (!$(this).hasClass('open')) { $(this).addClass('open'); require(['modDir/tongxin/weixing'], function (weixing) { weixing.init(layerName); }); } else if ($(this).hasClass('open')) { $(this).removeClass('open'); if (ONEMAP.M.txWeixing) { ONEMAP.M.txWeixing.remove(); ONEMAP.M.txWeixing.removeMeun(); } } }) //区域通信 $(".menu-title-quyu").bind("click", function () { //ONEMAP.M.sideNav.show3dMap(); // ONEMAP.C.publisher.publish("modalChange","topBarEvent"); var layerName = $(this).text(); // if (isLoad) { if (!$(this).hasClass('open')) { $(this).addClass('open'); require(['modDir/tongxin/quyu'], function (quyu) { quyu.init(layerName); }); } else if ($(this).hasClass('open')) { $(this).removeClass('open'); if (ONEMAP.M.quyu) { ONEMAP.M.quyu.remove(); ONEMAP.M.quyu.removeMeun(); } } }) //模拟数据 $(".menu-title-moni").bind("click", function () { ONEMAP.M.sideNav.show3dMap(); // ONEMAP.C.publisher.publish("modalChange","topBarEvent"); var layerName = $(this).text(); // if (isLoad) { if (!$(this).hasClass('open')) { $(this).addClass('open'); require(['modDir/tongxin/moni'], function (moni) { moni.init(layerName); }); } else if ($(this).hasClass('open')) { $(this).removeClass('open'); if (ONEMAP.M.moni) { ONEMAP.M.moni.remove(); ONEMAP.M.moni.removeMeun(); } } }) // 扩展服务 $("#serveEX").bind("click", function () { if ($(this).parent().hasClass('active')) { $("#mCSB_5_container").css("top", "-100px"); $("#mCSB_5_dragger_vertical").css("top", "86px"); } }) } //卫星资源菜单勾选与取消 function checkBoxStates(id) { var f = false; var layerLength = ONEMAP.M.myLayers.checkLength(); var o = $("#" + id); var checkBox = o.children().filter('span') if (layerLength < map23DConfig.layerMaxLength) { if (checkBox.hasClass("menu-select-no")) { checkBox.removeClass("menu-select-no").addClass("menu-select"); f = true; } else { checkBox.removeClass("menu-select").addClass("menu-select-no"); f = false; } return f; } else { if (checkBox.hasClass("menu-select")) { checkBox.removeClass("menu-select").addClass("menu-select-no"); } else { ONEMAP.C.publisher.publish({ type: 'warning', message: '图层数量已达上限' }, 'noteBar::add'); } return false; } } // 全屏 function fullMap(option) { if (option) { // $("#menu").fadeOut('slow'); $("#menu").animate({ left: "-340px" }, 1) $("#menu").removeClass("moveOut"); } else { // $("#menu").fadeIn('slow') $("#menu").animate({ left: "0px" }, 1) $("#menu").removeClass("moveOut"); } } /** * 注册订阅 * @type {Function} * 推送:ONEMAP.C.publisher.publish(options,'moduleName::type'); * 订阅:ONEMAP.C.publisher.subscribe(layoutResize,'sideBarLayoutChange'); */ function subscribe() { ONEMAP.C.publisher.subscribe(fullMap, 'layout::fullMap'); ONEMAP.C.publisher.subscribe(layoutResize, 'menuListClick'); ONEMAP.C.publisher.subscribe(layoutesizeGCMS, 'seitchNetwork'); } function layoutesizeGCMS(type) { if (type == 'network') { var curType = 2; } else { var curType = 1; } if (map23DConfig.netType != curType) { if (ONEMAP.M.gcmsNav) { ONEMAP.M.gcmsNav.getNavData(); } } } return ONEMAP.M.menu = { init: init, status: status }; })