source: extensions/GMaps/js/gmapsMarkup.min.js @ 12204

Last change on this file since 12204 was 12204, checked in by grum, 13 years ago

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

File size: 7.5 KB
Line 
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 TracBrowser for help on using the repository browser.