/** * [ATLAS.M.atlasView] * @return {[object]} */ define(['html!templates/atlas/atlasView', 'css!styles/atlas/atlasView'], function(tplLayout){ /** * 模块数据 用于数据存储和外部调用 * @type {Object} */ var modValue = { options:{} } /** * 模块界面样式 例如:宽,高 * @type {Object} */ var styles = {} /** * 模块状态,用于存储模块的状态 例如:收起,关闭 * @type {Object} */ var status = {} /** * 初始化并订阅事件 * @return {[type]} [description] */ function init(){ //获取url参数 modValue.options = JSON.parse(ATLAS.C.encryption.deCode(ATLAS.T.getQueryString('serialize'))); modValue.options.type = parseInt(ATLAS.T.getQueryString('viewType')); if(modValue.options.type == 1){ modValue.options.guid = ATLAS.T.getQueryString('guid'); $('body').addClass('singleAtlas'); } if(modValue.options.type == 2){ modValue.options.leftGuid = ATLAS.T.getQueryString('left'); modValue.options.rightGuid = ATLAS.T.getQueryString('right'); $('body').addClass('compareAtlas'); } if(modValue.options.type == 3 || modValue.options.type == 4){ modValue.options.productionId = ATLAS.T.getQueryString('productionId'); $('body').addClass('atlasBook'); } setLayout(); bindEvent(); switch(modValue.options.type){ case 1: require(['modDir/atlas/singleAtlas'], function (singleAtlas) { singleAtlas.init(modValue.options); }); break; case 2: require(['modDir/atlas/compareView'], function (compareView) { compareView.init(modValue.options); }); break; case 3: case 4: require(['modDir/atlas/atlasBook'], function (atlasBook) { atlasBook.init(modValue.options); }); break; } } /** * 设置界面 */ function setLayout(){ $('#contentWrap').append(tplLayout); layoutResize(); $(window).resize(function() { layoutResize(); }); $(".category-list").mCustomScrollbar({ }); $(".info-list").mCustomScrollbar({ }); $("#atlasInfoDetailAll .contentWrap").mCustomScrollbar({ }); $('#atlasList .content').mCustomScrollbar({ horizontalScroll:true }); } /** * 界面事件绑定 * @return {[type]} [description] */ function bindEvent(){ $('#atlasInfo .header .abtn-up').bind('click',function(){ if($(this).hasClass('abtn-down')){ $(this).removeClass('abtn-down'); $(this).parent().next().show(); }else { $(this).addClass('abtn-down'); $(this).parent().next().hide(); } $(".info-list").mCustomScrollbar('update'); }); $('#atlasInfoDetail .abtn-more').bind('click',function(){ $('#atlasInfoDetailAll').show(); }) $('#atlasInfoDetailAll .abtn-close').bind('click',function(){ $('#atlasInfoDetailAll').hide(); }) $('.abtn-min-atlas-category').bind('click',function(){ if($(this).hasClass('min')){ $(this).removeClass('min'); $('#contentWrap').removeClass('hide-category'); }else { $(this).addClass('min'); $('#contentWrap').addClass('hide-category'); } ATLAS.C.publisher.publish({},'atlasView::layoutResize'); }) $('.abtn-min-atlas-info').bind('click',function(){ if($(this).hasClass('min')){ $(this).removeClass('min'); $('#contentWrap').removeClass('hide-info'); }else { $(this).addClass('min'); $('#contentWrap').addClass('hide-info'); } ATLAS.C.publisher.publish({},'atlasView::layoutResize'); }) $('.abtn-min-atlas-list').bind('click',function(){ if($(this).hasClass('min')){ $(this).removeClass('min'); $('#contentWrap').removeClass('hide-list'); }else { $(this).addClass('min'); $('#contentWrap').addClass('hide-list'); } ATLAS.C.publisher.publish({},'atlasView::layoutResize'); }) } /** * 界面重置 * @return {[type]} [description] */ function layoutResize(){ $('.category-list').css({height:$('#atlasCategory').height()-100}); } /** * 获取地图集目录数据 * @type {Function} * @private */ function getAtlasCatalogData(aid){ if(_this.options.type === 4){ var ajaxUrl = atlasUrlConfig.catalogServerUrl+'/production/modValue.options.type?production_id='+aid; }else { var ajaxUrl = atlasUrlConfig.catalogServerUrl+'/production/product_category?production_id='+aid; } ATLAS.V.loading.load(); $.ajax({ type:"get", dataType:'jsonp', url:ajaxUrl, success:function(data){ ATLAS.V.loading.loaded(); modValue.atlasCatalogData = data; setSideBarCatalog(); }, error:function(data){ ATLAS.V.loading.loaded(); ATLAS.C.publisher.publish({type:'error',message:'获取地图集目录数据失败!'},'noteBar::add'); } }); } /** * 设置图集目录 */ function setSideBarCatalog(){ $('#thematicCategory dl').empty(); var dtCount = 1; var liCount = 1; var first = true; for(var item in modValue.atlasCatalogData.category){ var cItem =modValue.atlasCatalogData.category[item]; if(modValue.options.type === 4){ var itemDt = $('