From 190a3a6a267bf7bc10d244ff80295e9caf2e10cf Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Thu, 20 Mar 2014 10:14:32 +0000 Subject: [PATCH] Reimplement the Navi widget with pub/sub. --- tools/htdocs/mkws.js | 50 +++++++++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/tools/htdocs/mkws.js b/tools/htdocs/mkws.js index b6f0e0e..da6e4d8 100644 --- a/tools/htdocs/mkws.js +++ b/tools/htdocs/mkws.js @@ -163,7 +163,8 @@ function widget($, team, type, node) { Stat: promoteStat, Termlists: promoteTermlists, Pager: promotePager, - Records: promoteRecords + Records: promoteRecords, + Navi: promoteNavi }; var promote = type2fn[type]; @@ -370,6 +371,31 @@ function widget($, team, type, node) { } }); } + + + function promoteNavi() { + team.queue("navi").subscribe(function() { + var filters = team.filters(); + var text = ""; + + for (var i in filters) { + if (text) { + text += " | "; + } + var filter = filters[i]; + if (filter.id) { + text += M('source') + ': ' + filter.name + ''; + } else { + text += M(filter.field) + ': ' + filter.value + ''; + } + } + + $(node).html(text); + }); + } } @@ -407,6 +433,7 @@ function team($, teamName) { that.currentPage = function() { return m_currentPage; } that.currentRecordId = function() { return m_currentRecordId; } that.currentRecordData = function() { return m_currentRecordData; } + that.filters = function() { return m_filters; } var debug = function (s) { var now = $.now(); @@ -546,26 +573,7 @@ function team($, teamName) { function redrawNavi () { - var navi = findnode('.mkwsNavi'); - if (!navi) return; - - var text = ""; - for (var i in m_filters) { - if (text) { - text += " | "; - } - var filter = m_filters[i]; - if (filter.id) { - text += M('source') + ': ' + filter.name + ''; - } else { - text += M(filter.field) + ': ' + filter.value + ''; - } - } - - navi.html(text); + queue("navi").publish(); } -- 1.7.10.4