[Mapbender-commits] r2515 - in branches/beck_dev/mapbender/http: extensions javascripts php

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Jun 19 10:05:06 EDT 2008


Author: greq
Date: 2008-06-19 10:05:06 -0400 (Thu, 19 Jun 2008)
New Revision: 2515

Added:
   branches/beck_dev/mapbender/http/extensions/jquery.mousewheel.min.js
Modified:
   branches/beck_dev/mapbender/http/javascripts/map.php
   branches/beck_dev/mapbender/http/php/mod_map1.php
   branches/beck_dev/mapbender/http/php/system.php
Log:
http://trac.osgeo.org/mapbender/ticket/243

Added: branches/beck_dev/mapbender/http/extensions/jquery.mousewheel.min.js
===================================================================
--- branches/beck_dev/mapbender/http/extensions/jquery.mousewheel.min.js	                        (rev 0)
+++ branches/beck_dev/mapbender/http/extensions/jquery.mousewheel.min.js	2008-06-19 14:05:06 UTC (rev 2515)
@@ -0,0 +1,16 @@
+/* Copyright (c) 2006 Brandon Aaron (brandon.aaron at gmail.com || http://brandonaaron.net)
+ * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
+ * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
+ * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
+ * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
+ *
+ * $LastChangedDate: 2007-12-14 23:57:10 -0600 (Fri, 14 Dec 2007) $
+ * $Rev: 4163 $
+ *
+ * Version: 3.0
+ * 
+ * Requires: $ 1.2.2+
+ */
+(function($){$.event.special.mousewheel={setup:function(){var handler=$.event.special.mousewheel.handler;if($.browser.mozilla)$(this).bind('mousemove.mousewheel',function(event){$.data(this,'mwcursorposdata',{pageX:event.pageX,pageY:event.pageY,clientX:event.clientX,clientY:event.clientY});});if(this.addEventListener)this.addEventListener(($.browser.mozilla?'DOMMouseScroll':'mousewheel'),handler,false);else
+this.onmousewheel=handler;},teardown:function(){var handler=$.event.special.mousewheel.handler;$(this).unbind('mousemove.mousewheel');if(this.removeEventListener)this.removeEventListener(($.browser.mozilla?'DOMMouseScroll':'mousewheel'),handler,false);else
+this.onmousewheel=function(){};$.removeData(this,'mwcursorposdata');},handler:function(event){var args=Array.prototype.slice.call(arguments,1);event=$.event.fix(event||window.event);$.extend(event,$.data(this,'mwcursorposdata')||{});var delta=0,returnValue=true;if(event.wheelDelta)delta=event.wheelDelta/120;if(event.detail)delta=-event.detail/3;if($.browser.opera)delta=-event.wheelDelta;event.data=event.data||{};event.type="mousewheel";args.unshift(delta);args.unshift(event);return $.event.handle.apply(this,args);}};$.fn.extend({mousewheel:function(fn){return fn?this.bind("mousewheel",fn):this.trigger("mousewheel");},unmousewheel:function(fn){return this.unbind("mousewheel",fn);}});})(jQuery);
\ No newline at end of file

Modified: branches/beck_dev/mapbender/http/javascripts/map.php
===================================================================
--- branches/beck_dev/mapbender/http/javascripts/map.php	2008-06-19 11:47:30 UTC (rev 2514)
+++ branches/beck_dev/mapbender/http/javascripts/map.php	2008-06-19 14:05:06 UTC (rev 2515)
@@ -63,6 +63,7 @@
 echo "mapbender.versionNumber = '" . MB_VERSION_NUMBER . "';";
 echo "mapbender.versionAppendix = '" . MB_VERSION_APPENDIX . "';";
 echo "mapbender.releaseDate = new Date(".date("Y",MB_RELEASE_DATE).",".date("n",MB_RELEASE_DATE).",".date("j",MB_RELEASE_DATE).");";
+echo "mapbender.zoomMousewheel = " . ZOOM_MOUSEWHEEL . ";";
 echo "var owsproxy = '".OWSPROXY."';";
 echo "var global_mb_log_js = '".LOG_JS."';";
 echo "var global_mb_log_level = '".LOG_LEVEL."';";
@@ -74,9 +75,9 @@
 //
 // Load external JavaScript libraries
 //
-require_once(dirname(__FILE__) . "/../extensions/jquery.js");
+require_once(dirname(__FILE__) . "/../extensions/jquery-1.2.6.min.js");
 require_once(dirname(__FILE__) . "/../extensions/jqjson.js");
-
+require_once(dirname(__FILE__) . "/../extensions/jquery.mousewheel.min.js");
 //
 // Load internal JavaScript libraries
 //

Modified: branches/beck_dev/mapbender/http/php/mod_map1.php
===================================================================
--- branches/beck_dev/mapbender/http/php/mod_map1.php	2008-06-19 11:47:30 UTC (rev 2514)
+++ branches/beck_dev/mapbender/http/php/mod_map1.php	2008-06-19 14:05:06 UTC (rev 2515)
@@ -48,15 +48,72 @@
 echo "var mod_map1_height = '".$e_height."';\n";
 echo "</script>\n";
 ?>
+<!--
+<script type='text/javascript' src='../extensions/jquery-1.2.6.min.js'></script>
+<script type='text/javascript' src='../extensions/jquery.mousewheel.min.js'></script>
+<script type='text/javascript' src='../extensions/jqjson.js'></script>
+-->
 <script type="text/javascript">
 <!--
 
+var mapTimeout;
+var	sum_delta = 0;
+var lastTimestamp;
+var lastScrollPositionX;
+var lastScrollPositionY;
+
 function init () {
+	
 	parent.eventInitMap.register(function init_mod_map1(){
 		parent.mb_registerMapObj('mapframe1', 'maps', null,mod_map1_width, mod_map1_height);
+		
+		parent.$(document, window.frames['mapframe1']).mousewheel(function (event, delta) {
+			if (sum_delta == 0) {
+				mapTimeout = setTimeout(function () {
+						lastScrollPositionX=event.pageX;
+						lastScrollPositionY=event.pageY;
+						mousewheelZoom();	
+					}, 
+					100);
+			}
+			sum_delta = sum_delta + (delta);
+			var currentTime = new Date();
+			lastTimestamp = currentTime.getTime();			
+		});
 	});
 }
 
+function mousewheelZoom () {
+	var currentTime = new Date();
+
+	if (currentTime.getTime() - lastTimestamp > 200) {
+				
+		var ind = parent.getMapObjIndexByName('mapframe1');			
+		var pos = parent.makeClickPos2RealWorldPos("mapframe1", lastScrollPositionX, lastScrollPositionY);
+				
+		if (sum_delta > 0) {
+			parent.zoom("mapframe1", true, Math.pow(parent.mapbender.zoomMousewheel, sum_delta), pos[0],pos[1]);
+		}
+		else {
+			parent.zoom("mapframe1", false, Math.pow(parent.mapbender.zoomMousewheel, -sum_delta), pos[0], pos[1]);
+		}
+		
+		var newPosX =  parent.parent.mb_mapObj[ind].width - lastScrollPositionX;
+		var newPosY =  parent.parent.mb_mapObj[ind].height - lastScrollPositionY;
+				
+		var posAfterZoom = parent.makeClickPos2RealWorldPos("mapframe1", newPosX, newPosY);
+		parent.zoom('mapframe1', false, 1.0, posAfterZoom[0], posAfterZoom[1]); 
+		
+		sum_delta = 0;
+		clearTimeout(mapTimeout);
+	}
+	else {
+		mapTimeout = setTimeout(function () {
+				mousewheelZoom(sum_delta);	
+			}, 
+			100);
+	}
+}
 // -->
 </script>
 </head>

Modified: branches/beck_dev/mapbender/http/php/system.php
===================================================================
--- branches/beck_dev/mapbender/http/php/system.php	2008-06-19 11:47:30 UTC (rev 2514)
+++ branches/beck_dev/mapbender/http/php/system.php	2008-06-19 14:05:06 UTC (rev 2515)
@@ -32,4 +32,6 @@
 #
 # available log levels 
 #
-define("LOG_LEVEL_LIST", "off,error,warning,notice,all");
\ No newline at end of file
+define("LOG_LEVEL_LIST", "off,error,warning,notice,all");
+
+define("ZOOM_MOUSEWHEEL", "1.1");
\ No newline at end of file



More information about the Mapbender_commits mailing list