Skip to content
This repository
Browse code

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]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1181 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit c3ca5ab7a80702b63dc77748043f8a72ff1529a5 1 parent 6acda70
David Heinemeier Hansson authored
2  actionpack/CHANGELOG
... ...
@@ -1,5 +1,7 @@
1 1
 *SVN*
2 2
 
  3
+* 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]
  4
+
3 5
 * Added that deleting a cookie should not just set it to an empty string but also instantly expire it #1118 [todd@robotcoop.com]
4 6
 
5 7
 * Added AssetTagHelper#image_path, AssetTagHelper#javascript_path, and AssetTagHelper#stylesheet_path #1110 [Larry Halff]
22  actionpack/lib/action_view/helpers/javascript_helper.rb
@@ -95,16 +95,16 @@ def form_remote_tag(options = {})
95 95
       
96 96
       # Returns a button input tag that will submit form using XMLHttpRequest in tghe background instead of regular
97 97
       # reloading POST arrangement. <tt>options</tt> argument is the same as in <tt>form_remote_tag</tt>
98  
-      def submit_to_remote(name,value,options = {})
99  
-	options[:with] = 'Form.serialize(this.form)'
  98
+      def submit_to_remote(name, value, options = {})
  99
+        options[:with] = 'Form.serialize(this.form)'
100 100
 
101  
-	options[:html] ||= {}
102  
-	options[:html][:type] = 'button'
103  
-	options[:html][:onclick] = "#{remote_function(options)}; return false;"
104  
-	options[:html][:name] = name
105  
-	options[:html][:value] = value
106  
-	
107  
-	tag("input", options[:html], false)
  101
+        options[:html] ||= {}
  102
+        options[:html][:type] = 'button'
  103
+        options[:html][:onclick] = "#{remote_function(options)}; return false;"
  104
+        options[:html][:name] = name
  105
+        options[:html][:value] = value
  106
+
  107
+        tag("input", options[:html], false)
108 108
       end
109 109
 
110 110
       def remote_function(options) #:nodoc: for now
@@ -134,9 +134,7 @@ def remote_function(options) #:nodoc: for now
134 134
       # create remote <script> links.
135 135
       def define_javascript_functions
136 136
         javascript = '<script type="text/javascript">'
137  
-        Dir.glob(File.join(JAVASCRIPT_PATH, '*')).each do |filename|
138  
-          javascript << "\n" << IO.read(filename)
139  
-        end
  137
+        Dir.glob(File.join(JAVASCRIPT_PATH, '*')).each { |filename| javascript << "\n" << IO.read(filename) }
140 138
         javascript << '</script>'
141 139
       end
142 140
 
21  actionpack/lib/action_view/helpers/javascripts/prototype.js
... ...
@@ -1,4 +1,4 @@
1  
-/*  Prototype: an object-oriented Javascript library, version 1.0.1
  1
+/*  Prototype: an object-oriented Javascript library, version 1.1.0
2 2
  *  (c) 2005 Sam Stephenson <sam@conio.net>
3 3
  *
4 4
  *  Prototype is freely distributable under the terms of an MIT-style license. 
@@ -62,14 +62,29 @@ var Try = {
62 62
   }
63 63
 }
64 64
 
65  
-var Toggle = {
66  
-  display: function() {
  65
+// Deprecated accessor for Element.toggle
  66
+var Toggle = { display: function() { Element.toggle(arguments); } }
  67
+
  68
+var Element = {
  69
+  toggle: function() {
67 70
     for (var i = 0; i < arguments.length; i++) {
68 71
       var element = $(arguments[i]);
69 72
       element.style.display = 
70 73
         (element.style.display == 'none' ? '' : 'none');
71 74
     }
72 75
   }
  76
+  hide: function() {
  77
+    for (var i = 0; i < arguments.length; i++) {
  78
+      var element = $(arguments[i]);
  79
+      element.style.display = 'none';
  80
+    }
  81
+  }
  82
+  show: function() {
  83
+    for (var i = 0; i < arguments.length; i++) {
  84
+      var element = $(arguments[i]);
  85
+      element.style.display = '';
  86
+    }
  87
+  }
73 88
 }
74 89
 
75 90
 /*--------------------------------------------------------------------------*/
21  railties/html/javascripts/prototype.js
... ...
@@ -1,4 +1,4 @@
1  
-/*  Prototype: an object-oriented Javascript library, version 1.0.1
  1
+/*  Prototype: an object-oriented Javascript library, version 1.1.0
2 2
  *  (c) 2005 Sam Stephenson <sam@conio.net>
3 3
  *
4 4
  *  Prototype is freely distributable under the terms of an MIT-style license. 
@@ -62,14 +62,29 @@ var Try = {
62 62
   }
63 63
 }
64 64
 
65  
-var Toggle = {
66  
-  display: function() {
  65
+// Deprecated accessor for Element.toggle
  66
+var Toggle = { display: function() { Element.toggle(arguments); } }
  67
+
  68
+var Element = {
  69
+  toggle: function() {
67 70
     for (var i = 0; i < arguments.length; i++) {
68 71
       var element = $(arguments[i]);
69 72
       element.style.display = 
70 73
         (element.style.display == 'none' ? '' : 'none');
71 74
     }
72 75
   }
  76
+  hide: function() {
  77
+    for (var i = 0; i < arguments.length; i++) {
  78
+      var element = $(arguments[i]);
  79
+      element.style.display = 'none';
  80
+    }
  81
+  }
  82
+  show: function() {
  83
+    for (var i = 0; i < arguments.length; i++) {
  84
+      var element = $(arguments[i]);
  85
+      element.style.display = '';
  86
+    }
  87
+  }
73 88
 }
74 89
 
75 90
 /*--------------------------------------------------------------------------*/

0 notes on commit c3ca5ab

Please sign in to comment.
Something went wrong with that request. Please try again.