A free, self-hostable news aggregator…
Begin to fix JS for new aside
Marien Fressinaud4204336bd67f
diff --git a/app/layout/aside_feed.phtml b/app/layout/aside_feed.phtmlindex 66b7b51af..d7b12426b 100644--- a/app/layout/aside_feed.phtml+++ b/app/layout/aside_feed.phtml@@ -22,15 +22,15 @@<form id="mark-read-aside" method="post" style="display: none"></form><ul class="tree">- <li class="tree-folder<?php echo FreshRSS_Context::isCurrentGet('a') ? ' active' : ''; ?>">+ <li class="tree-folder all<?php echo FreshRSS_Context::isCurrentGet('a') ? ' active' : ''; ?>"><div class="tree-folder-title">- <?php echo _i('all'); ?> <a data-unread="<?php echo format_number(FreshRSS_Context::$total_unread); ?>" href="<?php echo _url('index', 'index'); ?>"><?php echo _t('main_stream'); ?></a>+ <?php echo _i('all'); ?> <a class="title" data-unread="<?php echo format_number(FreshRSS_Context::$total_unread); ?>" href="<?php echo _url('index', 'index'); ?>"><?php echo _t('main_stream'); ?></a></div></li>- <li class="tree-folder<?php echo FreshRSS_Context::isCurrentGet('s') ? ' active' : ''; ?>">+ <li class="tree-folder favorites<?php echo FreshRSS_Context::isCurrentGet('s') ? ' active' : ''; ?>"><div class="tree-folder-title">- <?php echo _i('bookmark'); ?> <a data-unread="<?php echo format_number(FreshRSS_Context::$total_starred['unread']); ?>" href="<?php echo _url('index', 'index', 'get', 's'); ?>"><?php echo _t('favorite_feeds', format_number(FreshRSS_Context::$total_starred['all'])); ?></a>+ <?php echo _i('bookmark'); ?> <a class="title" data-unread="<?php echo format_number(FreshRSS_Context::$total_starred['unread']); ?>" href="<?php echo _url('index', 'index', 'get', 's'); ?>"><?php echo _t('favorite_feeds', format_number(FreshRSS_Context::$total_starred['all'])); ?></a></div></li>@@ -44,7 +44,8 @@?><li class="tree-folder<?php echo $c_active ? ' active' : ''; ?>" data-unread="<?php echo $cat->nbNotRead(); ?>"><div class="tree-folder-title">- <?php echo _i('category'); ?> <a data-unread="<?php echo format_number($cat->nbNotRead()); ?>" href="<?php echo _url('index', 'index', 'get', 'c_' . $cat->id()); ?>"><?php echo $cat->name(); ?></a>+ <a class="dropdown-toggle" href="#"><?php echo _i($c_show ? 'up' : 'down'); ?></a>+ <a class="title" data-unread="<?php echo format_number($cat->nbNotRead()); ?>" href="<?php echo _url('index', 'index', 'get', 'c_' . $cat->id()); ?>"><?php echo $cat->name(); ?></a></div><ul class="tree-folder-items<?php echo $c_show ? ' active' : ''; ?>">@@ -52,14 +53,14 @@foreach ($feeds as $feed) {$f_active = FreshRSS_Context::isCurrentGet('f_' . $feed->id());?>- <li class="item<?php echo $f_active ? ' active' : ''; ?><?php echo $feed->inError() ? ' error' : ''; ?><?php echo $feed->nbEntries() <= 0 ? ' empty' : ''; ?>" data-unread="<?php echo $feed->nbNotRead(); ?>">+ <li id="f_<?php echo $feed->id(); ?>" class="item<?php echo $f_active ? ' active' : ''; ?><?php echo $feed->inError() ? ' error' : ''; ?><?php echo $feed->nbEntries() <= 0 ? ' empty' : ''; ?>" data-unread="<?php echo $feed->nbNotRead(); ?>" data-priority="<?php echo $feed->priority(); ?>"><div class="dropdown"><div class="dropdown-target"></div><a class="dropdown-toggle" data-fweb="<?php echo $feed->website(); ?>"><?php echo _i('configure'); ?></a><?php /* feed_config_template */ ?></div><img class="favicon" src="<?php echo $feed->favicon(); ?>" alt="✇" />- <a data-unread="<?php echo format_number($feed->nbNotRead()); ?>" data-priority="<?php echo $feed->priority(); ?>" href="<?php echo _url('index', 'index', 'get', 'f_' . $feed->id()); ?>"><?php echo $feed->name(); ?></a>+ <a data-unread="<?php echo format_number($feed->nbNotRead()); ?>" href="<?php echo _url('index', 'index', 'get', 'f_' . $feed->id()); ?>"><?php echo $feed->name(); ?></a></li><?php } ?></ul>diff --git a/p/scripts/main.js b/p/scripts/main.jsindex f4b3898db..24c0972fc 100644--- a/p/scripts/main.js+++ b/p/scripts/main.js@@ -56,31 +56,31 @@ function incLabel(p, inc, spaceAfter) {function incUnreadsFeed(article, feed_id, nb) {//Update unread: feed- var elem = $('#' + feed_id + '>.feed').get(0),+ var elem = $('#' + feed_id).get(0),feed_unreads = elem ? str2int(elem.getAttribute('data-unread')) : 0,feed_priority = elem ? str2int(elem.getAttribute('data-priority')) : 0;if (elem) {- elem.setAttribute('data-unread', numberFormat(feed_unreads + nb));- elem = $(elem).closest('li').get(0);+ elem.setAttribute('data-unread', feed_unreads + nb);+ elem = $(elem).children('a').get(0);if (elem) {- elem.setAttribute('data-unread', feed_unreads + nb);+ elem.setAttribute('data-unread', numberFormat(feed_unreads + nb));}}//Update unread: category- elem = $('#' + feed_id).parent().prevAll('.category').children(':first').get(0);+ elem = $('#' + feed_id).parents('.tree-folder').get(0);feed_unreads = elem ? str2int(elem.getAttribute('data-unread')) : 0;if (elem) {- elem.setAttribute('data-unread', numberFormat(feed_unreads + nb));- elem = $(elem).closest('li').get(0);+ elem.setAttribute('data-unread', feed_unreads + nb);+ elem = $(elem).find('.tree-folder-title .title').get(0);if (elem) {- elem.setAttribute('data-unread', feed_unreads + nb);+ elem.setAttribute('data-unread', numberFormat(feed_unreads + nb));}}//Update unread: allif (feed_priority > 0) {- elem = $('#aside_feed .all').children(':first').get(0);+ elem = $('#aside_feed .all .tree-folder-title .title').get(0);if (elem) {feed_unreads = elem ? str2int(elem.getAttribute('data-unread')) : 0;elem.setAttribute('data-unread', numberFormat(feed_unreads + nb));@@ -89,7 +89,7 @@ function incUnreadsFeed(article, feed_id, nb) {//Update unread: favouritesif (article && article.closest('div').hasClass('favorite')) {- elem = $('#aside_feed .favorites').children(':first').get(0);+ elem = $('#aside_feed .favorites .tree-folder-title .title').get(0);if (elem) {feed_unreads = elem ? str2int(elem.getAttribute('data-unread')) : 0;elem.setAttribute('data-unread', numberFormat(feed_unreads + nb));@@ -97,7 +97,7 @@ function incUnreadsFeed(article, feed_id, nb) {}var isCurrentView = false;- //Update unread: title+ // Update unread: titledocument.title = document.title.replace(/^((?:\([ 0-9]+\) )?)/, function (m, p1) {var $feed = $('#' + feed_id);if (article || ($feed.closest('.active').length > 0 && $feed.siblings('.active').length === 0)) {@@ -194,7 +194,7 @@ function mark_favorite(active) {}$b.find('.icon').replaceWith(data.icon);- var favourites = $('.favorites>a').contents().last().get(0);+ var favourites = $('#aside_feed .favorites .tree-folder-title .title').contents().last().get(0);if (favourites && favourites.textContent) {favourites.textContent = favourites.textContent.replace(/((?: \([ 0-9]+\))?\s*)$/, function (m, p1) {return incLabel(p1, inc, false);@@ -202,7 +202,7 @@ function mark_favorite(active) {}if (active.closest('div').hasClass('not_read')) {- var elem = $('#aside_feed .favorites').children(':first').get(0),+ var elem = $('#aside_feed .favorites .tree-folder-title .title').get(0),feed_unreads = elem ? str2int(elem.getAttribute('data-unread')) : 0;if (elem) {elem.setAttribute('data-unread', numberFormat(feed_unreads + inc));@@ -292,42 +292,42 @@ function next_entry() {}function prev_feed() {- var active_feed = $("#aside_feed .feeds li.active");+ var active_feed = $("#aside_feed .tree-folder-items .item.active");if (active_feed.length > 0) {- active_feed.prevAll(':visible:first').find('a.feed').each(function(){this.click();});+ active_feed.prevAll(':visible:first').find('a').each(function(){this.click();});} else {last_feed();}}function next_feed() {- var active_feed = $("#aside_feed .feeds li.active");+ var active_feed = $("#aside_feed .tree-folder-items .item.active");if (active_feed.length > 0) {- active_feed.nextAll(':visible:first').find('a.feed').each(function(){this.click();});+ active_feed.nextAll(':visible:first').find('a').each(function(){this.click();});} else {first_feed();}}function first_feed() {- var feed = $("#aside_feed .feeds.active li:visible:first");+ var feed = $("#aside_feed .tree-folder-items.active .item:visible:first");if (feed.length > 0) {feed.find('a')[1].click();}}function last_feed() {- var feed = $("#aside_feed .feeds.active li:visible:last");+ var feed = $("#aside_feed .tree-folder-items.active .item:visible:last");if (feed.length > 0) {feed.find('a')[1].click();}}function prev_category() {- var active_cat = $("#aside_feed .category.stick.active");+ var active_cat = $("#aside_feed .tree-folder.active");if (active_cat.length > 0) {- var prev_cat = active_cat.parent('li').prevAll(':visible:first').find('.category.stick a.btn');+ var prev_cat = active_cat.prevAll(':visible:first').find('.tree-folder-title .title');if (prev_cat.length > 0) {prev_cat[0].click();}@@ -338,10 +338,10 @@ function prev_category() {}function next_category() {- var active_cat = $("#aside_feed .category.stick.active");+ var active_cat = $("#aside_feed .tree-folder.active");if (active_cat.length > 0) {- var next_cat = active_cat.parent('li').nextAll(':visible:first').find('.category.stick a.btn');+ var next_cat = active_cat.nextAll(':visible:first').find('.tree-folder-title .title');if (next_cat.length > 0) {next_cat[0].click();}@@ -352,16 +352,16 @@ function next_category() {}function first_category() {- var cat = $("#aside_feed .category.stick:visible:first");+ var cat = $("#aside_feed .tree-folder:visible:first");if (cat.length > 0) {- cat.find('a.btn')[0].click();+ cat.find('.tree-folder-title .title')[0].click();}}function last_category() {- var cat = $("#aside_feed .category.stick:visible:last");+ var cat = $("#aside_feed .tree-folder:visible:last");if (cat.length > 0) {- cat.find('a.btn')[0].click();+ cat.find('.tree-folder-title .title')[0].click();}}@@ -487,7 +487,8 @@ function init_column_categories() {if (context['current_view'] !== 'normal') {return;}- $('#aside_feed').on('click', '.category>a.dropdown-toggle', function () {++ $('#aside_feed').on('click', '.tree-folder>.tree-folder-title>a.dropdown-toggle', function () {$(this).children().each(function() {if (this.alt === '▽') {this.src = this.src.replace('/icons/down.', '/icons/up.');@@ -497,12 +498,12 @@ function init_column_categories() {this.alt = '▽';}});- $(this).parent().next(".feeds").slideToggle();+ $(this).parent().next(".tree-folder-items").slideToggle();return false;});- $('#aside_feed').on('click', '.feeds .dropdown-toggle', function () {+ $('#aside_feed').on('click', '.tree-folder-items .item .dropdown-toggle', function () {if ($(this).nextAll('.dropdown-menu').length === 0) {- var feed_id = $(this).closest('li').attr('id').substr(2),+ var feed_id = $(this).closest('.item').attr('id').substr(2),feed_web = $(this).data('fweb'),template = $('#feed_config_template').html().replace(/!!!!!!/g, feed_id).replace('http://example.net/', feed_web);$(this).attr('href', '#dropdown-' + feed_id).prev('.dropdown-target').attr('id', 'dropdown-' + feed_id).parent().append(template);diff --git a/p/themes/Origine/origine.css b/p/themes/Origine/origine.cssindex e6d50c2e9..64bec06a2 100644--- a/p/themes/Origine/origine.css+++ b/p/themes/Origine/origine.css@@ -565,7 +565,7 @@ a.btn {position: relative;margin: 5px 0;}-.aside_feed .tree-folder-title > a:not([data-unread="0"]):after {+.aside_feed .tree-folder-title > .title:not([data-unread="0"]):after {position: absolute;top: 3px; right: 3px;padding: 0 5px;diff --git a/p/themes/base-theme/template.css b/p/themes/base-theme/template.cssindex 40ff8140a..fb02a5b53 100644--- a/p/themes/base-theme/template.css+++ b/p/themes/base-theme/template.css@@ -395,7 +395,7 @@ a.btn {.aside_feed.state_unread .tree-folder .item:not(.active)[data-unread="0"] {display: none;}-.aside_feed .tree-folder-title > a:not([data-unread="0"]):after {+.aside_feed .tree-folder-title > .title:not([data-unread="0"]):after {content: attr(data-unread);}