toolAddressBaike.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /**
  2. * [ONEMAP.M.toolAddressBaike]
  3. * @return {[object]}
  4. */
  5. define(['html!templates/tools/toolAddressBaike',
  6. 'css!styles/tools/toolAddressBaike'],
  7. function(tplLayout){
  8. /**
  9. * 模块数据 用于数据存储和外部调用
  10. * @type {Object}
  11. * 数据存放
  12. */
  13. var modValue = {}
  14. /**
  15. * 模块界面样式 例如:宽,高
  16. * @type {Object}
  17. */
  18. var styles = {}
  19. /**
  20. * 模块状态,用于存储模块的状态 例如:收起,关闭
  21. * @type {Object}
  22. */
  23. var status = {}
  24. /**
  25. * 初始化并订阅事件
  26. * @return {[type]} [description]
  27. */
  28. function init(options){
  29. remove();
  30. _.merge(modValue,options);
  31. showAddressBaike(options);
  32. subscribe();
  33. }
  34. /**
  35. * 设置界面
  36. */
  37. function setLayout(){
  38. }
  39. function showAddressBaike(options){
  40. $('#addressBaike').remove();
  41. $('body').append($(tplLayout));
  42. $('#baikeIframe').attr('src','/data/address_baike/'+options.bid+'/'+options.bid+'.html');
  43. $('#baikeDetailTitleLabel').html(options.title+'-地名百科');
  44. $('#addressBaike .modal-header .close').bind('click', function() {
  45. $('#addressBaike').remove();
  46. });
  47. var $box2 = $('#addressBaike').on('mousedown', '#coorForBaikeDetailModal', function(e) {
  48. var posix = {
  49. 'w': $box2.width(),
  50. 'h': $box2.height(),
  51. 'x': e.pageX,
  52. 'y': e.pageY
  53. };
  54. $.extend(document, {'move': true, 'call_down': function(e) {
  55. $box2.css({
  56. 'width': Math.max(30, e.pageX - posix.x + posix.w),
  57. 'height': Math.max(30, e.pageY - posix.y + posix.h)
  58. });
  59. var bodyHeight = Math.max(30, e.pageY - posix.y + posix.h )-51-$("#addressBaike .modal-header").height();
  60. $("#addressBaike .modal-body").css({height:bodyHeight});
  61. }});
  62. return false;
  63. });
  64. bindEvent();
  65. }
  66. /**
  67. * 界面事件绑定
  68. * @return {[type]} [description]
  69. */
  70. function bindEvent(){
  71. $("#addressBaike .close").bind('click', function() {
  72. $("#addressBaike").hide();
  73. })
  74. var $box2 = $('#addressBaike').on('mousedown', '#coorForBaikeDetailModal', function(e) {
  75. var posix = {
  76. 'w': $box2.width(),
  77. 'h': $box2.height(),
  78. 'x': e.pageX,
  79. 'y': e.pageY
  80. };
  81. $.extend(document, {
  82. 'move': true,
  83. 'call_down': function(e) {
  84. $box2.css({
  85. 'width': Math.max(30, e.pageX - posix.x + posix.w),
  86. 'height': Math.max(30, e.pageY - posix.y + posix.h)
  87. });
  88. var bodyHeight = Math.max(30, e.pageY - posix.y + posix.h) - 75;
  89. $("#addressBaike .modal-body").css({ height: bodyHeight });
  90. }
  91. });
  92. return false;
  93. });
  94. //拖拽
  95. $("#addressBaike .popup-ct").dragmove($('#addressBaike'));
  96. }
  97. /**
  98. * 界面重置
  99. * @return {[type]} [description]
  100. */
  101. function layoutResize(){
  102. }
  103. /**
  104. * 注册订阅
  105. * @type {Function}
  106. * 推送:ONEMAP.C.publisher.publish(options,'moduleName::type');
  107. * 订阅:ONEMAP.C.publisher.subscribe(layoutResize,'sideBarLayoutChange');
  108. */
  109. function subscribe(){}
  110. /**
  111. * 取消订阅
  112. * @type {Function}
  113. * 取消订阅:ONEMAP.C.publisher.unSubscribe(layoutResize,'sideBarLayoutChange');
  114. */
  115. function unSubscribe(){}
  116. /**
  117. * 模块移除
  118. * @return {[type]} [description]
  119. */
  120. function remove(){
  121. $('#addressBaike').remove();
  122. //取消订阅
  123. unSubscribe();
  124. }
  125. /**
  126. * 获取数据
  127. * @return {[type]} [description]
  128. */
  129. function getValue(name){
  130. if(modValue.hasOwnProperty(name)){
  131. return modValue[name]
  132. }else {
  133. return null;
  134. }
  135. }
  136. /**
  137. * 设置数据 默认合并
  138. */
  139. function setValue(name,value,rewrite){
  140. if(rewrite){
  141. modValue = value;
  142. return modValue;
  143. }else {
  144. _.merge(modValue, value);
  145. return modValue;
  146. }
  147. }
  148. return ONEMAP.M.toolAddressBaike = {
  149. init:init,
  150. layoutResize:layoutResize,
  151. getValue:getValue,
  152. setValue:setValue,
  153. remove:remove
  154. }
  155. });