1 |
2 |
- |
;(function($) {
|
2 |
|
|
$.extend({
|
3 |
|
|
viewPort : function () {
|
4 |
|
|
var scrollLeft = $(document).scrollLeft();
|
5 |
|
|
var scrollTop = $(document).scrollTop();
|
6 |
|
|
|
7 |
|
|
var windowWidth = $(window).width();// - 20;
|
8 |
|
|
var windowHeight = $(window).height();// - 20;
|
9 |
|
|
|
10 |
|
|
var offsetCenterLeft = windowWidth / 2 + scrollLeft;
|
11 |
|
|
var offsetCenterTop = windowHeight / 2 + scrollTop;
|
12 |
|
|
|
13 |
|
|
return {
|
14 |
|
|
left : scrollLeft,
|
15 |
|
|
right : scrollLeft + windowWidth,
|
16 |
|
|
top : scrollTop,
|
17 |
|
|
bottom : scrollTop + windowHeight,
|
18 |
|
|
center : { left : offsetCenterLeft, top : offsetCenterTop }
|
19 |
|
|
}
|
20 |
|
|
}
|
21 |
|
|
});
|
22 |
|
|
})(jQuery);
|
23 |
|
|
|
24 |
|
|
;(function($) {
|
25 |
|
|
$.fn.extend({
|
26 |
|
|
tableTracking: function(settings) {
|
27 |
|
|
var options = {
|
28 |
|
|
colCSS : {
|
29 |
|
|
backgroundColor : '#eeeeee'
|
30 |
|
|
},
|
31 |
|
|
rowCSS : {
|
32 |
|
|
backgroundColor : '#dddddd'
|
33 |
|
|
},
|
34 |
|
|
cellCSS : {
|
35 |
|
|
backgroundColor : '#aaaaaa'
|
36 |
|
|
},
|
37 |
|
|
toolTip : {
|
38 |
|
|
offsetTop : -5,
|
39 |
|
|
offsetLeft : -5,
|
40 |
|
|
css : {
|
41 |
|
|
border : 'black 2px solid',
|
42 |
|
|
position : 'absolute',
|
43 |
|
|
/*height : '100px',
|
44 |
|
|
width : '100px',*/
|
45 |
|
|
backgroundColor : 'white'
|
46 |
|
|
}
|
47 |
|
|
},
|
48 |
|
|
delay : 0,
|
49 |
|
|
follow : true,
|
50 |
|
|
clickLock : true,
|
51 |
|
|
forceHorizontalViewPort : true,
|
52 |
|
|
forceVirticalViewPort : false
|
53 |
|
|
}
|
54 |
|
|
|
55 |
|
|
|
56 |
|
|
var lastCell = null;
|
57 |
|
|
var lastCellIndex = null;
|
58 |
|
|
var lastRowIndex = null;
|
59 |
|
|
|
60 |
|
|
$.extend(options, settings);
|
61 |
|
|
|
62 |
|
|
return this.each(function() {
|
63 |
|
|
var $activeTip = null;
|
64 |
|
|
|
65 |
|
|
if (this.tagName == 'TABLE') {
|
66 |
|
|
$(this).find('td').each(function () {
|
67 |
|
|
//var $cell = $(this);
|
68 |
|
|
var timer = null;
|
69 |
|
|
if (options.follow) {
|
70 |
|
|
this.onmouseover = function (e) {
|
71 |
|
|
e = e || event;
|
72 |
|
|
var target = e.target || e.srcElement;
|
73 |
|
|
|
74 |
|
|
if (options.delay) {
|
75 |
|
|
timer = setTimeout(function (){ cellMouseOver(target) }, options.delay)
|
76 |
|
|
}
|
77 |
|
|
else {
|
78 |
|
|
cellMouseOver(target)
|
79 |
|
|
}
|
80 |
|
|
|
81 |
|
|
}
|
82 |
|
|
this.onmouseout = function (e) {
|
83 |
|
|
e = e || event;
|
84 |
|
|
var target = e.target || e.srcElement;
|
85 |
|
|
|
86 |
|
|
if (timer) {
|
87 |
|
|
clearTimeout(timer);
|
88 |
|
|
timer = null;
|
89 |
|
|
}
|
90 |
|
|
|
91 |
|
|
cellMouseOut(target);
|
92 |
|
|
}
|
93 |
|
|
}
|
94 |
|
|
else {
|
95 |
|
|
this.onclick = function (e) {
|
96 |
|
|
e = e || event;
|
97 |
|
|
var target = e.target || e.srcElement;
|
98 |
|
|
cellClick(target)
|
99 |
|
|
}
|
100 |
|
|
}
|
101 |
|
|
});
|
102 |
|
|
}
|
103 |
|
|
|
104 |
|
|
function cellClick(cell) {
|
105 |
|
|
if (lastCell) {
|
106 |
|
|
cellMouseOut(lastCell);
|
107 |
|
|
}
|
108 |
|
|
|
109 |
|
|
cellMouseOver(cell);
|
110 |
|
|
lastCell = cell;
|
111 |
|
|
}
|
112 |
|
|
|
113 |
|
|
function rowMouseOver (row) {
|
114 |
|
|
for (var x = 0 ; x < row.cells.length; x++) {
|
115 |
|
|
swapCSS(row.cells[x], options.rowCSS);
|
116 |
|
|
}
|
117 |
|
|
}
|
118 |
|
|
|
119 |
|
|
function rowMouseOut (row) {
|
120 |
|
|
for (var x = 0 ; x < row.cells.length; x++) {
|
121 |
|
|
swapCSS(row.cells[x]);
|
122 |
|
|
}
|
123 |
|
|
}
|
124 |
|
|
|
125 |
|
|
function cellMouseOver (cell) {
|
126 |
|
|
colMouseOver(cell.parentNode.parentNode, cell.cellIndex);
|
127 |
|
|
rowMouseOver(cell.parentNode);
|
128 |
|
|
swapCSS(cell, options.cellCSS);
|
129 |
|
|
displayTip(cell);
|
130 |
|
|
|
131 |
|
|
/*if (cell.cellIndex != lastCellIndex && lastCellIndex != null) {
|
132 |
|
|
colMouseOut(cell.parentNode.parentNode, lastCellIndex);
|
133 |
|
|
}
|
134 |
|
|
|
135 |
|
|
if (cell.parentNode.rowIndex != lastRowIndex && lastRowIndex != null) {
|
136 |
|
|
rowMouseOut(cell.parentNode.parentNode.rows[lastRowIndex]);
|
137 |
|
|
}
|
138 |
|
|
|
139 |
|
|
lastCellIndex = cell.cellIndex;
|
140 |
|
|
lastRowIndex = cell.parentNode.rowIndex;*/
|
141 |
|
|
}
|
142 |
|
|
|
143 |
|
|
function cellMouseOut (cell) {
|
144 |
|
|
colMouseOut(cell.parentNode.parentNode, cell.cellIndex);
|
145 |
|
|
rowMouseOut(cell.parentNode);
|
146 |
|
|
swapCSS(cell);
|
147 |
|
|
hideTip();
|
148 |
|
|
}
|
149 |
|
|
|
150 |
|
|
function colMouseOver (table, colIndex) {
|
151 |
|
|
for (var x = 0; x < table.rows.length; x++) {
|
152 |
|
|
var row = table.rows[x];
|
153 |
|
|
|
154 |
|
|
if (row.cells.length > colIndex) {
|
155 |
|
|
swapCSS(row.cells[colIndex], options.colCSS);
|
156 |
|
|
}
|
157 |
|
|
}
|
158 |
|
|
}
|
159 |
|
|
|
160 |
|
|
function colMouseOut (table, colIndex) {
|
161 |
|
|
var x;
|
162 |
|
|
for (x = 0; x < table.rows.length; x++) {
|
163 |
|
|
var row = table.rows[x];
|
164 |
|
|
|
165 |
|
|
if (row.cells.length > colIndex) {
|
166 |
|
|
swapCSS(row.cells[colIndex]);
|
167 |
|
|
}
|
168 |
|
|
}
|
169 |
|
|
}
|
170 |
|
|
|
171 |
|
|
function displayTip (cell) {
|
172 |
|
|
if (options.tipContents) {
|
173 |
|
|
var $cell = $(cell);
|
174 |
|
|
var contents = options.tipContents(cell);
|
175 |
|
|
var container = getTipContainer(cell);
|
176 |
|
|
container.css ({
|
177 |
|
|
top : $cell.offset().top + $cell.outerHeight() + options.toolTip.offsetTop,
|
178 |
|
|
left : $cell.offset().left + $cell.outerWidth() + options.toolTip.offsetLeft
|
179 |
|
|
})
|
180 |
|
|
|
181 |
|
|
container.html('');
|
182 |
|
|
|
183 |
|
|
container.append(contents);
|
184 |
|
|
container.css({ display : 'inline'})//.dropShadow();
|
185 |
|
|
}
|
186 |
|
|
}
|
187 |
|
|
|
188 |
|
|
function hideTip () {
|
189 |
|
|
if ($activeTip) {
|
190 |
|
|
$activeTip.css({ display : 'none'})
|
191 |
|
|
}
|
192 |
|
|
}
|
193 |
|
|
|
194 |
|
|
function monitorActiveTip() {
|
195 |
|
|
var scrolling = false;
|
196 |
|
|
|
197 |
|
|
$(window).bind('scrollstart', function () { scrolling = true });
|
198 |
|
|
$(window).bind('scrollstop', function () { scrolling = false });
|
199 |
|
|
|
200 |
|
|
var interval = setInterval(function () {
|
201 |
|
|
if (!scrolling && $activeTip.css('display') != "none") {
|
202 |
|
|
//alert($activeTip.css('display'));
|
203 |
|
|
var outerWidth = $activeTip.outerWidth();
|
204 |
|
|
var outerHeight = $activeTip.outerHeight();
|
205 |
|
|
|
206 |
|
|
var viewPort = $.viewPort();
|
207 |
|
|
var position = $activeTip.position();
|
208 |
|
|
|
209 |
|
|
if (position.left + outerWidth > viewPort.right ) {
|
210 |
|
|
$activeTip.css({
|
211 |
|
|
left : viewPort.right - outerWidth
|
212 |
|
|
});
|
213 |
|
|
}
|
214 |
|
|
else if ( position.left < viewPort.left ) {
|
215 |
|
|
$activeTip.css({
|
216 |
|
|
left : viewPort.left
|
217 |
|
|
});
|
218 |
|
|
}
|
219 |
|
|
|
220 |
|
|
/*if (position.top + outerHeight > viewPort.bottom) {
|
221 |
|
|
$activeTip.css({
|
222 |
|
|
top : viewPort.bottom - outerHeight
|
223 |
|
|
});
|
224 |
|
|
}
|
225 |
|
|
else if ( position.top < viewPort.top) {
|
226 |
|
|
$activeTip.css({
|
227 |
|
|
top : viewPort.top
|
228 |
|
|
});
|
229 |
|
|
}*/
|
230 |
|
|
}
|
231 |
|
|
}, 100);
|
232 |
|
|
}
|
233 |
|
|
|
234 |
|
|
function getTipContainer(appendTo) {
|
235 |
|
|
|
236 |
|
|
if (!$activeTip) {
|
237 |
|
|
$activeTip = $('<div />').css(options.toolTip.css).appendTo(appendTo);
|
238 |
|
|
|
239 |
|
|
if (options.forceHorizontalViewPort || options.forceVerticalViewPort) {
|
240 |
|
|
monitorActiveTip();
|
241 |
|
|
}
|
242 |
|
|
}
|
243 |
|
|
|
244 |
|
|
return $activeTip;
|
245 |
|
|
}
|
246 |
|
|
|
247 |
|
|
function swapCSS(obj, css) {
|
248 |
|
|
var $obj = $(obj);
|
249 |
|
|
|
250 |
|
|
if (!obj.origCSS) {
|
251 |
|
|
obj.origCSS = { };
|
252 |
|
|
}
|
253 |
|
|
|
254 |
|
|
if (obj.origCSS && !css) {
|
255 |
|
|
for (var at in obj.origCSS) {
|
256 |
|
|
var val = (obj.origCSS[at]) ? obj.origCSS[at] : '';
|
257 |
|
|
obj.style[at] = val;
|
258 |
|
|
}
|
259 |
|
|
|
260 |
|
|
obj.currCSS = null;
|
261 |
|
|
obj.origCSS = null;
|
262 |
|
|
}
|
263 |
|
|
else if (obj.currCSS != css) {
|
264 |
|
|
for (var attr in css) {
|
265 |
|
|
var currVal = $obj.css(attr)
|
266 |
|
|
if (!obj.origCSS[attr]) {
|
267 |
|
|
obj.origCSS[attr] = currVal; //(currVal) ? currVal : 'none';
|
268 |
|
|
}
|
269 |
|
|
}
|
270 |
|
|
|
271 |
|
|
obj.currCSS = css;
|
272 |
|
|
$obj.css(css);
|
273 |
|
|
}
|
274 |
|
|
}
|
275 |
|
|
})
|
276 |
|
|
|
277 |
|
|
}
|
278 |
|
|
});
|
279 |
|
|
})(jQuery);
|