Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
37ad5759
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
37ad5759
编写于
1月 23, 2010
作者:
S
Stephen St. Martin
提交者:
Stefan Penner
1月 27, 2010
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
port existing test suite to check for new output, and fix all breaking tests
上级
7bf5aef9
变更
2
展开全部
显示空白变更内容
内联
并排
Showing
2 changed file
with
268 addition
and
162 deletion
+268
-162
actionpack/lib/action_view/helpers/ajax_helper.rb
actionpack/lib/action_view/helpers/ajax_helper.rb
+45
-41
actionpack/test/template/ajax_helper_test.rb
actionpack/test/template/ajax_helper_test.rb
+223
-121
未找到文件。
actionpack/lib/action_view/helpers/ajax_helper.rb
浏览文件 @
37ad5759
...
...
@@ -105,13 +105,15 @@ def remote_form_for(record_or_name_or_array, *args, &proc)
# <% end -%>
def
form_remote_tag
(
options
=
{},
&
block
)
html_options
=
options
.
delete
(
:callbacks
)
attributes
=
{}
attributes
.
merge!
(
extract_remote_attributes!
(
options
))
attributes
.
merge!
(
html_options
)
if
html_options
attributes
.
merge!
(
options
)
url
=
attributes
.
delete
(
"data-url"
)
attributes
.
delete
(
:builder
)
form_tag
(
attributes
.
delete
(
:action
)
||
url
,
attributes
,
&
block
)
form_tag
(
attributes
.
delete
(
:action
)
||
attributes
.
delete
(
"data-url"
),
attributes
,
&
block
)
end
# Returns a link to a remote action defined by <tt>options[:url]</tt>
...
...
@@ -287,13 +289,12 @@ def form_remote_tag(options = {}, &block)
# link_to_remote "Delete this post",
# { :update => "posts", :url => { :action => "destroy", :id => post.id } },
# :href => url_for(:action => "destroy", :id => post.id)
def
link_to_remote
(
name
,
url
,
options
=
{})
def
link_to_remote
(
name
,
options
,
html_
options
=
{})
attributes
=
{}
attributes
.
merge!
(
extract_remote_attributes!
(
options
))
attributes
.
merge!
(
options
)
attributes
.
merge!
(
html_
options
)
url
=
url_for
(
url
)
if
url
.
is_a?
(
Hash
)
content_tag
(
:a
,
name
,
attributes
.
merge
(
:href
=>
url
))
content_tag
(
:a
,
name
,
attributes
.
merge
(
:href
=>
"#"
))
end
# Creates a button with an onclick event which calls a remote action
...
...
@@ -303,7 +304,6 @@ def link_to_remote(name, url, options = {})
def
button_to_remote
(
name
,
options
=
{},
html_options
=
{})
attributes
=
html_options
.
merge!
(
:type
=>
"button"
,
:value
=>
name
)
attributes
.
merge!
(
extract_remote_attributes!
(
options
))
attributes
.
merge!
(
extract_request_attributes!
(
options
))
tag
(
:input
,
attributes
)
end
...
...
@@ -341,10 +341,12 @@ def button_to_remote(name, options = {}, html_options = {})
# <tt>options</tt> argument is the same as in form_remote_tag.
def
submit_to_remote
(
name
,
value
,
options
=
{})
html_options
=
options
.
delete
(
:html
)
||
{}
html_options
.
merge!
(
:name
=>
name
,
:value
=>
value
,
:type
=>
"
submit
"
)
html_options
.
merge!
(
:name
=>
name
,
:value
=>
value
,
:type
=>
"
button
"
)
attributes
=
extract_remote_attributes!
(
options
)
attributes
.
merge!
(
html_options
)
attributes
[
"data-submit"
]
=
true
attributes
.
delete
(
"data-remote"
)
tag
(
:input
,
attributes
)
end
...
...
@@ -376,7 +378,7 @@ def submit_to_remote(name, value, options = {})
#
def
periodically_call_remote
(
options
=
{})
attributes
=
extract_observer_attributes!
(
options
)
attributes
[
"data-
js-type"
]
=
"periodical_executer"
attributes
[
"data-
periodical"
]
=
true
script_decorator
(
attributes
)
end
...
...
@@ -493,9 +495,11 @@ def extract_remote_attributes!(options)
def
extract_request_attributes!
(
options
)
attributes
=
{}
attributes
[
"data-method"
]
=
options
.
delete
(
:method
)
attributes
[
"data-remote-type"
]
=
options
.
delete
(
:type
)
url
=
options
.
delete
(
:url
)
attributes
[
"data-url"
]
=
url
.
is_a?
(
Hash
)
?
url_for
(
url
)
:
url
url_options
=
options
.
delete
(
:url
)
url_options
=
url_options
.
merge
(
:escape
=>
false
)
if
url_options
.
is_a?
(
Hash
)
attributes
[
"data-url"
]
=
escape_javascript
(
url_for
(
url_options
))
#TODO: Remove all references to prototype - BR
if
options
.
delete
(
:form
)
...
...
@@ -528,18 +532,16 @@ def extract_update_attributes!(options)
end
def
extract_observer_attributes!
(
options
)
callback
=
options
.
delete
(
:function
)
frequency
=
options
.
delete
(
:frequency
)
attributes
=
extract_remote_attributes!
(
options
)
attributes
[
"data-observe"
]
=
true
attributes
[
"data-observed"
]
=
options
.
delete
(
:observed
)
callback
=
options
.
delete
(
:function
)
frequency
=
options
.
delete
(
:frequency
)
if
callback
attributes
[
"data-observer-code"
]
=
create_js_function
(
callback
,
"element"
,
"value"
)
end
if
frequency
&&
frequency
!=
0
attributes
[
"data-frequency"
]
=
frequency
.
to_i
end
attributes
[
"data-onobserve"
]
=
create_js_function
(
callback
,
"element"
,
"value"
)
if
callback
attributes
[
"data-frequency"
]
=
frequency
.
to_i
if
frequency
&&
frequency
!=
0
attributes
.
delete
(
"data-remote"
)
purge_unused_attributes!
(
attributes
)
end
...
...
@@ -558,32 +560,34 @@ def create_js_function(statements, *arguments)
module
AjaxHelperCompat
include
AjaxHelper
def
set_callbacks
(
options
,
html
)
[
:complete
,
:failure
,
:success
,
:interactive
,
:loaded
,
:loading
].
each
do
|
type
|
html
[
"data-
#{
type
}
-code"
]
=
options
.
delete
(
type
.
to_sym
)
def
link_to_remote
(
name
,
options
,
html_options
=
{}
)
set_callbacks
(
options
,
html_options
)
super
end
options
.
each
do
|
option
,
value
|
if
option
.
is_a?
(
Integer
)
html
[
"data-
#{
option
}
-code"
]
=
options
.
delete
(
option
)
end
end
def
button_to_remote
(
name
,
options
=
{},
html_options
=
{})
set_callbacks
(
options
,
html_options
)
super
end
def
link_to_remote
(
name
,
url
,
options
=
nil
)
if
!
options
&&
url
.
is_a?
(
Hash
)
&&
url
.
key?
(
:url
)
url
,
options
=
url
.
delete
(
:url
),
url
def
form_remote_tag
(
options
,
&
block
)
html
=
{}
set_callbacks
(
options
,
html
)
options
.
merge!
(
:callbacks
=>
html
)
super
end
options
=
{}
if
options
.
nil?
set_callbacks
(
options
,
options
[
:html
]
||=
{})
super
private
def
set_callbacks
(
options
,
html
)
[
:uninitialized
,
:complete
,
:failure
,
:success
,
:interactive
,
:loaded
,
:loading
].
each
do
|
type
|
html
[
"data-on
#{
type
}
"
]
=
options
.
delete
(
type
.
to_sym
)
end
def
button_to_remote
(
name
,
options
=
{},
html_options
=
{})
set_callbacks
(
options
,
html_options
)
super
options
.
each
do
|
option
,
value
|
if
option
.
is_a?
(
Integer
)
html
[
"data-on
#{
option
}
"
]
=
options
.
delete
(
option
)
end
end
end
end
end
...
...
actionpack/test/template/ajax_helper_test.rb
浏览文件 @
37ad5759
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录