123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195 |
- /**
- * [ONEMAP.M.mod]
- * @return {[object]}
- */
- define(['css!styles/user/userCenter',
- 'css!styles/user/userFav'],
- function(){
- /**
- * 模块数据 用于数据存储和外部调用
- * @type {Object}
- * 数据存放
- */
- var modValue = {
- subModName:null,
- modName:""
- }
- /**
- * 模块界面样式 例如:宽,高
- * @type {Object}
- */
- var styles = {}
- /**
- * 模块状态,用于存储模块的状态 例如:收起,关闭
- * @type {Object}
- */
- var status = {
- initialized:false,
- appdDom:''
- }
- //分页
- var pageContainer,
- favPageBtnGroup,
- pageJump;
-
- /**
- * 初始化并订阅事件
- * @return {[type]} [description]
- */
- function init(options){
- // console.log("userCenterinit");
- // status.appdDom = options.appdDom;
-
- //未初始化,初始化布局
- // if (!status.initialized) {
- //设置容器布局
- // setLayout();
-
- bindEvent();
- //订阅推送
- subscribe();
- modValue.modName = options.modName
- setMod(modValue);
- status.initialized = true;
-
- // }
-
- // setMod(options.modName);
-
- //设置zIndex 为最高
- var zIndex = ONEMAP.M.sideBar.getZIndex();
- $('#userCenter').css({zIndex:zIndex});
- // ONEMAP.D.currentSideBarMod = 'userCenter';
- // 开启侧栏
- // ONEMAP.C.publisher.publish('handShow','layout::sideBar');
- }
- /**
- * 初始化布局
- */
- // function setLayout(){
- // if(status.appdDom == 'userSideBar'){
- // $(tplLayout).appendTo($("#usdFavor"));
- // } else{
- // $(tplLayout).appendTo($("#sideBarBody"));
- // }
- // };
- /**
- * 窗口布局重置
- * @type {Function}
- */
- function layoutResize() {
-
- };
- /**
- * 界面事件绑定
- * @return {[type]} [description]
- */
- function bindEvent(){
- $("#userCenter .nav-userRoute").unbind('click').bind('click',function(){
- modValue.modName = 'userRoute';
- setMod(modValue);
- });
- $("#userCenter .nav-userPoint").unbind('click').bind('click',function(){
- modValue.modName = 'userPoint';
- setMod(modValue);
- });
- $("#userCenter .nav-userThematic").unbind('click').bind('click',function(){
- modValue.modName = 'userThematic';
- setMod(modValue);
- });
- $("#userCenter .nav-userDraw").unbind('click').bind('click',function(){
- // console.log("userDraw");
- modValue.modName = 'userDraw';
- setMod(modValue);
- // if($("#toolsBar").hasClass('cur')){
- // $("#toolsBar p").click();
- // }
- });
- }
- /**
- * 显示相应模块的内容
- * @type {Function}
- * @private
- */
- function setMod(options){
- //移除上一个模块
- if(modValue.subModName && modValue.subModName !== options.modName){
- ONEMAP.M[modValue.subModName].remove();
- }
- modValue.subModName = options.modName;
- $('#userCenter .nav .active').removeClass('active');
- $('#userCenter .nav-'+modValue.subModName).addClass('active');
- switch (modValue.subModName){
- // case "userFav":
- // require(['modDir/user/userFav'],function(userFav){
- // userFav.init();
- // });
- // break;
- case "userRoute":
- require(['modDir/user/userRoute'],function(userRoute){
- userRoute.init();
- });
- break;
- case "userPoint":
- require(['modDir/user/userPoint'],function(userPoint){
- userPoint.init();
- });
- break;
- case "userThematic":
- require(['modDir/user/userThematic'],function(userThematic){
- userThematic.init();
- });
- break;
- case "userDraw":
- require(['modDir/user/userDraw'],function(userDraw){
- userDraw.init();
- });
- break;
- }
- }
-
- /**
- * 注册订阅
- * @type {Function}
- * 推送:ONEMAP.C.publisher.publish(options,'moduleName::type');
- * 订阅:ONEMAP.C.publisher.subscribe(layoutResize,'sideBarLayoutChange');
- */
- function subscribe(){
- ONEMAP.C.publisher.subscribe(setMod,'showCenter');
- }
- /**
- * 取消订阅
- * @type {Function}
- * 取消订阅:ONEMAP.C.publisher.unSubscribe(layoutResize,'sideBarLayoutChange');
- */
- function unSubscribe(){}
- /**
- * 模块移除
- * @return {[type]} [description]
- */
- function remove(){
- //取消订阅
- unSubscribe();
- }
- return ONEMAP.M.userCenter = {
- init:init,
- layoutResize:layoutResize,
- setMod:setMod
- }
- });
|