提交 d8343a6a 编写于 作者: S Stephen St. Martin 提交者: Stefan Penner

restructure compatibility module so it is no longer a child

上级 565a696e
......@@ -3,7 +3,7 @@
module ActionView #:nodoc:
module Helpers #:nodoc:
autoload :ActiveModelHelper, 'action_view/helpers/active_model_helper'
autoload :AjaxHelper, 'action_view/helpers/ajax_helper'
autoload :AjaxHelperCompat, 'action_view/helpers/ajax_helper'
autoload :AssetTagHelper, 'action_view/helpers/asset_tag_helper'
autoload :AtomFeedHelper, 'action_view/helpers/atom_feed_helper'
autoload :CacheHelper, 'action_view/helpers/cache_helper'
......@@ -48,7 +48,7 @@ module ClassMethods
include FormTagHelper
include JavaScriptHelper
include NumberHelper
include AjaxHelper
include AjaxHelperCompat
include RawOutputHelper
include RecordIdentificationHelper
include RecordTagHelper
......
......@@ -154,34 +154,37 @@ def purge_unused_attributes!(attributes)
def create_js_function(statements, *arguments)
"function(#{arguments.join(", ")}) {#{statements}}"
end
end
# TODO: All evaled goes here per wycat
module Rails2Compatibility
def set_callbacks(options, html)
[:complete, :failure, :success, :interactive, :loaded, :loading].each do |type|
html["data-#{type}-code"] = options.delete(type.to_sym)
end
# TODO: All evaled goes here per wycat
module AjaxHelperCompat
include AjaxHelper
options.each do |option, value|
if option.is_a?(Integer)
html["data-#{option}-code"] = options.delete(option)
end
end
def set_callbacks(options, html)
[:complete, :failure, :success, :interactive, :loaded, :loading].each do |type|
html["data-#{type}-code"] = options.delete(type.to_sym)
end
def link_to_remote(name, url, options = nil)
if !options && url.is_a?(Hash) && url.key?(:url)
url, options = url.delete(:url), url
options.each do |option, value|
if option.is_a?(Integer)
html["data-#{option}-code"] = options.delete(option)
end
set_callbacks(options, options[:html] ||= {})
super
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
end
set_callbacks(options, options[:html] ||= {})
super
end
def button_to_remote(name, options = {}, html_options = {})
html_options.merge!(:testing => true)
set_callbacks(options, html_options)
super
end
end
end
......
......@@ -39,7 +39,7 @@ module JavaScriptHelper
JAVASCRIPT_PATH = File.join(File.dirname(__FILE__), 'javascripts')
end
include AjaxHelper::Rails2Compatibility
include AjaxHelperCompat
# Returns a link of the given +name+ that will trigger a JavaScript +function+ using the
# onclick handler and return false after the fact.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册