From 81505f54b006d2d2e021ec3bfb688eeb3604983d Mon Sep 17 00:00:00 2001 From: crschmidt Date: Thu, 24 Jan 2008 03:16:42 +0000 Subject: [PATCH] Add generic 'button' control. r=tschaub. (Closes #872) git-svn-id: http://svn.openlayers.org/trunk/openlayers@5870 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers.js | 1 + lib/OpenLayers/Control/Button.js | 42 ++++++++++++++++++++++++++++++++ tests/Control/test_Button.html | 17 +++++++++++++ tests/list-tests.html | 1 + 4 files changed, 61 insertions(+) create mode 100644 lib/OpenLayers/Control/Button.js create mode 100644 tests/Control/test_Button.html diff --git a/lib/OpenLayers.js b/lib/OpenLayers.js index 10ab9c4c74..834f14b020 100644 --- a/lib/OpenLayers.js +++ b/lib/OpenLayers.js @@ -129,6 +129,7 @@ "OpenLayers/Handler/Keyboard.js", "OpenLayers/Control.js", "OpenLayers/Control/Attribution.js", + "OpenLayers/Control/Button.js", "OpenLayers/Control/ZoomBox.js", "OpenLayers/Control/ZoomToMaxExtent.js", "OpenLayers/Control/DragPan.js", diff --git a/lib/OpenLayers/Control/Button.js b/lib/OpenLayers/Control/Button.js new file mode 100644 index 0000000000..217095d7e0 --- /dev/null +++ b/lib/OpenLayers/Control/Button.js @@ -0,0 +1,42 @@ +/* Copyright (c) 2006-2007 MetaCarta, Inc., published under a modified BSD license. + * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt + * for the full text of the license. */ + +/** + * @requires OpenLayers/Control.js + */ + +/** + * Class: OpenLayers.Control.Button + * A very simple button controlfor use with . + * When clicked, the function trigger() is executed. + * + * Inherits from: + * - + * + * Use: + * (code) + * var button = new OpenLayers.Control.Button({ + * displayClass: "MyButton", trigger: myFunction + * }); + * panel.addControls([button]); + * (end) + * + * Will create a button with CSS class MyButtonItemInactive, that + * will call the function MyFunction() when clicked. + */ +OpenLayers.Control.Button = OpenLayers.Class(OpenLayers.Control, { + /** + * Property: type + * {Integer} OpenLayers.Control.TYPE_BUTTON. + */ + type: OpenLayers.Control.TYPE_BUTTON, + + /* + * Method: trigger + * Called by a control panel when the button is clicked. + */ + trigger: function() {}, + + CLASS_NAME: "OpenLayers.Control.Button" +}); \ No newline at end of file diff --git a/tests/Control/test_Button.html b/tests/Control/test_Button.html new file mode 100644 index 0000000000..925e621550 --- /dev/null +++ b/tests/Control/test_Button.html @@ -0,0 +1,17 @@ + + + + + + + + diff --git a/tests/list-tests.html b/tests/list-tests.html index 121e4f6193..3a57abf651 100644 --- a/tests/list-tests.html +++ b/tests/list-tests.html @@ -73,6 +73,7 @@
  • Tile/test_WFS.html
  • test_Control.html
  • Control/test_Attribution.html
  • +
  • Control/test_Button.html
  • Control/test_DragFeature.html
  • Control/test_DragPan.html
  • Control/test_LayerSwitcher.html