Browse Source

Fixed mouse click handling brokenness introduced by 03b6a15e86. Also Beginning to phase out special-case hack for form submission.

Dan Helfman 10 years ago
parent
commit
3f2c51e338

+ 1
- 1
static/html/login.html View File

@@ -13,7 +13,7 @@ No account yet? Want to make a wiki? You can <a href="/users/demo" target="_top"
13 13
 href="/pricing" target="_top">sign up</a> for a free account.
14 14
 </p>
15 15
 
16
-<form id="login_form">
16
+<form id="login_form" target="/users/login">
17 17
 <p>
18 18
 <b>username</b><br />
19 19
 <input type="text" name="username" id="username" class="text_field" size="30" maxlength="30" />

+ 1
- 1
static/html/password reset.html View File

@@ -19,7 +19,7 @@ You'll also get a username reminder.
19 19
 support@luminotes.com to your whitelist.
20 20
 </p>
21 21
 
22
-<form id="send_reset_form">
22
+<form id="send_reset_form" target="/users/send_reset">
23 23
 <p>
24 24
 <b>email address</b><br />
25 25
 <input type="text" name="email_address" id="email_address" class="text_field" size="30" maxlength="60" />

+ 1
- 1
static/html/sign up.html View File

@@ -19,7 +19,7 @@ yet, <a href="/users/demo" target="_top">try the demo</a> first!
19 19
 
20 20
 <p>
21 21
 
22
-<form id="signup_form">
22
+<form id="signup_form" target="/users/signup">
23 23
 <p>
24 24
 <b>username</b><br />
25 25
 <input type="text" name="username" id="username" class="text_field" size="30" maxlength="30" />

+ 25
- 32
static/js/Editor.js View File

@@ -153,41 +153,34 @@ Editor.prototype.finish_init = function () {
153 153
   connect( this.document.body, "onfocus", function ( event ) { self.focused( event ); } );
154 154
   connect( this.iframe.contentWindow, "onblur", function ( event ) { self.blurred( event ); } );
155 155
   connect( this.iframe.contentWindow, "onfocus", function ( event ) { self.focused( event ); } );
156
+  connect( this.document, "onclick", function ( event ) { self.mouse_clicked( event ); } );
157
+
158
+  // handle each form submit event by forwarding it on as a custom event
159
+  var forms = getElementsByTagAndClassName( "form", null, this.document );
160
+  for ( var i in forms ) {
161
+    var form = forms[ i ];
162
+    connect( form, "onsubmit", function ( event ) {
163
+      signal( self, "submit_form", form.getAttribute( "target" ), form );
164
+      event.stop();
165
+    } );
166
+  }
156 167
 
157
-  // special-case: connect any submit buttons within the contents of this note
158
-  withDocument( this.document, function () {
159
-    var signup_button = getElement( "signup_button" );
160
-    if ( signup_button ) {
161
-      var signup_form = getElement( "signup_form" );
162
-      connect( signup_button, "onclick", function ( event ) {
163
-        signal( self, "submit_form", "/users/signup", signup_form ); event.stop();
164
-      } );
165
-    }
166
-
167
-    var login_button = getElement( "login_button" );
168
-    if ( login_button ) {
169
-      var login_form = getElement( "login_form" );
170
-      connect( login_button, "onclick", function ( event ) {
171
-        signal( self, "submit_form", "/users/login", login_form ); event.stop();
172
-      } );
173
-    }
174
-
175
-    var send_reset_button = getElement( "send_reset_button" );
176
-    if ( send_reset_button ) {
177
-      var send_reset_form = getElement( "send_reset_form" );
178
-      connect( send_reset_button, "onclick", function ( event ) {
179
-        signal( self, "submit_form", "/users/send_reset", send_reset_form ); event.stop();
180
-      } );
181
-    }
168
+  // connect each (non-submit) button to issue an event
169
+  var buttons = getElementsByTagAndClassName( "input", "button", this.document );
170
+  for ( var i in buttons ) {
171
+    var button = buttons[ i ];
172
+    if ( button.getAttribute( "type" ) == "submit")
173
+      continue;
182 174
 
183
-    var reset_button = getElement( "reset_button" );
184
-    if ( reset_button ) {
185
-      var reset_form = getElement( "reset_form" );
186
-      connect( reset_button, "onclick", function ( event ) {
187
-        signal( self, "submit_form", "/users/reset_password", reset_form ); event.stop();
188
-      } );
189
-    }
175
+    connect( button, "onclick", function ( event ) {
176
+      signal( self, "button_clicked", this, button );
177
+      event.stop();
178
+    } );
179
+  }
190 180
 
181
+  // special-case: connect any submit buttons within the contents of this note
182
+  // TODO: phase out entirely
183
+  withDocument( this.document, function () {
191 184
     var invite_button = getElement( "invite_button" );
192 185
     if ( invite_button ) {
193 186
       var invite_form = getElement( "invite_form" );

+ 2
- 2
static/js/Wiki.js View File

@@ -1588,7 +1588,7 @@ Wiki.prototype.share_notebook = function () {
1588 1588
   this.display_invites( invite_area );
1589 1589
 
1590 1590
   var div = createDOM( "div", {}, 
1591
-    createDOM( "form", { "id": "invite_form" },
1591
+    createDOM( "form", { "id": "invite_form", "target": "/users/send_invites" },
1592 1592
       createDOM( "input", { "type": "hidden", "name": "notebook_id", "value": this.notebook_id } ),
1593 1593
       createDOM( "p", {},
1594 1594
         createDOM( "b", {}, "people to invite" ),
@@ -1708,7 +1708,7 @@ Wiki.prototype.display_settings = function () {
1708 1708
   var group_list = createDOM( "ul" );
1709 1709
 
1710 1710
   var div = createDOM( "div", {}, 
1711
-    createDOM( "form", { "id": "settings_form" },
1711
+    createDOM( "form", { "id": "settings_form", "target": "/users/update_settings" },
1712 1712
       createDOM( "p", {},
1713 1713
         createDOM( "b", {}, "email address" ),
1714 1714
         createDOM( "br", {} ),

+ 1
- 0
view/Redeem_reset_note.py View File

@@ -35,6 +35,7 @@ class Redeem_reset_note( Span ):
35 35
             value = ( len( users ) > 1 ) and u"reset passwords" or u"reset password" ),
36 36
         ),
37 37
         id = "reset_form",
38
+        target = "/users/reset_password",
38 39
       ),
39 40
       P(
40 41
         Strong( u"tip:" ),

Loading…
Cancel
Save