Anonymous avatar Anonymous committed 81811ef

[svn] * Sync'd javascript, prototype helpers and prototype.js to latest Rails
modifications. Added more prototype tests.

Comments (0)

Files changed (5)

 WebHelpers ChangeLog
 
 0.2 (**svn**)
+* Sync'd javascript, prototype helpers and prototype.js to latest Rails
+  modifications. Added more prototype tests.
 * Sync'd form_options, form_tag helpers. form_tag's form function can now
   accept other HTTP methods, and will include a hidden field for them if
   its not 'get' or 'post'.

tests/test_prototype.py

             form_remote_tag(update=dict(failure="glass_of_water"),url='http://www.example.com/fast'))
         self.assertEqual("""<form action="http://www.example.com/fast" method="post" onsubmit="new Ajax.Updater({success:'glass_of_beer',failure:'glass_of_water'}, 'http://www.example.com/fast', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;">""",
             form_remote_tag(update=dict(success='glass_of_beer',failure="glass_of_water"),url='http://www.example.com/fast'))
+    
+    def test_form_remote_tag_with_method(self):
+        self.assertEqual("""<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater('glass_of_beer', 'http://www.example.com/fast', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;\"><input name="_method" type="hidden" value="put" />""",
+            form_remote_tag(update="glass_of_beer", url='http://www.example.com/fast', html={'method':'put'}))
 
     def test_on_callbacks(self):
         callbacks = ['uninitialized','loading','loaded','interactive','complete','success','failure']

webhelpers/rails/javascript.py

 * For information on using Ajax, see `Prototype Helpers <module-railshelpers.helpers.prototype.html>`_.
 * For information on using controls and visual effects, see `Scriptaculous Helpers <module-railshelpers.helpers.scriptaculous.html>`_.
 """
+# Last synced with Rails copy at Revision 4235 on Aug 19th, 2006.
+
 import re
 from tags import *
 

webhelpers/rails/javascripts/prototype.js

   request: function(url) {
     var parameters = this.options.parameters || '';
     if (parameters.length > 0) parameters += '&_=';
-
+    
+    /* Simulate other verbs over post */ 
+    if (this.options.method != 'get' && this.options.method != 'post') { 
+      parameters += (parameters.length > 0 ? '&' : '') + '_method=' + this.options.method 
+      this.options.method = 'post' 
+    }
+    
     try {
       this.url = url;
       if (this.options.method == 'get' && parameters.length > 0)

webhelpers/rails/prototype.py

 See also `Scriptaculous <module-railshelpers.helpers.scriptaculous.html>`_ for
 helpers which work with the Scriptaculous controls and visual effects library.
 """
+# Last synced with Rails copy at Revision 4235 on Aug 19th, 2006.
+
 import sys
 if sys.version < '2.4':
     from sets import ImmutableSet as frozenset
 
 from javascript import *
 from javascript import options_for_javascript
+from form_tag import form
 from tags import tag, camelize
 from urls import get_url
 
     the ``url`` (and the default method is ``post``).
     """
     options['form'] = True
-    options['html'] = options.get('html') or {}
+    if 'html' not in options: options['html'] = {}
     options['html']['onsubmit'] = "%s; return false;" % remote_function(**options)
-    options['html']['action'] = options['html'].get('action') or get_url(options['url'])
-    options['html']['method'] = options['html'].get('method') or 'post'
+    action = options['html'].get('action', get_url(options['url']))
+    options['html']['method'] = options['html'].get('method', 'post')
     
-    return tag("form", open=True, **options['html'])
+    return form(action, **options['html'])
 
 def submit_to_remote(name, value, **options):
     """
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.