summaryrefslogtreecommitdiff
path: root/themes/default/js
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2008-11-15 06:23:09 +0000
committerBharat Mediratta <bharat@menalto.com>2008-11-15 06:23:09 +0000
commitae7839ffaada72c522ffcd9b3f4f1cc04027a720 (patch)
tree50ce67306eace68cd23c294fc1aa40ba32c03bcc /themes/default/js
parent26c8772e16b0328358d23ee4c29f9b592e632b28 (diff)
Revise the user login code.
* Remove user registration link and popup from the theme; this shouldn't be done in a popup. Use ajaxform to simplify the way that we load the login popup. * Create form.html.php, this is a template for Forge based forms. * Move user validation rules into User_Model and let forms populate the rules into their forms as useful. * Undo r18688's changes regarding the REST code. We should never accept a null resource, this breaks the REST abstraction. * Change login and user controllers to use Forge which lets us delete login.html.php and user.html.php since those now are generated by the theme-owned form template
Diffstat (limited to 'themes/default/js')
-rw-r--r--themes/default/js/user.js79
1 files changed, 21 insertions, 58 deletions
diff --git a/themes/default/js/user.js b/themes/default/js/user.js
index b389a67e..42ab1aa7 100644
--- a/themes/default/js/user.js
+++ b/themes/default/js/user.js
@@ -1,66 +1,29 @@
-$(document).ready(function() {
- $("#gLoginForm").submit(function() {
- process_login();
- return false;
- });
- $("#gLogoutLink").click(function() {
- process_logout();
- return false;
- });
-});
-
-function show_form(formName) {
- $(formName + "Link").css({display: "none"});
- $(formName + "Text").css({display: "inline"});
- $(formName + "Close").css({display: "inline"});
- var url = $(formName + "Form").attr("formSrc");
- $.get(url, null, function(data, textStatus) {
- $(formName + "Form").html(data);
- $(formName + "Form").css({display: "block"});
+function show_login(url) {
+ $("#gLoginLink").hide();
+ $("#gLoginClose").show();
+ $.get(url, function(data) {
+ $("#gLoginFormContainer").html(data);
+ ajaxify_login_form();
});
}
-function hide_form(formName) {
- $(formName + "Link").css({display: "inline"});
- $(formName + "Form").css({display: "none"});
- $(formName + "Form").html("");
- $(formName + "Text").css({display: "none"});
- $(formName + "Close").css({display: "none"});
-}
-
-function process_login() {
- $.ajax({
- url: $("#gLogin").attr("action"),
- type: "POST",
- data: $("#gLogin").serialize(),
- dataType: "json",
- error: function(XMLHttpRequest, textStatus, errorThrown) {
- alert("textStatus: " + textStatus + "\nerrorThrown: " + errorThrown);
- },
- success: function(data, textStatus) {
- if (data.error_message != "") {
- $("#gLoginMessage").html(data.error_message);
- $("#gLoginMessage").css({display: "block"});
- $("#gLogin").addClass("gError");
- } else {
+function ajaxify_login_form() {
+ $("form#gLogin").ajaxForm({
+ target: "#gLoginFormContainer",
+ success: function(responseText, statusText) {
+ if (!responseText) {
window.location.reload();
+ } else {
+ ajaxify_login_form();
}
- }
+ },
});
}
-function process_logout() {
- $.ajax({
- url: $("#gLogoutLink").attr("href"),
- type: "GET",
- dataType: "json",
- error: function(XMLHttpRequest, textStatus, errorThrown) {
- alert("textStatus: " + textStatus + "\nerrorThrown: " + errorThrown);
- },
- success: function(data, textStatus) {
- if (data.logout) {
- window.location.reload();
- }
- }
- });
-} \ No newline at end of file
+function close_login() {
+ $("#gLogin").remove();
+ $("#gLoginClose").hide();
+ $("#gLoginLink").show();
+ $("input#gUsername").val("");
+ $("input#gPassword").val("");
+}