You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by hu...@apache.org on 2016/09/04 07:23:42 UTC
[10/11] incubator-ponymail git commit: start work on the top menu
start work on the top menu
populate with available lists, sorted by usage
Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/346ed350
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/346ed350
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/346ed350
Branch: refs/heads/coffee-and-cake
Commit: 346ed350cd2e611463859f5fae13d45604ffc12c
Parents: 9d75f3c
Author: Daniel Gruno <hu...@apache.org>
Authored: Sun Sep 4 09:23:01 2016 +0200
Committer: Daniel Gruno <hu...@apache.org>
Committed: Sun Sep 4 09:23:01 2016 +0200
----------------------------------------------------------------------
site/js/coffee/preferences.coffee | 41 +++++++++++++++++++++++++++++++++-
1 file changed, 40 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/346ed350/site/js/coffee/preferences.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/preferences.coffee b/site/js/coffee/preferences.coffee
index 4ec06ab..0e691dd 100644
--- a/site/js/coffee/preferences.coffee
+++ b/site/js/coffee/preferences.coffee
@@ -15,9 +15,48 @@
limitations under the License.
###
+### maxLists: default max lists to show in top menu before resorting to 'more lists' ###
+maxLists = 2
+
setupAccount = (json, state) ->
- if json and isArray(json.lists)
+ myDomain = []
+
+ ### run parseURL for fetch list and domain ###
+ parseURL()
+
+ ### set up the list of...lists ###
+ if json and isHash(json.lists)
for domain, lists of json.lists
ponymail_lists[domain] = lists
+ ### if current domain, set up the top menu to use it ###
+ if domain == ponymail_domain
+ myDomain = lists
+
+ ### Are we on list.html? ###
if state.listview
+ ### Generate the lists part of the top menu ###
+ lmenu = get('listmenu')
+ if lmenu
+ ### Make an array of mailing lists ###
+ sortedList = []
+ for list, number of myDomain
+ sortedList.push(list)
+ ### Sort descending by business ###
+ sortedList.sort((a,b) => if myDomain[a] < myDomain[b] then 1 else -1)
+ for list in sortedList[0..maxLists-1]
+ li = new HTML('li', {},
+ new HTML('a', { href: "?#{list}@#{ponymail_domain}", onclick: "listView({list: '#{list}@#{ponymail_domain}'}); return false;"}, list+'@')
+ )
+ lmenu.inject(li)
+
+ ### Do we have more lists?? ###
+ if sortedList.length > maxLists
+ ### Remove the first N lists, sort the rest by name ###
+ sortedList.splice(0,maxLists)
+ sortedList.sort()
+
+ li = new HTML('li', {}, "More lists \u2304")
+ lmenu.inject(li)
+
+ ### Call listView to fetch email ###
listView(null, true)
\ No newline at end of file