menu.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  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. //三维数据
  145. $("#threeData").unbind('click').bind('click', function () {
  146. require(['modDir/menu/getCollect3DData'], function (getCollect3DData) {
  147. getCollect3DData.init();
  148. });
  149. })
  150. require(['modDir/menu/modelFly'], function (modelFly) {
  151. if (ONEMAP.M.liuLanQi != "other") {
  152. modelFly.init();
  153. }
  154. });
  155. //重要目标与事件
  156. $("#infoAndTrgt").unbind('click').bind('click', function () {
  157. if ($(this).parent().hasClass("info")) {
  158. $(this).parent().removeClass("info");
  159. $("#userIGListInfo .item").hide();
  160. //ONEMAP.C.publisher.publish('handHide', 'layout::sideBar');
  161. } else {
  162. $(this).parent().addClass("info");
  163. $("#userIGListInfo .item").show();
  164. require(['modDir/gcms/gcmsNav'], function (gcmsNav) {
  165. gcmsNav.init();
  166. });
  167. }
  168. })
  169. // 展开收起
  170. $("#menu .switch").off('click').on('click', function () {
  171. var h = parseFloat($("#menu").css("height")) - 12;
  172. if ($(this).attr("switch") == "guan") {
  173. $("#menu").animate({
  174. "margin-top": -h
  175. }, 200);
  176. $(this).attr("switch", "kai");
  177. } else if ($(this).attr("switch") == "kai") {
  178. $("#menu").animate({
  179. "margin-top": 0
  180. }, 200);
  181. $(this).attr("switch", "guan");
  182. }
  183. })
  184. // 选择图层
  185. $("#menu .test .im-3 input").off('change').on('change', function () {
  186. var that = $(this);
  187. require(['modDir/menu/testInfo'], function (testInfo) {
  188. testInfo.init(that);
  189. })
  190. })
  191. //卫星导航
  192. $("#wxdh-meun").off("click").on("click", function () {
  193. require(['modDir/weixing/daohang'], function (daohang) {
  194. daohang.init($(this));
  195. });
  196. });
  197. //定位经度
  198. $("#wx-dwjd").off("click").on("click", function () {
  199. var isLoad = checkBoxStates("wx-dwjd");
  200. var layerName = $(this).children().filter('p').text();
  201. if (isLoad) {
  202. require(['modDir/weixing/statesDwjd'], function (statesDwjd) {
  203. statesDwjd.init(layerName);
  204. });
  205. } else {
  206. if (ONEMAP.M.statesDwjd) {
  207. ONEMAP.M.statesDwjd.remove()
  208. }
  209. }
  210. })
  211. //北斗用户态势
  212. $("#bd-zhjMinor").off("click").on("click", function () {
  213. var isLoad = checkBoxStates("bd-zhjMinor");
  214. var layerName = $(this).children().filter('p').text();
  215. if (isLoad) {
  216. require(['modDir/weixing/zhjMinor'], function (zhjminor) {
  217. zhjminor.init(layerName);
  218. });
  219. } else {
  220. if (ONEMAP.M.zhjMinor) {
  221. ONEMAP.M.zhjMinor.remove()
  222. }
  223. }
  224. })
  225. // 专题一张图
  226. $("#heaven .im-0").off("click").on("click", function () {
  227. require(['modDir/menu/getCollect2DData'], function (getCollect2DData) {
  228. getCollect2DData.init();
  229. });
  230. })
  231. //通信卫星
  232. $(".menu-title-tongxin").bind("click", function () {
  233. //ONEMAP.M.sideNav.show3dMap();
  234. // ONEMAP.C.publisher.publish("modalChange","topBarEvent");
  235. var layerName = $(this).text();
  236. if (!$(this).hasClass('open')) {
  237. $(this).addClass('open');
  238. require(['modDir/tongxin/weixing'], function (weixing) {
  239. weixing.init(layerName);
  240. });
  241. } else if ($(this).hasClass('open')) {
  242. $(this).removeClass('open');
  243. if (ONEMAP.M.txWeixing) {
  244. ONEMAP.M.txWeixing.remove();
  245. ONEMAP.M.txWeixing.removeMeun();
  246. }
  247. }
  248. })
  249. //区域通信
  250. $(".menu-title-quyu").bind("click", function () {
  251. //ONEMAP.M.sideNav.show3dMap();
  252. // ONEMAP.C.publisher.publish("modalChange","topBarEvent");
  253. var layerName = $(this).text();
  254. // if (isLoad) {
  255. if (!$(this).hasClass('open')) {
  256. $(this).addClass('open');
  257. require(['modDir/tongxin/quyu'], function (quyu) {
  258. quyu.init(layerName);
  259. });
  260. } else if ($(this).hasClass('open')) {
  261. $(this).removeClass('open');
  262. if (ONEMAP.M.quyu) {
  263. ONEMAP.M.quyu.remove();
  264. ONEMAP.M.quyu.removeMeun();
  265. }
  266. }
  267. })
  268. //模拟数据
  269. $(".menu-title-moni").bind("click", function () {
  270. ONEMAP.M.sideNav.show3dMap();
  271. // ONEMAP.C.publisher.publish("modalChange","topBarEvent");
  272. var layerName = $(this).text();
  273. // if (isLoad) {
  274. if (!$(this).hasClass('open')) {
  275. $(this).addClass('open');
  276. require(['modDir/tongxin/moni'], function (moni) {
  277. moni.init(layerName);
  278. });
  279. } else if ($(this).hasClass('open')) {
  280. $(this).removeClass('open');
  281. if (ONEMAP.M.moni) {
  282. ONEMAP.M.moni.remove();
  283. ONEMAP.M.moni.removeMeun();
  284. }
  285. }
  286. })
  287. // 扩展服务
  288. $("#serveEX").bind("click", function () {
  289. if ($(this).parent().hasClass('active')) {
  290. $("#mCSB_5_container").css("top", "-100px");
  291. $("#mCSB_5_dragger_vertical").css("top", "86px");
  292. }
  293. })
  294. }
  295. //卫星资源菜单勾选与取消
  296. function checkBoxStates(id) {
  297. var f = false;
  298. var layerLength = ONEMAP.M.myLayers.checkLength();
  299. var o = $("#" + id);
  300. var checkBox = o.children().filter('span')
  301. if (layerLength < map23DConfig.layerMaxLength) {
  302. if (checkBox.hasClass("menu-select-no")) {
  303. checkBox.removeClass("menu-select-no").addClass("menu-select");
  304. f = true;
  305. } else {
  306. checkBox.removeClass("menu-select").addClass("menu-select-no");
  307. f = false;
  308. }
  309. return f;
  310. } else {
  311. if (checkBox.hasClass("menu-select")) {
  312. checkBox.removeClass("menu-select").addClass("menu-select-no");
  313. } else {
  314. ONEMAP.C.publisher.publish({
  315. type: 'warning',
  316. message: '图层数量已达上限'
  317. }, 'noteBar::add');
  318. }
  319. return false;
  320. }
  321. }
  322. // 全屏
  323. function fullMap(option) {
  324. if (option) {
  325. // $("#menu").fadeOut('slow');
  326. $("#menu").animate({
  327. left: "-340px"
  328. }, 1)
  329. $("#menu").removeClass("moveOut");
  330. } else {
  331. // $("#menu").fadeIn('slow')
  332. $("#menu").animate({
  333. left: "0px"
  334. }, 1)
  335. $("#menu").removeClass("moveOut");
  336. }
  337. }
  338. /**
  339. * 注册订阅
  340. * @type {Function}
  341. * 推送:ONEMAP.C.publisher.publish(options,'moduleName::type');
  342. * 订阅:ONEMAP.C.publisher.subscribe(layoutResize,'sideBarLayoutChange');
  343. */
  344. function subscribe() {
  345. ONEMAP.C.publisher.subscribe(fullMap, 'layout::fullMap');
  346. ONEMAP.C.publisher.subscribe(layoutResize, 'menuListClick');
  347. ONEMAP.C.publisher.subscribe(layoutesizeGCMS, 'seitchNetwork');
  348. }
  349. function layoutesizeGCMS(type) {
  350. if (type == 'network') {
  351. var curType = 2;
  352. } else {
  353. var curType = 1;
  354. }
  355. if (map23DConfig.netType != curType) {
  356. if (ONEMAP.M.gcmsNav) {
  357. ONEMAP.M.gcmsNav.getNavData();
  358. }
  359. }
  360. }
  361. return ONEMAP.M.menu = {
  362. init: init,
  363. status: status
  364. };
  365. })