-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix Better dialog width management depending on the title length #1474
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
107 changes: 107 additions & 0 deletions
107
test/aria/widgets/container/dialog/sizes/DialogMaxWidthTestCase.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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/* | ||
* Copyright 2012 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. | ||
*/ | ||
|
||
/** | ||
* Test for issue #10 | ||
*/ | ||
Aria.classDefinition({ | ||
$classpath : "test.aria.widgets.container.dialog.sizes.DialogMaxWidthTestCase", | ||
$extends : "aria.jsunit.TemplateTestCase", | ||
$dependencies : ["aria.utils.Json"], | ||
$constructor : function () { | ||
this.$TemplateTestCase.constructor.call(this); | ||
|
||
this.$json = aria.utils.Json; | ||
|
||
this.data = { | ||
title: "Short", | ||
width: 150 | ||
}; | ||
|
||
this.setTestEnv({ | ||
template : "test.aria.widgets.container.dialog.sizes.DialogMaxWidthTestCaseTpl", | ||
data : this.data | ||
}); | ||
}, | ||
$prototype : { | ||
|
||
checkSizes : function(dialogId, mainWidth) { | ||
var dialog = this.dialogs[dialogId]; | ||
|
||
var dom = dialog._domElt; | ||
var children = dom.children; | ||
var dlgBody = children[0]; | ||
var dlgTitle = children[1]; | ||
var dlgTitleText = aria.utils.Dom.getElementsByClassName(dlgTitle, "sDialog_title"); | ||
var dlgCloseIcon = aria.utils.Dom.getElementsByClassName(dlgTitle, "sDialog_close"); | ||
|
||
this.assertEqualsWithTolerance(dlgBody.offsetWidth, mainWidth, 8, dialogId + " width should be %2 instead of %1"); | ||
this.assertEqualsWithTolerance(dlgTitle.offsetWidth, mainWidth - 10, 8, dialogId + " title width should be %2 instead of %1"); | ||
this.assertEquals(dlgTitleText.offsetTop, dlgCloseIcon.offsetTop, "The close icon should be on teh first line"); | ||
}, | ||
|
||
|
||
runTemplateTest : function () { | ||
// The main template is Ready even if it contains a template inside the Dialog, wait | ||
var dialogIds = ["dialog1", "dialog2", "dialog3", "dialog4", "dialog5"]; | ||
this.waitFor({ | ||
condition : function() { | ||
// Wait for every dialog ready and open | ||
var dialogs = this.dialogs = {}; | ||
for (var i = 0; i < dialogIds.length; i += 1) { | ||
var id = dialogIds[i]; | ||
var currentInstance = dialogs[id] = this.getWidgetInstance(id); | ||
if (!currentInstance || !currentInstance._popup.isOpen) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
}, | ||
callback : { | ||
fn : this.checkWidths, | ||
scope : this | ||
} | ||
}); | ||
}, | ||
|
||
checkWidths : function () { | ||
this.checkSizes("dialog1", 400); | ||
this.checkSizes("dialog2", 400); | ||
this.checkSizes("dialog3", 238); | ||
this.checkSizes("dialog4", 400); | ||
|
||
this.changeContainerSize(); | ||
}, | ||
|
||
changeContainerSize : function () { | ||
|
||
var data = this.data; | ||
this.checkSizes("dialog5", 200); | ||
this.$json.setValue(data, "title", "This is now a very long title"); | ||
this.checkSizes("dialog5", 251); | ||
|
||
this.$json.setValue(data, "title", "This is now a very very very very very very very long title"); | ||
this.checkSizes("dialog5", 400); | ||
|
||
this.$json.setValue(data, "title", "Short again"); | ||
this.checkSizes("dialog5", 200); | ||
|
||
this.$json.setValue(data, "width", 500); | ||
this.checkSizes("dialog5", 400); | ||
|
||
this.end(); | ||
} | ||
} | ||
}); |
110 changes: 110 additions & 0 deletions
110
test/aria/widgets/container/dialog/sizes/DialogMaxWidthTestCaseTpl.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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/* | ||
* Copyright 2012 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.sizes.DialogMaxWidthTestCaseTpl" | ||
}} | ||
|
||
{macro main()} | ||
|
||
{@aria:Dialog { | ||
visible : true, | ||
macro : "largeContent", | ||
title: "Very very very very very very very very very very very very long title", | ||
id : "dialog1", | ||
maximizable : true, | ||
center : false, | ||
xpos : 20, | ||
ypos : 20, | ||
maxHeight: 350, | ||
maxWidth: 400 | ||
}/} | ||
|
||
{@aria:Dialog { | ||
visible : true, | ||
macro : "largeContent", | ||
title: "Normal title", | ||
id : "dialog2", | ||
center : false, | ||
xpos : 450, | ||
ypos : 20, | ||
maxHeight: 400, | ||
maxWidth: 400 | ||
}/} | ||
|
||
{@aria:Dialog { | ||
visible : true, | ||
macro : "smallContent", | ||
title: "Title larger than the content", | ||
id : "dialog3", | ||
center : false, | ||
xpos : 900, | ||
ypos : 20, | ||
maxHeight: 400, | ||
maxWidth: 400 | ||
}/} | ||
|
||
{@aria:Dialog { | ||
visible : true, | ||
macro : "smallContent", | ||
title: "Very very very very very very very very very very very very long title", | ||
id : "dialog4", | ||
center : false, | ||
xpos : 1150, | ||
ypos : 20, | ||
maxHeight: 400, | ||
maxWidth: 400 | ||
}/} | ||
|
||
{@aria:Dialog { | ||
visible : true, | ||
macro : "dynamicWidth", | ||
title: "Normal title", | ||
bind: { | ||
title: { | ||
to : "title", | ||
inside : data | ||
} | ||
}, | ||
id : "dialog5", | ||
center : false, | ||
xpos : 900, | ||
ypos : 200, | ||
maxHeight: 400, | ||
maxWidth: 400 | ||
}/} | ||
|
||
{/macro} | ||
|
||
{macro largeContent ()} | ||
<div style="width:700px; height: 3000px">Large dialog content</div> | ||
{/macro} | ||
{macro dynamicWidth ()} | ||
{section { | ||
macro: "dynamicWidthContent", | ||
bindRefreshTo: [{ | ||
inside: data, | ||
to: "width" | ||
}] | ||
}/} | ||
{/macro} | ||
{macro dynamicWidthContent ()} | ||
<div style="width:${data.width}px; height: 3000px">Large dialog content</div> | ||
{/macro} | ||
{macro smallContent ()} | ||
<div style="padding: 20px">Dialog content</div> | ||
{/macro} | ||
|
||
{/Template} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to include this check in the previous loop, instead of looping twice on the same things. What do you think?