123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- /**
- * [ONEMAP.M.toolAddressBaike]
- * @return {[object]}
- */
- define(['html!templates/tools/toolAddressBaike',
- 'css!styles/tools/toolAddressBaike'],
- function(tplLayout){
- /**
- * 模块数据 用于数据存储和外部调用
- * @type {Object}
- * 数据存放
- */
- var modValue = {}
- /**
- * 模块界面样式 例如:宽,高
- * @type {Object}
- */
- var styles = {}
- /**
- * 模块状态,用于存储模块的状态 例如:收起,关闭
- * @type {Object}
- */
- var status = {}
-
- /**
- * 初始化并订阅事件
- * @return {[type]} [description]
- */
- function init(options){
- remove();
- _.merge(modValue,options);
- showAddressBaike(options);
- subscribe();
- }
- /**
- * 设置界面
- */
- function setLayout(){
- }
- function showAddressBaike(options){
- $('#addressBaike').remove();
- $('body').append($(tplLayout));
-
- $('#baikeIframe').attr('src','/data/address_baike/'+options.bid+'/'+options.bid+'.html');
- $('#baikeDetailTitleLabel').html(options.title+'-地名百科');
- $('#addressBaike .modal-header .close').bind('click', function() {
- $('#addressBaike').remove();
- });
-
- var $box2 = $('#addressBaike').on('mousedown', '#coorForBaikeDetailModal', function(e) {
- var posix = {
- 'w': $box2.width(),
- 'h': $box2.height(),
- 'x': e.pageX,
- 'y': e.pageY
- };
-
- $.extend(document, {'move': true, 'call_down': function(e) {
- $box2.css({
- 'width': Math.max(30, e.pageX - posix.x + posix.w),
- 'height': Math.max(30, e.pageY - posix.y + posix.h)
- });
- var bodyHeight = Math.max(30, e.pageY - posix.y + posix.h )-51-$("#addressBaike .modal-header").height();
- $("#addressBaike .modal-body").css({height:bodyHeight});
- }});
- return false;
- });
- bindEvent();
- }
- /**
- * 界面事件绑定
- * @return {[type]} [description]
- */
- function bindEvent(){
- $("#addressBaike .close").bind('click', function() {
- $("#addressBaike").hide();
- })
- var $box2 = $('#addressBaike').on('mousedown', '#coorForBaikeDetailModal', function(e) {
- var posix = {
- 'w': $box2.width(),
- 'h': $box2.height(),
- 'x': e.pageX,
- 'y': e.pageY
- };
- $.extend(document, {
- 'move': true,
- 'call_down': function(e) {
- $box2.css({
- 'width': Math.max(30, e.pageX - posix.x + posix.w),
- 'height': Math.max(30, e.pageY - posix.y + posix.h)
- });
- var bodyHeight = Math.max(30, e.pageY - posix.y + posix.h) - 75;
- $("#addressBaike .modal-body").css({ height: bodyHeight });
- }
- });
- return false;
- });
- //拖拽
- $("#addressBaike .popup-ct").dragmove($('#addressBaike'));
- }
- /**
- * 界面重置
- * @return {[type]} [description]
- */
- function layoutResize(){
- }
- /**
- * 注册订阅
- * @type {Function}
- * 推送:ONEMAP.C.publisher.publish(options,'moduleName::type');
- * 订阅:ONEMAP.C.publisher.subscribe(layoutResize,'sideBarLayoutChange');
- */
- function subscribe(){}
- /**
- * 取消订阅
- * @type {Function}
- * 取消订阅:ONEMAP.C.publisher.unSubscribe(layoutResize,'sideBarLayoutChange');
- */
- function unSubscribe(){}
- /**
- * 模块移除
- * @return {[type]} [description]
- */
- function remove(){
- $('#addressBaike').remove();
- //取消订阅
- unSubscribe();
- }
- /**
- * 获取数据
- * @return {[type]} [description]
- */
- function getValue(name){
- if(modValue.hasOwnProperty(name)){
- return modValue[name]
- }else {
- return null;
- }
- }
- /**
- * 设置数据 默认合并
- */
- function setValue(name,value,rewrite){
- if(rewrite){
- modValue = value;
- return modValue;
- }else {
- _.merge(modValue, value);
- return modValue;
- }
- }
- return ONEMAP.M.toolAddressBaike = {
- init:init,
- layoutResize:layoutResize,
- getValue:getValue,
- setValue:setValue,
- remove:remove
- }
- });
|