Skip to content

Commit e358b1f

Browse files
committed
Remove old method of including javascripts define_javascript_functions.
javascript_include_tag and friends do a much better job.
1 parent 5501166 commit e358b1f

File tree

3 files changed

+2
-34
lines changed

3 files changed

+2
-34
lines changed

actionpack/CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
*Edge*
22

3+
* Remove define_javascript_functions, javascript_include_tag and friends are far superior. [Michael Koziarski]
4+
35
* Deprecate :use_full_path render option. The supplying the option no longer has an effect [Josh Peek]
46

57
* Add :as option to render a collection of partials with a custom local variable name. #509 [Simon Jefford, Pratik Naik]

actionpack/lib/action_view/helpers/javascript_helper.rb

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -114,32 +114,6 @@ def button_to_function(name, *args, &block)
114114
tag(:input, html_options.merge(:type => 'button', :value => name, :onclick => onclick))
115115
end
116116

117-
# Includes the Action Pack JavaScript libraries inside a single <script>
118-
# tag. The function first includes prototype.js and then its core extensions,
119-
# (determined by filenames starting with "prototype").
120-
# Afterwards, any additional scripts will be included in undefined order.
121-
#
122-
# Note: The recommended approach is to copy the contents of
123-
# lib/action_view/helpers/javascripts/ into your application's
124-
# public/javascripts/ directory, and use +javascript_include_tag+ to
125-
# create remote <script> links.
126-
def define_javascript_functions
127-
javascript = "<script type=\"#{Mime::JS}\">"
128-
129-
# load prototype.js and its extensions first
130-
prototype_libs = Dir.glob(File.join(JAVASCRIPT_PATH, 'prototype*')).sort.reverse
131-
prototype_libs.each do |filename|
132-
javascript << "\n" << IO.read(filename)
133-
end
134-
135-
# load other libraries
136-
(Dir.glob(File.join(JAVASCRIPT_PATH, '*')) - prototype_libs).each do |filename|
137-
javascript << "\n" << IO.read(filename)
138-
end
139-
javascript << '</script>'
140-
end
141-
142-
143117
JS_ESCAPE_MAP = {
144118
'\\' => '\\\\',
145119
'</' => '<\/',

actionpack/test/template/javascript_helper_test.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,6 @@
33
class JavaScriptHelperTest < ActionView::TestCase
44
tests ActionView::Helpers::JavaScriptHelper
55

6-
def test_define_javascript_functions
7-
# check if prototype.js is included first
8-
assert_not_nil define_javascript_functions.split("\n")[1].match(/Prototype JavaScript framework/)
9-
10-
# check that scriptaculous.js is not in here, only needed if loaded remotely
11-
assert_nil define_javascript_functions.split("\n")[1].match(/var Scriptaculous = \{/)
12-
end
13-
146
def test_escape_javascript
157
assert_equal '', escape_javascript(nil)
168
assert_equal %(This \\"thing\\" is really\\n netos\\'), escape_javascript(%(This "thing" is really\n netos'))

0 commit comments

Comments
 (0)