aboutsummaryrefslogtreecommitdiffstats
path: root/web/js
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2011-11-18 14:32:25 +0000
committerStruan Donald <struan@exo.org.uk>2011-11-18 14:32:25 +0000
commit9a83d679abbdb467ec1c363d086b35f09a4c7044 (patch)
tree30c8fece41b518080fd420d33c2aaf742ddd6ea0 /web/js
parentd941a8c26e943c941f8e37ecbd9a9982dd41cb70 (diff)
parent375610803cfcad104049ff895c77c53e6767e1e7 (diff)
Merge remote branch 'origin/master' into js-validation
Diffstat (limited to 'web/js')
-rw-r--r--web/js/OpenLayers.fixmystreet.js10
-rw-r--r--web/js/fixmystreet.js21
-rw-r--r--web/js/map-OpenLayers.js9
-rw-r--r--web/js/map-bing-ol.js10
4 files changed, 44 insertions, 6 deletions
diff --git a/web/js/OpenLayers.fixmystreet.js b/web/js/OpenLayers.fixmystreet.js
index 9616df8b6..eab691def 100644
--- a/web/js/OpenLayers.fixmystreet.js
+++ b/web/js/OpenLayers.fixmystreet.js
@@ -1100,7 +1100,15 @@ return true;}
return false;},deactivate:function(){var deactivated=OpenLayers.Strategy.prototype.deactivate.call(this);if(deactivated){this.layer.events.un({"refresh":this.load,"visibilitychanged":this.load,scope:this});}
return deactivated;},load:function(options){var layer=this.layer;layer.events.triggerEvent("loadstart");layer.protocol.read(OpenLayers.Util.applyDefaults({callback:OpenLayers.Function.bind(this.merge,this,layer.map.getProjectionObject()),filter:layer.filter},options));layer.events.un({"visibilitychanged":this.load,scope:this});},merge:function(mapProjection,resp){var layer=this.layer;layer.destroyFeatures();var features=resp.features;if(features&&features.length>0){if(!mapProjection.equals(layer.projection)){var geom;for(var i=0,len=features.length;i<len;++i){geom=features[i].geometry;if(geom){geom.transform(layer.projection,mapProjection);}}}
layer.addFeatures(features);}
-layer.events.triggerEvent("loadend");},CLASS_NAME:"OpenLayers.Strategy.Fixed"});OpenLayers.Date={toISOString:(function(){if("toISOString"in Date.prototype){return function(date){return date.toISOString();};}else{function pad(num,len){var str=num+"";while(str.length<len){str="0"+str;}
+layer.events.triggerEvent("loadend");},CLASS_NAME:"OpenLayers.Strategy.Fixed"});OpenLayers.Handler.Pinch=OpenLayers.Class(OpenLayers.Handler,{started:false,stopDown:false,pinching:false,last:null,start:null,initialize:function(control,callbacks,options){OpenLayers.Handler.prototype.initialize.apply(this,arguments);},touchstart:function(evt){var propagate=true;this.pinching=false;if(OpenLayers.Event.isMultiTouch(evt)){this.started=true;this.last=this.start={distance:this.getDistance(evt.touches),delta:0,scale:1};this.callback("start",[evt,this.start]);propagate=!this.stopDown;}else{this.started=false;this.start=null;this.last=null;}
+OpenLayers.Event.stop(evt);return propagate;},touchmove:function(evt){if(this.started&&OpenLayers.Event.isMultiTouch(evt)){this.pinching=true;var current=this.getPinchData(evt);this.callback("move",[evt,current]);this.last=current;OpenLayers.Event.stop(evt);}
+return true;},touchend:function(evt){if(this.started){this.started=false;this.pinching=false;this.callback("done",[evt,this.start,this.last]);this.start=null;this.last=null;}
+return true;},activate:function(){var activated=false;if(OpenLayers.Handler.prototype.activate.apply(this,arguments)){this.pinching=false;activated=true;}
+return activated;},deactivate:function(){var deactivated=false;if(OpenLayers.Handler.prototype.deactivate.apply(this,arguments)){this.started=false;this.pinching=false;this.start=null;this.last=null;deactivated=true;}
+return deactivated;},getDistance:function(touches){var t0=touches[0];var t1=touches[1];return Math.sqrt(Math.pow(t0.clientX-t1.clientX,2)+
+Math.pow(t0.clientY-t1.clientY,2));},getPinchData:function(evt){var distance=this.getDistance(evt.touches);var scale=distance/this.start.distance;return{distance:distance,delta:this.last.distance-distance,scale:scale};},CLASS_NAME:"OpenLayers.Handler.Pinch"});OpenLayers.Control.PinchZoom=OpenLayers.Class(OpenLayers.Control,{type:OpenLayers.Control.TYPE_TOOL,containerOrigin:null,pinchOrigin:null,currentCenter:null,autoActivate:true,initialize:function(options){OpenLayers.Control.prototype.initialize.apply(this,arguments);this.handler=new OpenLayers.Handler.Pinch(this,{start:this.pinchStart,move:this.pinchMove,done:this.pinchDone},this.handlerOptions);},activate:function(){var activated=OpenLayers.Control.prototype.activate.apply(this,arguments);if(activated){this.map.events.on({moveend:this.updateContainerOrigin,scope:this});this.updateContainerOrigin();}
+return activated;},deactivate:function(){var deactivated=OpenLayers.Control.prototype.deactivate.apply(this,arguments);if(this.map&&this.map.events){this.map.events.un({moveend:this.updateContainerOrigin,scope:this});}
+return deactivated;},updateContainerOrigin:function(){var container=this.map.layerContainerDiv;this.containerOrigin={x:parseInt(container.style.left,10),y:parseInt(container.style.top,10)};},pinchStart:function(evt,pinchData){this.pinchOrigin=evt.xy;this.currentCenter=evt.xy;},pinchMove:function(evt,pinchData){var scale=pinchData.scale;var containerOrigin=this.containerOrigin;var pinchOrigin=this.pinchOrigin;var current=evt.xy;var dx=Math.round((current.x-pinchOrigin.x)+(scale-1)*(containerOrigin.x-pinchOrigin.x));var dy=Math.round((current.y-pinchOrigin.y)+(scale-1)*(containerOrigin.y-pinchOrigin.y));this.applyTransform("translate("+dx+"px, "+dy+"px) scale("+scale+")");this.currentCenter=current;},applyTransform:function(transform){var style=this.map.layerContainerDiv.style;style['-webkit-transform']=transform;style['-moz-transform']=transform;},pinchDone:function(evt,start,last){this.applyTransform("");var zoom=this.map.getZoomForResolution(this.map.getResolution()/last.scale,true);if(zoom!==this.map.getZoom()||!this.currentCenter.equals(this.pinchOrigin)){var resolution=this.map.getResolutionForZoom(zoom);var location=this.map.getLonLatFromPixel(this.pinchOrigin);var zoomPixel=this.currentCenter;var size=this.map.getSize();location.lon+=resolution*((size.w/2)-zoomPixel.x);location.lat-=resolution*((size.h/2)-zoomPixel.y);this.map.setCenter(location,zoom);}},CLASS_NAME:"OpenLayers.Control.PinchZoom"});OpenLayers.Date={toISOString:(function(){if("toISOString"in Date.prototype){return function(date){return date.toISOString();};}else{function pad(num,len){var str=num+"";while(str.length<len){str="0"+str;}
return str;}
return function(date){var str;if(isNaN(date.getTime())){str="Invalid Date";}else{str=date.getUTCFullYear()+"-"+
pad(date.getUTCMonth()+1,2)+"-"+
diff --git a/web/js/fixmystreet.js b/web/js/fixmystreet.js
index 291e096f8..3bf30d9a6 100644
--- a/web/js/fixmystreet.js
+++ b/web/js/fixmystreet.js
@@ -3,6 +3,24 @@
* FixMyStreet JavaScript
*/
+function form_category_onchange() {
+ $.getJSON('/report/new/category_extras', {
+ latitude: fixmystreet.latitude,
+ longitude: fixmystreet.longitude,
+ category: this.options[ this.selectedIndex ].text,
+ }, function(data) {
+ if ( data.category_extra ) {
+ if ( $('#category_meta').size() ) {
+ $('#category_meta').html( data.category_extra);
+ } else {
+ $('#form_category_row').after( data.category_extra );
+ }
+ } else {
+ $('#category_meta').empty();
+ }
+ });
+}
+
$(function(){
$('html').removeClass('no-js').addClass('js');
@@ -123,6 +141,9 @@ $(function(){
timer = window.setTimeout(email_alert_close, 2000);
});
+
+ $('#form_category').change( form_category_onchange );
+
// Geolocation
if (geo_position_js.init()) {
$('#postcodeForm').append('<p id="geolocate_para">Or <a href="#" id="geolocate_link">locate me automatically</a>').css({ "padding-bottom": "0.5em" });
diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js
index 0f9974222..b911b7c71 100644
--- a/web/js/map-OpenLayers.js
+++ b/web/js/map-OpenLayers.js
@@ -144,9 +144,9 @@ function fixmystreet_onload() {
$('#all_pins_link').click(function(e) {
e.preventDefault();
fixmystreet.markers.setVisibility(true);
- var welsh = 0;
var texts = [
'en', 'Include stale reports', 'Hide stale reports',
+ 'nb', 'Inkluder utdaterte problemer', 'Skjul utdaterte rapporter',
'cy', 'Cynnwys hen adroddiadau', 'Cuddio hen adroddiadau'
];
for (var i=0; i<texts.length; i+=3) {
@@ -164,6 +164,8 @@ function fixmystreet_onload() {
}
if (lang == 'cy') {
document.getElementById('hide_pins_link').innerHTML = 'Cuddio pinnau';
+ } else if (lang == 'nb') {
+ document.getElementById('hide_pins_link').innerHTML = 'Gjem nĂ¥ler';
} else {
document.getElementById('hide_pins_link').innerHTML = 'Hide pins';
}
@@ -315,6 +317,11 @@ OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {
}, function(data) {
$('#councils_text').html(data.councils_text);
$('#form_category_row').html(data.category);
+ /* Need to reset this here as it gets removed when we replace
+ the HTML for the dropdown */
+ if ( data.has_open311 > 0 ) {
+ $('#form_category').change( form_category_onchange );
+ }
});
$('#side-form').show();
$('#side').hide();
diff --git a/web/js/map-bing-ol.js b/web/js/map-bing-ol.js
index 391f837c6..9f8dc9599 100644
--- a/web/js/map-bing-ol.js
+++ b/web/js/map-bing-ol.js
@@ -88,11 +88,13 @@ OpenLayers.Layer.Bing = OpenLayers.Class(OpenLayers.Layer.XYZ, {
"http://c.tilma.mysociety.org/sv/${z}/${x}/${y}.png"
];
} else {
+ var type = '';
+ if (z > 10) type = '&productSet=mmOS';
var url = [
- "http://ecn.t0.tiles.virtualearth.net/tiles/r${id}.png?g=701&productSet=mmOS",
- "http://ecn.t1.tiles.virtualearth.net/tiles/r${id}.png?g=701&productSet=mmOS",
- "http://ecn.t2.tiles.virtualearth.net/tiles/r${id}.png?g=701&productSet=mmOS",
- "http://ecn.t3.tiles.virtualearth.net/tiles/r${id}.png?g=701&productSet=mmOS"
+ "http://ecn.t0.tiles.virtualearth.net/tiles/r${id}.png?g=701" + type,
+ "http://ecn.t1.tiles.virtualearth.net/tiles/r${id}.png?g=701" + type,
+ "http://ecn.t2.tiles.virtualearth.net/tiles/r${id}.png?g=701" + type,
+ "http://ecn.t3.tiles.virtualearth.net/tiles/r${id}.png?g=701" + type,
];
}
var s = '' + x + y + z;