Allow AJAX based links.

This commit is contained in:
Antoine Nguyen
2014-12-17 14:52:28 +01:00
parent b1a362ae15
commit 9676b6076c
7 changed files with 38 additions and 14 deletions
+2
View File
@@ -25,6 +25,8 @@ def enabled_applications():
exts = Extension.objects.filter(enabled=True)
for ext in exts:
extclass = exts_pool.get_extension(ext.name)
if extclass is None:
continue
if extclass.available_for_topredirection:
result.append((ext.name, ext.name))
return sorted(result, key=lambda e: e[0])
+6 -6
View File
@@ -43,20 +43,20 @@ def extensions_menu(selection, user):
def admin_menu(selection, user):
entries = [
{"name": "extensions",
"class": "ajaxlink",
"class": "ajaxnav",
"url": "extensions/",
"label": _("Extensions"),
"img": ""},
{"name": "info",
"class": "ajaxlink",
"class": "ajaxnav",
"url": "info/",
"label": _("Information")},
{"name": "logs",
"class": "ajaxlink",
"class": "ajaxnav",
"url": "logs/?sort_order=-date_created",
"label": _("Logs")},
{"name": "parameters",
"class": "ajaxlink",
"class": "ajaxnav",
"url": "parameters/",
"img": "",
"label": _("Parameters")},
@@ -99,11 +99,11 @@ def user_menu(user, selection):
def uprefs_menu(selection, user):
entries = [
{"name": "profile",
"class": "ajaxlink",
"class": "ajaxnav",
"url": "profile/",
"label": _("Profile")},
{"name": "preferences",
"class": "ajaxlink",
"class": "ajaxnav",
"url": "preferences/",
"label": _("Preferences")},
]
+1 -1
View File
@@ -101,7 +101,7 @@ def user_menu(target, user):
return []
return [
{"name": "forward",
"class": "ajaxlink",
"class": "ajaxnav",
"url": "forward/",
"label": ugettext_lazy("Forward")}
]
@@ -258,7 +258,8 @@ Identities.prototype = {
listen: function() {
Admin.prototype.listen.call(this);
$(document).on("click", "a.ajaxlink", $.proxy(this.page_loader, this));
$(document).on("click", "a.ajaxnav", $.proxy(this.page_loader, this));
$(document).on("click", "a.ajaxcall", $.proxy(this.send_call, this));
},
page_loader: function(e) {
@@ -271,6 +272,27 @@ Identities.prototype = {
this.navobj.baseurl($link.attr("href")).update();
},
/**
* Send an ajax call.
*/
send_call: function(evt) {
var $link = get_target(evt, "a");
var $this = $(this);
var method = $link.attr("data-call_method");
if (method === undefined) {
method = "GET";
}
evt.preventDefault();
$.ajax({
url: $link.attr("href"),
type: method,
dataType: "json"
}).done(function(data) {
$this.reload_listing(data.respmsg);
});
},
/**
* Initialize the links embedded within a page.
*
@@ -37,7 +37,7 @@ def domains_menu(selection, user):
{"name": "domains",
"label": _("List domains"),
"img": "fa fa-user",
"class": "ajaxlink navigation",
"class": "ajaxnav navigation",
"url": domain_list_url},
{"name": "statistics",
"label": _("Statistics"),
@@ -89,12 +89,12 @@ def identities_menu(user, selection=None):
{"name": "identities",
"label": _("List identities"),
"img": "fa fa-user",
"class": "ajaxlink navigation",
"class": "ajaxnav navigation",
"url": "list/"},
{"name": "quotas",
"label": _("List quotas"),
"img": "fa fa-hdd-o",
"class": "ajaxlink navigation",
"class": "ajaxnav navigation",
"url": "quotas/"},
{"name": "newaccount",
"label": _("Add account"),
@@ -25,7 +25,7 @@ def menu(target, user):
return []
return [
{"name": "autoreply",
"class": "ajaxlink",
"class": "ajaxnav",
"url": "autoreply/",
"label": ugettext_lazy("Auto-reply message")}
]
+2 -2
View File
@@ -23,7 +23,7 @@ TwocolsNav.prototype = {
},
listen: function() {
$("a.ajaxlink").click($.proxy(this.load_section, this));
$("a.ajaxnav").click($.proxy(this.load_section, this));
$(document).on("click", "#update", $.proxy(function(e) {
simple_ajax_form_post(e, {
formid: this.options.formid,
@@ -130,7 +130,7 @@ TwocolsNav.prototype = {
* Select an entry in the left menu based on current url.
*/
select_left_menu: function() {
$("a.ajaxlink").parent().removeClass("active");
$("a.ajaxnav").parent().removeClass("active");
$("a[name=" + this.navobj.getbaseurl() + "]").parent().addClass("active");
},