forked from uq-eresearch/austese_collation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtableui.tpl.php
132 lines (129 loc) · 3.55 KB
/
tableui.tpl.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<link rel="stylesheet" href="/sites/all/libraries/ext-4.1.1a/resources/css/ext-all.css">
<link rel="stylesheet" href="/sites/all/libraries/ext-4.1.1a/resources/css/ext-all-gray.css">
<?php
$modulePrefix = arg(0);
$fullscreen = false;
if (!ISSET($project) && isset($_GET['project'])) {
$project = $_GET['project'];
} else {
$project = "";
}
?>
<div id="metadata"
<?php if (ISSET($project) && austese_access('edit metadata', $project)): ?>
data-editable="true"
<?php endif; ?>
<?php if ($fullscreen):?>
data-fullscreen="<?php print $fullscreen; ?>"
<?php endif; ?>
data-project="<?php print $project; ?>"
data-moduleprefix="<?php print $modulePrefix; ?>"
data-modulepath="<?php print drupal_get_path('module', 'collation'); ?>"
data-baseurl="http://<?php print $_SERVER['SERVER_NAME']; ?>"
<?php if (ISSET($project)):?>
data-project="<?php print $project; ?>"
<?php endif; ?>
>
</div>
<div id="uiplaceholder"></div>
<script type="text/javascript">
var leftScrollPos,rightScrollPos;
var scrolledDiff;
var scrolledSpan;
function getOffsetTopByElem( elem )
{
var offset = 0;
while ( elem != null )
{
offset += elem.offsetTop;
elem = elem.offsetParent;
}
return offset;
}
function getElementHeight( elem )
{
if ( elem.height )
return elem.height;
else
return elem.offsetHeight;
}
function getHeight( elem, inclBorder )
{
var borderHeight = getBorderValue(elem,"border-top-width")
+getBorderValue(elem,"border-bottom-width");
if ( elem.clientHeight )
return (inclBorder)?borderHeight+elem.clientHeight
:elem.clientHeight;
else
return (inclBorder)?elem.offsetHeight
:elem.offsetHeight-borderHeight;
}
function getOffsetTop( id )
{
var elem = document.getElementById(id);
return getOffsetTopForElem( elem );
}
function getOffsetTopForElem( elem )
{
var offset = 0;
while ( elem != null )
{
offset += elem.offsetTop;
elem = elem.offsetParent;
}
return offset;
}
function synchroScroll(scrolledDiv,staticDiv)
{
// 2. find the most central span in the scrolled div
scrolledDiff = 4294967296;
scrolledSpan = null;
var scrolledDivTop = getOffsetTopByElem( scrolledDiv );
var staticDivTop = getOffsetTopByElem( staticDiv );
var centre = getElementHeight(scrolledDiv)/2
+scrolledDiv.scrollTop;
findSpanAtOffset( scrolledDiv, centre, scrolledDivTop );
// 3. find the corresponding span on the other side
if ( scrolledSpan != null )
{
var staticId = scrolledSpan.getAttribute("id");
if ( staticId.charAt(0)=='a' )
staticId = "d"+staticId.substring(1);
else
staticId = "a"+staticId.substring(1);
var staticSpan = document.getElementById( staticId );
if ( staticSpan != null )
{
// 4. compute relative topOffset of scrolledSpan
var scrolledTopOffset = scrolledSpan.offsetTop
-scrolledDivTop;
// 5. compute relative topOffset of staticSpan
var staticTopOffset = staticSpan.offsetTop-staticDivTop;
// 6. scroll the static div level with scrolledSpan
var top = staticTopOffset-getElementHeight(staticDiv)/2;
if ( top < 0 )
staticDiv.scrollTop = 0;
else
staticDiv.scrollTop = top;
}
}
}
function findSpanAtOffset( elem, pos, divOffset )
{
if ( elem.nodeName == "SPAN"
&& elem.getAttribute('id') != null )
{
var idAttr = elem.getAttribute('id');
var spanRelOffset = elem.offsetTop-divOffset;
if ( Math.abs(spanRelOffset-pos) < scrolledDiff )
{
scrolledSpan = elem;
scrolledDiff = Math.abs(spanRelOffset-pos);
}
}
else if ( elem.firstChild != null )
findSpanAtOffset( elem.firstChild, pos, divOffset );
if ( elem.nextSibling != null )
findSpanAtOffset( elem.nextSibling, pos, divOffset );
}
</script>