From 7765941011a78e8062bc76ae3daba9aa56d279c8 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 13 May 2015 17:51:29 -0400 Subject: further generalization of openid selector Now template variables can be set to control which login methods are shown --- .../ikiwiki/openid/openid-jquery.js | 39 +++++++++++++--------- 1 file changed, 24 insertions(+), 15 deletions(-) (limited to 'underlays') diff --git a/underlays/openid-selector/ikiwiki/openid/openid-jquery.js b/underlays/openid-selector/ikiwiki/openid/openid-jquery.js index db8dca235..eaac50315 100644 --- a/underlays/openid-selector/ikiwiki/openid/openid-jquery.js +++ b/underlays/openid-selector/ikiwiki/openid/openid-jquery.js @@ -5,21 +5,23 @@ http://code.google.com/p/openid-selector/ This code is licenced under the New BSD License. */ -var selections_large = { +var selections_email_large = { email: { name: 'Email', icon: 'wikiicons/email.png', label: 'Enter your email address:', url: null - }, + } +}; +var selections_openid_large = { openid: { name: 'OpenID', icon: 'wikiicons/openidlogin-bg.gif', label: 'Enter your OpenID:', url: null - }, + } }; -var selections_small = { +var selections_openid_small = { verisign: { name: 'Verisign', icon: 'ikiwiki/openid/verisign.png', @@ -50,7 +52,7 @@ var selections_small = { url: 'http://openid.aol.com/{username}' } }; -var selections = $.extend({}, selections_large, selections_small); +var selections = $.extend({}, selections_email_large, selections_openid_large, selections_openid_small); var selector = { @@ -66,7 +68,7 @@ var selector = { selection_id: null, othersignin_id: null, - init: function(input_id, othersignin_id, othersignin_label) { + init: function(input_id, login_methods, othersignin_id, othersignin_label) { var selector_btns = $('#login_btns'); @@ -76,9 +78,17 @@ var selector = { $('#login_input_area').empty(); // add box for each selection - for (id in selections_large) { - selector_btns.append(this.getBoxHTML(selections_large[id], 'large')); - } + if (login_methods['openid']) { + for (id in selections_openid_large) { + selector_btns.append(this.getBoxHTML(selections_openid_large[id], 'large')); + } + } + if (login_methods['email']) { + for (id in selections_email_large) { + selector_btns.prepend(this.getBoxHTML(selections_email_large[id], 'large')); + } + } + if (othersignin_label != "") { this.othersignin_label=othersignin_label; } @@ -98,11 +108,11 @@ var selector = { $('#'+this.othersignin_id).hide(); } - if (selections_small) { + if (login_methods['openid'] && selections_openid_small) { selector_btns.append('
'); - for (id in selections_small) { - selector_btns.append(this.getBoxHTML(selections_small[id], 'small')); + for (id in selections_openid_small) { + selector_btns.append(this.getBoxHTML(selections_openid_small[id], 'small')); } } @@ -179,7 +189,7 @@ var selector = { else { selector.setOpenIdUrl(""); } - if(selector.ajaxHandler) { + if (selector.ajaxHandler) { selector.ajaxHandler(selector.selection_id, document.getElementById(selector.input_id).value); return false; } @@ -227,7 +237,7 @@ var selector = { var input_area = $('#login_input_area'); var html = ''; - var id = 'entry'; + var id = selection['name']+'_entry'; var value = ''; var label = selection['label']; var style = ''; @@ -240,7 +250,6 @@ var selector = { if (label) { html = ''; } - html += '' html += '' + ''; -- cgit v1.2.3