OpenLayers OpenLayers

Changeset 5910

Show
Ignore:
Timestamp:
01/27/08 09:44:16 (1 year ago)
Author:
crschmidt
Message:

Add support to set the 'title' property of a control such that it will
be displayed when hovering over the control in a control.panel via its
panel_div. r=me (Closes #822)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/examples/panel.html

    r5362 r5910  
    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); 
  • trunk/openlayers/lib/OpenLayers/Control.js

    r5614 r5910  
    8585     */ 
    8686    displayClass: "", 
     87     
     88    /** 
     89    * Property: title   
     90    * {string}  This property is used for showing a tooltip over the   
     91    * Control.   
     92    */  
     93    title: "", 
    8794 
    8895    /**  
     
    173180            this.div = OpenLayers.Util.createDiv(this.id); 
    174181            this.div.className = this.displayClass; 
     182            if (this.title != "") { 
     183                this.div.title = this.title; 
     184            } 
    175185        } 
    176186        if (px != null) { 
  • trunk/openlayers/lib/OpenLayers/Control/Panel.js

    r5631 r5910  
    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])); 
  • trunk/openlayers/tests/Control/test_Panel.html

    r5532 r5910  
    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         
  • trunk/openlayers/tests/test_Control.html

    r4676 r5910  
    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);