diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 5b413108c1..581668f19b 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Added Element.toggle, Element.show, and Element.hide to the prototype javascript library. Toggle.display has been deprecated, but will still work #992 [Lucas Carlson] + * Added that deleting a cookie should not just set it to an empty string but also instantly expire it #1118 [todd@robotcoop.com] * Added AssetTagHelper#image_path, AssetTagHelper#javascript_path, and AssetTagHelper#stylesheet_path #1110 [Larry Halff] diff --git a/actionpack/lib/action_view/helpers/javascript_helper.rb b/actionpack/lib/action_view/helpers/javascript_helper.rb index 9e91cd189e..7e11e09c1d 100644 --- a/actionpack/lib/action_view/helpers/javascript_helper.rb +++ b/actionpack/lib/action_view/helpers/javascript_helper.rb @@ -95,16 +95,16 @@ module ActionView # Returns a button input tag that will submit form using XMLHttpRequest in tghe background instead of regular # reloading POST arrangement. options argument is the same as in form_remote_tag - def submit_to_remote(name,value,options = {}) - options[:with] = 'Form.serialize(this.form)' + def submit_to_remote(name, value, options = {}) + options[:with] = 'Form.serialize(this.form)' - options[:html] ||= {} - options[:html][:type] = 'button' - options[:html][:onclick] = "#{remote_function(options)}; return false;" - options[:html][:name] = name - options[:html][:value] = value - - tag("input", options[:html], false) + options[:html] ||= {} + options[:html][:type] = 'button' + options[:html][:onclick] = "#{remote_function(options)}; return false;" + options[:html][:name] = name + options[:html][:value] = value + + tag("input", options[:html], false) end def remote_function(options) #:nodoc: for now @@ -134,9 +134,7 @@ module ActionView # create remote ' end diff --git a/actionpack/lib/action_view/helpers/javascripts/prototype.js b/actionpack/lib/action_view/helpers/javascripts/prototype.js index 1ab50882c4..c3e373cd64 100644 --- a/actionpack/lib/action_view/helpers/javascripts/prototype.js +++ b/actionpack/lib/action_view/helpers/javascripts/prototype.js @@ -1,4 +1,4 @@ -/* Prototype: an object-oriented Javascript library, version 1.0.1 +/* Prototype: an object-oriented Javascript library, version 1.1.0 * (c) 2005 Sam Stephenson * * Prototype is freely distributable under the terms of an MIT-style license. @@ -62,14 +62,29 @@ var Try = { } } -var Toggle = { - display: function() { +// Deprecated accessor for Element.toggle +var Toggle = { display: function() { Element.toggle(arguments); } } + +var Element = { + toggle: function() { for (var i = 0; i < arguments.length; i++) { var element = $(arguments[i]); element.style.display = (element.style.display == 'none' ? '' : 'none'); } } + hide: function() { + for (var i = 0; i < arguments.length; i++) { + var element = $(arguments[i]); + element.style.display = 'none'; + } + } + show: function() { + for (var i = 0; i < arguments.length; i++) { + var element = $(arguments[i]); + element.style.display = ''; + } + } } /*--------------------------------------------------------------------------*/ diff --git a/railties/html/javascripts/prototype.js b/railties/html/javascripts/prototype.js index 1ab50882c4..c3e373cd64 100644 --- a/railties/html/javascripts/prototype.js +++ b/railties/html/javascripts/prototype.js @@ -1,4 +1,4 @@ -/* Prototype: an object-oriented Javascript library, version 1.0.1 +/* Prototype: an object-oriented Javascript library, version 1.1.0 * (c) 2005 Sam Stephenson * * Prototype is freely distributable under the terms of an MIT-style license. @@ -62,14 +62,29 @@ var Try = { } } -var Toggle = { - display: function() { +// Deprecated accessor for Element.toggle +var Toggle = { display: function() { Element.toggle(arguments); } } + +var Element = { + toggle: function() { for (var i = 0; i < arguments.length; i++) { var element = $(arguments[i]); element.style.display = (element.style.display == 'none' ? '' : 'none'); } } + hide: function() { + for (var i = 0; i < arguments.length; i++) { + var element = $(arguments[i]); + element.style.display = 'none'; + } + } + show: function() { + for (var i = 0; i < arguments.length; i++) { + var element = $(arguments[i]); + element.style.display = ''; + } + } } /*--------------------------------------------------------------------------*/