123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- /**
- * [ONEMAP.M.gcmsFiles]
- * @return {[object]}
- */
- define([
- 'html!templates/gcms/gcmsFiles',
- 'vendorDir/handlebars/handlebars',
- 'css!styles/gcms/gcmsFiles'
- ],
- function(tpcLayout,Handlebars){
- //参数
- var modValue = {
- options:{}
- };
- //地图层
- //var _map = ONEMAP.M.mapHolder.map;
- /**
- * 模块初始化
- * @return {[type]} [description]
- */
- function init(options){
- modValue.options = {};
- for(var op in options){
- modValue.options[op] = options[op];
- }
- //获取内容数据
- getDetailData({callback:function(){
- showFiles();
- }});
-
- //订阅推送
- subscribe();
- }
- function getDetailData(options){
- ONEMAP.V.loading.load();
- $.ajax({
- url: onemapUrlConfig.gcmsServiceUrl+'/show/'+modValue.options['column_name']+'/'+modValue.options['article_id'],
- type:"GET",
- dataType: 'json'
- })
- .done(function(data) {
- ONEMAP.V.loading.loaded();
- if(data.code == 4){
- ONEMAP.C.noPermission('getDetailData');
- return false;
- }
- if(data.code == 3){
- ONEMAP.C.logout('getDetailData');
- }
- if(JSON.parse(data['data']['record'][modValue.options['field_name']]).length == 0){
- ONEMAP.C.publisher.publish({ type: 'warning', message: '没有文件数据' }, 'noteBar::add');
- remove();
- }else {
- ONEMAP.D.gcmsCurArticleData = data['data'];
- options.callback();
- }
- })
- .fail(function() {
- ONEMAP.V.loading.loaded();
- });
- }
- /**
- * 事件绑定
- * @return {[type]} [description]
- */
- function bindEvent(){
- $('#gcmsFilesModal .modal-header .close').bind('click', function() {
- remove();
- });
- $('#gcmsFilesModal .modal-header').dragmove($('#gcmsFilesModal'));
- var $box2 = $('#gcmsFilesModal').on('mousedown', '#coorForGcmsFilesModal', 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;
- $("#gcmsFilesModal .modal-body").css({height:bodyHeight});
- }});
- return false;
- });
- }
- function showFiles(){
- $('body').append(tpcLayout);
- bindEvent();
- if(map23DData.display.map2D){
- $('#gcmsFilesModal').removeClass('TD');
- }else{
- $('#gcmsFilesModal').addClass('TD');
- }
- $('#gcmsFilesModal').show();
- //显示列表
- $('#gcmsFilesList').empty();
- $(JSON.parse(ONEMAP.D.gcmsCurArticleData['record'][modValue.options['field_name']])).each(function(index, el) {
- $('<li><button vUrl="'+onemapUrlConfig.gcmsServiceUrl+'/file'+el+'" class="btn">文件['+(index+1)+']</button></li>').appendTo($('#gcmsFilesList'));
- });
- //$('#gcmsFilesList .btn:eq(0)').addClass('selected');
- $('#gcmsFilesList .btn').bind('click',function(){
- var filesFileUrl = $(this).attr('vUrl');
- window.open(filesFileUrl);
- });
- }
- /**
- * 界面布局重置
- * @type {Function}
- */
- function layoutResize(){
- }
- /**
- * 切换23D样式
- */
- function layoutResizeCSS(cid) {
- if (cid == '2d') {
- $('#gcmsFilesModal').removeClass('TD');
- } else {
- $('#gcmsFilesModal').addClass('TD');
- }
- }
- /**
- * 注册监听
- * @type {Function}
- */
- function subscribe(){
- ONEMAP.C.publisher.subscribe(remove,'gcmsArticleShowRemove');
- ONEMAP.C.publisher.subscribe(remove, 'cleanMap');
- ONEMAP.C.publisher.subscribe(layoutResizeCSS, 'change23D');
- }
- /**
- * 取消监听
- * @type {Function}
- */
- function unSubscribe() {}
- /**
- * 模块移除
- * @return {[type]} [description]
- */
- function remove(){
- $('#gcmsFilesModal').remove();
- unSubscribe();
- }
- return ONEMAP.M.gcmsFiles = {
- init:init,
- remove:remove
- }
- });
|