From 9170ee831aefddc2ec4ddeff69098fb7ec6e07a4 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Sun, 28 Dec 2014 22:22:43 -0500 Subject: [PATCH] reset search on tags page if input is empty --- public/src/client/tags.js | 13 ++++++++++++- src/socket.io/topics.js | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/public/src/client/tags.js b/public/src/client/tags.js index e5c2dcaa45..4763d3aa44 100644 --- a/public/src/client/tags.js +++ b/public/src/client/tags.js @@ -16,7 +16,7 @@ define('forum/tags', ['forum/infinitescroll'], function(infinitescroll) { } if (!$('#tag-search').val().length) { - return; + return resetSearch(); } timeoutId = setTimeout(function() { @@ -51,6 +51,17 @@ define('forum/tags', ['forum/infinitescroll'], function(infinitescroll) { }); }; + function resetSearch() { + socket.emit('topics.loadMoreTags', { + after: 0 + }, function(err, data) { + if (err) { + return app.alertError(err.message); + } + onTagsLoaded(data.tags, true); + }); + } + function onTagsLoaded(tags, replace, callback) { callback = callback || function() {}; infinitescroll.parseAndTranslate('tags', 'tags', {tags: tags}, function(html) { diff --git a/src/socket.io/topics.js b/src/socket.io/topics.js index 0734f18c83..e5222e04a5 100644 --- a/src/socket.io/topics.js +++ b/src/socket.io/topics.js @@ -556,7 +556,7 @@ SocketTopics.searchAndLoadTags = function(socket, data, callback) { }; SocketTopics.loadMoreTags = function(socket, data, callback) { - if(!data || !data.after) { + if(!data || !utils.isNumber(data.after)) { return callback(new Error('[[error:invalid-data]]')); }