OpenLayers OpenLayers

Ticket #822: 822.patch

File 822.patch, 4.8 kB (added by penyaskito, 1 year ago)

Patch (including tests and example)

  • examples/panel.html

    old new  
    6060        var map, layer; 
    6161 
    6262        function init(){ 
    63             map = new OpenLayers.Map( 'map', { controls: [] } ); 
     63            map = new OpenLayers.Map( 'map', { controls: [], 'fallThrough':true } ); 
    6464            layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",  
    6565                    "http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} ); 
    6666            map.addLayer(layer); 
     
    6969            map.addLayer(vlayer); 
    7070             
    7171             
    72             zb = new OpenLayers.Control.ZoomBox(); 
     72            zb = new OpenLayers.Control.ZoomBox( 
     73                {title:"Zoom box: Selecting it you can zoom on an area by clicking and dragging."}); 
    7374            var panel = new OpenLayers.Control.Panel({defaultControl: zb}); 
    7475            panel.addControls([ 
    75                 new OpenLayers.Control.MouseDefaults(), 
     76                new OpenLayers.Control.MouseDefaults( 
     77                    {title:'You can use the default mouse configuration'}),  
    7678                zb, 
    77                 new OpenLayers.Control.DrawFeature(vlayer, OpenLayers.Handler.Path), 
    78                 new OpenLayers.Control.ZoomToMaxExtent() 
     79                new OpenLayers.Control.DrawFeature(vlayer, OpenLayers.Handler.Path, 
     80                    {title:'Draw a feature'}), 
     81                new OpenLayers.Control.ZoomToMaxExtent({title:"Zoom to the max extent"})  
    7982            ]); 
    8083            map.addControl(panel); 
    8184 
  • lib/OpenLayers/Control.js

    old new  
    8484     * Control.  
    8585     */ 
    8686    displayClass: "", 
    87  
     87    /** 
     88    * Property: title   
     89    * {string}  This property is used for showing a tooltip over the   
     90    * Control.   
     91    */  
     92    title: "",     
    8893    /**  
    8994     * Property: active  
    9095     * {boolean} null 
     
    172177        if (this.div == null) { 
    173178            this.div = OpenLayers.Util.createDiv(this.id); 
    174179            this.div.className = this.displayClass; 
     180            if (this.title != "") { 
     181                this.div.title = this.title; 
     182            } 
    175183        } 
    176184        if (px != null) { 
    177185            this.position = px.clone(); 
  • lib/OpenLayers/Control/Panel.js

    old new  
    172172            var element = document.createElement("div"); 
    173173            var textNode = document.createTextNode(" "); 
    174174            controls[i].panel_div = element; 
     175            if (controls[i].title != "") { 
     176                controls[i].panel_div.title = controls[i].title; 
     177            } 
    175178            OpenLayers.Event.observe(controls[i].panel_div, "click",  
    176179                OpenLayers.Function.bind(this.onClick, this, controls[i])); 
    177180            OpenLayers.Event.observe(controls[i].panel_div, "mousedown",  
  • tests/Control/test_Panel.html

    old new  
    4646        t.ok(!toolControl.active && anotherToolControl.active && toggleControl.active, 
    4747              "activated the other tool control, the first one is inactive and the toggle control still active."); 
    4848    } 
    49  
     49    function test_02_Control_Panel_titles (t) {  
     50        t.plan(2);  
     51        var panel = new OpenLayers.Control.Panel();  
     52        var toolControl = new OpenLayers.Control.ZoomBox({  
     53            title:"Zoom box: Selecting it you can zoom on an area by clicking and dragging."  
     54        });  
     55        panel.addControls([toolControl]);  
     56        t.eq(panel.controls.length, 1, "added a control to the panel");  
     57        t.eq(panel.controls[0].title, toolControl.panel_div.title, "the title is correctly set");  
     58    }  
     59     
    5060    function test_Control_Panel_getBy(t) { 
    5161         
    5262        var panel = { 
  • tests/test_Control.html

    old new  
    2121        t.ok(control.map === map, "Control.map is set to the map object" ); 
    2222        t.ok(map.controls[map.controls.length - 1] === control, "map.controls contains control"); 
    2323    } 
    24  
     24     
     25    function test_Control_title(t) {  
     26        t.plan( 1 );  
     27        var titleText = 'Title test';  
     28        control = new OpenLayers.Control({title:titleText});  
     29        t.eq( control.title, titleText, "control.title set correctly" );  
     30    } 
     31     
    2532    function test_Control_destroy(t) { 
    2633        t.plan(3); 
    2734