menu.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. /**
  2. * [ONEMAP.M.menu]
  3. * @return {[object]}
  4. */
  5. define([
  6. 'modDir/menu/myLayer',
  7. 'html!templates/menu',
  8. 'modDir/menu/modelFly',
  9. // 'layoutDir/user',
  10. 'css!styles/menu',
  11. 'css!styles/tools/toolPublicPopup'
  12. ], function (layerController, tplLayout, modelFly, user) {
  13. /**
  14. * 模块状态,用于存储模块的状态 例如:收起,关闭
  15. * @type {Object}
  16. */
  17. var status = {
  18. showSideBar: false
  19. }
  20. function init() {
  21. setLayout();
  22. bindEvent();
  23. subscribe();
  24. };
  25. function setLayout() {
  26. $(tplLayout).appendTo($("#menu .cover-content"));
  27. //军综网关闭态势功能
  28. if (map23DConfig.netType == 2) {
  29. // $("#menu .ts").hide();
  30. // $("#menu .wxzy .dmz").hide();
  31. // $("#menu .zhj").hide();
  32. }
  33. // if(!ONEMAP.D.user.ticket){$("#menu .zhj").hide();}
  34. if (bowser.msie && !$('html').hasClass('websockets')) {
  35. $("#menu .ts").hide();
  36. $("#menu .zhj").hide();
  37. }
  38. // user.init();
  39. ONEMAP.C.layerLength = 0;
  40. ONEMAP.C.zoomArr = [];
  41. ONEMAP.C.zoomArr2w = [];
  42. if (!map23DConfig.atlas) {
  43. $("#map-library").hide();
  44. }
  45. if (!map23DConfig.sanweiMenu) {
  46. $(".menu-scroll .sanWei").remove();
  47. }
  48. if (!map23DData.show3DAlert) {
  49. $(".menu-scroll .sanWei").hide();
  50. var tdata = ONEMAP.D.globalSettingData.map3DModelSetting;
  51. if (tdata.length > 0) {
  52. $(".menu-scroll .sanWei").show()
  53. for (var i = 0; i < tdata.length; i++) {
  54. tdata[i].id
  55. '<li class="im-1"><p class="fu"><span class="no-bg">' + tdata[i].name + '</span></p></li>'
  56. }
  57. }
  58. for (var i = 0; i < tdata.length; i++) {
  59. if (tdata[i].url.indexOf("v2.0") > -1) {
  60. $(".menu-scroll .sanWei").show()
  61. }
  62. }
  63. }
  64. if (ONEMAP.D.isLoad) {
  65. $("#map-library").show();
  66. } else {
  67. $("#map-library").hide();
  68. }
  69. $("#menu .mnsc").mCustomScrollbar({
  70. scrollInertia: 500
  71. });
  72. // if(ONEMAP.D.user.ticket){
  73. if (ONEMAP.D.globalSettingData.kuozhanLink) {
  74. var kz = ONEMAP.D.globalSettingData.kuozhanLink;
  75. for (var i = 0, l = kz.length; i < l; i++) {
  76. var title = kz[i].title;
  77. var link = kz[i].link;
  78. var liDom = $('<li class="im-1"><a href="' + link + '" target="_blank">' + title + '</a></li>');
  79. liDom.appendTo($("#exKuozhan"));
  80. }
  81. }
  82. // }
  83. }
  84. /**
  85. * 窗口布局重置
  86. * @type {Function}
  87. */
  88. function layoutResize(options) {
  89. $("#menu .mnsc").mCustomScrollbar('update');
  90. };
  91. function bindEvent() {
  92. // if (ONEMAP.D.user.ticket.length <= 0) {
  93. // $(".sanWei").hide();
  94. // } else {
  95. // if(map23DData.show3DAlert){
  96. // $(".sanWei").show();
  97. // }else{
  98. // $(".sanWei").hide();
  99. // }
  100. // }
  101. //收起
  102. $("#menu .menu-title p").bind("click", function () {
  103. ONEMAP.C.publisher.publish('', 'layout::closeLeft');
  104. })
  105. layerController.init();
  106. // 根目录
  107. $("#menu .im-0").on('click', function () {
  108. if ($(this).parent().hasClass("active")) {
  109. $(this).parent().removeClass("active");
  110. } else {
  111. $(".menu-base").removeClass("active");
  112. $(this).parent().addClass("active");
  113. }
  114. })
  115. // 二三级目录
  116. $("#menu .fu").off('click').on('click', function () {
  117. if ($(this).parent().hasClass('active')) {
  118. $(this).parent().removeClass('active');
  119. // 关闭当前子目录
  120. if ($(this).parent().hasClass('im-1')) {
  121. $(this).find(".im-2").removeClass('active');
  122. }
  123. } else {
  124. $(this).parent().addClass('active');
  125. }
  126. $("#menu .infoMenu .im-1 ul.menu-content").mCustomScrollbar('update');;
  127. })
  128. $("#menu .meteo-twoLi").on('click', function () {
  129. if ($(this).hasClass('current')) {
  130. $(this).removeClass('current')
  131. } else {
  132. $(this).addClass('current')
  133. }
  134. })
  135. //二级目录展开
  136. $("#menu .current-menu2 .isExpend").off('click').on('click', function () {
  137. var o = $(this);
  138. if (o.parent().filter('li').hasClass('active')) {
  139. o.parent().filter('li').removeClass('active')
  140. } else {
  141. o.parent().filter('li').addClass('active');
  142. }
  143. })
  144. require(['modDir/menu/menuVue'], function () { });
  145. // // 矢量
  146. // $("#vector").unbind('click').bind('click', function () {
  147. // require(['modDir/menu/vector'], function (vector) {
  148. // vector.init();
  149. // });
  150. // })
  151. // // 栅格
  152. // $("#raster").unbind('click').bind('click', function () {
  153. // require(['modDir/menu/raster'], function (raster) {
  154. // raster.init();
  155. // });
  156. // })
  157. // //三维数据
  158. // $("#threeData").unbind('click').bind('click', function () {
  159. // require(['modDir/menu/getCollect3DData'], function (getCollect3DData) {
  160. // getCollect3DData.init();
  161. // });
  162. // })
  163. require(['modDir/menu/modelFly'], function (modelFly) {
  164. if (ONEMAP.M.liuLanQi != "other") {
  165. modelFly.init();
  166. }
  167. });
  168. //重要目标与事件
  169. $("#infoAndTrgt").unbind('click').bind('click', function () {
  170. if ($(this).parent().hasClass("info")) {
  171. $(this).parent().removeClass("info");
  172. $("#userIGListInfo .item").hide();
  173. //ONEMAP.C.publisher.publish('handHide', 'layout::sideBar');
  174. } else {
  175. $(this).parent().addClass("info");
  176. $("#userIGListInfo .item").show();
  177. require(['modDir/gcms/gcmsNav'], function (gcmsNav) {
  178. gcmsNav.init();
  179. });
  180. }
  181. })
  182. // 展开收起
  183. $("#menu .switch").off('click').on('click', function () {
  184. var h = parseFloat($("#menu").css("height")) - 12;
  185. if ($(this).attr("switch") == "guan") {
  186. $("#menu").animate({
  187. "margin-top": -h
  188. }, 200);
  189. $(this).attr("switch", "kai");
  190. } else if ($(this).attr("switch") == "kai") {
  191. $("#menu").animate({
  192. "margin-top": 0
  193. }, 200);
  194. $(this).attr("switch", "guan");
  195. }
  196. })
  197. // 选择图层
  198. $("#menu .test .im-3 input").off('change').on('change', function () {
  199. var that = $(this);
  200. require(['modDir/menu/testInfo'], function (testInfo) {
  201. testInfo.init(that);
  202. })
  203. })
  204. //卫星导航
  205. $("#wxdh-meun").off("click").on("click", function () {
  206. require(['modDir/weixing/daohang'], function (daohang) {
  207. daohang.init($(this));
  208. });
  209. });
  210. //定位经度
  211. $("#wx-dwjd").off("click").on("click", function () {
  212. var isLoad = checkBoxStates("wx-dwjd");
  213. var layerName = $(this).children().filter('p').text();
  214. if (isLoad) {
  215. require(['modDir/weixing/statesDwjd'], function (statesDwjd) {
  216. statesDwjd.init(layerName);
  217. });
  218. } else {
  219. if (ONEMAP.M.statesDwjd) {
  220. ONEMAP.M.statesDwjd.remove()
  221. }
  222. }
  223. })
  224. //北斗用户态势
  225. $("#bd-zhjMinor").off("click").on("click", function () {
  226. var isLoad = checkBoxStates("bd-zhjMinor");
  227. var layerName = $(this).children().filter('p').text();
  228. if (isLoad) {
  229. require(['modDir/weixing/zhjMinor'], function (zhjminor) {
  230. zhjminor.init(layerName);
  231. });
  232. } else {
  233. if (ONEMAP.M.zhjMinor) {
  234. ONEMAP.M.zhjMinor.remove()
  235. }
  236. }
  237. })
  238. // 专题一张图
  239. $("#heaven .im-0").off("click").on("click", function () {
  240. require(['modDir/menu/getCollect2DData'], function (getCollect2DData) {
  241. getCollect2DData.init();
  242. });
  243. })
  244. //通信卫星
  245. $(".menu-title-tongxin").bind("click", function () {
  246. //ONEMAP.M.sideNav.show3dMap();
  247. // ONEMAP.C.publisher.publish("modalChange","topBarEvent");
  248. var layerName = $(this).text();
  249. if (!$(this).hasClass('open')) {
  250. $(this).addClass('open');
  251. require(['modDir/tongxin/weixing'], function (weixing) {
  252. weixing.init(layerName);
  253. });
  254. } else if ($(this).hasClass('open')) {
  255. $(this).removeClass('open');
  256. if (ONEMAP.M.txWeixing) {
  257. ONEMAP.M.txWeixing.remove();
  258. ONEMAP.M.txWeixing.removeMeun();
  259. }
  260. }
  261. })
  262. //区域通信
  263. $(".menu-title-quyu").bind("click", function () {
  264. //ONEMAP.M.sideNav.show3dMap();
  265. // ONEMAP.C.publisher.publish("modalChange","topBarEvent");
  266. var layerName = $(this).text();
  267. // if (isLoad) {
  268. if (!$(this).hasClass('open')) {
  269. $(this).addClass('open');
  270. require(['modDir/tongxin/quyu'], function (quyu) {
  271. quyu.init(layerName);
  272. });
  273. } else if ($(this).hasClass('open')) {
  274. $(this).removeClass('open');
  275. if (ONEMAP.M.quyu) {
  276. ONEMAP.M.quyu.remove();
  277. ONEMAP.M.quyu.removeMeun();
  278. }
  279. }
  280. })
  281. //模拟数据
  282. $(".menu-title-moni").bind("click", function () {
  283. ONEMAP.M.sideNav.show3dMap();
  284. // ONEMAP.C.publisher.publish("modalChange","topBarEvent");
  285. var layerName = $(this).text();
  286. // if (isLoad) {
  287. if (!$(this).hasClass('open')) {
  288. $(this).addClass('open');
  289. require(['modDir/tongxin/moni'], function (moni) {
  290. moni.init(layerName);
  291. });
  292. } else if ($(this).hasClass('open')) {
  293. $(this).removeClass('open');
  294. if (ONEMAP.M.moni) {
  295. ONEMAP.M.moni.remove();
  296. ONEMAP.M.moni.removeMeun();
  297. }
  298. }
  299. })
  300. // 扩展服务
  301. $("#serveEX").bind("click", function () {
  302. if ($(this).parent().hasClass('active')) {
  303. $("#mCSB_5_container").css("top", "-100px");
  304. $("#mCSB_5_dragger_vertical").css("top", "86px");
  305. }
  306. })
  307. }
  308. //卫星资源菜单勾选与取消
  309. function checkBoxStates(id) {
  310. var f = false;
  311. var layerLength = ONEMAP.M.myLayers.checkLength();
  312. var o = $("#" + id);
  313. var checkBox = o.children().filter('span')
  314. if (layerLength < map23DConfig.layerMaxLength) {
  315. if (checkBox.hasClass("menu-select-no")) {
  316. checkBox.removeClass("menu-select-no").addClass("menu-select");
  317. f = true;
  318. } else {
  319. checkBox.removeClass("menu-select").addClass("menu-select-no");
  320. f = false;
  321. }
  322. return f;
  323. } else {
  324. if (checkBox.hasClass("menu-select")) {
  325. checkBox.removeClass("menu-select").addClass("menu-select-no");
  326. } else {
  327. ONEMAP.C.publisher.publish({
  328. type: 'warning',
  329. message: '图层数量已达上限'
  330. }, 'noteBar::add');
  331. }
  332. return false;
  333. }
  334. }
  335. // 全屏
  336. function fullMap(option) {
  337. if (option) {
  338. // $("#menu").fadeOut('slow');
  339. $("#menu").animate({
  340. left: "-340px"
  341. }, 1)
  342. $("#menu").removeClass("moveOut");
  343. } else {
  344. // $("#menu").fadeIn('slow')
  345. $("#menu").animate({
  346. left: "0px"
  347. }, 1)
  348. $("#menu").removeClass("moveOut");
  349. }
  350. }
  351. /**
  352. * 注册订阅
  353. * @type {Function}
  354. * 推送:ONEMAP.C.publisher.publish(options,'moduleName::type');
  355. * 订阅:ONEMAP.C.publisher.subscribe(layoutResize,'sideBarLayoutChange');
  356. */
  357. function subscribe() {
  358. ONEMAP.C.publisher.subscribe(fullMap, 'layout::fullMap');
  359. ONEMAP.C.publisher.subscribe(layoutResize, 'menuListClick');
  360. ONEMAP.C.publisher.subscribe(layoutesizeGCMS, 'seitchNetwork');
  361. }
  362. function layoutesizeGCMS(type) {
  363. if (type == 'network') {
  364. var curType = 2;
  365. } else {
  366. var curType = 1;
  367. }
  368. if (map23DConfig.netType != curType) {
  369. if (ONEMAP.M.gcmsNav) {
  370. ONEMAP.M.gcmsNav.getNavData();
  371. }
  372. }
  373. }
  374. return ONEMAP.M.menu = {
  375. init: init,
  376. status: status
  377. };
  378. })