From 6ec256dc344d8bb042e58eb6686eeabccb6d2665 Mon Sep 17 00:00:00 2001 From: JeremyRand Date: Mon, 3 Apr 2017 02:32:09 +0000 Subject: [PATCH] (WIP) Fix the sidebar when Javascript resorting is in use. TODO: Add some markup so that DOM traversal in the animations is less painful. --- htroot/js/yacysort.js | 161 ++++++++++++++++++++++++++++++++++ htroot/yacysearch.html | 3 + htroot/yacysearchtrailer.html | 6 +- 3 files changed, 167 insertions(+), 3 deletions(-) diff --git a/htroot/js/yacysort.js b/htroot/js/yacysort.js index 4ed983506..ab4e96b1f 100644 --- a/htroot/js/yacysort.js +++ b/htroot/js/yacysort.js @@ -72,6 +72,163 @@ var laterPage = function() { displayPage(); }; +var processSidebarNavProtocols = function(navProtocolsOld, navProtocolsNew) { + navProtocolsOld.find(".btn-group-xs").each( function(index, oldProtocol) { + var protocolId = $(oldProtocol).attr("id"); + + var newProtocol = navProtocolsNew.find("#" + protocolId); + + // Check whether the protocol has been removed in the new sidebar. + if (newProtocol.length === 0) { + console.log("Deleting nav-protocol..."); + $(oldProtocol).hide(1000); + } + } ); + + navProtocolsNew.find(".btn-group-xs").each( function(index, newProtocol) { + var protocolId = $(newProtocol).attr("id"); + + var oldProtocol = navProtocolsOld.find("#" + protocolId); + + // Check whether the protocol exists in both the new and old sidebar + if (oldProtocol.length === 1) { + // Replace the HTML. + // TODO: Look into smoother animations. + $(oldProtocol).html($(newProtocol).html()).show(1000); + } + + // Check whether the protocol has been added in the new sidebar. + if (oldProtocol.length === 0) { + // We need to insert the protocol in the right position. + + // TODO: Insert in the correct position instead of the end. + $(newProtocol).hide(); + $(navProtocolsOld).append($(newProtocol)); + $(newProtocol).show(1000); + } + } ); +}; + +// TODO: test this function +// This is for sidebar items that are