1
0
Fork 0

frio: fix for display auto position scroll + some cleanup

This commit is contained in:
rabuzarus 2016-08-10 13:07:13 +02:00
commit 7e65d84577
3 changed files with 31 additions and 14 deletions

View file

@ -0,0 +1,11 @@
/**
* @brief Javascript for the display module
*/
// Catch the GUID from the URL
var itemID = window.location.pathname.split("/").pop();
$(document).ready(function(){
// Scroll to the Item by its GUID
scrollToItem(itemID);
});

View file

@ -542,3 +542,22 @@ String.prototype.rtrim = function() {
var trimmed = this.replace(/\s+$/g, '');
return trimmed;
};
// Scroll to a specific item and highlight it
// Note: jquery.color.js is needed
function scrollToItem(itemID) {
if( typeof searchValue === "undefined")
return;
// Define the colors which are used for highlighting
var colWhite = {backgroundColor:'#F5F5F5'};
var colShiny = {backgroundColor:'#FFF176'};
// Scroll to the DIV with the ID (GUID)
$('html, body').animate({
scrollTop: $('#item-'+itemID).position().top
}, 400, function() {
// Highlight post/commenent with ID (GUID)
$('#item-'+itemID).animate(colWhite, 1000).animate(colShiny).animate(colWhite, 2000);
});
}