From 457712ce46beed04126535024daae603dd6136fc Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 17 May 2013 01:13:44 +0000 Subject: More working on security templates --- wqflask/wqflask/static/new/javascript/login.coffee | 33 ++++++++- wqflask/wqflask/static/new/javascript/login.js | 42 +++++++++-- wqflask/wqflask/templates/security/_scripts.html | 1 - wqflask/wqflask/templates/security/login_user.html | 81 ++++++++++++---------- .../wqflask/templates/security/register_user.html | 81 +++++++++++----------- 5 files changed, 155 insertions(+), 83 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/static/new/javascript/login.coffee b/wqflask/wqflask/static/new/javascript/login.coffee index a986cb31..4f38a299 100644 --- a/wqflask/wqflask/static/new/javascript/login.coffee +++ b/wqflask/wqflask/static/new/javascript/login.coffee @@ -1,5 +1,8 @@ $ -> - $(".modalize").colorbox() + $(".modalize").colorbox( + onComplete: -> + $(".focused").focus() + ) modal_replace = (event) -> event.preventDefault() @@ -7,8 +10,36 @@ $ -> $.colorbox( open: true href: this.href + onComplete: -> + $(".focused").focus() ) return false + $(".modal_replace").on("click", modal_replace) + + form_success = (data) -> + $.colorbox( + open: true + html: data + onComplete: -> + $("form").on("submit", submit_form) + ) + + + submit_form = (event) -> + event.preventDefault() + submit_to = $(this).attr('action') + data = $(this).serialize() + console.log("submit_to is:", submit_to) + $.ajax( + type: "POST" + url: submit_to + data: data + dataType: "html" + success: form_success + ) + + + $("form").on("submit", submit_form) diff --git a/wqflask/wqflask/static/new/javascript/login.js b/wqflask/wqflask/static/new/javascript/login.js index c34ae453..e537ac1e 100644 --- a/wqflask/wqflask/static/new/javascript/login.js +++ b/wqflask/wqflask/static/new/javascript/login.js @@ -2,17 +2,49 @@ (function() { $(function() { - var modal_replace; - $(".modalize").colorbox(); - modal_replace = function() { + var form_success, modal_replace, submit_form; + $(".modalize").colorbox({ + onComplete: function() { + return $(".focused").focus(); + } + }); + modal_replace = function(event) { + event.preventDefault(); console.log("in modal_replace:", $(this).attr("href")); $.colorbox({ open: true, - href: this.href + href: this.href, + onComplete: function() { + return $(".focused").focus(); + } }); return false; }; - return $(".modal_replace").on("click", modal_replace); + $(".modal_replace").on("click", modal_replace); + form_success = function(data) { + return $.colorbox({ + open: true, + html: data, + onComplete: function() { + return $("form").on("submit", submit_form); + } + }); + }; + submit_form = function(event) { + var data, submit_to; + event.preventDefault(); + submit_to = $(this).attr('action'); + data = $(this).serialize(); + console.log("submit_to is:", submit_to); + return $.ajax({ + type: "POST", + url: submit_to, + data: data, + dataType: "html", + success: form_success + }); + }; + return $("form").on("submit", submit_form); }); }).call(this); diff --git a/wqflask/wqflask/templates/security/_scripts.html b/wqflask/wqflask/templates/security/_scripts.html index 23ad3248..5a453dca 100644 --- a/wqflask/wqflask/templates/security/_scripts.html +++ b/wqflask/wqflask/templates/security/_scripts.html @@ -1,4 +1,3 @@ - diff --git a/wqflask/wqflask/templates/security/login_user.html b/wqflask/wqflask/templates/security/login_user.html index 15077af6..d6f6fb63 100644 --- a/wqflask/wqflask/templates/security/login_user.html +++ b/wqflask/wqflask/templates/security/login_user.html @@ -1,60 +1,69 @@ {% from "security/_macros.html" import render_only_errors %} {% include "security/_messages.html" %} -

Don't have an account?

+
+

Don't have an account?

-
- Create a new account -
+
+ Create a new account +
-
+
-

Already have an account?

+

Already have an account?

-
Sign in here
+
Sign in here
-
- {{ login_user_form.hidden_tag() }} -
+ + {{ login_user_form.hidden_tag() }} +
-
- -
- +
+ +
+ +
+ {{ render_only_errors(login_user_form.email) }}
- {{ render_only_errors(login_user_form.email) }} -
-
- -
- +
+ +
+ - {{ render_only_errors(login_user_form.password) }} - {% if security.recoverable %} + {{ render_only_errors(login_user_form.password) }} + {% if security.recoverable %} + + Forgot your password?
+
+ {% endif %} - Forgot your password?
- {% endif %} -
+ +
+
+ +
-
-
- +
+
+ - + +
- -
-
- +
+ + + + {% include "security/_scripts.html" %} diff --git a/wqflask/wqflask/templates/security/register_user.html b/wqflask/wqflask/templates/security/register_user.html index 174b7273..0f068914 100644 --- a/wqflask/wqflask/templates/security/register_user.html +++ b/wqflask/wqflask/templates/security/register_user.html @@ -1,60 +1,61 @@ {% from "security/_macros.html" import render_only_errors %} {% include "security/_messages.html" %} -

Already have an account?

+
+

Already have an account?

-
- Sign in using existing account -
+
+ Sign in using existing account +
-
+
-

Don't have an account?

+

Don't have an account?

-
Register here
+
Register here
-
- {{ register_user_form.hidden_tag() }} -
+ + {{ register_user_form.hidden_tag() }} +
-
- -
- +
+ +
+ +
+ {{ render_only_errors(register_user_form.email) }}
- {{ render_only_errors(register_user_form.email) }} -
-
- -
- +
+ +
+ +
+ {{ render_only_errors(register_user_form.password) }}
- {{ render_only_errors(register_user_form.password) }} -
- - {% if register_user_form.password_confirm %} -
- -
- -
- {{ render_only_errors(register_user_form.password_confirm) }} - - {% endif %} -
-
- + {% if register_user_form.password_confirm %} +
+ +
+ +
+ {{ render_only_errors(register_user_form.password_confirm) }}
-
+ {% endif %} -
+
+
+ +
+
- +
+ +
{% include "security/_scripts.html" %} -- cgit v1.2.3