123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367 |
- /**
- * [ONEMAP.M.gcmsVideo]
- * @return {[object]}
- */
- define([
- 'html!templates/gcms/gcmsVideo',
- 'vendorDir/handlebars/handlebars',
- 'css!styles/gcms/gcmsVideo'],
- function(tpcLayout,Handlebars){
- var modValue = {
- options:{},
- mapPointGroup:null,
- };
-
- /**
- * 模块初始化
- * @return {[type]} [description]
- */
- function init(options){
- remove();
- modValue.mapPointGroup = map23DControl.group({
- action: 'add'
- });
- modValue.options = {};
- for(var op in options){
- modValue.options[op] = options[op];
- }
- //获取内容数据
- getDetailData();
-
- //订阅推送
- 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.T.noPermission('getDetailData');
- }
- if(data.code == 3){
- ONEMAP.T.logout('getDetailData');
- }
- if(JSON.parse(data['data']['record'][modValue.options['field_name']])['features'].length == 0){
- ONEMAP.C.publisher.publish({ type: 'warning', message: '没有视频数据' }, 'noteBar::add');
- remove();
- }else {
- ONEMAP.D.gcmsCurArticleData = data['data'];
- showPoint();
- //showVideo();
- }
- })
- .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 showPoint(){
- var mapDrawData = JSON.parse(ONEMAP.D.gcmsCurArticleData['record'][modValue.options['field_name']]);
- if(mapDrawData['features'].length>0){
- $(mapDrawData['features']).each(function(index, el) {
- switch(el['properties']['type']){
- case 'VideoLocation'://点
- buildMarker(el);
- break;
- }
- });
- map2DViewer.map.fitBounds(map2DViewer.groups[modValue.mapPointGroup].getBounds());
-
- }else {
- ONEMAP.C.publisher.publish({ type: 'warning', message: '没有标注数据' }, 'noteBar::add');
- }
- };
- function buildMarker(options){
- var curGuid = map23DControl.marker({
- action: 'add',
- groupId: modValue.mapPointGroup,
- geojson: {
- "properties": {
- altitudeMode:0,
- iconUrl: onemapUrlConfig.gcmsServiceUrl+'/file'+options['properties']['style']['iconUrl']+'?jwt='+ONEMAP.D.user.ticket,
- iconSize: options['properties']['style']['iconSize'],
- iconAnchor: options['properties']['style']['iconAnchor'],
- popupAnchor: [0,-options['properties']['style']['iconAnchor'][1]]
- },
- "geometry": {
- "coordinates": options['geometry']['coordinates']
- }
- }
- });
- var file = options['properties']['file'];
- var oLabelObj = '<a href="javascript:ONEMAP.M.gcmsPointVideo.showVideo(\''+file+'\')">播放视频</a>';
- var options_popup = {
- name:'',
- content:oLabelObj
- };
- var new_popupHtml = ONEMAP.M.gcmsNav.creatPopupHtml(options_popup);
- map2DViewer.markers[curGuid].bindPopup(new_popupHtml,{
- closeButton:false,
- maxWidth:60,
- minWidth:40});
- map2DViewer.markers[curGuid].openPopup();
- map2DViewer.markers[curGuid].on('mouseover',function(){
- this.openPopup();
- })
- }
- function showVideo(file){
- $('#gcmsVideoModal').remove();
- $('#DIVSNplayerWMPvideoPlayer').remove();
- $('body').append(tpcLayout);
- bindEvent();
- var videoFileUrl = onemapUrlConfig.gcmsServiceUrl+'/file'+file+'?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');
- ONEMAP.C.publisher.subscribe(GroupControl, 'gcmsGroupControl');
- }
- /**
- * 取消监听
- * @type {Function}
- */
- function unSubscribe() {}
- function GroupControl(type) {
- if (type == "show") {
- map23DControl.group({
- action: 'show',
- guid: modValue.mapPointGroup
- })
- map23DControl.group({
- action: 'show',
- guid: modValue.mapPointGroup
- })
- } else if (type == "hide") {
- map23DControl.group({
- action: 'hide',
- guid: modValue.mapPointGroup
- })
- map23DControl.group({
- action: 'hide',
- guid: modValue.mapPointGroup
- })
- }
- }
- /**
- * 模块移除
- * @return {[type]} [description]
- */
- function remove(){
- map23DControl.group({
- action: 'cleanAll',
- guid: modValue.mapPointGroup
- })
- map23DControl.group({
- action: 'remove',
- guid: modValue.mapPointGroup
- })
- $('#gcmsVideoModal').remove();
- $('#DIVSNplayerWMPvideoPlayer').remove();
- unSubscribe();
- }
- return ONEMAP.M.gcmsPointVideo = {
- init:init,
- remove:remove,
- showVideo:showVideo
- }
- });
|