Skip to content

Commit

Permalink
fix Forgotten use case after ariatemplates#1474
Browse files Browse the repository at this point in the history
  • Loading branch information
fbasso committed Jun 4, 2015
1 parent bf28263 commit 5b0c924
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 19 deletions.
6 changes: 4 additions & 2 deletions src/aria/widgets/container/Dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -738,8 +738,10 @@ module.exports = Aria.classDefinition({
var titleWidth = ariaUtilsDom.getGeometry(titleDomElt).width;
var childNodes = titleBarDomElt.childNodes;
var iconsWidth = 0;
for (var i = 1, ii = childNodes.length; i < ii; i++) {
iconsWidth += childNodes[i].offsetWidth;
var titleDomElt = this._titleDomElt;
for (var i = 0, ii = childNodes.length; i < ii; i++) {
var node = childNodes[i];
iconsWidth += node !== titleDomElt ? node.offsetWidth : 0;
}

// First manage the width of the modal depending on the title bar and the max width
Expand Down
46 changes: 36 additions & 10 deletions test/aria/widgets/container/dialog/sizes/DialogMaxWidthTestCase.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,14 @@ Aria.classDefinition({
this.$json = aria.utils.Json;

this.data = {
title: "Short",
width: 150
dialog5 : {
title: "Short",
width: 150
},
dialog6 : {
title: "Short",
width: 150
}
};

this.setTestEnv({
Expand Down Expand Up @@ -55,7 +61,7 @@ Aria.classDefinition({

runTemplateTest : function () {
// The main template is Ready even if it contains a template inside the Dialog, wait
var dialogIds = ["dialog1", "dialog2", "dialog3", "dialog4", "dialog5"];
var dialogIds = ["dialog1", "dialog2", "dialog3", "dialog4", "dialog5", "dialog6"];
this.waitFor({
condition : function() {
// Wait for every dialog ready and open
Expand All @@ -82,25 +88,45 @@ Aria.classDefinition({
this.checkSizes("dialog3", 238);
this.checkSizes("dialog4", 400);

this.changeContainerSize();
this.changeDialog5ContainerSize();
},

changeContainerSize : function () {
changeDialog5ContainerSize : function () {

var data = this.data;
var dataDialog = this.data.dialog5;
this.checkSizes("dialog5", 200);
this.$json.setValue(data, "title", "This is now a very long title");
this.$json.setValue(dataDialog, "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.$json.setValue(dataDialog, "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.$json.setValue(dataDialog, "title", "Short again");
this.checkSizes("dialog5", 200);

this.$json.setValue(data, "width", 500);
this.$json.setValue(dataDialog, "width", 500);
this.checkSizes("dialog5", 400);

this.changeDialog6ContainerSize();
},

changeDialog6ContainerSize : function () {

var dataDialog = this.data.dialog6;
this.checkSizes("dialog6", 200);

this.$json.setValue(dataDialog, "title", "This is now a very long title");
this.checkSizes("dialog6", 273);

this.$json.setValue(dataDialog, "title", "This is now a very very very very very very very long title");
this.checkSizes("dialog6", 400);

this.$json.setValue(dataDialog, "title", "Short again");
this.checkSizes("dialog6", 200);

this.$json.setValue(dataDialog, "width", 500);
this.checkSizes("dialog6", 400);

this.end();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@

{@aria:Dialog {
visible : true,
macro : "dynamicWidth",
macro : "dynamicWidth5",
title: "Normal title",
bind: {
title: {
to : "title",
inside : data
inside : data.dialog5
}
},
id : "dialog5",
Expand All @@ -86,22 +86,53 @@
maxWidth: 400
}/}

{@aria:Dialog {
visible : true,
macro : "dynamicWidth6",
title: "Normal title",
bind: {
title: {
to : "title",
inside : data.dialog6
}
},
icon : "std:fire",
id : "dialog6",
center : false,
xpos : 20,
ypos : 400,
maxHeight: 400,
maxWidth: 400
}/}

{/macro}

{macro largeContent ()}
<div style="width:700px; height: 3000px">Large dialog content</div>
{/macro}
{macro dynamicWidth ()}
{macro dynamicWidth5 ()}
{section {
macro: "dynamicWidthContent5",
bindRefreshTo: [{
inside: data.dialog5,
to: "width"
}]
}/}
{/macro}
{macro dynamicWidth6 ()}
{section {
macro: "dynamicWidthContent",
macro: "dynamicWidthContent6",
bindRefreshTo: [{
inside: data,
inside: data.dialog6,
to: "width"
}]
}/}
{/macro}
{macro dynamicWidthContent ()}
<div style="width:${data.width}px; height: 3000px">Large dialog content</div>
{macro dynamicWidthContent5 ()}
<div style="width:${data.dialog5.width}px; height: 3000px">Large dialog content</div>
{/macro}
{macro dynamicWidthContent6 ()}
<div style="width:${data.dialog6.width}px; height: 3000px">Large dialog content</div>
{/macro}
{macro smallContent ()}
<div style="padding: 20px">Dialog content</div>
Expand Down

0 comments on commit 5b0c924

Please sign in to comment.