/** * [ONEMAP.M.gcmsVideo] * @return {[object]} */ define([ 'html!templates/gcms/gcmsVideo', 'vendorDir/handlebars/handlebars', 'css!styles/gcms/gcmsVideo'], 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(){ showVideo(); }}); //订阅推送 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(){ $('#gcmsVideoModal .modal-header .close').bind('click', function() { remove(); }); $('#gcmsVideoModal .modal-header').dragmove($('#gcmsVideoModal')); var $box2 = $('#gcmsVideoModal').on('mousedown', '#coorForGcmsVideoModal', 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 )-145; $("#gcmsVideoModal .modal-body").css({height:bodyHeight}); }}); $.extend(document, {'move': true, 'call_up': function(e) { $('#gcmsVideoList .selected').click(); }}); return false; }); } function showVideo(){ $('body').append(tpcLayout); bindEvent(); var videoFileUrl = onemapUrlConfig.gcmsServiceUrl+'/file'+JSON.parse(ONEMAP.D.gcmsCurArticleData['record'][modValue.options['field_name']])[0]+'?jwt='+ONEMAP.D.user.ticket; // if(Modernizr.video.h264.length>0){ // var videPlayerHtml = ''; // }else { var flashPlayerInfo = flashChecker(); if (flashPlayerInfo && flashPlayerInfo.v > 10) { var videPlayerHtml = _setFlashPlayer("videoPlayer", "scripts/vendor/player/snplayer.swf?file=type:mp4;url:" + videoFileUrl + "", "100%", "100%", "SkinURL=skin/default.zip", true); } else { if (document.all) { var flashPlayerLink = onemapUrlConfig.siteUrl+'/soft/flashplayer_winax.exe'; } else { var flashPlayerLink = onemapUrlConfig.siteUrl+'/soft/flashplayer_win.exe'; } var videPlayerHtml = '
' + '

请安装Adobe flash player 11以上版本的播放器。

' + '
Adobe Flash Player 11
' + '
'; } //} $('#gcmsVideoModal').show(); $('#gcmsVideoPlayer').empty().html(videPlayerHtml); //显示列表 $('#gcmsVideoList').empty(); $(JSON.parse(ONEMAP.D.gcmsCurArticleData['record'][modValue.options['field_name']])).each(function(index, el) { $('
  • ').appendTo($('#gcmsVideoList')); }); $('#gcmsVideoList .btn:eq(0)').addClass('selected'); $('#gcmsVideoList .btn').bind('click',function(){ var videoFileUrl = $(this).attr('vUrl'); // if(Modernizr.video.h264.length>0){ // var videPlayerHtml = ''; // }else { var flashPlayerInfo = flashChecker(); if (flashPlayerInfo && flashPlayerInfo.v > 10) { var videPlayerHtml = _setFlashPlayer("videoPlayer", "scripts/vendor/player/snplayer.swf?file=type:mp4;url:" + videoFileUrl + "", "100%", "100%", "SkinURL=skin/default.zip", true); } else { if (document.all) { var flashPlayerLink = onemapUrlConfig.siteUrl+'/soft/flashplayer_winax.exe'; } else { var flashPlayerLink = onemapUrlConfig.siteUrl+'/soft/flashplayer_win.exe'; } var videPlayerHtml = '
    ' + '

    请安装Adobe flash player 11以上版本的播放器。

    ' + '
    Adobe Flash Player 11
    ' + '
    '; } //} $('#gcmsVideoModal').show(); $('#gcmsVideoPlayer').empty().html(videPlayerHtml); $('#gcmsVideoModal .selected').removeClass('selected'); $(this).addClass('selected'); }); } function flashChecker(){ var hasFlash = 0; var flashVersion =0; try{ if(document.all){ var swf = new ActiveXObject('ShockwaveFlash.ShockwaveFlash'); if(swf){ hasFlash = 1; VSwf = swf.GetVariable('$version'); flashVersion = parseInt(VSwf.split(" ")[1].split(",")[0]); } }else { if(navigator.plugins && navigator.plugins.length > 0){ var swf = navigator.plugins["Shockwave Flash"]; } if(swf){ hasFlash = 1; var words = swf.description.split(" "); for(var i=0;i'; html += ''; html += ''; html += ''; html += ''; html += ''; html += '