Ignore:
Timestamp:
Sep 23, 2011, 10:44:08 PM (13 years ago)
Author:
grum
Message:

fix bugs
bug:2346 - Preview / next arrow do not work with [gmaps] tag in description
bug:2063 - Incompatibility with slideshow mode

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/GMaps/js/gmapsMarkup.min.js

    r10551 r12204  
    1 /* file: gmapsMarkup.js - v1.1.1 | minified on 2011/04/13 with http://jscompress.com/ */
    2 var markerImgProp=[null,{w:32,h:32,x:15,y:31},{w:32,h:32,x:15,y:31},{w:32,h:32,x:10,y:31},{w:30,h:40,x:4,y:39}];function markupMaps()
    3 {this.createMap=function(properties,gmapsIndex)
    4 {var bounds=new google.maps.LatLngBounds(new google.maps.LatLng(properties.mapBounds.south,properties.mapBounds.west),new google.maps.LatLng(properties.mapBounds.north,properties.mapBounds.east)),map=new google.maps.Map($("#"+properties.id).get(0),{backgroundColor:'#ffffff',mapTypeId:properties.mapType,zoom:properties.zoomLevel,center:bounds.getCenter(),navigationControl:(properties.navigationControl==-1)?false:true,scrollwheel:(properties.navigationControl==-1)?false:true,scaleControl:(properties.scaleControl=='n')?false:true,streetViewControl:(properties.streetViewControl=='n')?false:true,mapTypeControl:(properties.mapTypeControl==-1)?false:true,mapTypeControlOptions:{style:properties.mapTypeControl},markerTitle:''});if(properties.kmlFileUrl!='')
    5 {kmlFile=new google.maps.KmlLayer(properties.kmlFileUrl,{preserveViewport:true});kmlFile.setMap(map);}
    6 else
    7 {kmlFile=null;}
    8 re=/^mS(\d\d)_.*/i;iM=re.exec(properties.markerImg);if(iM!=null)iM=new Number(iM[1]);if(iM!=null)
    9 {map.markerImg=new google.maps.MarkerImage('plugins/GMaps/img/'+properties.markerImg,new google.maps.Size(markerImgProp[iM].w,markerImgProp[iM].h),new google.maps.Point(0,0),new google.maps.Point(markerImgProp[iM].x,markerImgProp[iM].y));}
    10 else
    11 {map.markerImg=null;}
    12 map.bounds=bounds;map.kmlFile=kmlFile;map.markers=new Array();map.gmapsIndex=gmapsIndex;map.width=properties.width;map.height=properties.height;map.callId=0;map.allowBubble=properties.allowBubble;map.initialized=false;properties.gMap=map;if(properties.geolocated)
    13 {if(properties.fitToBounds)
    14 {fitToBounds(map.bounds,gmapsIndex);}
    15 else
    16 {map.setCenter(map.bounds.getCenter());}}
    17 if(properties.markerVisible)
    18 {loadMarkers(map);}
    19 else
    20 {initializeMapViewport(gmapsIndex);}};var loadMarkers=function(map)
    21 {if(map.getBounds()==null)return(false);map.callId++;datas={requestId:gmapsMarkup.requestId,callId:map.callId,bounds:{north:map.getBounds().getNorthEast().lat(),east:map.getBounds().getNorthEast().lng(),south:map.getBounds().getSouthWest().lat(),west:map.getBounds().getSouthWest().lng()},width:map.width,height:map.height,distanceTreshold:20,loadIndex:map.gmapsIndex};$.ajax({type:"POST",url:"plugins/GMaps/gmaps_ajax.php",async:true,data:{ajaxfct:"public.maps.getMarkers",datas:datas},success:function(msg)
    22 {tmp=$.parseJSON(msg);if(gmapsMarkup.maps[tmp.loadIndex].gMap.callId==tmp.callId)
    23 {tmp.markers.sort(compareMarkers);applyMarkers(gmapsMarkup.maps[tmp.loadIndex].gMap,tmp.markers);initializeMapViewport(tmp.loadIndex);}}});};var applyMarkers=function(map,markers)
    24 {if(map==null)return(false);if(map.markers.length>0)
    25 {var i=0;while(i<map.markers.length)
    26 {newListIndex=markerInList(map.markers[i].uId,markers);if(newListIndex==-1)
    27 {map.markers[i].marker.setMap(null);map.markers.splice(i,1);}
    28 else
    29 {markers.splice(newListIndex,1);i++;}}}
    30 for(var i=0;i<markers.length;i++)
    31 {var marker=new google.maps.Marker({position:new google.maps.LatLng(markers[i].lat,markers[i].lng),map:map,title:markers[i].nbImgTxt});if(map.markerImg!=null)marker.setIcon(map.markerImg);marker.info=markers[i];marker.info.displayed=0;map.markers.push({marker:marker,uId:markers[i].uId});if(map.allowBubble)
    32 {google.maps.event.addListener(marker,'click',function()
    33 {displayWindowInfo(this);});}
    34 for(var index=0;index<marker.info.imgTn.length;index++)
    35 {switch(marker.info.imgTn[index].charAt(0))
    36 {case'G':marker.info.imgTn[index]='./galleries/'+marker.info.imgTn[index].substr(1);break;case'U':marker.info.imgTn[index]='./upload/'+marker.info.imgTn[index].substr(1);break;}}}};var compareMarkers=function(m1,m2)
    37 {if(m1.uId<m2.uId)
    38 {return(-1);}
    39 else if(m1.uId<m2.uId)
    40 {return(1);}
    41 return(0);};var markerInList=function(uniqueId,markerList)
    42 {for(var i=0;i<markerList.length;i++)
    43 {if(markerList[i].uId==uniqueId)return(i)}
    44 return(-1);};var displayWindowInfo=function(marker)
    45 {gmapsMarkup.currentInfo=marker.info;gmapsMarkup.infoWindow.close();gmapsMarkup.infoWindow.setContent($('#iGMapsInfoWindowContent').clone().each(renameId).get(0));gmapsMarkup.infoWindow.open(marker.map,marker);displayPictureInfo(gmapsMarkup.currentInfo.displayed);};var renameId=function(i,e)
    46 {if(e.id!='')e.id='c'+e.id;$(e).children().each(renameId);};var displayPictureInfo=function(index)
    47 {gmapsMarkup.currentInfo.displayed=index;if(gmapsMarkup.currentInfo.imgName[index]=='')
    48 {$('#ciGMIWC_title').html(' ');}
    49 else
    50 {$('#ciGMIWC_title').html(gmapsMarkup.currentInfo.imgName[index]);}
    51 $('#ciGMIWC_img').attr('src',gmapsMarkup.currentInfo.imgTn[index]);$('#ciGMIWC_img').unbind();if(gmapsMarkup.currentInfo.imgCatsUrl[index].length==1)
    52 {$('#ciGMIWC_img').bind('click',function()
    53 {window.location=gmapsMarkup.currentInfo.imgCatsUrl[gmapsMarkup.currentInfo.displayed][0];});}
    54 else
    55 {$('#ciGMIWC_showcatList').html('');for(var i=0;i<gmapsMarkup.currentInfo.imgCatsUrl[index].length;i++)
    56 {$('#ciGMIWC_showcatList').append('<li><a href="'+gmapsMarkup.currentInfo.imgCatsUrl[index][i]+'">'+gmapsMarkup.currentInfo.imgCatsNames[index][i]+'</a></li>');}
    57 $('#ciGMIWC_img, #ciGMIWC_showcat').bind('mouseenter',function(){$('#ciGMIWC_showcat').css('display','block');}).bind('mouseleave',function(){$('#ciGMIWC_showcat').css('display','none');});}
    58 if(gmapsMarkup.currentInfo.nbImg>1)
    59 {$('#ciGMIWC_picnum').html((index+1)+'/'+gmapsMarkup.currentInfo.nbImgTxt);$('#ciWALeft, #ciWARight').css('display','inline-block');}
    60 else
    61 {$('#ciGMIWC_picnum').html(gmapsMarkup.currentInfo.nbImgTxt);$('#ciWALeft, #ciWARight').css('display','none');}};this.displayPicturePrev=function()
    62 {gmapsMarkup.currentInfo.displayed--;if(gmapsMarkup.currentInfo.displayed<0)gmapsMarkup.currentInfo.displayed=gmapsMarkup.currentInfo.nbImg-1;displayPictureInfo(gmapsMarkup.currentInfo.displayed);};this.displayPictureNext=function()
    63 {gmapsMarkup.currentInfo.displayed++;if(gmapsMarkup.currentInfo.displayed>=gmapsMarkup.currentInfo.nbImg)gmapsMarkup.currentInfo.displayed=0;displayPictureInfo(gmapsMarkup.currentInfo.displayed);};var fitToBounds=function(bounds,mapIndex)
    64 {gmapsMarkup.maps[mapIndex].gMap.fitBounds(bounds);if(gmapsMarkup.maps[mapIndex].zoomLevelMaxActivated&&gmapsMarkup.maps[mapIndex].gMap.getZoom()>gmapsMarkup.maps[mapIndex].zoomLevel)
    65 {gmapsMarkup.maps[mapIndex].gMap.setZoom(gmapsMarkup.maps[mapIndex].zoomLevel);}};var initializeMapViewport=function(mapIndex)
    66 {if(mapIndex>-1&&!gmapsMarkup.maps[mapIndex].gMap.initialized)
    67 {$('#'+gmapsMarkup.maps[mapIndex].id+' span, #'+gmapsMarkup.maps[mapIndex].id+' a').css('font-size','55.0%');if(gmapsMarkup.maps[mapIndex].markerVisible)
    68 {google.maps.event.addListener(gmapsMarkup.maps[mapIndex].gMap,'dragend',function()
    69 {loadMarkers(this);});google.maps.event.addListener(gmapsMarkup.maps[mapIndex].gMap,'zoom_changed',function()
    70 {loadMarkers(this);gmapsMarkup.infoWindow.close();});}
    71 if(gmapsMarkup.maps[mapIndex].kmlZoom&&gmapsMarkup.maps[mapIndex].gMap.kmlFile!=null)
    72 {google.maps.event.addListenerOnce(gmapsMarkup.maps[mapIndex].gMap.kmlFile,'defaultviewport_changed',function()
    73 {fitToBounds(gmapsMarkup.maps[mapIndex].gMap.kmlFile.getDefaultViewport(),mapIndex);});}
    74 gmapsMarkup.maps[mapIndex].gMap.initialized=true;}};}
    75 $(window).load(function()
    76 {var mm=new markupMaps();gmapsMarkup.currentInfo=null;gmapsMarkup.infoWindow=new google.maps.InfoWindow();google.maps.event.addListener(gmapsMarkup.infoWindow,'closeclick',function(){gmapsMarkup.infoWindow.setContent('');$('#ciGMIWC_img').unbind();});$.ajax({type:"POST",url:"plugins/GMaps/gmaps_ajax.php",async:true,data:{ajaxfct:"public.maps.init",category:gmapsMarkup.categoryId,mapId:'y'},success:function(msg)
    77 {gmapsMarkup.requestId=msg;for(var i=0;i<gmapsMarkup.maps.length;i++)
    78 {$('#'+gmapsMarkup.maps[i].id).css({width:gmapsMarkup.maps[i].width+'px',height:gmapsMarkup.maps[i].height+'px'});mm.createMap(gmapsMarkup.maps[i],i);}}});if($('#iGMapsInfoWindow').length==0)
    79 {$('body').append($('<div/>',{id:'iGMapsInfoWindow',css:{display:'none'},}).append($('<div/>',{id:'iGMapsInfoWindowContent'}).append($('<div/>',{id:'iGMIWC_title',html:'(title)'})).append($('<table/>',{id:'iGMIWC_thumb'}).append($('<tr/>').append($('<td/>',{css:{width:'28px'}}).append($('<div id="iWALeft" onclick="mm.displayPicturePrev();"/>'))).append($('<td/>').append($('<img/>',{id:'iGMIWC_img',src:''}))).append($('<td/>',{css:{width:'28px'}}).append($('<div id="iWARight" onclick="mm.displayPictureNext();">'))))).append($('<div/>',{id:'iGMIWC_picnum',html:'0/0 photo'})).append($('<div/>',{id:'iGMIWC_showcat',css:{display:'none'}}).append($('<span/>',{html:'gmaps_i_show_this_picture_in'})).append($('<ul/>',{id:'iGMIWC_showcatList'})))));}});
     1/* file: gmapsMarkup.js - v1.1.2 | minified on 2011/09/23 with http://jscompress.com/ */
     2function markupMaps(){var a=[null,{w:32,h:32,x:15,y:31},{w:32,h:32,x:15,y:31},{w:32,h:32,x:10,y:31},{w:30,h:40,x:4,y:39}];this.createMap=function(b,c){var d=new google.maps.LatLngBounds(new google.maps.LatLng(b.mapBounds.south,b.mapBounds.west),new google.maps.LatLng(b.mapBounds.north,b.mapBounds.east)),e=new google.maps.Map($("#"+b.id).get(0),{backgroundColor:"#ffffff",mapTypeId:b.mapType,zoom:b.zoomLevel,center:d.getCenter(),navigationControl:b.navigationControl==-1?false:true,scrollwheel:b.navigationControl==-1?false:true,scaleControl:b.scaleControl=="n"?false:true,streetViewControl:b.streetViewControl=="n"?false:true,mapTypeControl:b.mapTypeControl==-1?false:true,mapTypeControlOptions:{style:b.mapTypeControl},markerTitle:""});if(b.kmlFileUrl!=""){kmlFile=new google.maps.KmlLayer(b.kmlFileUrl,{preserveViewport:true});kmlFile.setMap(e)}else{kmlFile=null}re=/^mS(\d\d)_.*/i;iM=re.exec(b.markerImg);if(iM!=null)iM=new Number(iM[1]);if(iM!=null){e.markerImg=new google.maps.MarkerImage("plugins/GMaps/img/"+b.markerImg,new google.maps.Size(a[iM].w,a[iM].h),new google.maps.Point(0,0),new google.maps.Point(a[iM].x,a[iM].y))}else{e.markerImg=null}e.bounds=d;e.kmlFile=kmlFile;e.markers=new Array;e.gmapsIndex=c;e.width=b.width;e.height=b.height;e.callId=0;e.allowBubble=b.allowBubble;e.initialized=false;b.gMap=e;if(b.geolocated){if(b.fitToBounds){this.fitToBounds(e.bounds,c)}else{e.setCenter(e.bounds.getCenter())}}if(b.markerVisible){this.loadMarkers(e)}else{this.initializeMapViewport(c)}};this.loadMarkers=function(a){var c=this;if(a.getBounds()==null)return false;a.callId++;datas={requestId:gmapsMarkup.requestId,callId:a.callId,bounds:{north:a.getBounds().getNorthEast().lat(),east:a.getBounds().getNorthEast().lng(),south:a.getBounds().getSouthWest().lat(),west:a.getBounds().getSouthWest().lng()},width:a.width,height:a.height,distanceTreshold:20,loadIndex:a.gmapsIndex};$.ajax({type:"POST",url:"plugins/GMaps/gmaps_ajax.php",async:true,data:{ajaxfct:"public.maps.getMarkers",datas:datas},success:function(a){tmp=$.parseJSON(a);if(gmapsMarkup.maps[tmp.loadIndex].gMap.callId==tmp.callId){tmp.markers.sort(b);c.applyMarkers(gmapsMarkup.maps[tmp.loadIndex].gMap,tmp.markers);c.initializeMapViewport(tmp.loadIndex)}}})};this.applyMarkers=function(a,b){if(a==null)return false;if(a.markers.length>0){var c=0;while(c<a.markers.length){newListIndex=this.markerInList(a.markers[c].uId,b);if(newListIndex==-1){a.markers[c].marker.setMap(null);a.markers.splice(c,1)}else{b.splice(newListIndex,1);c++}}}for(var c=0;c<b.length;c++){var d=this,e=new google.maps.Marker({position:new google.maps.LatLng(b[c].lat,b[c].lng),map:a,title:b[c].nbImgTxt});if(a.markerImg!=null)e.setIcon(a.markerImg);e.info=b[c];e.info.displayed=0;a.markers.push({marker:e,uId:b[c].uId});if(a.allowBubble){google.maps.event.addListener(e,"click",function(){d.displayWindowInfo(this)})}for(var f=0;f<e.info.imgTn.length;f++){switch(e.info.imgTn[f].charAt(0)){case"G":e.info.imgTn[f]="./galleries/"+e.info.imgTn[f].substr(1);break;case"U":e.info.imgTn[f]="./upload/"+e.info.imgTn[f].substr(1);break}}}};var b=function(a,b){if(a.uId<b.uId){return-1}else if(a.uId<b.uId){return 1}return 0};this.markerInList=function(a,b){for(var c=0;c<b.length;c++){if(b[c].uId==a)return c}return-1};this.displayWindowInfo=function(a){if(gmapsCM&&gmapsCM instanceof categoryMaps)gmapsCM.closePictureInfo();gmapsMarkup.currentInfo=a.info;gmapsMarkup.infoWindow.close();gmapsMarkup.infoWindow.setContent($("#iGMapsInfoWindowContent").clone().each(c).get(0));gmapsMarkup.infoWindow.open(a.map,a);$("#ciWALeft, #ciWARight").unbind("click");$("#ciWARight").bind("click",function(a){__this.displayPictureNext()});$("#ciWALeft").bind("click",function(a){__this.displayPicturePrev()});this.displayPictureInfo(gmapsMarkup.currentInfo.displayed)};var c=function(a,b){if(b.id!="")b.id="c"+b.id;$(b).children().each(c)};this.closePictureInfo=function(){gmapsMarkup.currentInfo=null;gmapsMarkup.infoWindow.setContent("");gmapsMarkup.infoWindow.close();$("#ciWALeft, #ciWARight").unbind("click")};this.displayPictureInfo=function(a){var b=this;$("#ciWALeft,#ciWARight").unbind("click");$("#ciWARight").bind("click",function(a){b.displayPictureNext()});$("#ciWALeft").bind("click",function(a){b.displayPicturePrev()});gmapsMarkup.currentInfo.displayed=a;if(gmapsMarkup.currentInfo.imgName[a]==""){$("#ciGMIWC_title").html(" ")}else{$("#ciGMIWC_title").html(gmapsMarkup.currentInfo.imgName[a])}$("#ciGMIWC_img").attr("src",gmapsMarkup.currentInfo.imgTn[a]);$("#ciGMIWC_img").unbind();if(gmapsMarkup.currentInfo.imgCatsUrl[a].length==1){$("#ciGMIWC_img").bind("click",function(){window.location=gmapsMarkup.currentInfo.imgCatsUrl[gmapsMarkup.currentInfo.displayed][0]})}else{$("#ciGMIWC_showcatList").html("");for(var c=0;c<gmapsMarkup.currentInfo.imgCatsUrl[a].length;c++){$("#ciGMIWC_showcatList").append('<li><a href="'+gmapsMarkup.currentInfo.imgCatsUrl[a][c]+'">'+gmapsMarkup.currentInfo.imgCatsNames[a][c]+"</a></li>")}$("#ciGMIWC_img, #ciGMIWC_showcat").bind("mouseenter",function(){$("#ciGMIWC_showcat").css("display","block")}).bind("mouseleave",function(){$("#ciGMIWC_showcat").css("display","none")})}if(gmapsMarkup.currentInfo.nbImg>1){$("#ciGMIWC_picnum").html(a+1+"/"+gmapsMarkup.currentInfo.nbImgTxt);$("#ciWALeft, #ciWARight").css("display","inline-block")}else{$("#ciGMIWC_picnum").html(gmapsMarkup.currentInfo.nbImgTxt);$("#ciWALeft, #ciWARight").css("display","none")}};this.displayPicturePrev=function(){gmapsMarkup.currentInfo.displayed--;if(gmapsMarkup.currentInfo.displayed<0)gmapsMarkup.currentInfo.displayed=gmapsMarkup.currentInfo.nbImg-1;this.displayPictureInfo(gmapsMarkup.currentInfo.displayed)};this.displayPictureNext=function(){gmapsMarkup.currentInfo.displayed++;if(gmapsMarkup.currentInfo.displayed>=gmapsMarkup.currentInfo.nbImg)gmapsMarkup.currentInfo.displayed=0;this.displayPictureInfo(gmapsMarkup.currentInfo.displayed)};this.fitToBounds=function(a,b){gmapsMarkup.maps[b].gMap.fitBounds(a);if(gmapsMarkup.maps[b].zoomLevelMaxActivated&&gmapsMarkup.maps[b].gMap.getZoom()>gmapsMarkup.maps[b].zoomLevel){gmapsMarkup.maps[b].gMap.setZoom(gmapsMarkup.maps[b].zoomLevel)}};this.initializeMapViewport=function(a){var b=this;if(a>-1&&!gmapsMarkup.maps[a].gMap.initialized){$("#"+gmapsMarkup.maps[a].id+" span, #"+gmapsMarkup.maps[a].id+" a").css("font-size","55.0%");if(gmapsMarkup.maps[a].markerVisible){google.maps.event.addListener(gmapsMarkup.maps[a].gMap,"dragend",function(){b.loadMarkers(this)});google.maps.event.addListener(gmapsMarkup.maps[a].gMap,"zoom_changed",function(){b.loadMarkers(this);gmapsMarkup.infoWindow.close()})}if(gmapsMarkup.maps[a].kmlZoom&&gmapsMarkup.maps[a].gMap.kmlFile!=null){google.maps.event.addListenerOnce(gmapsMarkup.maps[a].gMap.kmlFile,"defaultviewport_changed",function(){b.fitToBounds(gmapsMarkup.maps[a].gMap.kmlFile.getDefaultViewport(),a)})}gmapsMarkup.maps[a].gMap.initialized=true}}}var gmapsCM=null,gmapsMM=null;$(window).load(function(){gmapsMM=new markupMaps;gmapsMarkup.currentInfo=null;gmapsMarkup.infoWindow=new google.maps.InfoWindow;google.maps.event.addListener(gmapsMarkup.infoWindow,"closeclick",function(){gmapsMarkup.infoWindow.setContent("");$("#ciGMIWC_img").unbind()});$.ajax({type:"POST",url:"plugins/GMaps/gmaps_ajax.php",async:true,data:{ajaxfct:"public.maps.init",category:gmapsMarkup.categoryId,mapId:"y"},success:function(a){gmapsMarkup.requestId=a;for(var b=0;b<gmapsMarkup.maps.length;b++){$("#"+gmapsMarkup.maps[b].id).css({width:gmapsMarkup.maps[b].width+"px",height:gmapsMarkup.maps[b].height+"px"});gmapsMM.createMap(gmapsMarkup.maps[b],b)}}})})
Note: See TracChangeset for help on using the changeset viewer.