Permalink
Browse files

[Bug #6351] blocked and unblocked events are included implemented

  • Loading branch information...
msak committed Apr 23, 2012
1 parent de3bf29 commit f2ea243e25a9e5b7fc30f9fd13fb8a4b775ff21b
Showing with 65 additions and 0 deletions.
  1. +43 −0 framework/source/class/qx/test/ui/core/Blocker.js
  2. +22 −0 framework/source/class/qx/ui/core/Blocker.js
@@ -187,6 +187,49 @@ qx.Class.define("qx.test.ui.core.Blocker",
this.assertFalse(this.__blocker.isContentBlocked(), "isContentBlocked()");
this.assertFalse(blockerElement.isIncluded(), "isIncluded()");
this.assertUndefined(blockerElement.getStyle("zIndex"));
+ },
+
+ testBlockedEvent : function()
+ {
+ this.__blockedEventFired = false;
+ this.__unblockedEventFired = false;
+
+ this.__blocker.addListenerOnce("blocked", function(e){
+ this.__blockedEventFired = true;
+ }, this);
+
+ this.__blocker.addListenerOnce("unblocked", function(e){
+ this.__unblockedEventFired = true;
+ }, this);
+
+ this.__blocker.block();
+ this.__blocker.unblock();
+
+ this.wait(100, function() {
+ this.assertTrue(this.__blockedEventFired, "'blocked' event was not fired, after block() was executed!");
+ this.assertTrue(this.__unblockedEventFired, "'unblocked' event was not fired, after unblock() was executed!");
+ }, this);
+ },
+
+ testContentBlockedEvent : function()
+ {
+ this.__blockedEventFired = false;
+ this.__unblockedEventFired = false;
+ this.__blocker.addListenerOnce("blocked", function(e){
+ this.__blockedEventFired = true;
+ }, this);
+
+ this.__blocker.addListenerOnce("unblocked", function(e){
+ this.__unblockedEventFired = true;
+ }, this);
+
+ this.__blocker.blockContent(100);
+ this.__blocker.unblockContent(100);
+
+ this.wait(100, function() {
+ this.assertTrue(this.__blockedEventFired, "'blocked' event was not fired, after blockContent() was executed!");
+ this.assertTrue(this.__unblockedEventFired, "'unblocked' event was not fired, after unblockContent() was executed!");
+ }, this);
}
}
});
@@ -34,6 +34,22 @@
qx.Class.define("qx.ui.core.Blocker",
{
extend : qx.core.Object,
+
+
+ events :
+ {
+ /**
+ * Fires after {@link #block} or {@link #blockContent} executed.
+ */
+ blocked : "qx.event.type.Event",
+
+
+ /**
+ * Fires after {@link #unblock} or {@link #unblockContent} executed.
+ */
+ unblocked : "qx.event.type.Event"
+ },
+
/**
* Creates a blocker for the passed widget.
@@ -293,6 +309,8 @@ qx.Class.define("qx.ui.core.Blocker",
blocker.addListener("keypress", this.__stopTabEvent, this);
blocker.addListener("keydown", this.__stopTabEvent, this);
blocker.addListener("keyup", this.__stopTabEvent, this);
+
+ this.fireEvent("blocked", qx.event.type.Event);
}
},
@@ -354,6 +372,8 @@ qx.Class.define("qx.ui.core.Blocker",
blocker.removeListener("keydown", this.__stopTabEvent, this);
blocker.removeListener("keyup", this.__stopTabEvent, this);
blocker.exclude();
+
+ this.fireEvent("unblocked", qx.event.type.Event);
},
@@ -404,6 +424,7 @@ qx.Class.define("qx.ui.core.Blocker",
this.__timer.start();
this.__syncBlocker();
}
+ this.fireEvent("blocked", qx.event.type.Event);
}
},
@@ -471,6 +492,7 @@ qx.Class.define("qx.ui.core.Blocker",
if (this._isPageRoot) {
this.__timer.stop();
}
+ this.fireEvent("unblocked", qx.event.type.Event);
},

0 comments on commit f2ea243

Please sign in to comment.