Skip to content

Commit

Permalink
Merged from github master
Browse files Browse the repository at this point in the history
  • Loading branch information
migurski committed Apr 16, 2011
2 parents 816f4bd + 4e7c6b6 commit 552704e
Show file tree
Hide file tree
Showing 22 changed files with 2,118 additions and 327 deletions.
26 changes: 26 additions & 0 deletions CHANGELOG
Expand Up @@ -8,6 +8,32 @@ Following the semantic versioning recommendation best we can:
minor version, and backwards incompatible API changes increment
the major version." -- http://semver.org/

v0.14.3
- improve redraw behavior by ensuring layer is visible in getTileComplete
- use a closure in v0.14.2's setTimeout to ensure proper 'this'

v0.14.2
- add setTimeout to processQueue to avoid stack overflow/recursion
bug in IE 7/8 (https://github.com/stamen/modestmaps-js/issues/12)
thanks @yhahn!

v0.14.1
- reinstated display of children for missing tiles, except when if
map.enablePyramidLoading is set to true

v0.14.0
- added map.enablePyramidLoading flag for pyramid loading (off by default)
- fixed Coordinate.prototype.toKey (back to string join to avoid collisions)

v0.13.5
- changed the order of initialization so that event handlers go last
(this is so that attributes like layerParent are in place for complex
event handlers like anyzoom.js... handlers can also use callbacks now)

2011-01-03 note:
- broke modestmap.js file into src folder, now building with Makefile
- no functionality change to modestmaps.js (just whitespace changes)

v0.13.4
- changed to img.style.width instead of img.width, for ipads (see examples/touch/test.html)

Expand Down
23 changes: 23 additions & 0 deletions Makefile
@@ -1,5 +1,28 @@
JS_FILES = \
src/start.js \
src/utils.js \
src/point.js \
src/coordinate.js \
src/location.js \
src/transformation.js \
src/projection.js \
src/provider.js \
src/interaction.js \
src/callbacks.js \
src/requests.js \
src/map.js \
src/end.js

modestmaps.min.js: modestmaps.js
rm -f modestmaps.min.js
java -jar tools/yuicompressor-2.4.2.jar modestmaps.js > modestmaps.min.js
chmod a-w modestmaps.min.js

modestmaps.js: $(JS_FILES) Makefile
rm -f modestmaps.js
cat $(JS_FILES) >> modestmaps.js
chmod a-w modestmaps.js

clean:
rm modestmaps.js
rm modestmaps.min.js
156 changes: 156 additions & 0 deletions examples/anyscale/anyzoom.js
@@ -0,0 +1,156 @@
// TODO: namespace/anonymous function

var AnyZoomHandler = function(map) {
if (map !== undefined) {
this.init(map);
}
this.last = 0;
};

// https://bugs.webkit.org/show_bug.cgi?id=40441
var bug40441 = /WebKit\/533/.test(navigator.userAgent) ? -1 : 0;

AnyZoomHandler.prototype = {

init: function(map) {
this.map = map;
com.modestmaps.addEvent(map.layerParent, 'dblclick', this.getDoubleClick());
com.modestmaps.addEvent(map.layerParent, 'mousedown', this.getMouseDown());
com.modestmaps.addEvent(map.parent, 'mousewheel', this.getMouseWheel());
},

mouseDownHandler: null,

getMouseDown: function() {
if (!this.mouseDownHandler) {
var theHandler = this;
this.mouseDownHandler = function(e) {

com.modestmaps.addEvent(document, 'mouseup', theHandler.getMouseUp());
com.modestmaps.addEvent(document, 'mousemove', theHandler.getMouseMove());

theHandler.prevMouse = new com.modestmaps.Point(e.clientX, e.clientY);

theHandler.map.parent.style.cursor = 'move';

return com.modestmaps.cancelEvent(e);
};
}
return this.mouseDownHandler;
},

mouseMoveHandler: null,

getMouseMove: function() {
if (!this.mouseMoveHandler) {
var theHandler = this;
this.mouseMoveHandler = function(e) {

if (theHandler.prevMouse) {
theHandler.map.panBy(e.clientX - theHandler.prevMouse.x, e.clientY - theHandler.prevMouse.y);
theHandler.prevMouse.x = e.clientX;
theHandler.prevMouse.y = e.clientY;
}

return com.modestmaps.cancelEvent(e);
};
}
return this.mouseMoveHandler;
},

mouseUpHandler: null,

getMouseUp: function() {
if (!this.mouseUpHandler) {
var theHandler = this;
this.mouseUpHandler = function(e) {

com.modestmaps.removeEvent(document, 'mouseup', theHandler.getMouseUp());
com.modestmaps.removeEvent(document, 'mousemove', theHandler.getMouseMove());

theHandler.prevMouse = null;

theHandler.map.parent.style.cursor = '';

return com.modestmaps.cancelEvent(e);
};
}
return this.mouseUpHandler;
},

mouseWheelHandler: null,

getMouseWheel: function() {
if (!this.mouseWheelHandler) {
var theHandler = this;
this.mouseWheelHandler = function(e) {

var delta = 0;

if (e.wheelDelta) {
delta = e.wheelDelta / 120;
}
else if (e.detail) {
delta = -e.detail;
}

delta *= 0.1;

/* Detect fast & large wheel events on WebKit. */
if (bug40441 < 0) {
var now = new Date().getTime(), since = now - this.last;
if ((since > 9) && (Math.abs(e.wheelDelta) / since >= 50)) bug40441 = 1;
this.last = now;
}
if (bug40441 == 1) delta *= .03;

var point = theHandler.getMousePoint(e);

theHandler.map.zoomByAbout(delta, point);
//Math.min(0.5, Math.max(-0.5, delta/10.0)), point);

return com.modestmaps.cancelEvent(e);
};
}
return this.mouseWheelHandler;
},

doubleClickHandler: null,

getDoubleClick: function() {
if (!this.doubleClickHandler) {
var theHandler = this;
this.doubleClickHandler = function(e) {

var point = theHandler.getMousePoint(e);

// use shift-double-click to zoom out
theHandler.map.zoomByAbout(e.shiftKey ? -1 : 1, point);

return com.modestmaps.cancelEvent(e);
};
}
return this.doubleClickHandler;
},

// interaction helper

getMousePoint: function(e)
{
// start with just the mouse (x, y)
var point = new com.modestmaps.Point(e.clientX, e.clientY);

// correct for scrolled document
point.x += document.body.scrollLeft + document.documentElement.scrollLeft;
point.y += document.body.scrollTop + document.documentElement.scrollTop;

// correct for nested offsets in DOM
for(var node = this.map.parent; node; node = node.offsetParent) {
point.x -= node.offsetLeft;
point.y -= node.offsetTop;
}

return point;
}

};
144 changes: 2 additions & 142 deletions examples/anyscale/index.html
Expand Up @@ -3,151 +3,11 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<title>Modest Maps JS - Touch Tester</title>
<title>Modest Maps JS - Any Zoom Demo</title>
<script type="text/javascript" src="../../modestmaps.js"></script>
<script type="text/javascript" src="anyzoom.js"></script>
<script type="text/javascript">

var AnyZoomHandler = function(map) {
if (map !== undefined) {
this.init(map);
}
};

AnyZoomHandler.prototype = {

init: function(map) {
this.map = map;
com.modestmaps.addEvent(map.parent, 'dblclick', this.getDoubleClick());
com.modestmaps.addEvent(map.parent, 'mousedown', this.getMouseDown());
com.modestmaps.addEvent(map.parent, 'mousewheel', this.getMouseWheel());
},

mouseDownHandler: null,

getMouseDown: function() {
if (!this.mouseDownHandler) {
var theHandler = this;
this.mouseDownHandler = function(e) {

com.modestmaps.addEvent(document, 'mouseup', theHandler.getMouseUp());
com.modestmaps.addEvent(document, 'mousemove', theHandler.getMouseMove());

theHandler.prevMouse = new com.modestmaps.Point(e.clientX, e.clientY);

theHandler.map.parent.style.cursor = 'move';

return com.modestmaps.cancelEvent(e);
};
}
return this.mouseDownHandler;
},

mouseMoveHandler: null,

getMouseMove: function() {
if (!this.mouseMoveHandler) {
var theHandler = this;
this.mouseMoveHandler = function(e) {

if (theHandler.prevMouse) {
theHandler.map.panBy(e.clientX - theHandler.prevMouse.x, e.clientY - theHandler.prevMouse.y);
theHandler.prevMouse.x = e.clientX;
theHandler.prevMouse.y = e.clientY;
}

return com.modestmaps.cancelEvent(e);
};
}
return this.mouseMoveHandler;
},

mouseUpHandler: null,

getMouseUp: function() {
if (!this.mouseUpHandler) {
var theHandler = this;
this.mouseUpHandler = function(e) {

com.modestmaps.removeEvent(document, 'mouseup', theHandler.getMouseUp());
com.modestmaps.removeEvent(document, 'mousemove', theHandler.getMouseMove());

theHandler.prevMouse = null;

theHandler.map.parent.style.cursor = '';

return com.modestmaps.cancelEvent(e);
};
}
return this.mouseUpHandler;
},

mouseWheelHandler: null,

getMouseWheel: function() {
if (!this.mouseWheelHandler) {
var theHandler = this;
this.mouseWheelHandler = function(e) {

var delta = 0;

if (e.wheelDelta) {
delta = e.wheelDelta / 60;
}
else if (e.detail) {
delta = -e.detail / 2;
}

var point = theHandler.getMousePoint(e);

theHandler.map.zoomByAbout(Math.min(0.5, Math.max(-0.5, delta/10.0)), point);

return com.modestmaps.cancelEvent(e);
};
}
return this.mouseWheelHandler;
},

doubleClickHandler: null,

getDoubleClick: function() {
if (!this.doubleClickHandler) {
var theHandler = this;
this.doubleClickHandler = function(e) {

var point = theHandler.getMousePoint(e);

// use shift-double-click to zoom out
theHandler.map.zoomByAbout(e.shiftKey ? -1 : 1, point);

return com.modestmaps.cancelEvent(e);
};
}
return this.doubleClickHandler;
},

// interaction helper

getMousePoint: function(e)
{
// start with just the mouse (x, y)
var point = new com.modestmaps.Point(e.clientX, e.clientY);

// correct for scrolled document
point.x += document.body.scrollLeft + document.documentElement.scrollLeft;
point.y += document.body.scrollTop + document.documentElement.scrollTop;

// correct for nested offsets in DOM
for(var node = this.map.parent; node; node = node.offsetParent) {
point.x -= node.offsetLeft;
point.y -= node.offsetTop;
}

return point;
}

};


var map;

function initMap() {
Expand Down

0 comments on commit 552704e

Please sign in to comment.