123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384 |
- /**
- * [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
- '<li class="im-1"><p class="fu"><span class="no-bg">' + tdata[i].name + '</span></p></li>'
- }
- }
- 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 = $('<li class="im-1"><a href="' + link + '" target="_blank">' + title + '</a></li>');
- 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');
- }
- })
- //三维数据
- $("#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
- };
- })
|