1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/freshrss_ynh.git synced 2024-09-03 18:36:33 +02:00
freshrss_ynh/sources/p/scripts/global_view.js
2015-02-08 18:55:48 +01:00

85 lines
1.9 KiB
JavaScript
Executable file

"use strict";
var panel_loading = false;
function load_panel(link) {
if (panel_loading) {
return;
}
panel_loading = true;
$.get(link, function (data) {
$("#panel").append($(".nav_menu, #stream .day, #stream .flux, #stream .pagination, #stream.prompt", data));
$("#panel .nav_menu").children().not("#nav_menu_read_all").remove();
init_load_more($("#panel"));
init_posts();
$("#overlay").fadeIn();
$("#panel").slideToggle();
// force le démarrage du scroll en haut.
// Sans ça, si l'on scroll en lisant une catégorie par exemple,
// en en ouvrant une autre ensuite, on se retrouve au même point de scroll
$("#panel").scrollTop(0);
$('#panel').on('click', '#nav_menu_read_all button, #bigMarkAsRead', function () {
console.log($(this).attr("formaction"));
$.ajax({
type: "POST",
url: $(this).attr("formaction"),
async: false
});
window.location.reload(false);
return false;
});
panel_loading = false;
});
}
function init_close_panel() {
$("#overlay .close").click(function () {
$("#panel").html('');
$("#panel").slideToggle();
$("#overlay").fadeOut();
return false;
});
}
function init_global_view() {
// TODO: should be based on generic classes.
$(".box a").click(function () {
var link = $(this).attr("href");
load_panel(link);
return false;
});
$(".nav_menu #nav_menu_read_all, .nav_menu .toggle_aside").remove();
init_stream($("#panel"));
}
function init_all_global_view() {
if (!(window.$ && window.init_stream)) {
if (window.console) {
console.log('FreshRSS Global view waiting for JS…');
}
window.setTimeout(init_all_global_view, 50); //Wait for all js to be loaded
return;
}
init_global_view();
init_close_panel();
}
if (document.readyState && document.readyState !== 'loading') {
init_all_global_view();
} else if (document.addEventListener) {
document.addEventListener('DOMContentLoaded', function () {
init_all_global_view();
}, false);
}