123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284 |
- /**
- * [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 = '<video src="'+videoFileUrl+'" width="470" height="400" autoplay controls></video>';
- // }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 = '<div class="install-flash-player" style="text-align:center">' +
- '<p><strong>请安装Adobe flash player 11以上版本的播放器。</strong></p>' +
- '<a href="' + flashPlayerLink + '"><img src="images/layout/get_flash.png"/><br/><span>Adobe Flash Player 11</span></a>' +
- '</div>';
- }
- //}
-
-
- $('#gcmsVideoModal').show();
- $('#gcmsVideoPlayer').empty().html(videPlayerHtml);
- //显示列表
- $('#gcmsVideoList').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($('#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 = '<video src="'+videoFileUrl+'" width="470" height="400" autoplay controls></video>';
- // }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 = '<div class="install-flash-player" style="text-align:center">' +
- '<p><strong>请安装Adobe flash player 11以上版本的播放器。</strong></p>' +
- '<a href="' + flashPlayerLink + '"><img src="images/layout/get_flash.png"/><br/><span>Adobe Flash Player 11</span></a>' +
- '</div>';
- }
- //}
- $('#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<words.length; i++){
- if(isNaN(parseInt(words[i]))) continue;
- flashVersion = parseInt(words[i]);
- }
- }
- }
- }catch (e) {
- }
- return {
- f:hasFlash,
- v:flashVersion
- };
- }
- /**
- * 添加Flash Player
- * @type {Function}
- * @param id {String} 容器id
- * @param url {String} url
- * @param width {Number} 宽度
- * @param height {Number} 高度
- * @param vars {String} 参数
- * @param transparent {String} 是否透明
- * @returns {string} flash player code
- * @private
- */
- function _setFlashPlayer(id, url, width, height, vars, transparent){
- $('#DIVSNplayerWMPvideoPlayer').remove();
- var wmode = transparent ? "transparent" : "opaque";
- var html = '';
- html += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
- html += 'width="'+width+'" ';
- html += 'height="'+height+'" ';
- html += 'id="'+id+'"';
- html += '>';
- html += '<param name="movie" value="'+url+'" />';
- html += '<param name="allowFullScreen" value="true" />';
- html += '<param name="allowScriptAccess" value="always" />';
- html += '<param name="quality" value="high" />';
- html += '<param name="wmode" value="'+wmode+'" />';
- html += '<param name="flashvars" value="'+vars+'" />';
- html += '<embed type="application/x-shockwave-flash" ';
- html += 'width="'+width+'" ';
- html += 'height="'+height+'" ';
- html += 'name="'+id+'" ';
- html += 'src="'+url+'" ';
- html += 'allowfullscreen="true" ';
- html += 'allowscriptaccess="always" ';
- html += 'quality="high" ';
- html += 'wmode="'+wmode+'" ';
- html += 'flashvars="'+vars+'"'
- html += '></embed>';
- html += '</object>';
- return html;
- };
-
- /**
- * 界面布局重置
- * @type {Function}
- */
- function layoutResize(){
- }
-
- /**
- * 注册监听
- * @type {Function}
- */
- function subscribe(){
- ONEMAP.C.publisher.subscribe(remove,'gcmsArticleShowRemove');
- ONEMAP.C.publisher.subscribe(remove, 'cleanMap');
- }
- /**
- * 取消监听
- * @type {Function}
- */
- function unSubscribe() {}
- /**
- * 模块移除
- * @return {[type]} [description]
- */
- function remove(){
- $('#gcmsVideoModal').remove();
- $('#DIVSNplayerWMPvideoPlayer').remove();
- unSubscribe();
- }
- return ONEMAP.M.gcmsVideo = {
- init:init,
- remove:remove
- }
- });
|