diff options
author | Aurélien Bompard <aurelien@bompard.org> | 2013-11-28 12:25:25 +0100 |
---|---|---|
committer | Aurélien Bompard <aurelien@bompard.org> | 2013-11-28 14:05:18 +0100 |
commit | dc34f0e874c42018e11ed951efc5b3fcfe7e8feb (patch) | |
tree | d9aae53bff1beb78a076ecdbd65c86cefd22c85d /hyperkitty/static | |
parent | c976dc96c79a897b55ca8430b824eb8063cd0403 (diff) | |
download | hyperkitty-dc34f0e874c42018e11ed951efc5b3fcfe7e8feb.tar.gz hyperkitty-dc34f0e874c42018e11ed951efc5b3fcfe7e8feb.tar.xz hyperkitty-dc34f0e874c42018e11ed951efc5b3fcfe7e8feb.zip |
Load the list's recent activity via AJAX
Diffstat (limited to 'hyperkitty/static')
-rw-r--r-- | hyperkitty/static/hyperkitty/css/hyperkitty-index.css | 4 | ||||
-rw-r--r-- | hyperkitty/static/hyperkitty/js/hyperkitty-common.js | 20 | ||||
-rw-r--r-- | hyperkitty/static/hyperkitty/js/hyperkitty-index.js | 53 |
3 files changed, 77 insertions, 0 deletions
diff --git a/hyperkitty/static/hyperkitty/css/hyperkitty-index.css b/hyperkitty/static/hyperkitty/css/hyperkitty-index.css index 963d2de..c34f948 100644 --- a/hyperkitty/static/hyperkitty/css/hyperkitty-index.css +++ b/hyperkitty/static/hyperkitty/css/hyperkitty-index.css @@ -135,6 +135,10 @@ .all-lists table.lists .chart { height: 35px; } +.all-lists table.lists .chart .ajaxloader { + margin: 0 auto; + padding-top: 5px; +} .all-lists table.lists ul.list-stats { margin: 0; text-align: center; diff --git a/hyperkitty/static/hyperkitty/js/hyperkitty-common.js b/hyperkitty/static/hyperkitty/js/hyperkitty-common.js index 464cff5..45c3e47 100644 --- a/hyperkitty/static/hyperkitty/js/hyperkitty-common.js +++ b/hyperkitty/static/hyperkitty/js/hyperkitty-common.js @@ -237,6 +237,26 @@ function chart(elem_id, data, default_props) { } +function ajax_chart(elem, url, props) { + elem = $(elem); + $.ajax({ + dataType: "json", + url: url, + success: function(data) { + chart(elem.get(0), data.evolution, props); + }, + error: function(jqXHR, textStatus, errorThrown) { + //alert(jqXHR.responseText); + }, + complete: function(jqXHR, textStatus) { + // if the list is private we have no info, remove the img anyway + elem.find("img.ajaxloader").remove(); + } + }); +} + + + /* * Misc. diff --git a/hyperkitty/static/hyperkitty/js/hyperkitty-index.js b/hyperkitty/static/hyperkitty/js/hyperkitty-index.js new file mode 100644 index 0000000..a99f06e --- /dev/null +++ b/hyperkitty/static/hyperkitty/js/hyperkitty-index.js @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2012-2013 by the Free Software Foundation, Inc. + * + * This file is part of HyperKitty. + * + * HyperKitty is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * HyperKitty is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * HyperKitty. If not, see <http://www.gnu.org/licenses/>. + * + * Author: Aurelien Bompard <abompard@fedoraproject.org> + */ + + + +function setup_index(url_template) { + $("table.lists tr.list").click(function(e) { + document.location.href = $(this).find("a.list-name").attr("href"); + }); + $(".hide-switches input").click(function() { + var target = $("table.lists tr.list."+$(this).val()); + if ($(this).prop("checked")) { + target.hide(); + } else { + target.show(); + } + }); + + // Initials + $(".initials").animate({ right: 0 }, {duration: 600}); + // Override the scrolling because we have a fixed header + $(".initials a").click(function (e) { + e.preventDefault(); + var target = $("a[name="+$(this).attr("href").substring(1)+"]"); + $(window).scrollTop(target.offset().top - 70); + }); + + // Update list graphs + $(".all-lists table.lists tr.list").each(function() { + var listelem = $(this); + var listname = $.trim(listelem.find(".list-address").text()); + var url = url_template.replace(/PLACEHOLDER@PLACEHOLDER/, listname); + ajax_chart(listelem.find("div.chart"), url, {height: 30}); + }); +} |