Project

General

Profile

1
/*
2
License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
3
$Id: Button.js 3052 2007-08-01 21:25:21Z ahocevar $
4
*/
5

    
6
// Ensure this object's dependancies are loaded.
7
mapbuilder.loadScript(baseDir+"/widget/ButtonBase.js");
8

    
9
/**
10
 * Generic Button object. Set the <action> property in config for
11
 * the controller method to be called when selected
12
 * @base ButtonBase
13
 * @author Andreas Hocevar andreas.hocevarATgmail.com
14
 * @param widgetNode      The tool node from the Config XML file.
15
 * @param model  The ButtonBar widget.
16
 */
17
function Button(widgetNode, model) {
18
  ButtonBase.apply(this, new Array(widgetNode, model));
19

    
20
  /**
21
   * default css cursor to use when the button is selected
22
   */
23
  this.cursor = 'default';
24

    
25
  /**
26
   * Creates the OpenLayers control for this button.
27
   * This method will be called by ButtonBase when
28
   * MapPaneOL is ready to have buttons added.
29
   * The control should be defined in this method.
30
   * @type function
31
   * @param objRef reference to this object.
32
   * @return class (not instance!) of the OL control.
33
   */
34
  this.createControl = function(objRef) {
35
    var Control = OpenLayers.Class( OpenLayers.Control, {
36
      CLASS_NAME: 'mbControl.'+objRef.id,
37
      type: (objRef.buttonType == 'RadioButton') ? OpenLayers.Control.TYPE_TOOL : OpenLayers.Control.TYPE_BUTTON,
38
      // for button type      
39
      trigger: function() {
40
        eval('config.objects.'+objRef.action);
41
      },
42
      // for tool type (RadioButton)
43
      activate: function() {
44
        eval('config.objects.'+objRef.action);
45
        this.active = true;
46
        return true;
47
      }
48
    });
49
    return Control;
50
  }
51
  
52
  /**
53
   * Optional method to instantiate the control. If a
54
   * subclass provides this method, it will be used instead
55
   * of just callint new Control() in the superclass.
56
   * This is needed when a control has to be instantiated
57
   * with parameters.
58
   * @type OpenLayers.Control
59
   * @param objRef reference to this object.
60
   * @param {OpenLayers.Control} Control to instantiate
61
   * @return instance of the OL control
62
   */
63
  this.instantiateControl = function(objRef, Control) {
64
    // return OpenLayers.Control instance
65
    return new Control();
66
    
67
  }
68
}
69

    
70

    
(12-12/145)