Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Belgian Biodiversity Platform
yeti
Commits
af383691
Commit
af383691
authored
Apr 27, 2012
by
Julien Cigar
Browse files
allow width/height in percent
parent
fea716c0
Changes
1
Show whitespace changes
Inline
Side-by-side
ui.js
View file @
af383691
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
onscroll
:
'
scroll
'
,
onscroll
:
'
scroll
'
,
overlay
:
true
,
overlay
:
true
,
title
:
''
,
title
:
''
,
body
:
null
,
width
:
300
,
width
:
300
,
height
:
300
height
:
300
}
}
...
@@ -23,6 +24,7 @@
...
@@ -23,6 +24,7 @@
if
(
this
.
options
.
onscroll
==
'
scroll
'
)
{
if
(
this
.
options
.
onscroll
==
'
scroll
'
)
{
Yeti
.
Evt
.
bind
(
window
,
'
scroll
'
,
function
()
{
Yeti
.
Evt
.
bind
(
window
,
'
scroll
'
,
function
()
{
_self
.
set_sizes
();
_self
.
set_position
();
_self
.
set_position
();
});
});
}
}
...
@@ -31,7 +33,12 @@
...
@@ -31,7 +33,12 @@
this
.
frame
=
document
.
createElement
(
'
div
'
);
this
.
frame
=
document
.
createElement
(
'
div
'
);
this
.
header
=
document
.
createElement
(
'
div
'
);
this
.
header
=
document
.
createElement
(
'
div
'
);
this
.
title
=
document
.
createElement
(
'
span
'
);
this
.
title
=
document
.
createElement
(
'
span
'
);
if
(
this
.
options
.
body
===
null
)
{
this
.
body
=
document
.
createElement
(
'
div
'
);
this
.
body
=
document
.
createElement
(
'
div
'
);
}
else
{
this
.
body
=
Yeti
.
Element
(
this
.
options
.
body
);
}
this
.
frame
.
style
.
zIndex
=
this
.
options
.
zindex
;
this
.
frame
.
style
.
zIndex
=
this
.
options
.
zindex
;
this
.
frame
.
style
.
position
=
'
absolute
'
;
this
.
frame
.
style
.
position
=
'
absolute
'
;
...
@@ -68,11 +75,9 @@
...
@@ -68,11 +75,9 @@
this
.
frame
.
appendChild
(
this
.
header
);
this
.
frame
.
appendChild
(
this
.
header
);
this
.
frame
.
appendChild
(
this
.
body
);
this
.
frame
.
appendChild
(
this
.
body
);
this
.
frame
.
style
.
width
=
this
.
options
.
width
+
'
px
'
;
this
.
frame
.
style
.
height
=
this
.
options
.
height
+
'
px
'
;
this
.
set_title
(
this
.
options
.
title
);
this
.
set_title
(
this
.
options
.
title
);
this
.
set_body
(
this
.
options
.
body
);
this
.
set_sizes
();
this
.
set_position
();
this
.
set_position
();
}
}
...
@@ -82,6 +87,43 @@
...
@@ -82,6 +87,43 @@
}
}
}
}
UI
.
Frame
.
prototype
.
get_frame_size
=
function
()
{
var
size
=
new
Object
(),
props
=
[
'
width
'
,
'
height
'
]
;
for
(
var
i
=
0
,
_len
=
props
.
length
;
i
<
_len
;
i
++
)
{
var
key
=
props
[
i
],
value
=
this
.
options
[
key
]
;
switch
(
typeof
(
value
))
{
case
'
number
'
:
size
[
key
]
=
value
;
break
;
case
'
string
'
:
var
idx_percent
=
value
.
lastIndexOf
(
'
%
'
);
if
(
idx_percent
==
-
1
)
{
size
[
key
]
=
parseInt
(
value
);
}
else
{
var
window_size
=
Yeti
.
DOM
.
getWindowSize
();
size
[
key
]
=
window_size
[
key
]
*
(
parseInt
(
value
.
substring
(
0
,
idx_percent
))
/
100
);
}
break
;
}
}
return
size
;
}
UI
.
Frame
.
prototype
.
set_sizes
=
function
()
{
var
size
=
this
.
get_frame_size
();
this
.
frame
.
style
.
width
=
size
.
width
+
'
px
'
;
this
.
frame
.
style
.
height
=
size
.
height
+
'
px
'
;
this
.
body
.
style
.
height
=
(
size
.
height
-
this
.
header
.
offsetHeight
)
-
20
+
'
px
'
;
}
UI
.
Frame
.
prototype
.
get_position
=
function
()
{
UI
.
Frame
.
prototype
.
get_position
=
function
()
{
var
window_size
=
Yeti
.
DOM
.
getWindowSize
(),
var
window_size
=
Yeti
.
DOM
.
getWindowSize
(),
scroll_offset
=
Yeti
.
DOM
.
getScrollXY
()
scroll_offset
=
Yeti
.
DOM
.
getScrollXY
()
...
@@ -89,7 +131,8 @@
...
@@ -89,7 +131,8 @@
if
(
this
.
options
.
position
==
'
center
'
)
{
if
(
this
.
options
.
position
==
'
center
'
)
{
var
left
=
window_size
.
width
/
2
+
scroll_offset
.
X
,
var
left
=
window_size
.
width
/
2
+
scroll_offset
.
X
,
top
=
window_size
.
height
/
2
+
scroll_offset
.
Y
top
=
window_size
.
height
/
2
+
scroll_offset
.
Y
,
frame_size
=
this
.
get_frame_size
()
;
;
/* Additional border/padding/... ? */
/* Additional border/padding/... ? */
...
@@ -99,14 +142,14 @@
...
@@ -99,14 +142,14 @@
}
}
return
{
return
{
left
:
left
-
this
.
options
.
width
/
2
,
left
:
left
-
frame_size
.
width
/
2
,
top
:
top
-
this
.
options
.
height
/
2
top
:
top
-
frame_size
.
height
/
2
}
}
}
}
}
}
UI
.
Frame
.
prototype
.
set_position
=
function
(
position
)
{
UI
.
Frame
.
prototype
.
set_position
=
function
()
{
var
position
=
position
||
this
.
get_position
();
var
position
=
this
.
get_position
();
this
.
frame
.
style
.
left
=
position
.
left
+
'
px
'
;
this
.
frame
.
style
.
left
=
position
.
left
+
'
px
'
;
this
.
frame
.
style
.
top
=
position
.
top
+
'
px
'
;
this
.
frame
.
style
.
top
=
position
.
top
+
'
px
'
;
...
@@ -117,22 +160,12 @@
...
@@ -117,22 +160,12 @@
this
.
title
.
appendChild
(
document
.
createTextNode
(
value
));
this
.
title
.
appendChild
(
document
.
createTextNode
(
value
));
}
}
UI
.
Frame
.
prototype
.
set_body
=
function
(
value
)
{
var
content
=
Yeti
.
Element
(
value
);
if
(
content
)
{
Yeti
.
DOM
.
removeNodes
(
this
.
body
);
if
(
content
.
style
.
display
==
'
none
'
)
{
content
.
style
.
display
=
'
block
'
;
}
this
.
body
.
appendChild
(
content
);
}
}
UI
.
Frame
.
prototype
.
attach
=
function
()
{
UI
.
Frame
.
prototype
.
attach
=
function
()
{
if
(
this
.
overlay
)
{
if
(
this
.
overlay
)
{
this
.
container
.
appendChild
(
this
.
overlay
);
this
.
container
.
appendChild
(
this
.
overlay
);
}
}
this
.
container
.
appendChild
(
this
.
frame
);
this
.
container
.
appendChild
(
this
.
frame
);
this
.
body
.
style
.
display
=
'
block
'
;
this
.
attached
=
true
;
this
.
attached
=
true
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment