From bddd1bb6268e8ac2142c8d8c738929d2f2e8447a Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Fri, 29 Jan 2010 20:00:55 -0600 Subject: Deprecate link_to :popup --- .../lib/action_view/helpers/javascript_helper.rb | 19 ++++++------------- actionpack/lib/action_view/helpers/url_helper.rb | 18 ++---------------- 2 files changed, 8 insertions(+), 29 deletions(-) (limited to 'actionpack/lib/action_view/helpers') diff --git a/actionpack/lib/action_view/helpers/javascript_helper.rb b/actionpack/lib/action_view/helpers/javascript_helper.rb index ee6481b86d..02d0a88189 100644 --- a/actionpack/lib/action_view/helpers/javascript_helper.rb +++ b/actionpack/lib/action_view/helpers/javascript_helper.rb @@ -189,24 +189,21 @@ module ActionView protected def convert_options_to_javascript!(html_options, url = '') - confirm, popup = html_options.delete("confirm"), html_options.delete("popup") + confirm = html_options.delete("confirm") + + if html_options.key?("popup") + ActiveSupport::Deprecation.warn(":popup has been deprecated", caller) + end method, href = html_options.delete("method"), html_options['href'] - if popup && method - raise ActionView::ActionViewError, "You can't use :popup and :method in the same link" - elsif confirm && popup - add_confirm_to_attributes!(html_options, confirm) - html_options["data-popup"] = popup_attributes(popup) - elsif confirm && method + if confirm && method add_confirm_to_attributes!(html_options, confirm) add_method_to_attributes!(html_options, method, url) elsif confirm add_confirm_to_attributes!(html_options, confirm) elsif method add_method_to_attributes!(html_options, method, url) - elsif popup - html_options["data-popup"] = popup_attributes(popup) end end @@ -226,10 +223,6 @@ module ActionView html_options["data-disable-with"] = disable_with if disable_with end - def popup_attributes(popup) - popup.is_a?(Array) ? "{title: '#{popup.first}', options: '#{popup.last}'}" : "true" - end - def options_for_javascript(options) if options.empty? '{}' diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb index 4424dbba42..837dca6149 100644 --- a/actionpack/lib/action_view/helpers/url_helper.rb +++ b/actionpack/lib/action_view/helpers/url_helper.rb @@ -120,10 +120,6 @@ module ActionView # * :confirm => 'question?' - This will add a JavaScript confirm # prompt with the question specified. If the user accepts, the link is # processed normally, otherwise no action is taken. - # * :popup => true || array of window options - This will force the - # link to open in a popup window. By passing true, a default browser window - # will be opened with the URL. You can also specify an array of options - # that are passed to the window.open JavaScript call. # * :method => symbol of HTTP verb - This modifier will dynamically # create an HTML form and immediately submit the form for processing using # the HTTP verb specified. Useful for having links perform a POST operation @@ -136,10 +132,6 @@ module ActionView # the request object's methods for post?, delete? or put?. # * The +html_options+ will accept a hash of html attributes for the link tag. # - # You can mix and match the +html_options+ with the exception of - # :popup and :method which will raise an - # ActionView::ActionViewError exception. - # # ==== Examples # Because it relies on +url_for+, +link_to+ supports both older-style controller/action/id arguments # and newer RESTful routes. Current Rails style favors RESTful routes whenever possible, so base @@ -203,17 +195,11 @@ module ActionView # link_to "Nonsense search", searches_path(:foo => "bar", :baz => "quux") # # => Nonsense search # - # The three options specific to +link_to+ (:confirm, :popup, and :method) are used as follows: + # The three options specific to +link_to+ (:confirm and :method) are used as follows: # # link_to "Visit Other Site", "http://www.rubyonrails.org/", :confirm => "Are you sure?" # # => Visit Other Site # - # link_to "Help", { :action => "help" }, :popup => true - # # => Help - # - # link_to "View Image", @image, :popup => ['new_window_name', 'height=300,width=600'] - # # => View Image - # # link_to "Delete Image", @image, :confirm => "Are you sure?", :method => :delete # # => "submit", "value" => name) -- cgit v1.2.3