/** * [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 } });