aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam2013-05-17 01:13:44 +0000
committerSam2013-05-17 01:13:44 +0000
commit457712ce46beed04126535024daae603dd6136fc (patch)
tree757002335f798202799231f1710f12af4af2a665
parenta24df14b2ac5f5a12957c676278b2bdc379497dd (diff)
downloadgenenetwork2-457712ce46beed04126535024daae603dd6136fc.tar.gz
More working on security templates
-rw-r--r--wqflask/wqflask/static/new/javascript/login.coffee33
-rw-r--r--wqflask/wqflask/static/new/javascript/login.js42
-rw-r--r--wqflask/wqflask/templates/security/_scripts.html1
-rw-r--r--wqflask/wqflask/templates/security/login_user.html81
-rw-r--r--wqflask/wqflask/templates/security/register_user.html81
5 files changed, 155 insertions, 83 deletions
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 @@
<!--<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script language="javascript" type="text/javascript" src="/static/packages/colorbox/jquery.colorbox.js"></script>-->
<script type="text/javascript" src="/static/new/javascript/login.js"></script>
-
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" %}
-<h4>Don't have an account?</h4>
+<div style="padding: 20px;">
+ <h4>Don't have an account?</h4>
-<center>
- <a href="/register" class="btn btn-info modal_replace">Create a new account</a>
-</center>
+ <center>
+ <a href="/register" class="btn btn-info modal_replace">Create a new account</a>
+ </center>
-<hr />
+ <hr />
-<h4>Already have an account?</h4>
+ <h4>Already have an account?</h4>
-<h5>Sign in here</h5>
+ <h5>Sign in here</h5>
-<form class="form-horizontal" action="{{ url_for_security('login') }}"
- method="POST" name="login_user_form">
- {{ login_user_form.hidden_tag() }}
- <fieldset>
+ <form class="form-horizontal" action="{{ url_for_security('login') }}"
+ method="POST" name="login_user_form">
+ {{ login_user_form.hidden_tag() }}
+ <fieldset>
- <div class="control-group">
- <label class="control-label" for="email">Email Address</label>
- <div class="controls">
- <input id="email" class="focused" name="email" type="text" value="">
+ <div class="control-group">
+ <label class="control-label" for="email">Email Address</label>
+ <div class="controls">
+ <input id="email" class="focused" name="email" type="text" value="">
+ </div>
+ {{ render_only_errors(login_user_form.email) }}
</div>
- {{ render_only_errors(login_user_form.email) }}
- </div>
- <div class="control-group">
- <label class="control-label" for="password">Password</label>
- <div class="controls">
- <input id="password" name="password" type="password" value="">
+ <div class="control-group">
+ <label class="control-label" for="password">Password</label>
+ <div class="controls">
+ <input id="password" name="password" type="password" value="">
- {{ render_only_errors(login_user_form.password) }}
- {% if security.recoverable %}
+ {{ render_only_errors(login_user_form.password) }}
+ {% if security.recoverable %}
+
+ <a href="{{ url_for_security('forgot_password') }}">Forgot your password?</a><br/>
+ </div>
+ {% endif %}
- <a href="{{ url_for_security('forgot_password') }}">Forgot your password?</a><br/>
</div>
- {% endif %}
- </div>
+
+ <div class="control-group">
+ <div class="controls">
+ <label class="checkbox">
+ <input id="remember" name="remember" type="checkbox" value="y"> Remember me
+ </label>
+ </div>
- <div class="control-group">
- <div class="controls">
- <label class="checkbox">
- <input id="remember" name="remember" type="checkbox" value="y"> Remember me
- </label>
+ <div class="control-group">
+ <div class="controls">
+ <input id="next" name="next" type="hidden" value="">
- <input id="next" name="next" type="hidden" value="">
+ <input class="btn btn-primary" id="submit" name="submit" type="submit" value="Sign in">
+ </div>
- <input class="btn btn-primary" id="submit" name="submit" type="submit" value="Sign in">
- </div>
- </fieldset>
-</form>
+ </div>
+ </fieldset>
+
+ </form>
+</div>
{% 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" %}
-<h4>Already have an account?</h4>
+<div style="padding: 20px;">
+ <h4>Already have an account?</h4>
-<center>
- <a href="/login"
- class="btn btn-info modal_replace">Sign in using existing account</a>
-</center>
+ <center>
+ <a href="/login"
+ class="btn btn-info modal_replace">Sign in using existing account</a>
+ </center>
-<hr />
+ <hr />
-<h4>Don't have an account?</h4>
+ <h4>Don't have an account?</h4>
-<h5>Register here</h5>
+ <h5>Register here</h5>
-<form class="form-horizontal" action="{{ url_for_security('register') }}"
- method="POST" name="login_user_form">
- {{ register_user_form.hidden_tag() }}
- <fieldset>
+ <form class="form-horizontal" action="{{ url_for_security('register') }}"
+ method="POST" name="login_user_form">
+ {{ register_user_form.hidden_tag() }}
+ <fieldset>
- <div class="control-group">
- <label class="control-label" for="email">Email Address</label>
- <div class="controls">
- <input id="email" name="email" class="focused" type="text" value="">
+ <div class="control-group">
+ <label class="control-label" for="email">Email Address</label>
+ <div class="controls">
+ <input id="email" name="email" class="focused" type="text" value="">
+ </div>
+ {{ render_only_errors(register_user_form.email) }}
</div>
- {{ render_only_errors(register_user_form.email) }}
- </div>
- <div class="control-group">
- <label class="control-label" for="password">Password</label>
- <div class="controls">
- <input id="password" name="password" type="password" value="">
+ <div class="control-group">
+ <label class="control-label" for="password">Password</label>
+ <div class="controls">
+ <input id="password" name="password" type="password" value="">
+ </div>
+ {{ render_only_errors(register_user_form.password) }}
</div>
- {{ render_only_errors(register_user_form.password) }}
- </div>
-
- {% if register_user_form.password_confirm %}
- <div class="control-group">
- <label class="control-label" for="password_confirm">Password</label>
- <div class="controls">
- <input id="password" name="password_confirm" type="password" value="">
- </div>
- {{ render_only_errors(register_user_form.password_confirm) }}
-
- {% endif %}
- <div class="control-group">
- <div class="controls"">
- <input class="btn btn-primary" id="submit" name="submit" type="submit" value="Sign in">
+ {% if register_user_form.password_confirm %}
+ <div class="control-group">
+ <label class="control-label" for="password_confirm">Password</label>
+ <div class="controls">
+ <input id="password" name="password_confirm" type="password" value="">
+ </div>
+ {{ render_only_errors(register_user_form.password_confirm) }}
</div>
- </div>
+ {% endif %}
- </fieldset>
+ <div class="control-group">
+ <div class="controls"">
+ <input class="btn btn-primary" id="submit" name="submit" type="submit" value="Sign in">
+ </div>
+ </div>
-</form>
+ </fieldset>
+ </form>
+</div>
{% include "security/_scripts.html" %}
<!--{% include "security/_menu.html" %}-->