OpenLayers OpenLayers

Changeset 838

Show
Ignore:
Timestamp:
06/29/06 21:29:40 (2 years ago)
Author:
sderle
Message:

Committed Bill Noon's port of OL to Mochikit.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/openlayers/mochikit/examples/click.html

    r810 r838  
    88        } 
    99    </style> 
     10    <script type="text/javascript" src="../lib/MochiKit/MochiKit.js"></script> 
    1011    <script src="../lib/OpenLayers.js"></script> 
    1112    <script type="text/javascript"> 
    1213        <!-- 
    1314        function init(){ 
     15            MochiKit.LoggingPane.createLoggingPane(true); 
    1416            var map = new OpenLayers.Map('map'); 
    1517 
  • branches/openlayers/mochikit/examples/controls.html

    r810 r838  
    88        } 
    99    </style> 
     10    <script type="text/javascript" src="../lib/MochiKit/MochiKit.js"></script> 
    1011    <script src="../lib/OpenLayers.js"></script> 
    1112    <script type="text/javascript"> 
  • branches/openlayers/mochikit/examples/example.html

    r810 r838  
    88        } 
    99    </style> 
     10    <script type="text/javascript" src="../lib/MochiKit/MochiKit.js"></script> 
    1011    <script src="../lib/OpenLayers.js"></script> 
    1112    <script type="text/javascript"> 
    1213        <!-- 
    13         function init(){ 
     14        MochiKit.Signal.connect(window, 'onload', 
     15        function(){ 
     16            //MochiKit.LoggingPane.createLoggingPane(true); 
    1417            var map = new OpenLayers.Map('map'); 
    1518 
     
    2730                 transparent: "true", format: "image/png" }); 
    2831 
     32            ol_wms.setVisibility(true); 
    2933            jpl_wms.setVisibility(false); 
    3034            dm_wms.setVisibility(false); 
     
    3539            map.zoomToMaxExtent(); 
    3640        } 
     41        ); 
    3742        // --> 
    3843    </script> 
    3944  </head> 
    40   <body onload="init()"
     45  <body
    4146    <h1>OpenLayers Example</h1> 
    4247    <div id="map"></div> 
  • branches/openlayers/mochikit/examples/georss.html

    r803 r838  
    99        } 
    1010    </style> 
     11    <script type="text/javascript" src="../lib/MochiKit/MochiKit.js"></script> 
    1112    <script src="../lib/OpenLayers.js"></script> 
    1213    <script type="text/javascript"> 
  • branches/openlayers/mochikit/examples/markers.html

    r810 r838  
    11<html xmlns="http://www.w3.org/1999/xhtml"> 
    22  <head> 
     3    <script type="text/javascript" src="../lib/MochiKit/MochiKit.js"></script> 
    34    <meta http-equiv="imagetoolbar" content="no"> <!--ie image gizmo OFF!--> 
    45    <style type="text/css"> 
  • branches/openlayers/mochikit/examples/markersTextLayer.html

    r810 r838  
    11<html xmlns="http://www.w3.org/1999/xhtml"> 
    22  <head> 
     3    <script type="text/javascript" src="../lib/MochiKit/MochiKit.js"></script> 
    34    <meta http-equiv="imagetoolbar" content="no"> <!--ie image gizmo OFF!--> 
    45    <style type="text/css"> 
     
    1516 
    1617        function init(){ 
     18            MochiKit.LoggingPane.createLoggingPane(true); 
    1719            map = new OpenLayers.Map('map'); 
    1820            layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",  
  • branches/openlayers/mochikit/examples/markerss.html

    r810 r838  
    11<html xmlns="http://www.w3.org/1999/xhtml"> 
    22  <head> 
     3    <script type="text/javascript" src="../lib/MochiKit/MochiKit.js"></script> 
    34    <meta http-equiv="imagetoolbar" content="no"> <!--ie image gizmo OFF!--> 
    45    <style type="text/css"> 
  • branches/openlayers/mochikit/examples/mvs.html

    r830 r838  
    4242 
    4343function runMVS() { 
    44     OpenLayers.ProxyHost = '/proxy/?url=';  
    4544    if (document.location.protocol != "file:") { 
    4645        theArgs = getArgs(); 
     
    5049        theArgs.zoom = "0";             
    5150        theArgs.data = "textfile.txt"; 
    52         theArgs.controls = ['panzoom','mouse']; 
    53         theArgs.layers = ['openlayers']; 
    5451    } 
    5552 
     
    6259    var DEFAULT_LON = 0; 
    6360    var DEFAULT_ZOOM_LEVEL = 0; 
    64     var DEFAULT_CONTROLS = ['panzoom','mouse']; 
    65     var DEFAULT_LAYERS = ['openlayers']; 
    66      
     61 
    6762    var IDX_LAT = 0; 
    6863    var IDX_LON = 1; 
     
    7570 
    7671    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; 
    8372 
    84     safeArgs.layers = theArgs.layers ?  
    85         theArgs.layers.split(",") : DEFAULT_LAYERS; 
    86      
    8773    safeArgs.data = theArgs.data; // TODO: Make this "safe". 
    88      
     74 
    8975    // ----- 
    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); 
    12896 
    12997    if (safeArgs.data) { 
  • branches/openlayers/mochikit/examples/tiger.html

    r822 r838  
    88        } 
    99    </style> 
     10    <script type="text/javascript" src="../lib/MochiKit/MochiKit.js"></script> 
    1011    <script src="../lib/OpenLayers.js"></script> 
    1112    <script type="text/javascript"> 
  • branches/openlayers/mochikit/lib/OpenLayers.js

    r788 r838  
    66/// 
    77 
    8 OpenLayers = new Object(); 
    9  
    10 OpenLayers._scriptName = (  
    11     typeof(_OPENLAYERS_SFL_) == "undefined" ? "lib/OpenLayers.js"  
    12                                             : "OpenLayers.js" ); 
    13  
     8OpenLayers = {}; 
     9OpenLayers._scriptName = "lib/OpenLayers.js"; 
     10OpenLayers._scriptLocation = null; 
    1411OpenLayers._getScriptLocation = function () { 
     12    if (OpenLayers._scriptLocation != null){ 
     13        return OpenLayers._scriptLocation; 
     14    } 
    1515    var scriptLocation = ""; 
    1616    var SCRIPT_NAME = OpenLayers._scriptName; 
     
    2020        var src = scripts[i].getAttribute('src'); 
    2121        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')); 
    2624                break; 
    2725            } 
    2826        } 
    2927    } 
     28    OpenLayers._scriptLocation = scriptLocation; 
    3029    return scriptLocation; 
    3130} 
     
    4847     */ 
    4948    (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", 
    5453        "OpenLayers/Util.js", 
    55         "OpenLayers/Ajax.js", 
    56         "OpenLayers/Events.js", 
     54        // "OpenLayers/Ajax.js", 
     55        //"OpenLayers/Events.js", 
    5756        "OpenLayers/Map.js", 
    5857        "OpenLayers/Layer.js", 
     
    8685        "OpenLayers/Control/PanZoomBar.js", 
    8786        "OpenLayers/Control/LayerSwitcher.js" 
    88     ); // etc. 
     87    ]; // etc. 
    8988 
    9089    var allScriptTags = ""; 
    9190    var host = OpenLayers._getScriptLocation() + "lib/"; 
    9291 
    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++) { 
    10194        var currentScriptTag = "<script src='" + host + jsfiles[i] + "'></script>";  
    10295        allScriptTags += currentScriptTag; 
     96        //allScriptTags += "<script>MochiKit.Logging.logDebug('"+jsfiles[i]+"');</script>"; 
    10397    } 
    10498    document.write(allScriptTags); 
  • branches/openlayers/mochikit/lib/OpenLayers/Control.js

    r657 r838  
    55* @class 
    66*/ 
    7 OpenLayers.Control = Class.create(); 
     7OpenLayers.Control = function(options) { 
     8    this.initialize(options); 
     9
    810OpenLayers.Control.prototype = { 
    911 
     
    2224    */ 
    2325    initialize: function (options) { 
    24         Object.extend(this, options); 
     26        MochiKit.Base.update(this, options); 
    2527    }, 
    2628 
     
    5759        // eliminate circular references 
    5860        this.map = null; 
     61        MochiKit.Signal.disconnect(this); 
    5962    }, 
    6063 
  • branches/openlayers/mochikit/lib/OpenLayers/Control/KeyboardDefaults.js

    r806 r838  
    77 * @class 
    88 */ 
    9 OpenLayers.Control.KeyboardDefaults = Class.create(); 
    10 OpenLayers.Control.KeyboardDefaults.prototype =  
    11   Object.extend( new OpenLayers.Control(), { 
     9OpenLayers.Control.KeyboardDefaults = function() { 
     10    this.initialize(); 
     11
     12OpenLayers.Control.KeyboardDefaults.prototype = MochiKit.Base.merge( 
     13    OpenLayers.Control.prototype, { 
    1214 
    1315    /** @type int */ 
     
    2527     */ 
    2628    draw: function() { 
    27         Event.observe(document,  
    28                       'keypress',  
    29                       this.defaultKeyDown.bind(this)); 
     29        MochiKit.Signal.connect(document, "onkeypress", this, this.defaultKeyDown); 
    3030    }, 
    3131     
     
    3434    */ 
    3535    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); 
    3940                break; 
    40             case Event.KEY_RIGHT:  
     41            case 'KEY_ARROW_RIGHT':  
    4142                this.map.pan(50, 0); 
    4243                break; 
    43             case Event.KEY_UP: 
     44            case 'KEY_ARROW_UP': 
     45                this.map.pan(0, 50); 
     46                break; 
     47            case 'KEY_ARROW_DOWN': 
    4448                this.map.pan(0, -50); 
    45                 break; 
    46             case Event.KEY_DOWN: 
    47                 this.map.pan(0, 50); 
    4849                break; 
    4950        } 
  • branches/openlayers/mochikit/lib/OpenLayers/Control/LayerSwitcher.js

    r788 r838  
    66* @class 
    77*/ 
    8 OpenLayers.Control.LayerSwitcher = Class.create(); 
    9  
     8OpenLayers.Control.LayerSwitcher = function(options) { 
     9    this.initialize(options); 
     10
    1011/** color used in the UI to show a layer is active/displayed 
    1112* 
     
    2324 
    2425 
    25 OpenLayers.Control.LayerSwitcher.prototype =  
    26   Object.extend( new OpenLayers.Control(), { 
     26OpenLayers.Control.LayerSwitcher.prototype = MochiKit.Base.merge( 
     27   OpenLayers.Control.prototype, { 
    2728 
    2829    /** @type String */ 
     
    5253        // initialize our internal div 
    5354        OpenLayers.Control.prototype.draw.apply(this); 
    54  
     55        var connect = MochiKit.Signal.connect; 
     56         
    5557        this.div.style.position = "absolute"; 
    5658        this.div.style.top = "10px"; 
     
    6668        this.div.style.width = "10em"; 
    6769 
    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); 
    7072        return this.redraw();     
    7173    }, 
     
    9698    */ 
    9799    singleClick: function(evt) { 
    98         var div = Event.element(evt); 
     100        var div = evt.src(); 
    99101 
    100102        // See comment about OL #57 fix below. 
     
    117119            layer.setVisibility(!visible); 
    118120        } 
    119         Event.stop(evt); 
     121        evt.stop(); 
    120122    }, 
    121123     
     
    126128    */ 
    127129    ignoreEvent: function(evt) { 
    128         Event.stop(evt); 
     130        evt.stop(); 
    129131        return false; 
    130132    }, 
     
    136138    */             
    137139    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"}}); 
    146146        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); 
    156154         
    157155        // add reference to layer onto the div for use in event handlers 
     
    168166        // add div to main LayerSwitcher Div 
    169167        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, 
    174173                                      blend: false}); 
    175174 
    176175        // extend the event handlers to operate on the 
    177176        // 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        //} 
    182182        } 
    183183 
     
    194194 
    195195        // 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 ); 
    200201 
    201202        // If we are operating on a corner span we need to store a 
     
    214215    setTabActivation:function(div, activate) { 
    215216        var color = (activate) ? this.activeColor : this.nonActiveColor; 
    216         Rico.Corner.changeColor(div, color); 
     217        div.style.backgroundColor = color; 
     218        // Rico.Corner.changeColor(div, color); 
    217219    }, 
    218220 
  • branches/openlayers/mochikit/lib/OpenLayers/Control/MouseDefaults.js

    r788 r838  
    33 * text of the license. */ 
    44// @require: OpenLayers/Control.js 
    5 OpenLayers.Control.MouseDefaults = Class.create(); 
    6 OpenLayers.Control.MouseDefaults.prototype =  
    7   Object.extend( new OpenLayers.Control(), { 
     5OpenLayers.Control.MouseDefaults = function() { 
     6    this.initialize(); 
     7
     8OpenLayers.Control.MouseDefaults.prototype = MochiKit.Base.merge( 
     9    OpenLayers.Control.prototype, { 
    810 
    911    performedDrag: false, 
     
    1416     
    1517    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 ); 
    2225    }, 
    2326 
    2427    defaultClick: function (evt) { 
    25         if (!Event.isLeftClick(evt)) return; 
     28        if (!evt.mouse().button.left) return; 
    2629        var notAfterDrag = !this.performedDrag; 
    2730        this.performedDrag = false; 
     
    3336    */ 
    3437    defaultDblClick: function (evt) { 
    35         var newCenter = this.map.getLonLatFromViewPortPx( evt.xy );  
     38        var newCenter = this.map.getLonLatFromViewPortPx( 
     39            this.map.getMousePosition(evt.mouse().client));  
    3640        this.map.setCenter(newCenter, this.map.zoom + 1); 
    3741    }, 
     
    4145    */ 
    4246    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); 
    4551        this.performedDrag  = false; 
    46         if (evt.shiftKey) { 
     52        if (mod.shift) { 
    4753            this.map.div.style.cursor = "crosshair"; 
    4854            this.zoomBox = OpenLayers.Util.createDiv('zoomBox', 
     
    5965        } 
    6066        document.onselectstart=function() { return false; } 
    61         Event.stop(evt); 
     67        evt.stop(); 
    6268    }, 
    6369 
     
    6672    */ 
    6773    defaultMouseMove: function (evt) { 
     74        var xy = this.map.getMousePosition(evt.mouse().client); 
    6875        if (this.mouseDragStart != null) { 
    6976            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); 
    7279                this.zoomBox.style.width = deltaX+"px"; 
    7380                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"; 
    7683                } 
    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"; 
    7986                } 
    8087            } 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; 
    8390                var size = this.map.getSize(); 
    8491                var newXY = new OpenLayers.Pixel(size.w / 2 + deltaX, 
     
    8693                var newCenter = this.map.getLonLatFromViewPortPx( newXY );  
    8794                this.map.setCenter(newCenter, null, true); 
    88                 this.mouseDragStart = evt.xy.copyOf(); 
     95                this.mouseDragStart = MochiKit.Base.clone(xy); 
    8996                this.map.div.style.cursor = "move"; 
    9097            } 
     
    97104    */ 
    98105    defaultMouseUp: function (evt) { 
    99         if (!Event.isLeftClick(evt)) return; 
     106        var mouse = evt.mouse(); 
     107        if (!mouse.button.left) return; 
    100108        if (this.zoomBox) { 
    101109            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) ); 
    103111            var top = Math.max(start.lat, end.lat); 
    104112            var bottom = Math.min(start.lat, end.lat); 
     
    122130 
    123131    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)) { 
    126134                this.defaultMouseUp(evt); 
     135            } 
    127136        } 
    128137    } 
  • branches/openlayers/mochikit/lib/OpenLayers/Control/MouseToolbar.js

    r788 r838  
    33 * text of the license. */ 
    44// @require: OpenLayers/Control.js 
    5 OpenLayers.Control.MouseToolbar = Class.create(); 
     5OpenLayers.Control.MouseToolbar = function(position, direction) { 
     6    this.initialize(position, direction); 
     7
    68OpenLayers.Control.MouseToolbar.X = 6; 
    79OpenLayers.Control.MouseToolbar.Y = 300; 
    8 OpenLayers.Control.MouseToolbar.prototype =  
    9   Object.extend( new OpenLayers.Control(), { 
     10OpenLayers.Control.MouseToolbar.prototype = MochiKit.Base.merge( 
     11   OpenLayers.Control.prototype, { 
    1012     
    1113    mode: null, 
     
    3032    draw: function() { 
    3133        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 ); 
    3841        var sz = new OpenLayers.Size(28,28); 
    3942        var centered = this.position; 
     
    4447        this._addButton("measure", "measuring-stick-off.png", "measuring-stick-on.png", centered, sz, "Hold alt when clicking to show distance between selected points"); 
    4548        this.switchModeTo("pan"); 
    46         this.map.events.register("zoomend", this, function() { this.switchModeTo("pan"); }); 
     49        connect(this.map,"zoomend", this, function() { this.switchModeTo("pan"); }); 
    4750        return this.div; 
    4851         
     
    5659                                    "OpenLayers_Control_MouseToolbar_" + id,  
    5760                                    xy, sz, imgLocation, "absolute"); 
     61        var connect = MochiKit.Signal.connect; 
    5862 
    5963        //we want to add the outer div 
     
    6266        btn.activeImgLocation = activeImgLocation; 
    6367         
    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); 
    6770        btn.action = id; 
    6871        btn.title = title; 
     
    7679 
    7780    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(); 
    8188    }, 
    8289     
     
    8693    defaultDblClick: function (evt) { 
    8794        this.switchModeTo("pan"); 
    88         var newCenter = this.map.getLonLatFromViewPortPx( evt.xy );  
     95        var newCenter = this.map.getLonLatFromViewPortPx( 
     96            this.map.getMousePosition(evt.mouse().client));  
    8997        this.map.setCenter(newCenter, this.map.zoom + 2); 
    9098    }, 
     
    94102    */ 
    95103    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") { 
    99109            this.switchModeTo("zoombox"); 
    100         } else if (evt.altKey && this.mode !="measure") { 
     110        } else if (mod.alt && this.mode !="measure") { 
    101111            this.switchModeTo("measure"); 
    102112        } else if (!this.mode) { 
     
    164174        } 
    165175        document.onselectstart = function() { return false; }  
    166         Event.stop(evt); 
     176        evt.stop(); 
    167177    }, 
    168178 
     
    195205    defaultMouseMove: function (evt) { 
    196206        if (this.mouseDragStart != null) { 
     207            var xy = this.map.getMousePosition(evt.mouse().client); 
    197208            switch (this.mode) { 
    198209                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); 
    201212                    this.zoomBox.style.width = deltaX+"px"; 
    202213                    this.zoomBox.style.height = deltaY+"px"; 
    203                     i