From 9f31381bb6340349c83c394a6ffa15909a2ba3d1 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 15 Feb 2021 07:46:24 +0300 Subject: [PATCH] renderToolbar: support empty data i.e. dashboard feed --- classes/feeds.php | 2 +- js/Headlines.js | 86 +++++++++++++++++++++++++---------------------- 2 files changed, 46 insertions(+), 42 deletions(-) diff --git a/classes/feeds.php b/classes/feeds.php index 0a3e77a1a..ba320b52f 100755 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -141,7 +141,7 @@ class Feeds extends Handler_Protected { $reply['toolbar'] = [ 'site_url' => $feed_site_url, - 'title' => truncate_string(strip_tags($feed_title), 30), + 'title' => strip_tags($feed_title), 'error' => $last_error, 'last_updated' => $last_updated, 'plugin_menu_items' => $plugin_menu_items, diff --git a/js/Headlines.js b/js/Headlines.js index 954b6b45f..94541b974 100755 --- a/js/Headlines.js +++ b/js/Headlines.js @@ -572,49 +572,53 @@ const Headlines = { const search_query = Feeds._search_query ? Feeds._search_query.query : ""; const target = dijit.byId('toolbar-headlines'); - target.attr('innerHTML', - ` - - - rss_feed - - ${tb.site_url ? - `${tb.title}` : - `${tb.title}`} - ${search_query ? - ` - (${__("Cancel search")}) - ` : ''} - ${tb.error ? `error` : ''} - - - - -
- ${__("Select...")} -
-
${__('All')}
-
${__('Unread')}
-
${__('Invert')}
-
${__('None')}
-
-
${__('Toggle unread')}
-
${__('Toggle starred')}
-
${__('Toggle published')}
-
-
${__('Mark as read')}
-
${__('Set score')}
- ${tb.plugin_menu_items} - ${headlines.id === 0 && !headlines.is_cat ? + if (tb && typeof tb == 'object') { + target.attr('innerHTML', + ` + + + rss_feed + + ${tb.site_url ? + `${tb.title}` : + `${tb.title}`} + ${search_query ? ` -
-
${__('Delete permanently')}
+ (${__("Cancel search")}) ` : ''} -
- ${tb.plugin_buttons} - - `); + ${tb.error ? `error` : ''} + + + + +
+ ${__("Select...")} +
+
${__('All')}
+
${__('Unread')}
+
${__('Invert')}
+
${__('None')}
+
+
${__('Toggle unread')}
+
${__('Toggle starred')}
+
${__('Toggle published')}
+
+
${__('Mark as read')}
+
${__('Set score')}
+ ${tb.plugin_menu_items} + ${headlines.id === 0 && !headlines.is_cat ? + ` +
+
${__('Delete permanently')}
+ ` : ''} +
+ ${tb.plugin_buttons} + + `); + } else { + target.attr('innerHTML', ''); + } dojo.parser.parse(target.domNode); },