Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat #708 Dialog widget movable property
This commit add the possibility to bind the movable property of a dialog widget to the data model
- Loading branch information
Showing
5 changed files
with
285 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
test/aria/widgets/container/dialog/movable/test4/MovableDialogTemplateFour.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,58 @@ | |||
/* | |||
* Copyright 2013 Amadeus s.a.s. | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
* You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
* See the License for the specific language governing permissions and | |||
* limitations under the License. | |||
*/ | |||
|
|||
{Template { | |||
$classpath : "test.aria.widgets.container.dialog.movable.test4.MovableDialogTemplateFour" | |||
}} | |||
|
|||
{var modal = false /} | |||
|
|||
{macro main()} | |||
{var dataModel = data["firstDialog"] /} | |||
{@aria:Dialog { | |||
id : "firstDialog", | |||
contentMacro : { | |||
name : "displayDialogContent", | |||
args : ["one"] | |||
}, | |||
icon : "std:info", | |||
width : 500, | |||
maxHeight : 500, | |||
visible : true, | |||
modal : false, | |||
movable : false, | |||
bind : { | |||
"movable" : {inside:data, to:"movableDialog"}, | |||
"visible" : {inside:data, to:"visibleDialog"} | |||
} | |||
}/} | |||
{/macro} | |||
|
|||
{macro displayDialogContent()} | |||
{var dataModel = data["firstDialog"] /} | |||
|
|||
{@aria:Text { | |||
text : "movable : " | |||
}/} | |||
|
|||
{@aria:Text { | |||
id : "dialogText", | |||
bind : { | |||
text : {inside:data, to:"movableDialog"} | |||
} | |||
}/} | |||
{/macro} | |||
|
|||
{/Template} |
212 changes: 212 additions & 0 deletions
212
test/aria/widgets/container/dialog/movable/test4/MovableDialogTestCaseFour.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,212 @@ | |||
/* | |||
* Copyright 2013 Amadeus s.a.s. | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
* You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
* See the License for the specific language governing permissions and | |||
* limitations under the License. | |||
*/ | |||
|
|||
Aria.classDefinition({ | |||
$classpath : "test.aria.widgets.container.dialog.movable.test4.MovableDialogTestCaseFour", | |||
$extends : "aria.jsunit.RobotTestCase", | |||
$dependencies : ["aria.utils.Json", "aria.utils.Dom"], | |||
$constructor : function () { | |||
this.$RobotTestCase.constructor.call(this); | |||
|
|||
this.data = { | |||
firstDialog : { | |||
visible : true, | |||
xpos : 0, | |||
ypos : 0 | |||
} | |||
}; | |||
|
|||
this.setTestEnv({ | |||
template : "test.aria.widgets.container.dialog.movable.test4.MovableDialogTemplateFour", | |||
data : this.data | |||
}); | |||
}, | |||
$prototype : { | |||
runTemplateTest : function () { | |||
this.assertTrue(this.data.movableDialog === false, "Dialog movable property isn't equal to false"); | |||
|
|||
aria.core.Timer.addCallback({ | |||
fn : this._activateMovable, | |||
scope : this, | |||
delay : 500 | |||
}); | |||
}, | |||
|
|||
_activateMovable : function () { | |||
var handleGeometry = aria.utils.Dom.getGeometry(this._getHandle("firstDialog")); | |||
|
|||
this.dialogPos = { | |||
x : handleGeometry.x, | |||
y : handleGeometry.y | |||
}; | |||
|
|||
var from = { | |||
x : handleGeometry.x + handleGeometry.width / 2, | |||
y : handleGeometry.y + handleGeometry.height / 2 | |||
}; | |||
var options = { | |||
duration : 2000, | |||
to : { | |||
x : from.x + 150, | |||
y : from.y + 150 | |||
} | |||
}; | |||
|
|||
this.assertTrue(this.data.movableDialog === false, "Dialog movable property isn't equal to false"); | |||
this.synEvent.execute([["drag", options, from]], { | |||
fn : this._afterDrag, | |||
scope : this | |||
}); | |||
}, | |||
|
|||
_afterDrag : function () { | |||
var self = this; | |||
var handleGeometry = aria.utils.Dom.getGeometry(this._getHandle("firstDialog")); | |||
|
|||
this.assertTrue(this.dialogPos.x === handleGeometry.x, "The Dialog has been moved"); | |||
this.assertTrue(this.dialogPos.y === handleGeometry.y, "The Dialog has been moved"); | |||
|
|||
aria.utils.Json.setValue(this.data, "movableDialog", !this.data.movableDialog); | |||
|
|||
this.assertTrue(this.data.movableDialog === true, "Dialog movable property isn't equal to true"); | |||
|
|||
aria.core.Timer.addCallback({ | |||
fn : this._secondDrag, | |||
scope : this, | |||
delay : 1000 | |||
}); | |||
}, | |||
|
|||
_secondDrag : function () { | |||
var handleGeometry = aria.utils.Dom.getGeometry(this._getHandle("firstDialog")); | |||
this.dialogPos = { | |||
x : handleGeometry.x, | |||
y : handleGeometry.y | |||
}; | |||
|
|||
var from = { | |||
x : handleGeometry.x + handleGeometry.width / 2, | |||
y : handleGeometry.y + handleGeometry.height / 2 | |||
}; | |||
var options = { | |||
duration : 2000, | |||
to : { | |||
x : from.x + 150, | |||
y : from.y + 150 | |||
} | |||
}; | |||
|
|||
this.synEvent.execute([["drag", options, from]], { | |||
fn : this._afterSecondDrag, | |||
scope : this | |||
}); | |||
}, | |||
|
|||
_afterSecondDrag : function () { | |||
var self = this; | |||
var handleGeometry = aria.utils.Dom.getGeometry(this._getHandle("firstDialog")); | |||
|
|||
this.assertTrue(this.dialogPos.x !== handleGeometry.x, "The Dialog is not movable"); | |||
this.assertTrue(this.dialogPos.y !== handleGeometry.y, "The Dialog is not movable"); | |||
|
|||
aria.utils.Json.setValue(this.data, "movableDialog", !this.data.movableDialog); | |||
|
|||
this.assertTrue(this.data.movableDialog === false, "Dialog movable property isn't equal to false"); | |||
|
|||
aria.core.Timer.addCallback({ | |||
fn : this._thirdDrag, | |||
scope : this, | |||
delay : 1000 | |||
}); | |||
}, | |||
|
|||
_thirdDrag : function () { | |||
var handleGeometry = aria.utils.Dom.getGeometry(this._getHandle("firstDialog")); | |||
|
|||
this.dialogPos = { | |||
x : handleGeometry.x, | |||
y : handleGeometry.y | |||
}; | |||
|
|||
var from = { | |||
x : handleGeometry.x + handleGeometry.width / 2, | |||
y : handleGeometry.y + handleGeometry.height / 2 | |||
}; | |||
var options = { | |||
duration : 2000, | |||
to : { | |||
x : from.x + 150, | |||
y : from.y + 150 | |||
} | |||
}; | |||
|
|||
this.synEvent.execute([["drag", options, from]], { | |||
fn : this._afterThirdDrag, | |||
scope : this | |||
}); | |||
}, | |||
|
|||
_afterThirdDrag : function () { | |||
var self = this; | |||
var handleGeometry = aria.utils.Dom.getGeometry(this._getHandle("firstDialog")); | |||
|
|||
this.assertTrue(this.dialogPos.x === handleGeometry.x, "The Dialog has been moved"); | |||
this.assertTrue(this.dialogPos.y === handleGeometry.y, "The Dialog has been moved"); | |||
|
|||
aria.utils.Json.setValue(this.data, "visibleDialog", false); | |||
|
|||
this.assertTrue(this.data.movableDialog === false, "Dialog movable property isn't equal to false"); | |||
aria.utils.Json.setValue(this.data, "movableDialog", !this.data.movableDialog); | |||
aria.utils.Json.setValue(this.data, "visibleDialog", true); | |||
|
|||
var handleGeometry = aria.utils.Dom.getGeometry(this._getHandle("firstDialog")); | |||
this.dialogPos = { | |||
x : handleGeometry.x, | |||
y : handleGeometry.y | |||
}; | |||
|
|||
var from = { | |||
x : handleGeometry.x + handleGeometry.width / 2, | |||
y : handleGeometry.y + handleGeometry.height / 2 | |||
}; | |||
var options = { | |||
duration : 2000, | |||
to : { | |||
x : from.x - 150, | |||
y : from.y - 150 | |||
} | |||
}; | |||
|
|||
this.synEvent.execute([["drag", options, from]], { | |||
fn : this._afterFourthDrag, | |||
scope : this | |||
}); | |||
}, | |||
|
|||
_afterFourthDrag : function () { | |||
var self = this; | |||
var handleGeometry = aria.utils.Dom.getGeometry(this._getHandle("firstDialog")); | |||
|
|||
this.assertTrue(this.dialogPos.x !== handleGeometry.x, "The Dialog is not movable"); | |||
this.assertTrue(this.dialogPos.y !== handleGeometry.y, "The Dialog is not movable"); | |||
|
|||
this.end(); | |||
}, | |||
|
|||
_getHandle : function (dialogId) { | |||
return this.getWidgetInstance(dialogId)._titleBarDomElt; | |||
} | |||
} | |||
}); |