diff options
Diffstat (limited to 'media')
-rw-r--r-- | media/js/natparks.min.js | 12 | ||||
-rw-r--r-- | media/js/photos.js | 100 | ||||
-rw-r--r-- | media/js/photos.min.js | 15 |
3 files changed, 127 insertions, 0 deletions
diff --git a/media/js/natparks.min.js b/media/js/natparks.min.js new file mode 100644 index 0000000..e0b4acc --- /dev/null +++ b/media/js/natparks.min.js @@ -0,0 +1,12 @@ +function mapit(lat,lon,zoom,id){var map;var centerCoord=new google.maps.LatLng(lat,lon);var mapOptions={zoom:zoom,center:centerCoord,mapTypeId:google.maps.MapTypeId.TERRAIN,disableDefaultUI:true,navigationControl:true,navigationControlOptions:{style:google.maps.NavigationControlStyle.SMALL}};map=new google.maps.Map(document.getElementById('map-wrapper-'+id),mapOptions);$.ajax({url:"/projects/data/"+id+"/",dataType:"json",success:function(data,text,request){draw_poly(data);}});function draw_poly(data){var poly=createPolygons(data.features[0].geometry);for(i=0;i<=poly.length-1;i++){poly[i].setMap(map);}}} +function create_map(obj){var lat=parseFloat(obj.title.split(',')[0]);var lon=parseFloat(obj.title.split(',')[1]);var zoom=parseInt(obj.title.split(',')[2]);var id=obj.title.split(',')[3];$(obj).parents().eq(3).append('<div class="map-container" id="map-container-'+id+'">');$('#map-container-'+id).append('<div class="map-wrapper" id="map-wrapper-'+id+'">');mapit(lat,lon,zoom,id);} +function remove_map(id){$(id).remove();} +function createPolygons(areajson,bounds){var coords=areajson.coordinates;var polygons=_(coords).reduce([],function(memo_n,n){var polygonpaths=_(n).reduce(new google.maps.MVCArray(),function(memo_o,o){var polygoncords=_(o).reduce(new google.maps.MVCArray(),function(memo_p,p){var mylatlng=new google.maps.LatLng(p[1],p[0]);if(bounds){bounds.extend(mylatlng);} +memo_p.push(mylatlng);return memo_p;});memo_o.push(polygoncords);return memo_o;});var polygon=new google.maps.Polygon({paths:polygonpaths,strokeColor:"#201a11",strokeOpacity:0.8,strokeWeight:2,fillColor:"#201a11",fillOpacity:0.35});memo_n.push(polygon);return memo_n;});return polygons;} +function get_exif(obj,id){$(obj).parents().eq(3).append('<div class="more-container" id="'+id+'">');$(obj).parents().eq(2).children('.meta').clone().appendTo('#'+id).css('visibility','visible');$('#exif-container').css({bottom:function(index,value){return parseFloat($(obj).parent().parent().css("height"))-14;}});} +function remove_exif(id){$('#'+id).remove();} +$(document).ready(function(){$('.map-link').click(function(){var more_id='more-container-'+$(this).parent().next().children('.more-link').attr('id').split('-')[1];var id='#map-container-'+this.title.split(',')[3];if($('#'+more_id).is(":visible")){remove_exif(more_id);} +if($(id).is(":visible")){remove_map(id);}else{create_map(this);} +return false;});$('.more-link').click(function(){var map_id='#map-container-'+$(this).parent().prev().children('.map-link').attr('title').split(',')[3];var id='more-container-'+this.id.split('-')[1];if($(map_id).is(":visible")){remove_map(map_id);} +if($('#'+id).is(":visible")){remove_exif(id);}else{get_exif(this,id);} +return false;});});
\ No newline at end of file diff --git a/media/js/photos.js b/media/js/photos.js new file mode 100644 index 0000000..32e262f --- /dev/null +++ b/media/js/photos.js @@ -0,0 +1,100 @@ +//Utility functions for map info window +function mapit(latlontitle) { + lat = parseFloat(latlontitle.split(',')[0]); + lon = parseFloat(latlontitle.split(',')[1]); + //title= latlontitle.split(',')[2]; + elid= latlontitle.split(',')[2]; + centerCoord = new google.maps.LatLng(lat, lon); + var mapitinit; + if (mapitinit == true) { + mapPanTo(); + } else { + mapInit(); + } + + function mapInit() { + var mapOptions = { + zoom: 8, + center: centerCoord, + disableDefaultUI: true, + navigationControl: true, + mapTypeId: google.maps.MapTypeId.TERRAIN, + navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL} + }; + map = new google.maps.Map(document.getElementById("mw-"+elid), mapOptions); + var marker = new google.maps.Marker({ + position: centerCoord, + map: map + //title: title + }); + mapitinit = true; + } + function mapPanTo(){ + var marker = new google.maps.Marker({ + position: centerCoord, + map: map + //title: title + }); + map.panTo(centerCoord); + } +} + +//########## utility functions to create/remove map container ############ +function create_map(obj) { + //find id of this image caption: + imgid = obj.title.split(',')[2]; + //create container divs + $('<div class="map-container" id="mc-'+imgid+'">').insertBefore($(obj).parent().parent()); + //$(obj).parent().parent().parent().prepend('<div class="map-container" id="mc-'+imgid+'">'); + $('#mc-'+imgid).append('<div class="map-wrapper" id="mw-'+imgid+'">'); + //deal with the variable height of div.legend + $('#mc-'+imgid).css({ + bottom: function(index, value) { + return parseFloat($(obj).parent().parent().height())+20; + } + }); + + mapit(obj.title); +} +function remove_map(imgid) { + $('#mc-'+imgid).remove(); +} + +//############ Document.ready events ############## +$(document).ready(function(){ + + //set up click events for map button + $('.map-link').click( function() { + imgid = this.title.split(',')[2]; + if ($('#mc-'+imgid).is(":visible")) { + remove_map(imgid); + } else { + create_map(this); + } + return false; + + }); + var $ele = $('#slides').children() + var $curr = 0 + $(document).bind('keydown', function (e) { + var code = e.which; + switch (code) { + case 39: + if ($curr <= $ele.size()) { + $.scrollTo($ele[$curr], 800 ); + $curr++ + } + break; + case 37: + if ($curr > 0) { + $curr-- + var $now = $curr + $now-- + $.scrollTo($ele[$now], 800 ); + } + break; + } + return; + }); +}); + diff --git a/media/js/photos.min.js b/media/js/photos.min.js new file mode 100644 index 0000000..b99b0e2 --- /dev/null +++ b/media/js/photos.min.js @@ -0,0 +1,15 @@ +function mapit(latlontitle){lat=parseFloat(latlontitle.split(',')[0]);lon=parseFloat(latlontitle.split(',')[1]);elid=latlontitle.split(',')[2];centerCoord=new google.maps.LatLng(lat,lon);var mapitinit;if(mapitinit==true){mapPanTo();}else{mapInit();} +function mapInit(){var mapOptions={zoom:8,center:centerCoord,disableDefaultUI:true,navigationControl:true,mapTypeId:google.maps.MapTypeId.TERRAIN,navigationControlOptions:{style:google.maps.NavigationControlStyle.SMALL}};map=new google.maps.Map(document.getElementById("mw-"+elid),mapOptions);var marker=new google.maps.Marker({position:centerCoord,map:map});mapitinit=true;} +function mapPanTo(){var marker=new google.maps.Marker({position:centerCoord,map:map});map.panTo(centerCoord);}} +function create_map(obj){imgid=obj.title.split(',')[2];$('<div class="map-container" id="mc-'+imgid+'">').insertBefore($(obj).parent().parent());$('#mc-'+imgid).append('<div class="map-wrapper" id="mw-'+imgid+'">');$('#mc-'+imgid).css({bottom:function(index,value){return parseFloat($(obj).parent().parent().height())+20;}});mapit(obj.title);} +function remove_map(imgid){$('#mc-'+imgid).remove();} +$(document).ready(function(){$('.map-link').click(function(){imgid=this.title.split(',')[2];if($('#mc-'+imgid).is(":visible")){remove_map(imgid);}else{create_map(this);} +return false;});var $ele=$('#slides').children() +var $curr=0 +$(document).bind('keydown',function(e){var code=e.which;switch(code){case 39:if($curr<=$ele.size()){$.scrollTo($ele[$curr],800);$curr++} +break;case 37:if($curr>0){$curr-- +var $now=$curr +$now-- +$.scrollTo($ele[$now],800);} +break;} +return;});});
\ No newline at end of file |