Revision 9278d6a7
Added by Andreas Kohlbecker over 7 years ago
modules/cdm_dataportal/cdm_taxontree/js/cdm_taxontree.js | ||
---|---|---|
18 | 18 |
|
19 | 19 |
$.fn.cdm_taxontree = function(options) { |
20 | 20 |
|
21 |
// firebug console stub (avoids errors if firebug is not active) |
|
22 |
if(typeof console === "undefined") { |
|
23 |
console = { log: function() { } }; |
|
24 |
} |
|
25 |
|
|
21 | 26 |
var opts = $.extend({}, $.fn.cdm_taxontree.defaults, options); |
22 | 27 |
|
23 | 28 |
var vertical_scroller_selector = 'cdm_taxontree_scroller_xy'; |
... | ... | |
36 | 41 |
handle_taxon_node_click(event); |
37 | 42 |
} |
38 | 43 |
); |
39 |
// Stop event propagation for links (unclear why this is nessecary,
|
|
44 |
// Stop event propagation for links (unclear why this is necessary,
|
|
40 | 45 |
// was this needed for the filter buttons?) |
41 | 46 |
cdm_taxontree_list.delegate("li a", "click", function(event) { |
42 | 47 |
event.stopPropagation(); |
... | ... | |
161 | 166 |
function scrollToFocused() { |
162 | 167 |
var focusedElement = cdm_taxontree_parent.find('.focused'); |
163 | 168 |
if(focusedElement.length > 0){ |
164 |
var lineHeight = focusedElement.css('line-height'); |
|
165 |
lineHeight = lineHeight.replace('px', ''); |
|
166 |
lineHeight = lineHeight.length == 0 ? 18 : lineHeight; |
|
167 |
cdm_taxontree_parent.find('div.' + vertical_scroller_selector).scrollTop(focusedElement.position().top - (4 * lineHeight)); |
|
169 |
var lineHeight = focusedElement.css('line-height'); |
|
170 |
lineHeight = lineHeight.replace('px', ''); |
|
171 |
lineHeight = lineHeight.length == 0 ? 18 : lineHeight; |
|
172 |
console.log("cdm_taxontree.scrollToFocused() - lineHeight:" + lineHeight); |
|
173 |
console.log("cdm_taxontree.scrollToFocused() - focusedElement.position().top: " + focusedElement.position().top); |
|
174 |
|
|
175 |
// IMPORTANT !!!!!! |
|
176 |
// In some cases (cichorieae theme related?) the scroll to moves the div to a wrong position |
|
177 |
// Doing it twice, solves the problem |
|
178 |
cdm_taxontree_parent.find('div.' + vertical_scroller_selector).scrollTop(focusedElement.position().top - (4 * lineHeight)); |
|
179 |
cdm_taxontree_parent.find('div.' + vertical_scroller_selector).scrollTop(focusedElement.position().top - (4 * lineHeight)); |
|
168 | 180 |
} |
169 | 181 |
|
170 | 182 |
} |
Also available in: Unified diff
solving autoscroll problems in taxon tree