[Commits] r1287 - in core/trunk/geoext: lib/GeoExt/widgets tests/lib/GeoExt/widgets
commits at geoext.org
commits at geoext.org
Fri Jul 24 23:51:56 CEST 2009
Author: tschaub
Date: 2009-07-24 23:51:55 +0200 (Fri, 24 Jul 2009)
New Revision: 1287
Modified:
core/trunk/geoext/lib/GeoExt/widgets/Action.js
core/trunk/geoext/tests/lib/GeoExt/widgets/Action.html
Log:
Changing the action constructor so actions configured with pressed or checked properties true will have their controls activated. r=elemoine (closes #129)
Modified: core/trunk/geoext/lib/GeoExt/widgets/Action.js
===================================================================
--- core/trunk/geoext/lib/GeoExt/widgets/Action.js 2009-07-24 16:39:36 UTC (rev 1286)
+++ core/trunk/geoext/lib/GeoExt/widgets/Action.js 2009-07-24 21:51:55 UTC (rev 1287)
@@ -100,6 +100,9 @@
config.map.addControl(ctrl);
delete config.map;
}
+ if((config.pressed || config.checked) && ctrl.map) {
+ ctrl.activate();
+ }
ctrl.events.on({
activate: this.onCtrlActivate,
deactivate: this.onCtrlDeactivate,
Modified: core/trunk/geoext/tests/lib/GeoExt/widgets/Action.html
===================================================================
--- core/trunk/geoext/tests/lib/GeoExt/widgets/Action.html 2009-07-24 16:39:36 UTC (rev 1286)
+++ core/trunk/geoext/tests/lib/GeoExt/widgets/Action.html 2009-07-24 21:51:55 UTC (rev 1287)
@@ -368,6 +368,71 @@
t.eq(deactivateCtrl1Cnt, 1, "click on item2 deactivates ctrl1 once");
t.eq(activateCtrl2Cnt, 1, "click on item2 activates ctrl2 once");
}
+
+ function test_pressed(t) {
+
+ t.plan(2);
+
+ var map = new OpenLayers.Map();
+ var ctrl1 = new OpenLayers.Control();
+ var ctrl2 = new OpenLayers.Control();
+
+ // confirm that control is activated with pressed true
+ var act1 = new GeoExt.Action({
+ control: ctrl1,
+ map: map,
+ pressed: true,
+ enableToggle: true,
+ toggleGroup: "group"
+ });
+ t.eq(ctrl1.active, true, "ctrl1 activated with pressed true");
+
+ // confirm that a control is not activated with pressed false
+ var act2 = new GeoExt.Action({
+ control: ctrl2,
+ map: map,
+ pressed: false,
+ enableToggle: true,
+ toggleGroup: "group"
+ });
+ t.ok(!ctrl2.active, "ctrl2 not activated with pressed false");
+
+ map.destroy();
+
+ }
+
+ function test_checked(t) {
+
+ t.plan(2);
+
+ var map = new OpenLayers.Map();
+ var ctrl1 = new OpenLayers.Control();
+ var ctrl2 = new OpenLayers.Control();
+
+ // confirm that control is activated with checked true
+ var act1 = new GeoExt.Action({
+ control: ctrl1,
+ map: map,
+ checked: true,
+ enableToggle: true,
+ toggleGroup: "group"
+ });
+ t.eq(ctrl1.active, true, "ctrl1 activated with checked true");
+
+ // confirm that a control is not activated with checked false
+ var act2 = new GeoExt.Action({
+ control: ctrl2,
+ map: map,
+ checked: false,
+ enableToggle: true,
+ toggleGroup: "group"
+ });
+ t.ok(!ctrl2.active, "ctrl2 not activated with checked false");
+
+ map.destroy();
+
+ }
+
</script>
<body>
<div id="toolbar"></div>
More information about the Commits
mailing list