Skip to content

Commit 996bd2f

Browse files
committed
upgrade version to 0.0.10
1 parent 40d3e8a commit 996bd2f

File tree

2 files changed

+86
-86
lines changed

2 files changed

+86
-86
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-wtpbox",
3-
"version": "0.0.9",
3+
"version": "0.0.10",
44
"main": "src/pbox.js",
55
"dependencies": {
66
"angular": "~1.2.25",

src/pbox.js

Lines changed: 85 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -15,101 +15,101 @@
1515
boxWidth = $boxElement.outerWidth(true),
1616
boxHeight = $boxElement.outerHeight(true),
1717
top, left, right, bottom;
18-
if ((options.top !== undefined || options.bottom !== undefined) && (options.left !== undefined || options.right !== undefined)) {
19-
top = options.top;
20-
bottom = options.bottom;
21-
left = options.left;
22-
right = options.right;
23-
} else {
24-
var calLeftRight = function () {
25-
if (options.align === "left") {
26-
left = elementLeft;
27-
if (left + boxWidth > docClientWidth) {
28-
left = docClientWidth - boxWidth - options.offset;
29-
}
30-
} else if (options.align === "right") {
31-
right = docClientWidth - elementLeft - elementOuterWidth;
32-
left = undefined;
33-
if (right + boxWidth > docClientWidth) {
34-
right = options.offset;
35-
}
18+
if (options.top !== undefined && options.left !== undefined) {
19+
elementTop = options.top;
20+
elementLeft = options.left;
21+
elementOuterWidth = 0;
22+
elementOuterHeight = 0;
23+
}
24+
25+
var calLeftRight = function () {
26+
if (options.align === "left") {
27+
left = elementLeft;
28+
if (left + boxWidth > docClientWidth) {
29+
left = docClientWidth - boxWidth - options.offset;
3630
}
37-
else {
38-
left = elementLeft - boxWidth / 2 + elementOuterWidth / 2;
39-
if (left < 0) {
40-
left = options.offset;
41-
} else if (left + boxWidth > docClientWidth) {
42-
left = docClientWidth - boxWidth - options.offset;
43-
}
31+
} else if (options.align === "right") {
32+
right = docClientWidth - elementLeft - elementOuterWidth;
33+
left = undefined;
34+
if (right + boxWidth > docClientWidth) {
35+
right = options.offset;
4436
}
45-
};
37+
}
38+
else {
39+
left = elementLeft - boxWidth / 2 + elementOuterWidth / 2;
40+
if (left < 0) {
41+
left = options.offset;
42+
} else if (left + boxWidth > docClientWidth) {
43+
left = docClientWidth - boxWidth - options.offset;
44+
}
45+
}
46+
};
4647

47-
var calTopBottom = function () {
48-
if (options.align === "top") {
49-
top = elementTop;
50-
if (top + boxHeight > docClientHeight) {
51-
top = docClientHeight - boxHeight;
52-
}
53-
} else if (options.align === "bottom") {
54-
bottom = docClientHeight - elementTop - elementOuterHeight;
55-
if (bottom + boxHeight > docClientHeight) {
56-
bottom = docClientHeight - boxHeight;
57-
}
48+
var calTopBottom = function () {
49+
if (options.align === "top") {
50+
top = elementTop;
51+
if (top + boxHeight > docClientHeight) {
52+
top = docClientHeight - boxHeight;
5853
}
59-
else {
60-
top = ~~(elementTop - boxHeight / 2 + elementOuterHeight / 2);
61-
if (top < 0) {
62-
top = options.offset;
63-
} else if (top + boxHeight > docClientHeight) {
64-
top = docClientHeight - boxHeight + options.offset;
65-
}
54+
} else if (options.align === "bottom") {
55+
bottom = docClientHeight - elementTop - elementOuterHeight;
56+
if (bottom + boxHeight > docClientHeight) {
57+
bottom = docClientHeight - boxHeight;
6658
}
67-
};
59+
}
60+
else {
61+
top = ~~(elementTop - boxHeight / 2 + elementOuterHeight / 2);
62+
if (top < 0) {
63+
top = options.offset;
64+
} else if (top + boxHeight > docClientHeight) {
65+
top = docClientHeight - boxHeight + options.offset;
66+
}
67+
}
68+
};
6869

69-
switch (options.placement) {
70-
case "bottom":
71-
top = elementTop + elementOuterHeight + options.offset;
72-
calLeftRight();
73-
if (options.autoAdapt && top + boxHeight > docClientHeight) {
74-
top = undefined;
75-
bottom = docClientHeight - elementTop + options.offset;
76-
if (bottom + boxHeight > docClientHeight) {
77-
top = options.offset;
78-
bottom = undefined;
79-
}
80-
}
81-
break;
82-
case "top":
70+
switch (options.placement) {
71+
case "bottom":
72+
top = elementTop + elementOuterHeight + options.offset;
73+
calLeftRight();
74+
if (options.autoAdapt && top + boxHeight > docClientHeight) {
75+
top = undefined;
8376
bottom = docClientHeight - elementTop + options.offset;
84-
if (options.autoAdapt && bottom + boxHeight > docClientHeight) {
77+
if (bottom + boxHeight > docClientHeight) {
78+
top = options.offset;
8579
bottom = undefined;
86-
top = elementTop + elementOuterHeight + options.offset;
87-
if (top + boxHeight > docClientWidth) {
88-
top = undefined;
89-
bottom = docClientHeight - boxHeight + options.offset;
90-
}
9180
}
92-
calLeftRight();
93-
break;
94-
case "left":
95-
right = ~~(docClientWidth - elementLeft + options.offset);
96-
if (options.autoAdapt && right + boxWidth + options.offset > docClientWidth) {
97-
right = undefined;
98-
left = ~~(elementLeft + elementOuterWidth + options.offset);
99-
}
100-
calTopBottom();
101-
break;
102-
case "right":
103-
left = elementLeft + elementOuterWidth + options.offset;
104-
if (options.autoAdapt && left + boxWidth + options.offset > docClientWidth) {
105-
left = undefined;
106-
right = docClientWidth - elementLeft + options.offset;
81+
}
82+
break;
83+
case "top":
84+
bottom = docClientHeight - elementTop + options.offset;
85+
if (options.autoAdapt && bottom + boxHeight > docClientHeight) {
86+
bottom = undefined;
87+
top = elementTop + elementOuterHeight + options.offset;
88+
if (top + boxHeight > docClientWidth) {
89+
top = undefined;
90+
bottom = docClientHeight - boxHeight + options.offset;
10791
}
108-
calTopBottom();
109-
break;
110-
default:
111-
break;
112-
}
92+
}
93+
calLeftRight();
94+
break;
95+
case "left":
96+
right = ~~(docClientWidth - elementLeft + options.offset);
97+
if (options.autoAdapt && right + boxWidth + options.offset > docClientWidth) {
98+
right = undefined;
99+
left = ~~(elementLeft + elementOuterWidth + options.offset);
100+
}
101+
calTopBottom();
102+
break;
103+
case "right":
104+
left = elementLeft + elementOuterWidth + options.offset;
105+
if (options.autoAdapt && left + boxWidth + options.offset > docClientWidth) {
106+
left = undefined;
107+
right = docClientWidth - elementLeft + options.offset;
108+
}
109+
calTopBottom();
110+
break;
111+
default:
112+
break;
113113
}
114114

115115
if (top !== undefined) {

0 commit comments

Comments
 (0)