Revision e3235962
Added by Andreas Kohlbecker almost 8 years ago
modules/cdm_dataportal/js/jquery.cdm.taxonomic_children.js | ||
---|---|---|
236 | 236 |
.css('left', trigger_position.left + 'px') |
237 | 237 |
.css('padding-left', this.$element.width() + 'px') |
238 | 238 |
.css('padding-right', this.$element.width() + 'px') |
239 |
.css('z-index', 10) |
|
239 | 240 |
.show(); |
240 | 241 |
|
241 | 242 |
if(!this.isDataLoaded){ |
... | ... | |
243 | 244 |
plugin.handleDataLoaded(html); |
244 | 245 |
}); |
245 | 246 |
} else { |
247 |
this.adjustHeight(); |
|
246 | 248 |
this.scrollToSelected(); |
247 | 249 |
} |
248 | 250 |
}, |
... | ... | |
259 | 261 |
this.isDataLoaded = true; |
260 | 262 |
var listContainer = $(html); |
261 | 263 |
this.children.append(listContainer); |
262 |
var itemsCount = listContainer.children().length;
|
|
264 |
this.itemsCount = listContainer.children().length;
|
|
263 | 265 |
|
264 |
// adjust heights |
|
265 |
var viewPortRows = (itemsCount > this.options.viewPortRows.min ? this.options.viewPortRows.max : this.options.viewPortRows.min); |
|
266 |
this.adjustHeight(); |
|
267 |
this.scrollToSelected(); |
|
268 |
}, |
|
269 |
|
|
270 |
calculateViewPortRows: function() { |
|
271 |
|
|
272 |
var max; |
|
273 |
if(this.options.viewPortRows.max) { |
|
274 |
max = this.options.viewPortRows.max; |
|
275 |
} else { |
|
276 |
// no absolute maximum defined: calculate the current max based on the window viewport |
|
277 |
max = Math.floor( ($(window).height() - this.element.getBoundingClientRect().top) / this.lineHeight) - 2; |
|
278 |
this.log('max: ' + max); |
|
279 |
} |
|
280 |
return (this.itemsCount > this.options.viewPortRows.min ? max : this.options.viewPortRows.min); |
|
281 |
}, |
|
282 |
|
|
283 |
adjustHeight: function(itemsCount){ |
|
284 |
|
|
285 |
var viewPortRows = this.calculateViewPortRows(itemsCount); //(itemsCount > this.options.viewPortRows.min ? this.options.viewPortRows.max : this.options.viewPortRows.min); |
|
266 | 286 |
this.log('itemsCount: ' + itemsCount + ' => viewPortRows: ' + viewPortRows); |
267 | 287 |
|
268 | 288 |
this.container.css('height', viewPortRows * this.lineHeight + 'px'); |
269 | 289 |
this.children |
270 |
.css('padding-top', this.lineHeight + 'px') // one row above current |
|
271 |
.css('padding-bottom', (viewPortRows - 2) * this.lineHeight + 'px'); // subtract 2 lines (current + one above) |
|
272 |
|
|
273 |
this.scrollToSelected(viewPortRows); |
|
290 |
.css('padding-top', this.lineHeight + 'px') // one row above current |
|
291 |
.css('padding-bottom', (viewPortRows - 2) * this.lineHeight + 'px'); // subtract 2 lines (current + one above) |
|
274 | 292 |
}, |
275 | 293 |
|
276 | 294 |
scrollToSelected: function () { |
... | ... | |
379 | 397 |
cdmWebappClassificationRootRequest: "portal/classification/{classificationUuid}/childNodes.json", |
380 | 398 |
proxyRequest: "cdm_api/proxy/{contentRequest}/{renderFunction}", |
381 | 399 |
renderFunction: "cdm_taxontree", |
382 |
viewPortRows: {min: 5, max: 5}
|
|
400 |
viewPortRows: {min: 5, max: undefined}
|
|
383 | 401 |
}; |
384 | 402 |
|
385 | 403 |
})( jQuery, window, document ); |
Also available in: Unified diff
#5852 classification breadcrumbs childlist adapts to windows viewport