mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-01-31 16:41:04 -05:00
Modification de la zone du viewport qui faisait toute la taille de l'écran. Désormais le viewport va du haut de l'écran jusqu'à sa moitié Modification de la zone de marquage en la réduisant : début au 3/4 de l'article et fin 50px plus loin (ou bas de l'article si dépasse)
327 lines
7.4 KiB
PHTML
327 lines
7.4 KiB
PHTML
<?php if ($this->conf->displayPosts () == 'no') { ?>
|
|
var hide_posts = true;
|
|
<?php } else { ?>
|
|
var hide_posts = false;
|
|
<?php } ?>
|
|
|
|
<?php
|
|
$s = $this->conf->shortcuts ();
|
|
$mark = $this->conf->markWhen ();
|
|
?>
|
|
|
|
function is_reader_mode() {
|
|
var stream = $("#stream.reader");
|
|
return stream.html() != null;
|
|
}
|
|
|
|
function is_normal_mode() {
|
|
var stream = $("#stream.normal");
|
|
return stream.html() != null;
|
|
}
|
|
|
|
function redirect (url, new_tab) {
|
|
if (url) {
|
|
if (new_tab) {
|
|
window.open (url);
|
|
} else {
|
|
location.href = url;
|
|
}
|
|
}
|
|
}
|
|
|
|
function toggleContent (new_active, old_active) {
|
|
old_active.removeClass ("active");
|
|
if (old_active[0] != new_active[0]) {
|
|
new_active.addClass ("active");
|
|
}
|
|
|
|
if (hide_posts) {
|
|
old_active.children (".flux_content").toggle (0);
|
|
|
|
if (old_active[0] != new_active[0]) {
|
|
new_active.children (".flux_content").toggle (0, function () {
|
|
$("html,body").scrollTop (new_active.position ().top);
|
|
});
|
|
}
|
|
} else {
|
|
$("html,body").scrollTop (new_active.position ().top);
|
|
}
|
|
|
|
<?php if ($mark['article'] == 'yes') { ?>
|
|
mark_read(new_active, true);
|
|
<?php } ?>
|
|
}
|
|
|
|
function mark_read (active, only_not_read) {
|
|
if (active[0] === undefined || (
|
|
only_not_read === true && !active.hasClass("not_read"))) {
|
|
return false;
|
|
}
|
|
|
|
if (active.hasClass ("not_read")) {
|
|
active.removeClass ("not_read");
|
|
} else {
|
|
active.addClass ("not_read");
|
|
}
|
|
|
|
url = active.find ("a.read").attr ("href");
|
|
if (url === undefined) {
|
|
return false;
|
|
}
|
|
|
|
$.ajax ({
|
|
type: 'POST',
|
|
url: url,
|
|
data : { ajax: true }
|
|
}).done (function (data) {
|
|
res = jQuery.parseJSON(data);
|
|
|
|
active.find ("a.read").attr ("href", res.url);
|
|
});
|
|
}
|
|
|
|
function mark_favorite (active) {
|
|
if (active[0] === undefined) {
|
|
return false;
|
|
}
|
|
|
|
url = active.find ("a.bookmark").attr ("href");
|
|
if (url === undefined) {
|
|
return false;
|
|
}
|
|
|
|
$.ajax ({
|
|
type: 'POST',
|
|
url: url,
|
|
data : { ajax: true }
|
|
}).done (function (data) {
|
|
res = jQuery.parseJSON(data);
|
|
|
|
active.find ("a.bookmark").attr ("href", res.url);
|
|
if (active.hasClass ("favorite")) {
|
|
active.removeClass ("favorite");
|
|
} else {
|
|
active.addClass ("favorite");
|
|
}
|
|
});
|
|
}
|
|
|
|
function prev_entry() {
|
|
old_active = $(".flux.active");
|
|
last_active = $(".flux:last");
|
|
new_active = old_active.prevAll (".flux:first");
|
|
|
|
if (new_active.hasClass("flux")) {
|
|
toggleContent (new_active, old_active);
|
|
} else if (old_active[0] === undefined &&
|
|
new_active[0] === undefined) {
|
|
toggleContent (last_active, old_active);
|
|
}
|
|
}
|
|
|
|
function next_entry() {
|
|
old_active = $(".flux.active");
|
|
first_active = $(".flux:first");
|
|
new_active = old_active.nextAll (".flux:first");
|
|
|
|
if (new_active.hasClass("flux")) {
|
|
toggleContent (new_active, old_active);
|
|
} else if (old_active[0] === undefined &&
|
|
new_active[0] === undefined) {
|
|
toggleContent (first_active, old_active);
|
|
}
|
|
}
|
|
|
|
function init_img () {
|
|
$(".flux_content .content img").each (function () {
|
|
if ($(this).width () > ($(".flux_content .content").width()) / 2) {
|
|
$(this).addClass("big");
|
|
}
|
|
});
|
|
}
|
|
|
|
function inMarkViewport(flux) {
|
|
var top = flux.position().top;
|
|
var height = flux.height();
|
|
var begin = top + 3 * height / 4;
|
|
var bot = Math.min(begin + 75, top + height);
|
|
|
|
var windowTop = $(window).scrollTop();
|
|
var windowBot = windowTop + $(window).height() / 2;
|
|
|
|
return (windowBot >= begin && windowBot <= bot);
|
|
}
|
|
|
|
function init_posts () {
|
|
init_img ();
|
|
<?php if($this->conf->lazyload() == 'yes') { ?>
|
|
$(".flux .content img").lazyload();
|
|
<?php } ?>
|
|
|
|
if (hide_posts) {
|
|
$(".flux:not(.active) .flux_content").hide ();
|
|
}
|
|
|
|
var flux_header_toggle = $(".flux_header .item.title, .flux_header .item.date");
|
|
flux_header_toggle.unbind('click'); // évite d'associer 2 fois le toggle
|
|
flux_header_toggle.click (function () {
|
|
old_active = $(".flux.active");
|
|
new_active = $(this).parent ().parent ();
|
|
|
|
toggleContent (new_active, old_active);
|
|
});
|
|
|
|
$(".flux a.read").click (function () {
|
|
active = $(this).parents (".flux");
|
|
mark_read (active, false);
|
|
|
|
return false;
|
|
});
|
|
|
|
$(".flux a.bookmark").click (function () {
|
|
active = $(this).parents (".flux");
|
|
mark_favorite (active);
|
|
|
|
return false;
|
|
});
|
|
|
|
$(".flux .content a").click (function () {
|
|
$(this).attr ('target', '_blank');
|
|
});
|
|
|
|
<?php if ($mark['site'] == 'yes') { ?>
|
|
$(".flux .link a").click (function () {
|
|
mark_read($(this).parent().parent().parent(), true);
|
|
});
|
|
<?php } ?>
|
|
|
|
<?php if ($mark['scroll'] == 'yes') { ?>
|
|
$(window).scroll(function() {
|
|
$('.flux.not_read:visible').each(function() {
|
|
if($(this).children(".flux_content").is(':visible') &&
|
|
inMarkViewport($(this))) {
|
|
mark_read($(this), true);
|
|
}
|
|
});
|
|
});
|
|
<?php } ?>
|
|
}
|
|
|
|
function init_column_categories () {
|
|
if(!is_normal_mode()) {
|
|
return;
|
|
}
|
|
|
|
$(".category").addClass ("stick");
|
|
$(".categories .category .btn:first-child").width ("160px");
|
|
$(".category").append ("<a class=\"btn dropdown-toggle\" href=\"#\"><i class=\"icon i_down\"></i></a>");
|
|
|
|
$(".category + .feeds").not(".active").hide();
|
|
$(".category.active a.dropdown-toggle i").toggleClass ("i_up");
|
|
|
|
$(".category a.dropdown-toggle").click (function () {
|
|
$(this).children ().toggleClass ("i_up");
|
|
$(this).parent ().next (".feeds").slideToggle();
|
|
return false;
|
|
});
|
|
}
|
|
|
|
function init_shortcuts () {
|
|
// Touches de manipulation
|
|
shortcut.add("<?php echo $s['mark_read']; ?>", function () {
|
|
// on marque comme lu ou non lu
|
|
active = $(".flux.active");
|
|
mark_read (active, false);
|
|
}, {
|
|
'disable_in_input':true
|
|
});
|
|
shortcut.add("shift+<?php echo $s['mark_read']; ?>", function () {
|
|
// on marque tout comme lu
|
|
url = $(".nav_menu a.read_all").attr ("href");
|
|
redirect (url, false);
|
|
}, {
|
|
'disable_in_input':true
|
|
});
|
|
shortcut.add("<?php echo $s['mark_favorite']; ?>", function () {
|
|
// on marque comme favori ou non favori
|
|
active = $(".flux.active");
|
|
mark_favorite (active);
|
|
}, {
|
|
'disable_in_input':true
|
|
});
|
|
|
|
// Touches de navigation
|
|
shortcut.add("<?php echo $s['prev_entry']; ?>", prev_entry, {
|
|
'disable_in_input':true
|
|
});
|
|
shortcut.add("shift+<?php echo $s['prev_entry']; ?>", function () {
|
|
old_active = $(".flux.active");
|
|
first = $(".flux:first");
|
|
|
|
if (first.hasClass("flux")) {
|
|
toggleContent (first, old_active);
|
|
}
|
|
}, {
|
|
'disable_in_input':true
|
|
});
|
|
shortcut.add("<?php echo $s['next_entry']; ?>", next_entry, {
|
|
'disable_in_input':true
|
|
});
|
|
shortcut.add("shift+<?php echo $s['next_entry']; ?>", function () {
|
|
old_active = $(".flux.active");
|
|
last = $(".flux:last");
|
|
|
|
if (last.hasClass("flux")) {
|
|
toggleContent (last, old_active);
|
|
}
|
|
}, {
|
|
'disable_in_input':true
|
|
});
|
|
shortcut.add("<?php echo $s['next_page']; ?>", function () {
|
|
url = $(".pager-next a").attr ("href");
|
|
redirect (url, false);
|
|
}, {
|
|
'disable_in_input':true
|
|
});
|
|
shortcut.add("<?php echo $s['prev_page']; ?>", function () {
|
|
url = $(".pager-previous a").attr ("href");
|
|
redirect (url, false);
|
|
}, {
|
|
'disable_in_input':true
|
|
});
|
|
shortcut.add("<?php echo $s['go_website']; ?>", function () {
|
|
url = $(".flux.active .link a").attr ("href");
|
|
|
|
<?php if ($mark['site'] == 'yes') { ?>
|
|
$(".flux.active").each (function () {
|
|
mark_read($(this), true);
|
|
});
|
|
<?php } ?>
|
|
|
|
redirect (url, true);
|
|
}, {
|
|
'disable_in_input':true
|
|
});
|
|
}
|
|
|
|
function init_nav_entries() {
|
|
$('.nav_entries a.previous_entry').click(function() {
|
|
prev_entry();
|
|
return false;
|
|
});
|
|
$('.nav_entries a.next_entry').click(function() {
|
|
next_entry();
|
|
return false;
|
|
});
|
|
}
|
|
|
|
$(document).ready (function () {
|
|
if(is_reader_mode()) {
|
|
hide_posts = false;
|
|
}
|
|
init_posts ();
|
|
init_column_categories ();
|
|
init_shortcuts ();
|
|
init_nav_entries();
|
|
});
|