layout.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. /**
  2. * [ONEMAP.M.pcLayout]
  3. * @return {[object]}
  4. */
  5. define([
  6. 'html!templates/layout',
  7. 'css!styles/layout',
  8. 'layoutDir/noteBar',
  9. 'css!styles/popupHtml.css'
  10. ], function(tplLayout) {
  11. /**
  12. * pc端界面布局 模块
  13. * @exports ONEMAP.M.pcLayout
  14. * @type {Object}
  15. */
  16. //布局完成后加载地图和侧栏内容,如果url传来参数,将解析参数加载相应的模块
  17. /**
  18. * 界面样式数值变量
  19. * @type {Object}
  20. */
  21. var styles = {
  22. //头部高度
  23. headerHeight: 61,
  24. //工具栏高度
  25. toolbarHeight: 30,
  26. //地图视窗宽
  27. mapWidth: null,
  28. //地图视窗高
  29. mapHeight: null,
  30. //侧栏宽度
  31. sideBarWidth: 270,
  32. //侧栏高度
  33. sideBarHeight: '100%',
  34. };
  35. /**
  36. * 模块状态,用于存储模块的状态 例如:收起,关闭
  37. * @type {Object}
  38. */
  39. var status = {
  40. showSideBar: false,
  41. showFullMap: false
  42. }
  43. /**
  44. * 加载布局 初始化
  45. * 先加载 CSS,html,html事件,地图,地图控件
  46. * @type {Function}
  47. * @returns {*}
  48. */
  49. function init() {
  50. setLayout();
  51. $(window).resize(function() {
  52. layoutResize();
  53. });
  54. subscribe();
  55. bindEvent();
  56. };
  57. /**
  58. * 设置布局
  59. * @return {[type]} [description]
  60. */
  61. function setLayout() {
  62. // $("body").html("");
  63. // console.log(tplLayout);
  64. $('body').append(tplLayout);
  65. $("#openSTSideContent").appendTo($("#map2DWrap"));
  66. //设置系统标题,logo,版权信息
  67. document.title = onemapUrlConfig.systemName;
  68. // require(['layoutDir/header'], function(header) {
  69. // header.init();
  70. // });
  71. require(['layoutDir/sideNav'], function(sideNav) {
  72. sideNav.init();
  73. require(['modDir/mapHolder'], function(mapHolder) {
  74. mapHolder.init();
  75. require(['layoutDir/topBar'], function(topBar) {
  76. topBar.init();
  77. });
  78. require(['layoutDir/footer'], function(footer) {
  79. footer.init();
  80. });
  81. });
  82. });
  83. require(['layoutDir/sideBar'], function(sideBar) {
  84. sideBar.init();
  85. });
  86. require(['layoutDir/menu'], function(menu) {
  87. menu.init();
  88. });
  89. require(['layoutDir/layerController'], function(layerController) {
  90. layerController.init();
  91. });
  92. };
  93. function layoutResize() {
  94. };
  95. function bindEvent(){
  96. $("#openSTSideContent").bind('click',function(){
  97. if(status.showSideBar){
  98. ONEMAP.C.publisher.publish('handHide','layout::sideBar');
  99. }else{
  100. ONEMAP.C.publisher.publish('handShow','layout::sideBar');
  101. }
  102. })
  103. //全屏
  104. $(".tools-fullScreen").unbind('click').bind('click',function(){
  105. require(['modDir/tools/toolFullScreen'], function(toolFullScreen) {
  106. toolFullScreen.init();
  107. });
  108. });
  109. }
  110. /**
  111. * 设置侧栏显示状态
  112. * @param {[type]} options [description]
  113. * 显示: ONEMAP.C.publisher.publish('show','layout::sideBar');
  114. * 隐藏: ONEMAP.C.publisher.publish('show','layout::sideBar');
  115. */
  116. function SideBarStatusControl(options){
  117. if(options == 'show' || options == 'handShow'){
  118. if(!status.showSideBar){
  119. $('#wrapper').animate({
  120. right: 310},
  121. 300, function() {
  122. ONEMAP.C.publisher.publish({},'layout::resize');
  123. sideBarBtn("show");
  124. });
  125. status.showSideBar = true;
  126. ONEMAP.C.publisher.publish('sideBarStatus', 'sideBarStatus');
  127. }
  128. }else {
  129. if(status.showSideBar){
  130. sideBarBtn("hide");
  131. $('#wrapper').animate({
  132. right: 0},
  133. 300, function() {
  134. ONEMAP.C.publisher.publish({},'layout::resize');
  135. });
  136. status.showSideBar = false;
  137. ONEMAP.C.publisher.publish('sideBarStatus', 'sideBarStatus');
  138. }
  139. }
  140. }
  141. function setSideBarStatus(options){
  142. if(options == "handHide" || options == "handShow"){
  143. SideBarStatusControl(options)
  144. }else{
  145. if($('.abtn-mini-side-bar').hasClass('close')){
  146. return false;
  147. }else{
  148. SideBarStatusControl(options);
  149. }
  150. }
  151. };
  152. //侧栏控制按钮
  153. function sideBarBtn(options){
  154. if(options === "show"){
  155. $("#openSTSideContent img").attr("src",onemapUrlConfig.siteUrl+"/images/layout/close3dSideIcon.png");
  156. $("#openSTSideContent").css("right","410px");
  157. }else{
  158. $("#openSTSideContent img").attr("src",onemapUrlConfig.siteUrl+"/images/layout/open3dSideIcon.png");
  159. $("#openSTSideContent").css("right","0px");
  160. }
  161. }
  162. /**
  163. * 设置全屏显示状态
  164. * @param {[type]} options [description]
  165. * 全屏: ONEMAP.C.publisher.publish(true,'layout::fullMap');
  166. * 取消全屏: ONEMAP.C.publisher.publish(false,'layout::fullMap');
  167. */
  168. function setFullMapStatus(options){
  169. if(options == true){
  170. status.showFullMap = true;
  171. ONEMAP.C.publisher.publish({},'layout::resize');
  172. $("#menu").animate({
  173. left:-340
  174. }, 500)
  175. $('#header').animate({
  176. top: -61},
  177. 500, function() {});
  178. $('#footer').animate({
  179. bottom: -30},
  180. 500, function() {});
  181. $('#topBar').animate({
  182. right: -45},
  183. 500, function() {});
  184. $('#menu').animate({
  185. right: -310},
  186. 500, function() {});
  187. $('#sideNav').hide();
  188. }else {
  189. status.showFullMap = false;
  190. ONEMAP.C.publisher.publish({},'layout::resize');
  191. $("#menu").animate({
  192. left: 0
  193. }, 400)
  194. $('#header').animate({
  195. top: 0},
  196. 500, function() {});
  197. $('#footer').animate({
  198. bottom: 0},
  199. 500, function() {});
  200. $('#topBar').animate({
  201. right: 0},
  202. 500, function() {});
  203. $('#menu').animate({
  204. right: 0},
  205. 500, function() {});
  206. $('#sideNav').show();
  207. }
  208. }
  209. function controlShijing(data){
  210. if(data.zoom<11){
  211. $(".abtn-show-shijing").hide();
  212. }else{
  213. $(".abtn-show-shijing").show();
  214. }
  215. }
  216. /**
  217. * 注册监听
  218. * @type {Function}
  219. */
  220. function subscribe() {
  221. ONEMAP.C.publisher.subscribe(setSideBarStatus,'layout::sideBar');
  222. ONEMAP.C.publisher.subscribe(setFullMapStatus,'layout::fullMap');
  223. };
  224. return ONEMAP.M.pcLayout = {
  225. init: init,
  226. styles:styles,
  227. status:status
  228. };
  229. });