From b0864cfb5ab308e88c88fbb6819ac914053352ea Mon Sep 17 00:00:00 2001 From: rolux Date: Sat, 9 Feb 2013 10:44:47 +0530 Subject: [PATCH] add live updates for list items counts, fixes #1213 --- static/js/pandora/allItems.js | 6 +++++- static/js/pandora/list.js | 13 ++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/static/js/pandora/allItems.js b/static/js/pandora/allItems.js index a3a03326e..ebaf98d9d 100644 --- a/static/js/pandora/allItems.js +++ b/static/js/pandora/allItems.js @@ -60,9 +60,13 @@ pandora.ui.allItems = function() { pandora.api.find({ query: {conditions: [], operator: '&'} }, function(result) { - $items.html(Ox.formatNumber(result.data.items)); + that.update(result.data.items); }); + that.update = function(items) { + $items.html(Ox.formatNumber(items)); + }; + that.resizeElement = function(width) { $name.css({width: width + 'px'}); }; diff --git a/static/js/pandora/list.js b/static/js/pandora/list.js index 0b98d0023..f2a07cd33 100644 --- a/static/js/pandora/list.js +++ b/static/js/pandora/list.js @@ -111,7 +111,6 @@ pandora.ui.list = function() { that.size(); }, sort: function(data) { - Ox.Log('', '---- SORT ----', data) pandora.UI.set({ listSort: [{key: data.key, operator: data.operator}] }); @@ -397,6 +396,18 @@ pandora.ui.list = function() { }); }, init: function(data) { + var find = pandora.user.ui.find, folder, list; + if (find.conditions.length == 0) { + pandora.$ui.allItems.update(data.items); + } else if ( + find.conditions.length == 1 + && find.conditions[0].key == 'list' + && find.conditions[0].operator == '==' + ) { + list = find.conditions[0].value; + folder = pandora.getListData(list).folder; + pandora.$ui.folderList[folder].value(list, 'items', data.items); + } pandora.$ui.statusbar.set('total', data); data = []; pandora.site.totals.forEach(function(v) {