actionpack 1.10.2 → 1.11.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of actionpack might be problematic. Click here for more details.
- data/CHANGELOG +57 -3
- data/README +7 -7
- data/lib/action_controller/assertions.rb +28 -11
- data/lib/action_controller/base.rb +22 -15
- data/lib/action_controller/caching.rb +6 -6
- data/lib/action_controller/components.rb +1 -1
- data/lib/action_controller/cookies.rb +3 -3
- data/lib/action_controller/dependencies.rb +1 -1
- data/lib/action_controller/filters.rb +40 -3
- data/lib/action_controller/flash.rb +4 -0
- data/lib/action_controller/helpers.rb +1 -1
- data/lib/action_controller/layout.rb +2 -1
- data/lib/action_controller/pagination.rb +2 -1
- data/lib/action_controller/rescue.rb +1 -1
- data/lib/action_controller/session/active_record_store.rb +18 -29
- data/lib/action_controller/templates/rescues/_trace.rhtml +0 -3
- data/lib/action_controller/templates/scaffolds/layout.rhtml +1 -1
- data/lib/action_controller/vendor/html-scanner/html/document.rb +2 -2
- data/lib/action_pack.rb +24 -0
- data/lib/action_pack/version.rb +2 -2
- data/lib/action_view/base.rb +1 -1
- data/lib/action_view/helpers/asset_tag_helper.rb +21 -3
- data/lib/action_view/helpers/form_options_helper.rb +1 -1
- data/lib/action_view/helpers/javascript_helper.rb +1 -0
- data/lib/action_view/helpers/javascripts/controls.js +18 -5
- data/lib/action_view/helpers/javascripts/dragdrop.js +6 -3
- data/lib/action_view/helpers/javascripts/effects.js +181 -290
- data/lib/action_view/helpers/javascripts/prototype.js +8 -8
- data/lib/action_view/helpers/text_helper.rb +22 -0
- data/lib/action_view/helpers/url_helper.rb +1 -1
- data/lib/action_view/template_error.rb +2 -1
- data/rakefile +1 -1
- data/test/controller/components_test.rb +5 -0
- data/test/controller/filters_test.rb +2 -1
- data/test/controller/flash_test.rb +6 -0
- data/test/controller/new_render_test.rb +11 -0
- data/test/controller/redirect_test.rb +10 -0
- data/test/fixtures/layouts/standard.rhtml +1 -1
- data/test/template/asset_tag_helper_test.rb +19 -2
- data/test/template/javascript_helper_test.rb +1 -0
- data/test/template/text_helper_test.rb +9 -0
- metadata +5 -4
- data/lib/action_view/helpers/javascripts/slider.js +0 -258
@@ -1,4 +1,4 @@
|
|
1
|
-
/* Prototype JavaScript framework, version 1.4.
|
1
|
+
/* Prototype JavaScript framework, version 1.4.0_rc2
|
2
2
|
* (c) 2005 Sam Stephenson <sam@conio.net>
|
3
3
|
*
|
4
4
|
* THIS FILE IS AUTOMATICALLY GENERATED. When sending patches, please diff
|
@@ -11,7 +11,7 @@
|
|
11
11
|
/*--------------------------------------------------------------------------*/
|
12
12
|
|
13
13
|
var Prototype = {
|
14
|
-
Version: '1.4.
|
14
|
+
Version: '1.4.0_rc2',
|
15
15
|
|
16
16
|
emptyFunction: function() {},
|
17
17
|
K: function(x) {return x}
|
@@ -787,7 +787,7 @@ Ajax.PeriodicalUpdater.prototype = Object.extend(new Ajax.Base(), {
|
|
787
787
|
document.getElementsByClassName = function(className, parentElement) {
|
788
788
|
var children = ($(parentElement) || document.body).getElementsByTagName('*');
|
789
789
|
return $A(children).inject([], function(elements, child) {
|
790
|
-
if (
|
790
|
+
if (child.className.match(new RegExp("(^|\\s)" + className + "(\\s|$)")))
|
791
791
|
elements.push(child);
|
792
792
|
return elements;
|
793
793
|
});
|
@@ -1131,7 +1131,7 @@ var Form = {
|
|
1131
1131
|
},
|
1132
1132
|
|
1133
1133
|
getElements: function(form) {
|
1134
|
-
|
1134
|
+
form = $(form);
|
1135
1135
|
var elements = new Array();
|
1136
1136
|
|
1137
1137
|
for (tagName in Form.Element.Serializers) {
|
@@ -1143,7 +1143,7 @@ var Form = {
|
|
1143
1143
|
},
|
1144
1144
|
|
1145
1145
|
getInputs: function(form, typeName, name) {
|
1146
|
-
|
1146
|
+
form = $(form);
|
1147
1147
|
var inputs = form.getElementsByTagName('input');
|
1148
1148
|
|
1149
1149
|
if (!typeName && !name)
|
@@ -1179,7 +1179,7 @@ var Form = {
|
|
1179
1179
|
},
|
1180
1180
|
|
1181
1181
|
focusFirstElement: function(form) {
|
1182
|
-
|
1182
|
+
form = $(form);
|
1183
1183
|
var elements = Form.getElements(form);
|
1184
1184
|
for (var i = 0; i < elements.length; i++) {
|
1185
1185
|
var element = elements[i];
|
@@ -1197,7 +1197,7 @@ var Form = {
|
|
1197
1197
|
|
1198
1198
|
Form.Element = {
|
1199
1199
|
serialize: function(element) {
|
1200
|
-
|
1200
|
+
element = $(element);
|
1201
1201
|
var method = element.tagName.toLowerCase();
|
1202
1202
|
var parameter = Form.Element.Serializers[method](element);
|
1203
1203
|
|
@@ -1207,7 +1207,7 @@ Form.Element = {
|
|
1207
1207
|
},
|
1208
1208
|
|
1209
1209
|
getValue: function(element) {
|
1210
|
-
|
1210
|
+
element = $(element);
|
1211
1211
|
var method = element.tagName.toLowerCase();
|
1212
1212
|
var parameter = Form.Element.Serializers[method](element);
|
1213
1213
|
|
@@ -202,6 +202,28 @@ module ActionView
|
|
202
202
|
html
|
203
203
|
end
|
204
204
|
|
205
|
+
# Strips all HTML tags from the input, including comments. This uses the html-scanner
|
206
|
+
# tokenizer and so it's HTML parsing ability is limited by that of html-scanner.
|
207
|
+
#
|
208
|
+
# Returns the tag free text.
|
209
|
+
def strip_tags(html)
|
210
|
+
if html.index("<")
|
211
|
+
text = ""
|
212
|
+
tokenizer = HTML::Tokenizer.new(html)
|
213
|
+
|
214
|
+
while token = tokenizer.next
|
215
|
+
node = HTML::Node.parse(nil, 0, 0, token, false)
|
216
|
+
# result is only the content of any Text nodes
|
217
|
+
text << node.to_s if node.class == HTML::Text
|
218
|
+
end
|
219
|
+
# strip any comments, and if they have a newline at the end (ie. line with
|
220
|
+
# only a comment) strip that too
|
221
|
+
text.gsub(/<!--(.*?)-->[\n]?/m, "")
|
222
|
+
else
|
223
|
+
html # already plain text
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
205
227
|
# Returns a Cycle object whose to_s value cycles through items of an
|
206
228
|
# array every time it is called. This can be used to alternate classes
|
207
229
|
# for table rows:
|
@@ -282,7 +282,7 @@ module ActionView
|
|
282
282
|
#
|
283
283
|
# "attr" => bool_value
|
284
284
|
#
|
285
|
-
# if the
|
285
|
+
# if the associated _bool_value_ evaluates to true, it is
|
286
286
|
# replaced with the attribute's name; otherwise the attribute is
|
287
287
|
# removed from the _html_options_ hash. (See the XHTML 1.0 spec,
|
288
288
|
# section 4.5 "Attribute Minimization" for more:
|
@@ -47,7 +47,7 @@ module ActionView
|
|
47
47
|
|
48
48
|
def line_number
|
49
49
|
if file_name
|
50
|
-
regexp = /#{Regexp.escape File.basename(file_name)}:(\d+)
|
50
|
+
regexp = /#{Regexp.escape File.basename(file_name)}:(\d+)/
|
51
51
|
[@original_exception.message, @original_exception.clean_backtrace].flatten.each do |line|
|
52
52
|
return $1.to_i if regexp =~ line
|
53
53
|
end
|
@@ -83,3 +83,4 @@ module ActionView
|
|
83
83
|
end
|
84
84
|
|
85
85
|
Exception::TraceSubstitutions << [/:in\s+`_run_(html|xml).*'\s*$/, ''] if defined?(Exception::TraceSubstitutions)
|
86
|
+
Exception::TraceSubstitutions << [%r{^\s*#{Regexp.escape RAILS_ROOT}}, '#{RAILS_ROOT}'] if defined?(RAILS_ROOT)
|
data/rakefile
CHANGED
@@ -62,7 +62,7 @@ spec = Gem::Specification.new do |s|
|
|
62
62
|
s.has_rdoc = true
|
63
63
|
s.requirements << 'none'
|
64
64
|
|
65
|
-
s.add_dependency('activesupport', '= 1.2.
|
65
|
+
s.add_dependency('activesupport', '= 1.2.3' + PKG_BUILD)
|
66
66
|
|
67
67
|
s.require_path = 'lib'
|
68
68
|
s.autorequire = 'action_controller'
|
@@ -116,6 +116,11 @@ class ComponentsTest < Test::Unit::TestCase
|
|
116
116
|
assert_redirected_to :action => "being_called"
|
117
117
|
end
|
118
118
|
|
119
|
+
def test_component_multiple_redirect_redirects
|
120
|
+
test_component_redirect_redirects
|
121
|
+
test_internal_calling
|
122
|
+
end
|
123
|
+
|
119
124
|
def test_component_as_string_redirect_renders_redirecte_action
|
120
125
|
get :calling_redirected_as_string
|
121
126
|
|
@@ -99,6 +99,7 @@ class FilterTest < Test::Unit::TestCase
|
|
99
99
|
|
100
100
|
class PrependingController < TestController
|
101
101
|
prepend_before_filter :wonderful_life
|
102
|
+
skip_before_filter :fire_flash
|
102
103
|
|
103
104
|
private
|
104
105
|
def wonderful_life
|
@@ -225,7 +226,7 @@ class FilterTest < Test::Unit::TestCase
|
|
225
226
|
end
|
226
227
|
|
227
228
|
def test_prepending_filter
|
228
|
-
assert_equal [ :wonderful_life, :
|
229
|
+
assert_equal [ :wonderful_life, :ensure_login ], PrependingController.before_filters
|
229
230
|
end
|
230
231
|
|
231
232
|
def test_running_filters
|
@@ -9,6 +9,9 @@ class FlashTest < Test::Unit::TestCase
|
|
9
9
|
|
10
10
|
def set_flash_now
|
11
11
|
flash.now["that"] = "hello"
|
12
|
+
flash.now["foo"] ||= "bar"
|
13
|
+
flash.now["foo"] ||= "err"
|
14
|
+
@flashy = flash.now["that"]
|
12
15
|
@flash_copy = {}.update flash
|
13
16
|
render :inline => "hello"
|
14
17
|
end
|
@@ -75,10 +78,13 @@ class FlashTest < Test::Unit::TestCase
|
|
75
78
|
@request.action = "set_flash_now"
|
76
79
|
response = process_request
|
77
80
|
assert_equal "hello", response.template.assigns["flash_copy"]["that"]
|
81
|
+
assert_equal "bar" , response.template.assigns["flash_copy"]["foo"]
|
82
|
+
assert_equal "hello", response.template.assigns["flashy"]
|
78
83
|
|
79
84
|
@request.action = "attempt_to_use_flash_now"
|
80
85
|
first_response = process_request
|
81
86
|
assert_nil first_response.template.assigns["flash_copy"]["that"]
|
87
|
+
assert_nil first_response.template.assigns["flash_copy"]["foo"]
|
82
88
|
assert_nil first_response.template.assigns["flashy"]
|
83
89
|
end
|
84
90
|
|
@@ -34,6 +34,11 @@ class NewRenderTestController < ActionController::Base
|
|
34
34
|
def render_text_hello_world
|
35
35
|
render :text => "hello world"
|
36
36
|
end
|
37
|
+
|
38
|
+
def render_text_hello_world_with_layout
|
39
|
+
@variable_for_layout = ", I'm here!"
|
40
|
+
render :text => "hello world", :layout => true
|
41
|
+
end
|
37
42
|
|
38
43
|
def render_custom_code
|
39
44
|
render :text => "hello world", :status => "404 Moved"
|
@@ -169,6 +174,7 @@ class NewRenderTestController < ActionController::Base
|
|
169
174
|
case action_name
|
170
175
|
when "hello_world", "layout_test", "rendering_without_layout",
|
171
176
|
"rendering_nothing_on_layout", "render_text_hello_world",
|
177
|
+
"render_text_hello_world_with_layout",
|
172
178
|
"partial_only", "partial_only_with_layout",
|
173
179
|
"accessing_params_in_template",
|
174
180
|
"accessing_params_in_template_with_layout",
|
@@ -226,6 +232,11 @@ class NewRenderTest < Test::Unit::TestCase
|
|
226
232
|
assert_equal "hello world", @response.body
|
227
233
|
end
|
228
234
|
|
235
|
+
def test_do_with_render_text_and_layout
|
236
|
+
get :render_text_hello_world_with_layout
|
237
|
+
assert_equal "<html>hello world, I'm here!</html>", @response.body
|
238
|
+
end
|
239
|
+
|
229
240
|
def test_do_with_render_custom_code
|
230
241
|
get :render_custom_code
|
231
242
|
assert_response :missing
|
@@ -22,6 +22,10 @@ class RedirectController < ActionController::Base
|
|
22
22
|
redirect_to :action => "hello_world"
|
23
23
|
end
|
24
24
|
|
25
|
+
def redirect_to_back
|
26
|
+
redirect_to :back
|
27
|
+
end
|
28
|
+
|
25
29
|
def rescue_errors(e) raise e end
|
26
30
|
|
27
31
|
protected
|
@@ -66,6 +70,12 @@ class RedirectTest < Test::Unit::TestCase
|
|
66
70
|
get :redirect_with_assigns
|
67
71
|
assert_equal "world", assigns["hello"]
|
68
72
|
end
|
73
|
+
|
74
|
+
def test_redirect_to_back
|
75
|
+
@request.env["HTTP_REFERER"] = "http://www.example.com/coming/from"
|
76
|
+
get :redirect_to_back
|
77
|
+
assert_redirect_url "http://www.example.com/coming/from"
|
78
|
+
end
|
69
79
|
end
|
70
80
|
|
71
81
|
module ModuleTest
|
@@ -1 +1 @@
|
|
1
|
-
<html><%= @content_for_layout %></html>
|
1
|
+
<html><%= @content_for_layout %><%= @variable_for_layout %></html>
|
@@ -24,6 +24,7 @@ class AssetTagHelperTest < Test::Unit::TestCase
|
|
24
24
|
|
25
25
|
@controller.request = @request
|
26
26
|
|
27
|
+
ActionView::Helpers::AssetTagHelper::reset_javascript_include_default
|
27
28
|
end
|
28
29
|
|
29
30
|
AutoDiscoveryToTag = {
|
@@ -48,6 +49,7 @@ class AssetTagHelperTest < Test::Unit::TestCase
|
|
48
49
|
%(javascript_include_tag("xmlhr")) => %(<script src="/javascripts/xmlhr.js" type="text/javascript"></script>),
|
49
50
|
%(javascript_include_tag("xmlhr", :lang => "vbscript")) => %(<script lang="vbscript" src="/javascripts/xmlhr.js" type="text/javascript"></script>),
|
50
51
|
%(javascript_include_tag("common.javascript", "/elsewhere/cools")) => %(<script src="/javascripts/common.javascript" type="text/javascript"></script>\n<script src="/elsewhere/cools.js" type="text/javascript"></script>),
|
52
|
+
%(javascript_include_tag(:defaults)) => %(<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>)
|
51
53
|
}
|
52
54
|
|
53
55
|
StylePathToTag = {
|
@@ -85,6 +87,13 @@ class AssetTagHelperTest < Test::Unit::TestCase
|
|
85
87
|
def test_javascript_include
|
86
88
|
JavascriptIncludeToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
|
87
89
|
end
|
90
|
+
|
91
|
+
def test_register_javascript_include_default
|
92
|
+
ActionView::Helpers::AssetTagHelper::register_javascript_include_default 'slider'
|
93
|
+
assert_dom_equal %(<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/slider.js" type="text/javascript"></script>), javascript_include_tag(:defaults)
|
94
|
+
ActionView::Helpers::AssetTagHelper::register_javascript_include_default 'lib1', '/elsewhere/blub/lib2'
|
95
|
+
assert_dom_equal %(<script src="/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/javascripts/effects.js" type="text/javascript"></script>\n<script src="/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/javascripts/controls.js" type="text/javascript"></script>\n<script src="/javascripts/slider.js" type="text/javascript"></script>\n<script src="/javascripts/lib1.js" type="text/javascript"></script>\n<script src="/elsewhere/blub/lib2.js" type="text/javascript"></script>), javascript_include_tag(:defaults)
|
96
|
+
end
|
88
97
|
|
89
98
|
def test_style_path
|
90
99
|
StylePathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
|
@@ -127,7 +136,8 @@ class AssetTagHelperNonVhostTest < Test::Unit::TestCase
|
|
127
136
|
end.new
|
128
137
|
|
129
138
|
@controller.request = @request
|
130
|
-
|
139
|
+
|
140
|
+
ActionView::Helpers::AssetTagHelper::reset_javascript_include_default
|
131
141
|
end
|
132
142
|
|
133
143
|
AutoDiscoveryToTag = {
|
@@ -143,7 +153,7 @@ class AssetTagHelperNonVhostTest < Test::Unit::TestCase
|
|
143
153
|
JavascriptIncludeToTag = {
|
144
154
|
%(javascript_include_tag("xmlhr")) => %(<script src="/calloboration/hieraki/javascripts/xmlhr.js" type="text/javascript"></script>),
|
145
155
|
%(javascript_include_tag("common.javascript", "/elsewhere/cools")) => %(<script src="/calloboration/hieraki/javascripts/common.javascript" type="text/javascript"></script>\n<script src="/calloboration/hieraki/elsewhere/cools.js" type="text/javascript"></script>),
|
146
|
-
%(javascript_include_tag(:defaults)) => %(<script src=
|
156
|
+
%(javascript_include_tag(:defaults)) => %(<script src="/calloboration/hieraki/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/calloboration/hieraki/javascripts/effects.js" type="text/javascript"></script>\n<script src="/calloboration/hieraki/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/calloboration/hieraki/javascripts/controls.js" type="text/javascript"></script>)
|
147
157
|
}
|
148
158
|
|
149
159
|
StylePathToTag = {
|
@@ -177,6 +187,13 @@ class AssetTagHelperNonVhostTest < Test::Unit::TestCase
|
|
177
187
|
def test_javascript_include
|
178
188
|
JavascriptIncludeToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
|
179
189
|
end
|
190
|
+
|
191
|
+
def test_register_javascript_include_default
|
192
|
+
ActionView::Helpers::AssetTagHelper::register_javascript_include_default 'slider'
|
193
|
+
assert_dom_equal %(<script src="/calloboration/hieraki/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/calloboration/hieraki/javascripts/effects.js" type="text/javascript"></script>\n<script src="/calloboration/hieraki/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/calloboration/hieraki/javascripts/controls.js" type="text/javascript"></script>\n<script src="/calloboration/hieraki/javascripts/slider.js" type="text/javascript"></script>), javascript_include_tag(:defaults)
|
194
|
+
ActionView::Helpers::AssetTagHelper::register_javascript_include_default 'lib1', '/elsewhere/blub/lib2'
|
195
|
+
assert_dom_equal %(<script src="/calloboration/hieraki/javascripts/prototype.js" type="text/javascript"></script>\n<script src="/calloboration/hieraki/javascripts/effects.js" type="text/javascript"></script>\n<script src="/calloboration/hieraki/javascripts/dragdrop.js" type="text/javascript"></script>\n<script src="/calloboration/hieraki/javascripts/controls.js" type="text/javascript"></script>\n<script src="/calloboration/hieraki/javascripts/slider.js" type="text/javascript"></script>\n<script src="/calloboration/hieraki/javascripts/lib1.js" type="text/javascript"></script>\n<script src="/calloboration/hieraki/elsewhere/blub/lib2.js" type="text/javascript"></script>), javascript_include_tag(:defaults)
|
196
|
+
end
|
180
197
|
|
181
198
|
def test_style_path
|
182
199
|
StylePathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
|
@@ -125,6 +125,7 @@ class JavaScriptHelperTest < Test::Unit::TestCase
|
|
125
125
|
assert_equal "new Effect.Highlight('posts',{});", visual_effect(:highlight, :posts)
|
126
126
|
assert_equal "new Effect.Fade('fademe',{duration:4.0});", visual_effect(:fade, "fademe", :duration => 4.0)
|
127
127
|
assert_equal "new Effect.Shake(element,{});", visual_effect(:shake)
|
128
|
+
assert_equal "new Effect.DropOut('dropme',{queue:'end'});", visual_effect(:drop_out, 'dropme', :queue => :end)
|
128
129
|
end
|
129
130
|
|
130
131
|
def test_sortable_element
|
@@ -268,4 +268,13 @@ class TextHelperTest < Test::Unit::TestCase
|
|
268
268
|
assert_equal(%w{Specialized Fuji Giant}, @cycles)
|
269
269
|
end
|
270
270
|
|
271
|
+
def test_strip_tags
|
272
|
+
assert_equal("This is a test.", strip_tags("<p>This <u>is<u> a <a href='test.html'><strong>test</strong></a>.</p>"))
|
273
|
+
assert_equal("This is a test.", strip_tags("This is a test."))
|
274
|
+
assert_equal(
|
275
|
+
%{This is a test.\n\n\nIt no longer contains any HTML.\n}, strip_tags(
|
276
|
+
%{<title>This is <b>a <a href="" target="_blank">test</a></b>.</title>\n\n<!-- it has a comment -->\n\n<p>It no <b>longer <strong>contains <em>any <strike>HTML</strike></em>.</strong></b></p>\n}))
|
277
|
+
assert_equal("This has a here.", strip_tags("This has a <!-- comment --> here."))
|
278
|
+
end
|
279
|
+
|
271
280
|
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: actionpack
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.
|
7
|
-
date: 2005-
|
6
|
+
version: 1.11.0
|
7
|
+
date: 2005-11-07 00:00:00 +01:00
|
8
8
|
summary: Web-flow and rendering framework putting the VC in MVC.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -41,6 +41,7 @@ files:
|
|
41
41
|
- lib/action_controller
|
42
42
|
- lib/action_controller.rb
|
43
43
|
- lib/action_pack
|
44
|
+
- lib/action_pack.rb
|
44
45
|
- lib/action_view
|
45
46
|
- lib/action_view.rb
|
46
47
|
- lib/action_controller/assertions.rb
|
@@ -138,7 +139,6 @@ files:
|
|
138
139
|
- lib/action_view/helpers/javascripts/dragdrop.js
|
139
140
|
- lib/action_view/helpers/javascripts/effects.js
|
140
141
|
- lib/action_view/helpers/javascripts/prototype.js
|
141
|
-
- lib/action_view/helpers/javascripts/slider.js
|
142
142
|
- lib/action_view/vendor/builder
|
143
143
|
- lib/action_view/vendor/builder.rb
|
144
144
|
- lib/action_view/vendor/builder/blankslate.rb
|
@@ -148,6 +148,7 @@ files:
|
|
148
148
|
- test/abstract_unit.rb
|
149
149
|
- test/controller
|
150
150
|
- test/fixtures
|
151
|
+
- test/temp
|
151
152
|
- test/template
|
152
153
|
- test/testing_sandbox.rb
|
153
154
|
- test/controller/action_pack_assertions_test.rb
|
@@ -266,5 +267,5 @@ dependencies:
|
|
266
267
|
-
|
267
268
|
- "="
|
268
269
|
- !ruby/object:Gem::Version
|
269
|
-
version: 1.2.
|
270
|
+
version: 1.2.3
|
270
271
|
version:
|
@@ -1,258 +0,0 @@
|
|
1
|
-
// Copyright (c) 2005 Marty Haught
|
2
|
-
//
|
3
|
-
// See scriptaculous.js for full license.
|
4
|
-
|
5
|
-
if(!Control) var Control = {};
|
6
|
-
Control.Slider = Class.create();
|
7
|
-
|
8
|
-
// options:
|
9
|
-
// axis: 'vertical', or 'horizontal' (default)
|
10
|
-
// increment: (default: 1)
|
11
|
-
// step: (default: 1)
|
12
|
-
//
|
13
|
-
// callbacks:
|
14
|
-
// onChange(value)
|
15
|
-
// onSlide(value)
|
16
|
-
Control.Slider.prototype = {
|
17
|
-
initialize: function(handle, track, options) {
|
18
|
-
this.handle = $(handle);
|
19
|
-
this.track = $(track);
|
20
|
-
|
21
|
-
this.options = options || {};
|
22
|
-
|
23
|
-
this.axis = this.options.axis || 'horizontal';
|
24
|
-
this.increment = this.options.increment || 1;
|
25
|
-
this.step = parseInt(this.options.step) || 1;
|
26
|
-
this.value = 0;
|
27
|
-
|
28
|
-
var defaultMaximum = Math.round(this.track.offsetWidth / this.increment);
|
29
|
-
if(this.isVertical()) defaultMaximum = Math.round(this.track.offsetHeight / this.increment);
|
30
|
-
|
31
|
-
this.maximum = this.options.maximum || defaultMaximum;
|
32
|
-
this.minimum = this.options.minimum || 0;
|
33
|
-
|
34
|
-
// Will be used to align the handle onto the track, if necessary
|
35
|
-
this.alignX = parseInt (this.options.alignX) || 0;
|
36
|
-
this.alignY = parseInt (this.options.alignY) || 0;
|
37
|
-
|
38
|
-
// Zero out the slider position
|
39
|
-
this.setCurrentLeft(Position.cumulativeOffset(this.track)[0] - Position.cumulativeOffset(this.handle)[0] + this.alignX);
|
40
|
-
this.setCurrentTop(this.trackTop() - Position.cumulativeOffset(this.handle)[1] + this.alignY);
|
41
|
-
|
42
|
-
this.offsetX = 0;
|
43
|
-
this.offsetY = 0;
|
44
|
-
|
45
|
-
this.originalLeft = this.currentLeft();
|
46
|
-
this.originalTop = this.currentTop();
|
47
|
-
this.originalZ = parseInt(this.handle.style.zIndex || "0");
|
48
|
-
|
49
|
-
// Prepopulate Slider value
|
50
|
-
this.setSliderValue(parseInt(this.options.sliderValue) || 0);
|
51
|
-
|
52
|
-
this.active = false;
|
53
|
-
this.dragging = false;
|
54
|
-
this.disabled = false;
|
55
|
-
|
56
|
-
// FIXME: use css
|
57
|
-
this.handleImage = $(this.options.handleImage) || false;
|
58
|
-
this.handleDisabled = this.options.handleDisabled || false;
|
59
|
-
this.handleEnabled = false;
|
60
|
-
if(this.handleImage)
|
61
|
-
this.handleEnabled = this.handleImage.src || false;
|
62
|
-
|
63
|
-
if(this.options.disabled)
|
64
|
-
this.setDisabled();
|
65
|
-
|
66
|
-
// Value Array
|
67
|
-
this.values = this.options.values || false; // Add method to validate and sort??
|
68
|
-
|
69
|
-
Element.makePositioned(this.handle); // fix IE
|
70
|
-
|
71
|
-
this.eventMouseDown = this.startDrag.bindAsEventListener(this);
|
72
|
-
this.eventMouseUp = this.endDrag.bindAsEventListener(this);
|
73
|
-
this.eventMouseMove = this.update.bindAsEventListener(this);
|
74
|
-
this.eventKeypress = this.keyPress.bindAsEventListener(this);
|
75
|
-
|
76
|
-
Event.observe(this.handle, "mousedown", this.eventMouseDown);
|
77
|
-
Event.observe(document, "mouseup", this.eventMouseUp);
|
78
|
-
Event.observe(document, "mousemove", this.eventMouseMove);
|
79
|
-
Event.observe(document, "keypress", this.eventKeypress);
|
80
|
-
},
|
81
|
-
dispose: function() {
|
82
|
-
Event.stopObserving(this.handle, "mousedown", this.eventMouseDown);
|
83
|
-
Event.stopObserving(document, "mouseup", this.eventMouseUp);
|
84
|
-
Event.stopObserving(document, "mousemove", this.eventMouseMove);
|
85
|
-
Event.stopObserving(document, "keypress", this.eventKeypress);
|
86
|
-
},
|
87
|
-
setDisabled: function(){
|
88
|
-
this.disabled = true;
|
89
|
-
if(this.handleDisabled)
|
90
|
-
this.handleImage.src = this.handleDisabled;
|
91
|
-
},
|
92
|
-
setEnabled: function(){
|
93
|
-
this.disabled = false;
|
94
|
-
if(this.handleEnabled)
|
95
|
-
this.handleImage.src = this.handleEnabled;
|
96
|
-
},
|
97
|
-
currentLeft: function() {
|
98
|
-
return parseInt(this.handle.style.left || '0');
|
99
|
-
},
|
100
|
-
currentTop: function() {
|
101
|
-
return parseInt(this.handle.style.top || '0');
|
102
|
-
},
|
103
|
-
setCurrentLeft: function(left) {
|
104
|
-
this.handle.style.left = left +"px";
|
105
|
-
},
|
106
|
-
setCurrentTop: function(top) {
|
107
|
-
this.handle.style.top = top +"px";
|
108
|
-
},
|
109
|
-
trackLeft: function(){
|
110
|
-
return Position.cumulativeOffset(this.track)[0];
|
111
|
-
},
|
112
|
-
trackTop: function(){
|
113
|
-
return Position.cumulativeOffset(this.track)[1];
|
114
|
-
},
|
115
|
-
getNearestValue: function(value){
|
116
|
-
if(this.values){
|
117
|
-
var i = 0;
|
118
|
-
var offset = Math.abs(this.values[0] - value);
|
119
|
-
var newValue = this.values[0];
|
120
|
-
|
121
|
-
for(i=0; i < this.values.length; i++){
|
122
|
-
var currentOffset = Math.abs(this.values[i] - value);
|
123
|
-
if(currentOffset < offset){
|
124
|
-
newValue = this.values[i];
|
125
|
-
offset = currentOffset;
|
126
|
-
}
|
127
|
-
}
|
128
|
-
return newValue;
|
129
|
-
}
|
130
|
-
return value;
|
131
|
-
},
|
132
|
-
setSliderValue: function(sliderValue){
|
133
|
-
// First check our max and minimum and nearest values
|
134
|
-
sliderValue = this.getNearestValue(sliderValue);
|
135
|
-
if(sliderValue > this.maximum) sliderValue = this.maximum;
|
136
|
-
if(sliderValue < this.minimum) sliderValue = this.minimum;
|
137
|
-
var offsetDiff = (sliderValue - (this.value||this.minimum)) * this.increment;
|
138
|
-
|
139
|
-
if(this.isVertical()){
|
140
|
-
this.setCurrentTop(offsetDiff + this.currentTop());
|
141
|
-
} else {
|
142
|
-
this.setCurrentLeft(offsetDiff + this.currentLeft());
|
143
|
-
}
|
144
|
-
this.value = sliderValue;
|
145
|
-
this.updateFinished();
|
146
|
-
},
|
147
|
-
minimumOffset: function(){
|
148
|
-
return(this.isVertical() ?
|
149
|
-
this.trackTop() + this.alignY :
|
150
|
-
this.trackLeft() + this.alignX);
|
151
|
-
},
|
152
|
-
maximumOffset: function(){
|
153
|
-
return(this.isVertical() ?
|
154
|
-
this.trackTop() + this.alignY + (this.maximum - this.minimum) * this.increment :
|
155
|
-
this.trackLeft() + this.alignX + (this.maximum - this.minimum) * this.increment);
|
156
|
-
},
|
157
|
-
isVertical: function(){
|
158
|
-
return (this.axis == 'vertical');
|
159
|
-
},
|
160
|
-
startDrag: function(event) {
|
161
|
-
if(Event.isLeftClick(event)) {
|
162
|
-
if(!this.disabled){
|
163
|
-
this.active = true;
|
164
|
-
var pointer = [Event.pointerX(event), Event.pointerY(event)];
|
165
|
-
var offsets = Position.cumulativeOffset(this.handle);
|
166
|
-
this.offsetX = (pointer[0] - offsets[0]);
|
167
|
-
this.offsetY = (pointer[1] - offsets[1]);
|
168
|
-
this.originalLeft = this.currentLeft();
|
169
|
-
this.originalTop = this.currentTop();
|
170
|
-
}
|
171
|
-
Event.stop(event);
|
172
|
-
}
|
173
|
-
},
|
174
|
-
update: function(event) {
|
175
|
-
if(this.active) {
|
176
|
-
if(!this.dragging) {
|
177
|
-
var style = this.handle.style;
|
178
|
-
this.dragging = true;
|
179
|
-
if(style.position=="") style.position = "relative";
|
180
|
-
style.zIndex = this.options.zindex;
|
181
|
-
}
|
182
|
-
this.draw(event);
|
183
|
-
// fix AppleWebKit rendering
|
184
|
-
if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
|
185
|
-
Event.stop(event);
|
186
|
-
}
|
187
|
-
},
|
188
|
-
draw: function(event) {
|
189
|
-
var pointer = [Event.pointerX(event), Event.pointerY(event)];
|
190
|
-
var offsets = Position.cumulativeOffset(this.handle);
|
191
|
-
|
192
|
-
offsets[0] -= this.currentLeft();
|
193
|
-
offsets[1] -= this.currentTop();
|
194
|
-
|
195
|
-
// Adjust for the pointer's position on the handle
|
196
|
-
pointer[0] -= this.offsetX;
|
197
|
-
pointer[1] -= this.offsetY;
|
198
|
-
var style = this.handle.style;
|
199
|
-
|
200
|
-
if(this.isVertical()){
|
201
|
-
if(pointer[1] > this.maximumOffset())
|
202
|
-
pointer[1] = this.maximumOffset();
|
203
|
-
if(pointer[1] < this.minimumOffset())
|
204
|
-
pointer[1] = this.minimumOffset();
|
205
|
-
|
206
|
-
// Increment by values
|
207
|
-
if(this.values){
|
208
|
-
this.value = this.getNearestValue(Math.round((pointer[1] - this.minimumOffset()) / this.increment) + this.minimum);
|
209
|
-
pointer[1] = this.trackTop() + this.alignY + (this.value - this.minimum) * this.increment;
|
210
|
-
} else {
|
211
|
-
this.value = Math.round((pointer[1] - this.minimumOffset()) / this.increment) + this.minimum;
|
212
|
-
}
|
213
|
-
style.top = pointer[1] - offsets[1] + "px";
|
214
|
-
} else {
|
215
|
-
if(pointer[0] > this.maximumOffset()) pointer[0] = this.maximumOffset();
|
216
|
-
if(pointer[0] < this.minimumOffset()) pointer[0] = this.minimumOffset();
|
217
|
-
// Increment by values
|
218
|
-
if(this.values){
|
219
|
-
this.value = this.getNearestValue(Math.round((pointer[0] - this.minimumOffset()) / this.increment) + this.minimum);
|
220
|
-
pointer[0] = this.trackLeft() + this.alignX + (this.value - this.minimum) * this.increment;
|
221
|
-
} else {
|
222
|
-
this.value = Math.round((pointer[0] - this.minimumOffset()) / this.increment) + this.minimum;
|
223
|
-
}
|
224
|
-
style.left = (pointer[0] - offsets[0]) + "px";
|
225
|
-
}
|
226
|
-
if(this.options.onSlide) this.options.onSlide(this.value);
|
227
|
-
},
|
228
|
-
endDrag: function(event) {
|
229
|
-
if(this.active && this.dragging) {
|
230
|
-
this.finishDrag(event, true);
|
231
|
-
Event.stop(event);
|
232
|
-
}
|
233
|
-
this.active = false;
|
234
|
-
this.dragging = false;
|
235
|
-
},
|
236
|
-
finishDrag: function(event, success) {
|
237
|
-
this.active = false;
|
238
|
-
this.dragging = false;
|
239
|
-
this.handle.style.zIndex = this.originalZ;
|
240
|
-
this.originalLeft = this.currentLeft();
|
241
|
-
this.originalTop = this.currentTop();
|
242
|
-
this.updateFinished();
|
243
|
-
},
|
244
|
-
updateFinished: function() {
|
245
|
-
if(this.options.onChange) this.options.onChange(this.value);
|
246
|
-
},
|
247
|
-
keyPress: function(event) {
|
248
|
-
if(this.active && !this.disabled) {
|
249
|
-
switch(event.keyCode) {
|
250
|
-
case Event.KEY_ESC:
|
251
|
-
this.finishDrag(event, false);
|
252
|
-
Event.stop(event);
|
253
|
-
break;
|
254
|
-
}
|
255
|
-
if(navigator.appVersion.indexOf('AppleWebKit')>0) Event.stop(event);
|
256
|
-
}
|
257
|
-
}
|
258
|
-
}
|