123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320 |
- /**
- * [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 = $('<dt tid="'+cItem.guid+'">'+cItem.name+'<i></i></dt>');
- }else {
- var itemDt = $('<dt>'+dtCount+'.'+cItem.name+'<i></i></dt>');
- }
- $('#thematicCategory dl').append(itemDt);
- var itemDd = $('<dd></dd>');
- $('#thematicCategory dl').append(itemDd);
- var itemDdUl = $('<ul></ul>');
- itemDd.append(itemDdUl);
- for(var i= 0,l=cItem.list.length; i<l; i++){
- var mItem = cItem.list[i];
- //默认显示第一幅图
- if(first === true){
- var mItemLi = $('<li style="display:block;">'+
- '<a class="select" tid="'+mItem.guid+'" href="javascript:void(0)">'+
- dtCount+'.'+liCount+'-'+mItem.name+'<i></i></a></li>');
- //AJAX获取专题图数据,添加专题图到地图容器
- modValue.getThematicData(mItem.guid);
- first = false;
- }else {
- var mItemLi = $('<li style="display:block;">'+
- '<a tid="'+mItem.guid+'" href="javascript:void(0)">'+
- dtCount+'.'+liCount+'-'+mItem.name+'<i></i></a></li>');
- }
- mItemLi.find('a').bind('click',{da:mItem},function(e){
- $('#thematicCategory dd ul li .select').removeClass('select');
- $(this).addClass('select');
- //ie6 hack
- e.preventDefault();
- //AJAX获取专题图数据,添加专题图到地图容器
- modValue.getThematicData(e.data.da.guid);
- });
- mItemLi.appendTo(itemDdUl);
- liCount++;
- }
- dtCount++;
- liCount = 1;
- }
- $('#thematicCategory dt:first').addClass('select');
- $('#thematicCategory dd:first').css({display:"block"}).addClass('open');
- $('#thematicCategory dt').bind('click',function(){
- if($(this).hasClass('select')){
- $(this).removeClass('select');
- $(this).next().removeClass('open').css({display:"none"});
- }else {
- $(this).addClass('select');
- $(this).next().css({display:"block"}).addClass('open').css({height:'auto'});
- }
- })
- }
- /**
- * AJAX获取相应GUID的专题图数据
- * @type {Function}
- * @param guid {Number} guid
- * @private
- */
- function getThematicData(guid){
- var ajaxUrl = atlasUrlConfig.thematicDataServerUrl+'/production/metadata?production_id='+guid;
- ATLAS.V.loading.load();
- $.ajax({
- type:"get",
- dataType:'jsonp',
- url:ajaxUrl,
- success:function(data){
- ATLAS.V.loading.loaded();
- modValue.currentThematicData = data.metadata;
- //添加专题图到地图容器中
- addThematicToMap();
- },
- error:function(data){
- ATLAS.V.loading.loaded();
- ATLAS.C.publisher.publish({type:'error',message:'获取地图数据失败!'},'noteBar::add');
- }
- });
- }
- /**
- * 添加专题图到地图上
- */
- function addThematicToMap(){
- }
- /**
- * 注册订阅
- * @type {Function}
- * 推送:ATLAS.C.publisher.publish(options,'atlasView::type');
- * 订阅:ATLAS.C.publisher.subscribe(layoutResize,'sideBarLayoutChange');
- */
- function subscribe(){}
- /**
- * 取消订阅
- * @type {Function}
- * 取消订阅:ATLAS.C.publisher.unSubscribe(layoutResize,'sideBarLayoutChange');
- */
- function unSubscribe(){}
- /**
- * 模块移除
- * @return {[type]} [description]
- */
- function remove(){
- //取消订阅
- //unSubscribe();
- }
-
- return ATLAS.M.atlasView = {
- init:init,
- layoutResize:layoutResize
- }
- });
|