From 3f2c51e3384f03f9319d9d7b78c500b590be4b1f Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Fri, 30 May 2008 17:10:57 -0700 Subject: [PATCH] Fixed mouse click handling brokenness introduced by 03b6a15e86e1. Also Beginning to phase out special-case hack for form submission. --- static/html/login.html | 2 +- static/html/password reset.html | 2 +- static/html/sign up.html | 2 +- static/js/Editor.js | 57 +++++++++++++++------------------ static/js/Wiki.js | 4 +-- view/Redeem_reset_note.py | 1 + 6 files changed, 31 insertions(+), 37 deletions(-) diff --git a/static/html/login.html b/static/html/login.html index 3502b36..3899cc8 100644 --- a/static/html/login.html +++ b/static/html/login.html @@ -13,7 +13,7 @@ No account yet? Want to make a wiki? You can sign up for a free account.

-
+

username
diff --git a/static/html/password reset.html b/static/html/password reset.html index 034073c..bbce667 100644 --- a/static/html/password reset.html +++ b/static/html/password reset.html @@ -19,7 +19,7 @@ You'll also get a username reminder. support@luminotes.com to your whitelist.

- +

email address
diff --git a/static/html/sign up.html b/static/html/sign up.html index a54e95c..3c7ef83 100644 --- a/static/html/sign up.html +++ b/static/html/sign up.html @@ -19,7 +19,7 @@ yet, try the demo first!

- +

username
diff --git a/static/js/Editor.js b/static/js/Editor.js index 8454880..a3a3862 100644 --- a/static/js/Editor.js +++ b/static/js/Editor.js @@ -153,41 +153,34 @@ Editor.prototype.finish_init = function () { connect( this.document.body, "onfocus", function ( event ) { self.focused( event ); } ); connect( this.iframe.contentWindow, "onblur", function ( event ) { self.blurred( event ); } ); connect( this.iframe.contentWindow, "onfocus", function ( event ) { self.focused( event ); } ); + connect( this.document, "onclick", function ( event ) { self.mouse_clicked( event ); } ); + + // handle each form submit event by forwarding it on as a custom event + var forms = getElementsByTagAndClassName( "form", null, this.document ); + for ( var i in forms ) { + var form = forms[ i ]; + connect( form, "onsubmit", function ( event ) { + signal( self, "submit_form", form.getAttribute( "target" ), form ); + event.stop(); + } ); + } + + // connect each (non-submit) button to issue an event + var buttons = getElementsByTagAndClassName( "input", "button", this.document ); + for ( var i in buttons ) { + var button = buttons[ i ]; + if ( button.getAttribute( "type" ) == "submit") + continue; + + connect( button, "onclick", function ( event ) { + signal( self, "button_clicked", this, button ); + event.stop(); + } ); + } // special-case: connect any submit buttons within the contents of this note + // TODO: phase out entirely withDocument( this.document, function () { - var signup_button = getElement( "signup_button" ); - if ( signup_button ) { - var signup_form = getElement( "signup_form" ); - connect( signup_button, "onclick", function ( event ) { - signal( self, "submit_form", "/users/signup", signup_form ); event.stop(); - } ); - } - - var login_button = getElement( "login_button" ); - if ( login_button ) { - var login_form = getElement( "login_form" ); - connect( login_button, "onclick", function ( event ) { - signal( self, "submit_form", "/users/login", login_form ); event.stop(); - } ); - } - - var send_reset_button = getElement( "send_reset_button" ); - if ( send_reset_button ) { - var send_reset_form = getElement( "send_reset_form" ); - connect( send_reset_button, "onclick", function ( event ) { - signal( self, "submit_form", "/users/send_reset", send_reset_form ); event.stop(); - } ); - } - - var reset_button = getElement( "reset_button" ); - if ( reset_button ) { - var reset_form = getElement( "reset_form" ); - connect( reset_button, "onclick", function ( event ) { - signal( self, "submit_form", "/users/reset_password", reset_form ); event.stop(); - } ); - } - var invite_button = getElement( "invite_button" ); if ( invite_button ) { var invite_form = getElement( "invite_form" ); diff --git a/static/js/Wiki.js b/static/js/Wiki.js index 8fdcc15..926e138 100644 --- a/static/js/Wiki.js +++ b/static/js/Wiki.js @@ -1588,7 +1588,7 @@ Wiki.prototype.share_notebook = function () { this.display_invites( invite_area ); var div = createDOM( "div", {}, - createDOM( "form", { "id": "invite_form" }, + createDOM( "form", { "id": "invite_form", "target": "/users/send_invites" }, createDOM( "input", { "type": "hidden", "name": "notebook_id", "value": this.notebook_id } ), createDOM( "p", {}, createDOM( "b", {}, "people to invite" ), @@ -1708,7 +1708,7 @@ Wiki.prototype.display_settings = function () { var group_list = createDOM( "ul" ); var div = createDOM( "div", {}, - createDOM( "form", { "id": "settings_form" }, + createDOM( "form", { "id": "settings_form", "target": "/users/update_settings" }, createDOM( "p", {}, createDOM( "b", {}, "email address" ), createDOM( "br", {} ), diff --git a/view/Redeem_reset_note.py b/view/Redeem_reset_note.py index 61e93e0..b052bee 100644 --- a/view/Redeem_reset_note.py +++ b/view/Redeem_reset_note.py @@ -35,6 +35,7 @@ class Redeem_reset_note( Span ): value = ( len( users ) > 1 ) and u"reset passwords" or u"reset password" ), ), id = "reset_form", + target = "/users/reset_password", ), P( Strong( u"tip:" ),