Changeset 838
- Timestamp:
- 06/29/06 21:29:40 (2 years ago)
- Files:
-
- branches/openlayers/mochikit/examples/click.html (modified) (1 diff)
- branches/openlayers/mochikit/examples/controls.html (modified) (1 diff)
- branches/openlayers/mochikit/examples/example.html (modified) (3 diffs)
- branches/openlayers/mochikit/examples/georss.html (modified) (1 diff)
- branches/openlayers/mochikit/examples/markers.html (modified) (1 diff)
- branches/openlayers/mochikit/examples/markersTextLayer.html (modified) (2 diffs)
- branches/openlayers/mochikit/examples/markerss.html (modified) (1 diff)
- branches/openlayers/mochikit/examples/mvs.html (modified) (4 diffs)
- branches/openlayers/mochikit/examples/tiger.html (modified) (1 diff)
- branches/openlayers/mochikit/lib/OpenLayers.js (modified) (4 diffs)
- branches/openlayers/mochikit/lib/OpenLayers/Control.js (modified) (3 diffs)
- branches/openlayers/mochikit/lib/OpenLayers/Control/KeyboardDefaults.js (modified) (3 diffs)
- branches/openlayers/mochikit/lib/OpenLayers/Control/LayerSwitcher.js (modified) (11 diffs)
- branches/openlayers/mochikit/lib/OpenLayers/Control/MouseDefaults.js (modified) (9 diffs)
- branches/openlayers/mochikit/lib/OpenLayers/Control/MouseToolbar.js (modified) (12 diffs)
- branches/openlayers/mochikit/lib/OpenLayers/Control/PanZoom.js (modified) (7 diffs)
- branches/openlayers/mochikit/lib/OpenLayers/Control/PanZoomBar.js (modified) (10 diffs)
- branches/openlayers/mochikit/lib/OpenLayers/Feature.js (modified) (2 diffs)
- branches/openlayers/mochikit/lib/OpenLayers/Feature/WFS.js (modified) (2 diffs)
- branches/openlayers/mochikit/lib/OpenLayers/Icon.js (modified) (1 diff)
- branches/openlayers/mochikit/lib/OpenLayers/Layer.js (modified) (2 diffs)
- branches/openlayers/mochikit/lib/OpenLayers/Layer/GeoRSS.js (modified) (5 diffs)
- branches/openlayers/mochikit/lib/OpenLayers/Layer/Google.js (modified) (1 diff)
- branches/openlayers/mochikit/lib/OpenLayers/Layer/Grid.js (modified) (2 diffs)
- branches/openlayers/mochikit/lib/OpenLayers/Layer/KaMap.js (modified) (2 diffs)
- branches/openlayers/mochikit/lib/OpenLayers/Layer/Markers.js (modified) (1 diff)
- branches/openlayers/mochikit/lib/OpenLayers/Layer/Text.js (modified) (4 diffs)
- branches/openlayers/mochikit/lib/OpenLayers/Layer/VirtualEarth.js (modified) (1 diff)
- branches/openlayers/mochikit/lib/OpenLayers/Layer/WFS.js (modified) (4 diffs)
- branches/openlayers/mochikit/lib/OpenLayers/Layer/WMS.js (modified) (3 diffs)
- branches/openlayers/mochikit/lib/OpenLayers/Layer/WMS/Untiled.js (modified) (3 diffs)
- branches/openlayers/mochikit/lib/OpenLayers/Layer/WorldWind.js (modified) (2 diffs)
- branches/openlayers/mochikit/lib/OpenLayers/Layer/Yahoo.js (modified) (1 diff)
- branches/openlayers/mochikit/lib/OpenLayers/Map.js (modified) (18 diffs)
- branches/openlayers/mochikit/lib/OpenLayers/Marker.js (modified) (4 diffs)
- branches/openlayers/mochikit/lib/OpenLayers/Popup.js (modified) (3 diffs)
- branches/openlayers/mochikit/lib/OpenLayers/Popup/Anchored.js (modified) (1 diff)
- branches/openlayers/mochikit/lib/OpenLayers/Popup/AnchoredBubble.js (modified) (1 diff)
- branches/openlayers/mochikit/lib/OpenLayers/Tile.js (modified) (1 diff)
- branches/openlayers/mochikit/lib/OpenLayers/Tile/Image.js (modified) (1 diff)
- branches/openlayers/mochikit/lib/OpenLayers/Tile/WFS.js (modified) (4 diffs)
- branches/openlayers/mochikit/lib/OpenLayers/Util.js (modified) (9 diffs)
- branches/openlayers/mochikit/tests/run-tests.html (modified) (2 diffs)
- branches/openlayers/mochikit/tests/test_Bounds.html (modified) (1 diff)
- branches/openlayers/mochikit/tests/test_Control.html (modified) (1 diff)
- branches/openlayers/mochikit/tests/test_Control_PanZoom.html (modified) (3 diffs)
- branches/openlayers/mochikit/tests/test_Control_PanZoomBar.html (modified) (1 diff)
- branches/openlayers/mochikit/tests/test_Events.html (modified) (1 diff)
- branches/openlayers/mochikit/tests/test_Feature.html (modified) (1 diff)
- branches/openlayers/mochikit/tests/test_Icon.html (modified) (1 diff)
- branches/openlayers/mochikit/tests/test_Layer.html (modified) (1 diff)
- branches/openlayers/mochikit/tests/test_Layer_Markers.html (modified) (1 diff)
- branches/openlayers/mochikit/tests/test_Layer_Text.html (modified) (1 diff)
- branches/openlayers/mochikit/tests/test_Layer_WMS.html (modified) (1 diff)
- branches/openlayers/mochikit/tests/test_LonLat.html (modified) (1 diff)
- branches/openlayers/mochikit/tests/test_Map.html (modified) (4 diffs)
- branches/openlayers/mochikit/tests/test_Marker.html (modified) (1 diff)
- branches/openlayers/mochikit/tests/test_Pixel.html (modified) (1 diff)
- branches/openlayers/mochikit/tests/test_Popup.html (modified) (1 diff)
- branches/openlayers/mochikit/tests/test_Size.html (modified) (1 diff)
- branches/openlayers/mochikit/tests/test_Tile.html (modified) (1 diff)
- branches/openlayers/mochikit/tests/test_Tile_Image.html (modified) (1 diff)
- branches/openlayers/mochikit/tests/test_Util.html (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/openlayers/mochikit/examples/click.html
r810 r838 8 8 } 9 9 </style> 10 <script type="text/javascript" src="../lib/MochiKit/MochiKit.js"></script> 10 11 <script src="../lib/OpenLayers.js"></script> 11 12 <script type="text/javascript"> 12 13 <!-- 13 14 function init(){ 15 MochiKit.LoggingPane.createLoggingPane(true); 14 16 var map = new OpenLayers.Map('map'); 15 17 branches/openlayers/mochikit/examples/controls.html
r810 r838 8 8 } 9 9 </style> 10 <script type="text/javascript" src="../lib/MochiKit/MochiKit.js"></script> 10 11 <script src="../lib/OpenLayers.js"></script> 11 12 <script type="text/javascript"> branches/openlayers/mochikit/examples/example.html
r810 r838 8 8 } 9 9 </style> 10 <script type="text/javascript" src="../lib/MochiKit/MochiKit.js"></script> 10 11 <script src="../lib/OpenLayers.js"></script> 11 12 <script type="text/javascript"> 12 13 <!-- 13 function init(){ 14 MochiKit.Signal.connect(window, 'onload', 15 function(){ 16 //MochiKit.LoggingPane.createLoggingPane(true); 14 17 var map = new OpenLayers.Map('map'); 15 18 … … 27 30 transparent: "true", format: "image/png" }); 28 31 32 ol_wms.setVisibility(true); 29 33 jpl_wms.setVisibility(false); 30 34 dm_wms.setVisibility(false); … … 35 39 map.zoomToMaxExtent(); 36 40 } 41 ); 37 42 // --> 38 43 </script> 39 44 </head> 40 <body onload="init()">45 <body> 41 46 <h1>OpenLayers Example</h1> 42 47 <div id="map"></div> branches/openlayers/mochikit/examples/georss.html
r803 r838 9 9 } 10 10 </style> 11 <script type="text/javascript" src="../lib/MochiKit/MochiKit.js"></script> 11 12 <script src="../lib/OpenLayers.js"></script> 12 13 <script type="text/javascript"> branches/openlayers/mochikit/examples/markers.html
r810 r838 1 1 <html xmlns="http://www.w3.org/1999/xhtml"> 2 2 <head> 3 <script type="text/javascript" src="../lib/MochiKit/MochiKit.js"></script> 3 4 <meta http-equiv="imagetoolbar" content="no"> <!--ie image gizmo OFF!--> 4 5 <style type="text/css"> branches/openlayers/mochikit/examples/markersTextLayer.html
r810 r838 1 1 <html xmlns="http://www.w3.org/1999/xhtml"> 2 2 <head> 3 <script type="text/javascript" src="../lib/MochiKit/MochiKit.js"></script> 3 4 <meta http-equiv="imagetoolbar" content="no"> <!--ie image gizmo OFF!--> 4 5 <style type="text/css"> … … 15 16 16 17 function init(){ 18 MochiKit.LoggingPane.createLoggingPane(true); 17 19 map = new OpenLayers.Map('map'); 18 20 layer = new OpenLayers.Layer.WMS( "OpenLayers WMS", branches/openlayers/mochikit/examples/markerss.html
r810 r838 1 1 <html xmlns="http://www.w3.org/1999/xhtml"> 2 2 <head> 3 <script type="text/javascript" src="../lib/MochiKit/MochiKit.js"></script> 3 4 <meta http-equiv="imagetoolbar" content="no"> <!--ie image gizmo OFF!--> 4 5 <style type="text/css"> branches/openlayers/mochikit/examples/mvs.html
r830 r838 42 42 43 43 function runMVS() { 44 OpenLayers.ProxyHost = '/proxy/?url=';45 44 if (document.location.protocol != "file:") { 46 45 theArgs = getArgs(); … … 50 49 theArgs.zoom = "0"; 51 50 theArgs.data = "textfile.txt"; 52 theArgs.controls = ['panzoom','mouse'];53 theArgs.layers = ['openlayers'];54 51 } 55 52 … … 62 59 var DEFAULT_LON = 0; 63 60 var DEFAULT_ZOOM_LEVEL = 0; 64 var DEFAULT_CONTROLS = ['panzoom','mouse']; 65 var DEFAULT_LAYERS = ['openlayers']; 66 61 67 62 var IDX_LAT = 0; 68 63 var IDX_LON = 1; … … 75 70 76 71 safeArgs.zoom = theArgs.zoom ? parseInt(theArgs.zoom) : DEFAULT_ZOOM_LEVEL; 77 78 safeArgs.controls = theArgs.controls ?79 theArgs.controls.split(",") : DEFAULT_CONTROLS;80 81 safeArgs.controls = theArgs.controls ?82 theArgs.controls.split(",") : DEFAULT_CONTROLS;83 72 84 safeArgs.layers = theArgs.layers ?85 theArgs.layers.split(",") : DEFAULT_LAYERS;86 87 73 safeArgs.data = theArgs.data; // TODO: Make this "safe". 88 74 89 75 // ----- 90 var theMVS = new OpenLayers.Map($('map'), {controls: [], maxResolution: 'auto'}); 91 for(var i = 0; i < safeArgs.controls.length; i++) { 92 switch(safeArgs.controls[i]) { 93 case 'panzoombar': 94 theMVS.addControl(new OpenLayers.Control.PanZoomBar()); 95 break; 96 case 'panzoom': 97 theMVS.addControl(new OpenLayers.Control.PanZoom()); 98 break; 99 case 'layerswitcher': 100 theMVS.addControl(new OpenLayers.Control.LayerSwitcher()); 101 break; 102 case 'mouse': 103 theMVS.addControl(new OpenLayers.Control.MouseDefaults()); 104 break; 105 } 106 } 107 for(var i = 0; i < safeArgs.layers.length; i++) { 108 switch(safeArgs.layers[i]) { 109 case 'openlayers': 110 theMVS.addLayer( 111 new OpenLayers.Layer.WMS( "OpenLayers WMS", 112 "http://labs.metacarta.com/wms/vmap0", 113 {layers: 'basic'} ) 114 ); 115 break; 116 case 'nasa': 117 theMVS.addLayer( 118 new OpenLayers.Layer.WMS("NASA Mosaic", 119 "http://wms.jpl.nasa.gov/wms.cgi", 120 {"EXCEPTIONS" : "application/vnd.ogc.se_inimage", 121 "format" : "image/jpeg", 122 layers:"modis,global_mosaic"} 123 )); 124 break; 125 } 126 } 127 theMVS.setCenter(new OpenLayers.LonLat(safeArgs.centerLon, safeArgs.centerLat), safeArgs.zoom); 76 var theMVS = new OpenLayers.Map('map', {maxResolution: 'auto'}); 77 theMVS.addLayer( 78 new OpenLayers.Layer.WMS("OpenLayers WMS", 79 "http://labs.metacarta.com/wms/vmap0?", 80 {layers: 'basic'} 81 )); 82 83 /* not yet..... 84 85 theMVS.addLayer( 86 new OpenLayers.Layer.WMS("NASA Mosaic", 87 "http://wms.jpl.nasa.gov/wms.cgi", 88 {"EXCEPTIONS" : "application/vnd.ogc.se_inimage", 89 "format" : "image/jpeg", 90 layers:"modis,global_mosaic"} 91 )); 92 */ 93 theMVS.setCenter( 94 new OpenLayers.LonLat(safeArgs.centerLon, safeArgs.centerLat), 95 safeArgs.zoom); 128 96 129 97 if (safeArgs.data) { branches/openlayers/mochikit/examples/tiger.html
r822 r838 8 8 } 9 9 </style> 10 <script type="text/javascript" src="../lib/MochiKit/MochiKit.js"></script> 10 11 <script src="../lib/OpenLayers.js"></script> 11 12 <script type="text/javascript"> branches/openlayers/mochikit/lib/OpenLayers.js
r788 r838 6 6 /// 7 7 8 OpenLayers = new Object(); 9 10 OpenLayers._scriptName = ( 11 typeof(_OPENLAYERS_SFL_) == "undefined" ? "lib/OpenLayers.js" 12 : "OpenLayers.js" ); 13 8 OpenLayers = {}; 9 OpenLayers._scriptName = "lib/OpenLayers.js"; 10 OpenLayers._scriptLocation = null; 14 11 OpenLayers._getScriptLocation = function () { 12 if (OpenLayers._scriptLocation != null){ 13 return OpenLayers._scriptLocation; 14 } 15 15 var scriptLocation = ""; 16 16 var SCRIPT_NAME = OpenLayers._scriptName; … … 20 20 var src = scripts[i].getAttribute('src'); 21 21 if (src) { 22 var index = src.lastIndexOf(SCRIPT_NAME); 23 // is it found, at the end of the URL? 24 if ((index > -1) && (index + SCRIPT_NAME.length == src.length)) { 25 scriptLocation = src.slice(0, -SCRIPT_NAME.length); 22 if (src.match(/MochiKit.js$/)) { 23 scriptLocation = src.substring(0, src.lastIndexOf('lib/MochiKit/MochiKit.js')); 26 24 break; 27 25 } 28 26 } 29 27 } 28 OpenLayers._scriptLocation = scriptLocation; 30 29 return scriptLocation; 31 30 } … … 48 47 */ 49 48 (function() { 50 var jsfiles= new Array(51 "Prototype.js",52 "Rico/Corner.js",53 "Rico/Color.js",49 var jsfiles= [ 50 //"Prototype.js", 51 //"Rico/Corner.js", 52 //"Rico/Color.js", 54 53 "OpenLayers/Util.js", 55 "OpenLayers/Ajax.js",56 "OpenLayers/Events.js",54 // "OpenLayers/Ajax.js", 55 //"OpenLayers/Events.js", 57 56 "OpenLayers/Map.js", 58 57 "OpenLayers/Layer.js", … … 86 85 "OpenLayers/Control/PanZoomBar.js", 87 86 "OpenLayers/Control/LayerSwitcher.js" 88 ); // etc.87 ]; // etc. 89 88 90 89 var allScriptTags = ""; 91 90 var host = OpenLayers._getScriptLocation() + "lib/"; 92 91 93 // check to see if prototype.js was already loaded 94 // if so, skip the first dynamic include 95 // 96 var start=1; 97 try { x = Prototype; } 98 catch (e) { start=0; } 99 100 for (var i = start; i < jsfiles.length; i++) { 92 //"<script>MochiKit.Logging.logDebug(Start loading');</script>"; 93 for (var i = 0; i < jsfiles.length; i++) { 101 94 var currentScriptTag = "<script src='" + host + jsfiles[i] + "'></script>"; 102 95 allScriptTags += currentScriptTag; 96 //allScriptTags += "<script>MochiKit.Logging.logDebug('"+jsfiles[i]+"');</script>"; 103 97 } 104 98 document.write(allScriptTags); branches/openlayers/mochikit/lib/OpenLayers/Control.js
r657 r838 5 5 * @class 6 6 */ 7 OpenLayers.Control = Class.create(); 7 OpenLayers.Control = function(options) { 8 this.initialize(options); 9 } 8 10 OpenLayers.Control.prototype = { 9 11 … … 22 24 */ 23 25 initialize: function (options) { 24 Object.extend(this, options);26 MochiKit.Base.update(this, options); 25 27 }, 26 28 … … 57 59 // eliminate circular references 58 60 this.map = null; 61 MochiKit.Signal.disconnect(this); 59 62 }, 60 63 branches/openlayers/mochikit/lib/OpenLayers/Control/KeyboardDefaults.js
r806 r838 7 7 * @class 8 8 */ 9 OpenLayers.Control.KeyboardDefaults = Class.create(); 10 OpenLayers.Control.KeyboardDefaults.prototype = 11 Object.extend( new OpenLayers.Control(), { 9 OpenLayers.Control.KeyboardDefaults = function() { 10 this.initialize(); 11 } 12 OpenLayers.Control.KeyboardDefaults.prototype = MochiKit.Base.merge( 13 OpenLayers.Control.prototype, { 12 14 13 15 /** @type int */ … … 25 27 */ 26 28 draw: function() { 27 Event.observe(document, 28 'keypress', 29 this.defaultKeyDown.bind(this)); 29 MochiKit.Signal.connect(document, "onkeypress", this, this.defaultKeyDown); 30 30 }, 31 31 … … 34 34 */ 35 35 defaultKeyDown: function (evt) { 36 switch(evt.keyCode) { 37 case Event.KEY_LEFT: 38 this.map.pan(-50, 0); 36 MochiKit.Logging.logDebug('defaultKeyDown: ', MochiKit.Base.items(evt.key())); 37 switch(evt.key().string) { 38 case 'KEY_ARROW_LEFT': 39 this.map.pan( -50, 0); 39 40 break; 40 case Event.KEY_RIGHT:41 case 'KEY_ARROW_RIGHT': 41 42 this.map.pan(50, 0); 42 43 break; 43 case Event.KEY_UP: 44 case 'KEY_ARROW_UP': 45 this.map.pan(0, 50); 46 break; 47 case 'KEY_ARROW_DOWN': 44 48 this.map.pan(0, -50); 45 break;46 case Event.KEY_DOWN:47 this.map.pan(0, 50);48 49 break; 49 50 } branches/openlayers/mochikit/lib/OpenLayers/Control/LayerSwitcher.js
r788 r838 6 6 * @class 7 7 */ 8 OpenLayers.Control.LayerSwitcher = Class.create(); 9 8 OpenLayers.Control.LayerSwitcher = function(options) { 9 this.initialize(options); 10 } 10 11 /** color used in the UI to show a layer is active/displayed 11 12 * … … 23 24 24 25 25 OpenLayers.Control.LayerSwitcher.prototype = 26 Object.extend( new OpenLayers.Control(), {26 OpenLayers.Control.LayerSwitcher.prototype = MochiKit.Base.merge( 27 OpenLayers.Control.prototype, { 27 28 28 29 /** @type String */ … … 52 53 // initialize our internal div 53 54 OpenLayers.Control.prototype.draw.apply(this); 54 55 var connect = MochiKit.Signal.connect; 56 55 57 this.div.style.position = "absolute"; 56 58 this.div.style.top = "10px"; … … 66 68 this.div.style.width = "10em"; 67 69 68 this.map.events.register("addlayer", this, this.redraw);69 this.map.events.register("removelayer", this, this.redraw);70 connect(this.map,"addlayer", this, this.redraw); 71 connect(this.map,"removelayer", this, this.redraw); 70 72 return this.redraw(); 71 73 }, … … 96 98 */ 97 99 singleClick: function(evt) { 98 var div = Event.element(evt);100 var div = evt.src(); 99 101 100 102 // See comment about OL #57 fix below. … … 117 119 layer.setVisibility(!visible); 118 120 } 119 Event.stop(evt);121 evt.stop(); 120 122 }, 121 123 … … 126 128 */ 127 129 ignoreEvent: function(evt) { 128 Event.stop(evt);130 evt.stop(); 129 131 return false; 130 132 }, … … 136 138 */ 137 139 addTab: function(layer) { 138 139 // Outer DIV - for Rico Corners 140 // 141 var backdropLabelOuter = document.createElement('div'); 142 backdropLabelOuter.id = "LayerSwitcher_" + layer.name + "_Tab"; 143 backdropLabelOuter.style.marginTop = "4px"; 144 backdropLabelOuter.style.marginBottom = "4px"; 145 140 var DOM = MochiKit.DOM; 141 var color = (layer.getVisibility()) ? this.activeColor : this.nonActiveColor; 142 var backdropLabelOuter = DOM.DIV({ 143 id: "LayerSwitcher_" + layer.name + "_Tab", style: { 144 backgroundColor: color, 145 marginTop: "4px", marginBottom: "4px"}}); 146 146 this._setEventHandlers(backdropLabelOuter); 147 148 // Inner Label - for Rico Corners 149 // 150 var backdropLabel = document.createElement('p'); 151 backdropLabel.innerHTML = layer.name; 152 backdropLabel.style.marginTop = "0px"; 153 backdropLabel.style.marginBottom = "0px"; 154 backdropLabel.style.paddingLeft = "10px"; 155 backdropLabel.style.paddingRight = "10px"; 147 148 var backdropLabel = DOM.P({style: { 149 marginTop: "0px", marginBottom: "0px", 150 paddingTop: "4px", paddingBottom: "4px", 151 paddingLeft: "10px", paddingRight: "10px" 152 }}, 153 layer.name); 156 154 157 155 // add reference to layer onto the div for use in event handlers … … 168 166 // add div to main LayerSwitcher Div 169 167 this.div.appendChild(backdropLabelOuter); 170 171 Rico.Corner.round(backdropLabelOuter, {corners: "tl bl", 172 bgColor: "transparent", 173 color: "white", 168 if (false) { 169 MochiKit.Visual.roundElement(backdropLabelOuter, {corners: "tl bl", 170 //bgColor: "transparent", 171 //color: "fromElement", 172 //__unstable__wrapElement: true, 174 173 blend: false}); 175 174 176 175 // extend the event handlers to operate on the 177 176 // rounded corners as well. (Fixes OL #57.) 178 var spanElements=backdropLabel.parentNode.getElementsByTagName("span"); 179 180 for (var currIdx = 0; currIdx < spanElements.length; currIdx++) { 181 this._setEventHandlers(spanElements[currIdx], backdropLabel); 177 //var spanElements=backdropLabel.parentNode.getElementsByTagName("span"); 178 179 //for (var currIdx = 0; currIdx < spanElements.length; currIdx++) { 180 //this._setEventHandlers(spanElements[currIdx], backdropLabel); 181 //} 182 182 } 183 183 … … 194 194 195 195 // We only want to respond to a mousedown event. 196 element.onclick = this.singleClick.bindAsEventListener(this); 197 element.ondblclick = this.singleClick.bindAsEventListener(this); 198 element.onmouseup = this.ignoreEvent.bindAsEventListener(this); 199 element.onmousedown = this.ignoreEvent.bindAsEventListener(this); 196 var connect = MochiKit.Signal.connect; 197 connect( element, "onclick", this, this.singleClick ); 198 connect( element, "ondblclick", this, this.singleClick ); 199 connect( element, "onmouseup", this, this.ignoreEvent ); 200 connect( element, "onmousedown", this, this.ignoreEvent ); 200 201 201 202 // If we are operating on a corner span we need to store a … … 214 215 setTabActivation:function(div, activate) { 215 216 var color = (activate) ? this.activeColor : this.nonActiveColor; 216 Rico.Corner.changeColor(div, color); 217 div.style.backgroundColor = color; 218 // Rico.Corner.changeColor(div, color); 217 219 }, 218 220 branches/openlayers/mochikit/lib/OpenLayers/Control/MouseDefaults.js
r788 r838 3 3 * text of the license. */ 4 4 // @require: OpenLayers/Control.js 5 OpenLayers.Control.MouseDefaults = Class.create(); 6 OpenLayers.Control.MouseDefaults.prototype = 7 Object.extend( new OpenLayers.Control(), { 5 OpenLayers.Control.MouseDefaults = function() { 6 this.initialize(); 7 } 8 OpenLayers.Control.MouseDefaults.prototype = MochiKit.Base.merge( 9 OpenLayers.Control.prototype, { 8 10 9 11 performedDrag: false, … … 14 16 15 17 draw: function() { 16 this.map.events.register( "click", this, this.defaultClick ); 17 this.map.events.register( "dblclick", this, this.defaultDblClick ); 18 this.map.events.register( "mousedown", this, this.defaultMouseDown ); 19 this.map.events.register( "mouseup", this, this.defaultMouseUp ); 20 this.map.events.register( "mousemove", this, this.defaultMouseMove ); 21 this.map.events.register( "mouseout", this, this.defaultMouseOut ); 18 var connect = MochiKit.Signal.connect; 19 connect( this.map.div, "onclick", this, this.defaultClick ); 20 connect( this.map.div, "ondblclick", this, this.defaultDblClick ); 21 connect( this.map.div, "onmousedown", this, this.defaultMouseDown ); 22 connect( this.map.div, "onmouseup", this, this.defaultMouseUp ); 23 connect( this.map.div, "onmousemove", this, this.defaultMouseMove ); 24 connect( this.map.div, "onmouseout", this, this.defaultMouseOut ); 22 25 }, 23 26 24 27 defaultClick: function (evt) { 25 if (! Event.isLeftClick(evt)) return;28 if (!evt.mouse().button.left) return; 26 29 var notAfterDrag = !this.performedDrag; 27 30 this.performedDrag = false; … … 33 36 */ 34 37 defaultDblClick: function (evt) { 35 var newCenter = this.map.getLonLatFromViewPortPx( evt.xy ); 38 var newCenter = this.map.getLonLatFromViewPortPx( 39 this.map.getMousePosition(evt.mouse().client)); 36 40 this.map.setCenter(newCenter, this.map.zoom + 1); 37 41 }, … … 41 45 */ 42 46 defaultMouseDown: function (evt) { 43 if (!Event.isLeftClick(evt)) return; 44 this.mouseDragStart = evt.xy.copyOf(); 47 var mouse = evt.mouse(); 48 var mod = evt.modifier(); 49 if (!mouse.button.left) return; 50 this.mouseDragStart = this.map.getMousePosition(mouse.client); 45 51 this.performedDrag = false; 46 if ( evt.shiftKey) {52 if (mod.shift) { 47 53 this.map.div.style.cursor = "crosshair"; 48 54 this.zoomBox = OpenLayers.Util.createDiv('zoomBox', … … 59 65 } 60 66 document.onselectstart=function() { return false; } 61 Event.stop(evt);67 evt.stop(); 62 68 }, 63 69 … … 66 72 */ 67 73 defaultMouseMove: function (evt) { 74 var xy = this.map.getMousePosition(evt.mouse().client); 68 75 if (this.mouseDragStart != null) { 69 76 if (this.zoomBox) { 70 var deltaX = Math.abs(this.mouseDragStart.x - evt.xy.x);71 var deltaY = Math.abs(this.mouseDragStart.y - evt.xy.y);77 var deltaX = Math.abs(this.mouseDragStart.x - xy.x); 78 var deltaY = Math.abs(this.mouseDragStart.y - xy.y); 72 79 this.zoomBox.style.width = deltaX+"px"; 73 80 this.zoomBox.style.height = deltaY+"px"; 74 if ( evt.xy.x < this.mouseDragStart.x) {75 this.zoomBox.style.left = evt.xy.x+"px";81 if (xy.x < this.mouseDragStart.x) { 82 this.zoomBox.style.left = xy.x+"px"; 76 83 } 77 if ( evt.xy.y < this.mouseDragStart.y) {78 this.zoomBox.style.top = evt.xy.y+"px";84 if (xy.y < this.mouseDragStart.y) { 85 this.zoomBox.style.top = xy.y+"px"; 79 86 } 80 87 } else { 81 var deltaX = this.mouseDragStart.x - evt.xy.x;82 var deltaY = this.mouseDragStart.y - evt.xy.y;88 var deltaX = this.mouseDragStart.x - xy.x; 89 var deltaY = this.mouseDragStart.y - xy.y; 83 90 var size = this.map.getSize(); 84 91 var newXY = new OpenLayers.Pixel(size.w / 2 + deltaX, … … 86 93 var newCenter = this.map.getLonLatFromViewPortPx( newXY ); 87 94 this.map.setCenter(newCenter, null, true); 88 this.mouseDragStart = evt.xy.copyOf();95 this.mouseDragStart = MochiKit.Base.clone(xy); 89 96 this.map.div.style.cursor = "move"; 90 97 } … … 97 104 */ 98 105 defaultMouseUp: function (evt) { 99 if (!Event.isLeftClick(evt)) return; 106 var mouse = evt.mouse(); 107 if (!mouse.button.left) return; 100 108 if (this.zoomBox) { 101 109 var start = this.map.getLonLatFromViewPortPx( this.mouseDragStart ); 102 var end = this.map.getLonLatFromViewPortPx( evt.xy);110 var end = this.map.getLonLatFromViewPortPx( this.map.getMousePosition(mouse.client) ); 103 111 var top = Math.max(start.lat, end.lat); 104 112 var bottom = Math.min(start.lat, end.lat); … … 122 130 123 131 defaultMouseOut: function (evt) { 124 if (this.mouseDragStart != null 125 &&OpenLayers.Util.mouseLeft(evt, this.map.div)) {132 if (this.mouseDragStart != null) { 133 if (OpenLayers.Util.mouseLeft(evt, this.map.div)) { 126 134 this.defaultMouseUp(evt); 135 } 127 136 } 128 137 } branches/openlayers/mochikit/lib/OpenLayers/Control/MouseToolbar.js
r788 r838 3 3 * text of the license. */ 4 4 // @require: OpenLayers/Control.js 5 OpenLayers.Control.MouseToolbar = Class.create(); 5 OpenLayers.Control.MouseToolbar = function(position, direction) { 6 this.initialize(position, direction); 7 } 6 8 OpenLayers.Control.MouseToolbar.X = 6; 7 9 OpenLayers.Control.MouseToolbar.Y = 300; 8 OpenLayers.Control.MouseToolbar.prototype = 9 Object.extend( new OpenLayers.Control(), {10 OpenLayers.Control.MouseToolbar.prototype = MochiKit.Base.merge( 11 OpenLayers.Control.prototype, { 10 12 11 13 mode: null, … … 30 32 draw: function() { 31 33 OpenLayers.Control.prototype.draw.apply(this, arguments); 32 this.buttons = new Object(); 33 this.map.events.register( "dblclick", this, this.defaultDblClick ); 34 this.map.events.register( "mousedown", this, this.defaultMouseDown ); 35 this.map.events.register( "mouseup", this, this.defaultMouseUp ); 36 this.map.events.register( "mousemove", this, this.defaultMouseMove ); 37 this.map.events.register( "mouseout", this, this.defaultMouseOut ); 34 var connect = MochiKit.Signal.connect; 35 this.buttons = {}; 36 connect(this.map.div,"ondblclick", this, this.defaultDblClick ); 37 connect(this.map.div,"onmousedown", this, this.defaultMouseDown ); 38 connect(this.map.div,"onmouseup", this, this.defaultMouseUp ); 39 connect(this.map.div,"onmousemove", this, this.defaultMouseMove ); 40 connect(this.map.div,"onmouseout", this, this.defaultMouseOut ); 38 41 var sz = new OpenLayers.Size(28,28); 39 42 var centered = this.position; … … 44 47 this._addButton("measure", "measuring-stick-off.png", "measuring-stick-on.png", centered, sz, "Hold alt when clicking to show distance between selected points"); 45 48 this.switchModeTo("pan"); 46 this.map.events.register("zoomend", this, function() { this.switchModeTo("pan"); });49 connect(this.map,"zoomend", this, function() { this.switchModeTo("pan"); }); 47 50 return this.div; 48 51 … … 56 59 "OpenLayers_Control_MouseToolbar_" + id, 57 60 xy, sz, imgLocation, "absolute"); 61 var connect = MochiKit.Signal.connect; 58 62 59 63 //we want to add the outer div … … 62 66 btn.activeImgLocation = activeImgLocation; 63 67 64 btn.events = new OpenLayers.Events(this, btn); 65 btn.events.register("mousedown", this, this.buttonClick); 66 btn.events.register("mouseup", this, Event.stop); 68 connect(btn, 'onmousedown', this, this.buttonClick); 69 connect(btn, 'onmouseup', this, this.buttonUp); 67 70 btn.action = id; 68 71 btn.title = title; … … 76 79 77 80 buttonClick: function(evt) { 78 if (!Event.isLeftClick(evt)) return; 79 this.switchModeTo(evt.div.action); 80 Event.stop(evt); 81 if (!evt.mouse().button.left) return; 82 this.switchModeTo(evt.src().action); 83 evt.stop(); 84 }, 85 86 buttonUp: function(evt) { 87 evt.stop(); 81 88 }, 82 89 … … 86 93 defaultDblClick: function (evt) { 87 94 this.switchModeTo("pan"); 88 var newCenter = this.map.getLonLatFromViewPortPx( evt.xy ); 95 var newCenter = this.map.getLonLatFromViewPortPx( 96 this.map.getMousePosition(evt.mouse().client)); 89 97 this.map.setCenter(newCenter, this.map.zoom + 2); 90 98 }, … … 94 102 */ 95 103 defaultMouseDown: function (evt) { 96 if (!Event.isLeftClick(evt)) return; 97 this.mouseDragStart = evt.xy.copyOf(); 98 if (evt.shiftKey && this.mode !="zoombox") { 104 var mouse = evt.mouse(); 105 var mod = evt.modifier(); 106 if (!mouse.button.left) return; 107 this.mouseDragStart = this.map.getMousePosition(mouse.client); 108 if (mod.shift && this.mode !="zoombox") { 99 109 this.switchModeTo("zoombox"); 100 } else if ( evt.altKey&& this.mode !="measure") {110 } else if (mod.alt && this.mode !="measure") { 101 111 this.switchModeTo("measure"); 102 112 } else if (!this.mode) { … … 164 174 } 165 175 document.onselectstart = function() { return false; } 166 Event.stop(evt);176 evt.stop(); 167 177 }, 168 178 … … 195 205 defaultMouseMove: function (evt) { 196 206 if (this.mouseDragStart != null) { 207 var xy = this.map.getMousePosition(evt.mouse().client); 197 208 switch (this.mode) { 198 209 case "zoombox": 199 var deltaX = Math.abs(this.mouseDragStart.x - evt.xy.x);200 var deltaY = Math.abs(this.mouseDragStart.y - evt.xy.y);210 var deltaX = Math.abs(this.mouseDragStart.x - xy.x); 211 var deltaY = Math.abs(this.mouseDragStart.y - xy.y); 201 212 this.zoomBox.style.width = deltaX+"px"; 202 213 this.zoomBox.style.height = deltaY+"px"; 203 i
