From 66b9b607929c6c406fc814a16f5dcfecb219500c Mon Sep 17 00:00:00 2001 From: tommy tomson Date: Sun, 6 May 2012 23:26:44 +0200 Subject: diabook-theme: twitterbox-bugfix --- .../diabook/js/jquery.mapquery.mqMousePosition.js | 107 +++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 view/theme/diabook/js/jquery.mapquery.mqMousePosition.js (limited to 'view/theme/diabook/js/jquery.mapquery.mqMousePosition.js') diff --git a/view/theme/diabook/js/jquery.mapquery.mqMousePosition.js b/view/theme/diabook/js/jquery.mapquery.mqMousePosition.js new file mode 100644 index 000000000..54d0c5309 --- /dev/null +++ b/view/theme/diabook/js/jquery.mapquery.mqMousePosition.js @@ -0,0 +1,107 @@ +/* Copyright (c) 2011 by MapQuery Contributors (see AUTHORS for + * full list of contributors). Published under the MIT license. + * See https://github.com/mapquery/mapquery/blob/master/LICENSE for the + * full text of the license. */ + +/** +#jquery.mapquery.mqMousePosition.js +The file containing the mqMousePosition Widget + +### *$('selector')*.`mqMousePosition([options])` +_version added 0.1_ +####**Description**: create a widget to show the location under the mouse pointer + + + **options** + - **map**: the mapquery instance + - **precision**: the number of decimals (default 2) + - **x**: the label for the x-coordinate (default x) + - **y**: the label for the y-coordinate (default y) + + +>Returns: widget + + +The mqMousePosition allows us to show the coordinates under the mouse pointer + + + $('#mousepointer').mqMousePointer({ + map: '#map' + }); + + */ +(function($) { +$.template('mqMousePosition', + '
'+ + ''+ + '
'+ + '
'+ + '
'); + +$.widget("mapQuery.mqMousePosition", { + options: { + // The MapQuery instance + map: undefined, + + // The number of decimals for the coordinates + // default: 2 + // TODO: JCB20110630 use dynamic precision based on the pixel + // resolution, no need to configure precision + precision: 2, + + // The label of the x-value + // default: 'x' + x: 'x', + // The label of the y-value + // default: 'y' + y: 'y' + + }, + _create: function() { + var map; + var self = this; + var element = this.element; + var mousepos; + + //get the mapquery object + map = $(this.options.map).data('mapQuery'); + + map.bind("mousemove", + {widget:self,map:map}, + self._onMouseMove); + + + $.tmpl('mqMousePosition',{ + mouseposition:mousepos + }).appendTo(element); + + }, + _destroy: function() { + this.element.removeClass(' ui-widget ui-helper-clearfix ' + + 'ui-corner-all') + .empty(); + }, + _mouseMoved: function(data, element, map) { + var x = data.layerX; + var y = data.layerY; + var mapProjection = map.options.projection; + var displayProjection = map.options.projection; + //if the coordinates should be displayed in something else, + //set them via the map displayProjection option + var pos = map.olMap.getLonLatFromLayerPx(new OpenLayers.Pixel(x,y)); + if(map.options.displayProjection) { + displayProjection = map.options.displayProjection; + pos=pos.transform( + new OpenLayers.Projection(mapProjection), + new OpenLayers.Projection(displayProjection)); + } + $("#mq-mouseposition-x", element).html( + this.options.x+': '+pos.lon.toFixed(this.options.precision)); + $("#mq-mouseposition-y", element).html( + this.options.y+': '+pos.lat.toFixed(this.options.precision)); + }, + + _onMouseMove: function(evt, data) { + evt.data.widget._mouseMoved(data,evt.data.control,evt.data.map); + } +}); +})(jQuery); -- cgit v1.2.3 From 88443ed3fb3c4d91f93d3520f260aa40eb6ec694 Mon Sep 17 00:00:00 2001 From: tommy tomson Date: Tue, 8 May 2012 03:29:25 +0200 Subject: diabook-themes: state of the boxes at right_aside are now stored in db, instead of cookie. --- view/theme/diabook/js/jquery.mapquery.mqMousePosition.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'view/theme/diabook/js/jquery.mapquery.mqMousePosition.js') diff --git a/view/theme/diabook/js/jquery.mapquery.mqMousePosition.js b/view/theme/diabook/js/jquery.mapquery.mqMousePosition.js index 54d0c5309..d4370bfe4 100644 --- a/view/theme/diabook/js/jquery.mapquery.mqMousePosition.js +++ b/view/theme/diabook/js/jquery.mapquery.mqMousePosition.js @@ -94,10 +94,10 @@ $.widget("mapQuery.mqMousePosition", { new OpenLayers.Projection(mapProjection), new OpenLayers.Projection(displayProjection)); } - $("#mq-mouseposition-x", element).html( - this.options.x+': '+pos.lon.toFixed(this.options.precision)); - $("#mq-mouseposition-y", element).html( - this.options.y+': '+pos.lat.toFixed(this.options.precision)); + $("#id_diabook_ELPosX", element).val( + this.options.x+pos.lon.toFixed(this.options.precision)); + $("#id_diabook_ELPosY", element).val( + this.options.y+pos.lat.toFixed(this.options.precision)); }, _onMouseMove: function(evt, data) { -- cgit v1.2.3 From 48c48d644f4b6dca237e61594d5d95a0c1c3f6e8 Mon Sep 17 00:00:00 2001 From: tommy tomson Date: Fri, 11 May 2012 16:41:16 +0200 Subject: diabook-theme: update mapquery and small fix --- .../diabook/js/jquery.mapquery.mqMousePosition.js | 59 ++++++++-------------- 1 file changed, 22 insertions(+), 37 deletions(-) (limited to 'view/theme/diabook/js/jquery.mapquery.mqMousePosition.js') diff --git a/view/theme/diabook/js/jquery.mapquery.mqMousePosition.js b/view/theme/diabook/js/jquery.mapquery.mqMousePosition.js index d4370bfe4..9f7e151ff 100644 --- a/view/theme/diabook/js/jquery.mapquery.mqMousePosition.js +++ b/view/theme/diabook/js/jquery.mapquery.mqMousePosition.js @@ -44,8 +44,8 @@ $.widget("mapQuery.mqMousePosition", { // The number of decimals for the coordinates // default: 2 - // TODO: JCB20110630 use dynamic precision based on the pixel - // resolution, no need to configure precision + // TODO: JCB20110630 use dynamic precision based on the pixel + // resolution, no need to configure precision precision: 2, // The label of the x-value @@ -57,51 +57,36 @@ $.widget("mapQuery.mqMousePosition", { }, _create: function() { - var map; - var self = this; - var element = this.element; - var mousepos; - //get the mapquery object - map = $(this.options.map).data('mapQuery'); - - map.bind("mousemove", - {widget:self,map:map}, - self._onMouseMove); - + this.map = $(this.options.map).data('mapQuery'); - $.tmpl('mqMousePosition',{ - mouseposition:mousepos - }).appendTo(element); + this.map.element.bind('mousemove', {widget: this}, this._onMousemove); + $.tmpl('mqMousePosition', {}).appendTo(this.element); }, _destroy: function() { - this.element.removeClass(' ui-widget ui-helper-clearfix ' + + this.element.removeClass('ui-widget ui-helper-clearfix ' + 'ui-corner-all') .empty(); }, - _mouseMoved: function(data, element, map) { - var x = data.layerX; - var y = data.layerY; - var mapProjection = map.options.projection; - var displayProjection = map.options.projection; + _onMousemove: function(evt) { + var self = evt.data.widget; + var x = evt.pageX; + var y = evt.pageY; + var mapProjection = new OpenLayers.Projection(self.map.projection); + var displayProjection = new OpenLayers.Projection( + self.map.displayProjection); + var pos = self.map.olMap.getLonLatFromLayerPx( + new OpenLayers.Pixel(x, y)); //if the coordinates should be displayed in something else, - //set them via the map displayProjection option - var pos = map.olMap.getLonLatFromLayerPx(new OpenLayers.Pixel(x,y)); - if(map.options.displayProjection) { - displayProjection = map.options.displayProjection; - pos=pos.transform( - new OpenLayers.Projection(mapProjection), - new OpenLayers.Projection(displayProjection)); + //set them via the map displayProjection option + if(!mapProjection.equals(self.map.displayProjection)) { + pos = pos.transform(mapProjection, displayProjection); } - $("#id_diabook_ELPosX", element).val( - this.options.x+pos.lon.toFixed(this.options.precision)); - $("#id_diabook_ELPosY", element).val( - this.options.y+pos.lat.toFixed(this.options.precision)); - }, - - _onMouseMove: function(evt, data) { - evt.data.widget._mouseMoved(data,evt.data.control,evt.data.map); + $("#id_diabook_ELPosX", document.element).val( + self.options.x + pos.lon.toFixed(self.options.precision)); + $("#id_diabook_ELPosY", document.element).val( + self.options.y + pos.lat.toFixed(self.options.precision)); } }); })(jQuery); -- cgit v1.2.3