Skip to content

Commit

Permalink
add support for percentage position of left,right,top,bottom,horizont…
Browse files Browse the repository at this point in the history
…alCenter and verticalCenter properties.
  • Loading branch information
domchen committed Aug 3, 2016
1 parent bc81536 commit 90b1160
Show file tree
Hide file tree
Showing 11 changed files with 253 additions and 150 deletions.
102 changes: 54 additions & 48 deletions build/eui/eui.d.ts

Large diffs are not rendered by default.

84 changes: 66 additions & 18 deletions build/eui/eui.js
Original file line number Diff line number Diff line change
Expand Up @@ -1876,7 +1876,12 @@ var eui;
return this.$UIComponent[0 /* left */];
}
,function (value) {
value = +value;
if (!value || typeof value == "number") {
value = +value;
}
else {
value = value.toString().trim();
}
var values = this.$UIComponent;
if (values[0 /* left */] === value)
return;
Expand All @@ -1893,7 +1898,12 @@ var eui;
return this.$UIComponent[1 /* right */];
}
,function (value) {
value = +value;
if (!value || typeof value == "number") {
value = +value;
}
else {
value = value.toString().trim();
}
var values = this.$UIComponent;
if (values[1 /* right */] === value)
return;
Expand All @@ -1910,7 +1920,12 @@ var eui;
return this.$UIComponent[2 /* top */];
}
,function (value) {
value = +value;
if (!value || typeof value == "number") {
value = +value;
}
else {
value = value.toString().trim();
}
var values = this.$UIComponent;
if (values[2 /* top */] === value)
return;
Expand All @@ -1927,7 +1942,12 @@ var eui;
return this.$UIComponent[3 /* bottom */];
}
,function (value) {
value = +value;
if (!value || typeof value == "number") {
value = +value;
}
else {
value = value.toString().trim();
}
var values = this.$UIComponent;
if (values[3 /* bottom */] == value)
return;
Expand All @@ -1944,7 +1964,12 @@ var eui;
return this.$UIComponent[4 /* horizontalCenter */];
}
,function (value) {
value = +value;
if (!value || typeof value == "number") {
value = +value;
}
else {
value = value.toString().trim();
}
var values = this.$UIComponent;
if (values[4 /* horizontalCenter */] === value)
return;
Expand All @@ -1961,7 +1986,12 @@ var eui;
return this.$UIComponent[5 /* verticalCenter */];
}
,function (value) {
value = +value;
if (!value || typeof value == "number") {
value = +value;
}
else {
value = value.toString().trim();
}
var values = this.$UIComponent;
if (values[5 /* verticalCenter */] === value)
return;
Expand Down Expand Up @@ -20528,6 +20558,24 @@ var eui;
var sys;
(function (sys) {
var UIComponentClass = "eui.UIComponent";
/**
* @private
* @param value 要格式化的相对值
* @param total 在此值方向上的总长度
*/
function formatRelative(value, total) {
if (!value || typeof value == "number") {
return value;
}
var str = value;
var index = str.indexOf("%");
if (index == -1) {
return +str;
}
var percent = +str.substring(0, index);
return percent * 0.01 * total;
}
sys.formatRelative = formatRelative;
/**
* @private
* 一个工具方法,使用BasicLayout规则测量目标对象。
Expand All @@ -20546,12 +20594,12 @@ var eui;
continue;
}
var values = layoutElement.$UIComponent;
var hCenter = values[4 /* horizontalCenter */];
var vCenter = values[5 /* verticalCenter */];
var left = values[0 /* left */];
var right = values[1 /* right */];
var top = values[2 /* top */];
var bottom = values[3 /* bottom */];
var hCenter = +values[4 /* horizontalCenter */];
var vCenter = +values[5 /* verticalCenter */];
var left = +values[0 /* left */];
var right = +values[1 /* right */];
var top = +values[2 /* top */];
var bottom = +values[3 /* bottom */];
var extX;
var extY;
layoutElement.getPreferredBounds(bounds);
Expand Down Expand Up @@ -20606,12 +20654,12 @@ var eui;
continue;
}
var values = layoutElement.$UIComponent;
var hCenter = values[4 /* horizontalCenter */];
var vCenter = values[5 /* verticalCenter */];
var left = values[0 /* left */];
var right = values[1 /* right */];
var top = values[2 /* top */];
var bottom = values[3 /* bottom */];
var hCenter = formatRelative(values[4 /* horizontalCenter */], unscaledWidth);
var vCenter = formatRelative(values[5 /* verticalCenter */], unscaledHeight);
var left = formatRelative(values[0 /* left */], unscaledWidth);
var right = formatRelative(values[1 /* right */], unscaledWidth);
var top = formatRelative(values[2 /* top */], unscaledHeight);
var bottom = formatRelative(values[3 /* bottom */], unscaledHeight);
var percentWidth = values[6 /* percentWidth */];
var percentHeight = values[7 /* percentHeight */];
var childWidth = NaN;
Expand Down
8 changes: 4 additions & 4 deletions build/eui/eui.min.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions src/extension/eui/components/BitmapLabel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ module eui {
* @version eui 1.0
* @platform Web,Native
*/
public left: number;
public left: number|string;

/**
* @copy eui.UIComponent#right
Expand All @@ -265,7 +265,7 @@ module eui {
* @version eui 1.0
* @platform Web,Native
*/
public right: number;
public right: number|string;

/**
* @copy eui.UIComponent#top
Expand All @@ -274,7 +274,7 @@ module eui {
* @version eui 1.0
* @platform Web,Native
*/
public top: number;
public top: number|string;

/**
* @copy eui.UIComponent#bottom
Expand All @@ -283,7 +283,7 @@ module eui {
* @version eui 1.0
* @platform Web,Native
*/
public bottom: number;
public bottom: number|string;

/**
* @copy eui.UIComponent#horizontalCenter
Expand All @@ -292,7 +292,7 @@ module eui {
* @version eui 1.0
* @platform Web,Native
*/
public horizontalCenter: number;
public horizontalCenter: number|string;

/**
* @copy eui.UIComponent#verticalCenter
Expand All @@ -301,7 +301,7 @@ module eui {
* @version eui 1.0
* @platform Web,Native
*/
public verticalCenter: number;
public verticalCenter: number|string;

/**
* @copy eui.UIComponent#percentWidth
Expand Down
12 changes: 6 additions & 6 deletions src/extension/eui/components/Component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ module eui {
* @version eui 1.0
* @platform Web,Native
*/
public left:number;
public left:number|string;

/**
* @inheritDoc
Expand All @@ -785,7 +785,7 @@ module eui {
* @version eui 1.0
* @platform Web,Native
*/
public right:number;
public right:number|string;

/**
* @inheritDoc
Expand All @@ -794,7 +794,7 @@ module eui {
* @version eui 1.0
* @platform Web,Native
*/
public top:number;
public top:number|string;

/**
* @inheritDoc
Expand All @@ -803,7 +803,7 @@ module eui {
* @version eui 1.0
* @platform Web,Native
*/
public bottom:number;
public bottom:number|string;

/**
* @inheritDoc
Expand All @@ -812,7 +812,7 @@ module eui {
* @version eui 1.0
* @platform Web,Native
*/
public horizontalCenter:number;
public horizontalCenter:number|string;

/**
* @inheritDoc
Expand All @@ -821,7 +821,7 @@ module eui {
* @version eui 1.0
* @platform Web,Native
*/
public verticalCenter:number;
public verticalCenter:number|string;

/**
* @inheritDoc
Expand Down
12 changes: 6 additions & 6 deletions src/extension/eui/components/EditableText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ module eui {
* @version eui 1.0
* @platform Web,Native
*/
public left: number;
public left: number|string;

/**
* @inheritDoc
Expand All @@ -422,7 +422,7 @@ module eui {
* @version eui 1.0
* @platform Web,Native
*/
public right: number;
public right: number|string;

/**
* @inheritDoc
Expand All @@ -431,7 +431,7 @@ module eui {
* @version eui 1.0
* @platform Web,Native
*/
public top: number;
public top: number|string;

/**
* @inheritDoc
Expand All @@ -440,7 +440,7 @@ module eui {
* @version eui 1.0
* @platform Web,Native
*/
public bottom: number;
public bottom: number|string;

/**
* @inheritDoc
Expand All @@ -449,7 +449,7 @@ module eui {
* @version eui 1.0
* @platform Web,Native
*/
public horizontalCenter: number;
public horizontalCenter: number|string;

/**
* @inheritDoc
Expand All @@ -458,7 +458,7 @@ module eui {
* @version eui 1.0
* @platform Web,Native
*/
public verticalCenter: number;
public verticalCenter: number|string;

/**
* @inheritDoc
Expand Down
12 changes: 6 additions & 6 deletions src/extension/eui/components/Group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ module eui {
* @version eui 1.0
* @platform Web,Native
*/
public left:number;
public left:number|string;

/**
* @inheritDoc
Expand All @@ -668,7 +668,7 @@ module eui {
* @version eui 1.0
* @platform Web,Native
*/
public right:number;
public right:number|string;

/**
* @inheritDoc
Expand All @@ -677,7 +677,7 @@ module eui {
* @version eui 1.0
* @platform Web,Native
*/
public top:number;
public top:number|string;

/**
* @inheritDoc
Expand All @@ -686,7 +686,7 @@ module eui {
* @version eui 1.0
* @platform Web,Native
*/
public bottom:number;
public bottom:number|string;

/**
* @inheritDoc
Expand All @@ -695,7 +695,7 @@ module eui {
* @version eui 1.0
* @platform Web,Native
*/
public horizontalCenter:number;
public horizontalCenter:number|string;

/**
* @inheritDoc
Expand All @@ -704,7 +704,7 @@ module eui {
* @version eui 1.0
* @platform Web,Native
*/
public verticalCenter:number;
public verticalCenter:number|string;

/**
* @inheritDoc
Expand Down
Loading

0 comments on commit 90b1160

Please sign in to comment.