Fix tests

This commit is contained in:
Paulo Gustavo Veiga 2021-10-02 17:10:21 -07:00
parent 79793820ea
commit 38ec9931d7
2 changed files with 134 additions and 132 deletions

View File

@ -14,8 +14,6 @@
web2d.peer.utils = {}; web2d.peer.utils = {};
</script> </script>
<script type="text/javascript" src="utils.js"></script>
<script type="text/javascript"> <script type="text/javascript">
function initialize() { function initialize() {
web2d.Toolkit.init(); web2d.Toolkit.init();

View File

@ -1,6 +1,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<script type="text/javascript"> <script type="text/javascript">
web2d = { web2d = {
@ -19,7 +20,6 @@
float: left; float: left;
margin: 10px; margin: 10px;
} }
</style> </style>
<script type="text/javascript"> <script type="text/javascript">
@ -29,10 +29,11 @@
this._element = element; this._element = element;
this._type = type; this._type = type;
this._listener = function logger(event) { this._listener = function logger(event) {
var oldColor = this.getAttribute('fillColor'); var oldColor = element.getAttribute('fillColor');
this.setFill("yellow"); element.setFill("yellow");
alert("Event on:" + this.getType() + ", Type:" + type);
this.setFill(oldColor); alert("Event on:" + element.getType() + ", Type:" + type);
element.setFill(oldColor);
}; };
} }
@ -63,7 +64,7 @@
} }
MultipleEventHandler.prototype.listenerCount = function () { MultipleEventHandler.prototype.listenerCount = function () {
return this._listeners.length; return this._listeners.length;
} }
MultipleEventHandler.prototype.unRegisterOneListener = function () { MultipleEventHandler.prototype.unRegisterOneListener = function () {
@ -131,140 +132,143 @@
<body onload="initialize();"> <body onload="initialize();">
<script type="text/javascript"> <script type="text/javascript">
// Logger.setEnabled(true); // Logger.setEnabled(true);
</script> </script>
<h1>Elements Event Handling</h1> <h1>Elements Event Handling</h1>
<table border="1"> <table border="1">
<colgroup style="width:80%;"> <colgroup style="width:80%;">
<col style="width:30%"/> <col style="width:30%" />
<col style="width:60%"/> <col style="width:60%" />
</colgroup> </colgroup>
<tbody> <tbody>
<tr> <tr>
<td> <td>
This examples shows the ability to attach listeners to handle several events. This examples shows the ability to attach listeners to handle several events.
In this example, you can attach different events to three elements: workspace, small elipse and the big In this example, you can attach different events to three elements: workspace, small elipse and the
elipse. big
Events will follow the event bubbling behaviour. elipse.
</td> Events will follow the event bubbling behaviour.
<td> </td>
<div id="workspaceContainer" style="float:left;"></div> <td>
<div id="workspaceContainer" style="float:left;"></div>
<div class="eventForm"> <div class="eventForm">
<form action=""> <form action="">
<fieldset> <fieldset>
<legend>Workspace Events</legend> <legend>Workspace Events</legend>
<label>Click Event: <label>Click Event:
<input type="button" value="Register" <input type="button" value="Register"
onclick="(!wClickEventLogger.changeState())?this.value='Register':this.value='Unregister'"/> onclick="(!wClickEventLogger.changeState())?this.value='Register':this.value='Unregister'" />
</label><br/> </label><br />
<label>Double Click Event: <label>Double Click Event:
<input type="button" value="Register" <input type="button" value="Register"
onclick="(!wDblCickEventLogger.changeState())?this.value='Register':this.value='Unregister'"/> onclick="(!wDblCickEventLogger.changeState())?this.value='Register':this.value='Unregister'" />
</label><br/> </label><br />
<label>Mouse Over Event: <label>Mouse Over Event:
<input type="button" value="Register" <input type="button" value="Register"
onclick="(!wMouseoverEventLogger.changeState())?this.value='Register':this.value='Unregister'"/> onclick="(!wMouseoverEventLogger.changeState())?this.value='Register':this.value='Unregister'" />
</label><br/> </label><br />
<label>Mouse Out Event: <label>Mouse Out Event:
<input type="button" value="Register" <input type="button" value="Register"
onclick="(!wMouseoutEventLogger.changeState())?this.value='Register':this.value='Unregister'"/> onclick="(!wMouseoutEventLogger.changeState())?this.value='Register':this.value='Unregister'" />
</label><br/> </label><br />
<label>Mouse Move Event: <label>Mouse Move Event:
<input type="button" value="Register" <input type="button" value="Register"
onclick="(!wMousemoveEventLogger.changeState())?this.value='Register':this.value='Unregister'"/> onclick="(!wMousemoveEventLogger.changeState())?this.value='Register':this.value='Unregister'" />
</label> </label>
</fieldset> </fieldset>
</form> </form>
<form action=""> <form action="">
<fieldset> <fieldset>
<legend>Small Elipse Events</legend> <legend>Small Elipse Events</legend>
<label>Click Event: <label>Click Event:
<input type="button" value="Register" <input type="button" value="Register"
onclick="(!esClickEventLogger.changeState())?this.value='Register':this.value='Unregister'"/> onclick="(!esClickEventLogger.changeState())?this.value='Register':this.value='Unregister'" />
</label><br/> </label><br />
<label>Double Click Event: <label>Double Click Event:
<input type="button" value="Register" <input type="button" value="Register"
onclick="(!esDblCickEventLogger.changeState())?this.value='Register':this.value='Unregister'"/> onclick="(!esDblCickEventLogger.changeState())?this.value='Register':this.value='Unregister'" />
</label><br/> </label><br />
<label>Mouse Over Event: <label>Mouse Over Event:
<input type="button" value="Register" <input type="button" value="Register"
onclick="(!esMouseoverEventLogger.changeState())?this.value='Register':this.value='Unregister'"/> onclick="(!esMouseoverEventLogger.changeState())?this.value='Register':this.value='Unregister'" />
</label><br/> </label><br />
<label>Mouse Out Event: <label>Mouse Out Event:
<input type="button" value="Register" <input type="button" value="Register"
onclick="(!esMouseoutEventLogger.changeState())?this.value='Register':this.value='Unregister'"/> onclick="(!esMouseoutEventLogger.changeState())?this.value='Register':this.value='Unregister'" />
</label><br/> </label><br />
<label>Mouse Move Event: <label>Mouse Move Event:
<input type="button" value="Register" <input type="button" value="Register"
onclick="(!esMousemoveEventLogger.changeState())?this.value='Register':this.value='Unregister'"/> onclick="(!esMousemoveEventLogger.changeState())?this.value='Register':this.value='Unregister'" />
</label> </label>
</fieldset> </fieldset>
</form> </form>
<form action=""> <form action="">
<fieldset> <fieldset>
<legend>Big Elipse Events</legend> <legend>Big Elipse Events</legend>
<label>Click Event: <label>Click Event:
<input type="button" value="Register" <input type="button" value="Register"
onclick="(!ebClickEventLogger.changeState())?this.value='Register':this.value='Unregister'"/> onclick="(!ebClickEventLogger.changeState())?this.value='Register':this.value='Unregister'" />
</label><br/> </label><br />
<label>Double Click Event: <label>Double Click Event:
<input type="button" value="Register" <input type="button" value="Register"
onclick="(!ebDblCickEventLogger.changeState())?this.value='Register':this.value='Unregister'"/> onclick="(!ebDblCickEventLogger.changeState())?this.value='Register':this.value='Unregister'" />
</label><br/> </label><br />
<label>Mouse Over Event: <label>Mouse Over Event:
<input type="button" value="Register" <input type="button" value="Register"
onclick="(!ebMouseoverEventLogger.changeState())?this.value='Register':this.value='Unregister'"/> onclick="(!ebMouseoverEventLogger.changeState())?this.value='Register':this.value='Unregister'" />
</label><br/> </label><br />
<label>Mouse Out Event: <label>Mouse Out Event:
<input type="button" value="Register" <input type="button" value="Register"
onclick="(!ebMouseoutEventLogger.changeState())?this.value='Register':this.value='Unregister'"/> onclick="(!ebMouseoutEventLogger.changeState())?this.value='Register':this.value='Unregister'" />
</label><br/> </label><br />
<label>Mouse Move Event: <label>Mouse Move Event:
<input type="button" value="Register" <input type="button" value="Register"
onclick="(!ebMousemoveEventLogger.changeState())?this.value='Register':this.value='Unregister'"/> onclick="(!ebMousemoveEventLogger.changeState())?this.value='Register':this.value='Unregister'" />
</label> </label>
</fieldset> </fieldset>
</form> </form>
</div> </div>
</td> </td>
</tr> </tr>
<tr> <tr>
<td>Multiple listeners can be attached to an element to handle an event type. <td>Multiple listeners can be attached to an element to handle an event type.
In this example, multiple listeners can be registered to the elipse element to handle the click event type. In this example, multiple listeners can be registered to the elipse element to handle the click
</td> event type.
<td> </td>
<div id="workspaceMultipleEvents" style="float:left;"></div> <td>
<div id="workspaceMultipleEvents" style="float:left;"></div>
<div class="eventForm"> <div class="eventForm">
<form action=""> <form action="">
<fieldset> <fieldset>
<legend>Elipse Click Events Listeners</legend> <legend>Elipse Click Events Listeners</legend>
<label>Registered Listeners #: <label>Registered Listeners #:
<input type="text" disabled="disabled" value="0" id="listenerCounter" maxlength="2" <input type="text" disabled="disabled" value="0" id="listenerCounter" maxlength="2"
size="2"/> size="2" />
</label> </label>
<br/> <br />
<input type="button" value="Register Listener" <input type="button" value="Register Listener"
onclick="multipleHandler.registerOneListener();$('#listenerCounter').first().value=multipleHandler.listenerCount();"/> onclick="multipleHandler.registerOneListener();$('#listenerCounter').first().value=multipleHandler.listenerCount();" />
<input type="button" value="UnRegister Listener" <input type="button" value="UnRegister Listener"
onclick="multipleHandler.unRegisterOneListener();$('#listenerCounter').first().value=multipleHandler.listenerCount();"/> onclick="multipleHandler.unRegisterOneListener();$('#listenerCounter').first().value=multipleHandler.listenerCount();" />
</fieldset> </fieldset>
</form> </form>
</div> </div>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</body> </body>
</html> </html>