lucasefe / themes_for_rails

Theme Support for Rails 3
This very same page :)
MIT License
308 stars 102 forks source link

Add theme_image_submit_tag #40

Closed arufanov closed 12 years ago

arufanov commented 12 years ago

Hi!

Rails has helper image_submit_tag, but gem not. This is possible to add a code like this to implement: theme_image_submit_tag. "

Displays an image which when clicked will submit the form.

#

source is passed to AssetTagHelper#path_to_image

#

==== Options

* :confirm => 'question?' - This will add a JavaScript confirm

prompt with the question specified. If the user accepts, the form is

processed normally, otherwise no action is taken.

* :disabled - If set to true, the user will not be able to use this input.

* Any other key creates standard HTML options for the tag.

#

==== Examples

image_submit_tag("login.png")

=>

#

image_submit_tag("purchase.png", :disabled => true)

=>

#

image_submit_tag("search.png", :class => 'search_button')

=>

#

image_submit_tag("agree.png", :disabled => true, :class => "agree_disagree_button")

=>

def theme_image_submit_tag(source, options = {}) options.stringify_keys!

if confirm = options.delete("confirm")
  add_confirm_to_attributes!(options, confirm)
end

tag :input, { "type" => "image", "src" => theme_image_path(source) }.update(options.stringify_keys)

end " There is only one difference at line: "tag :input, { "type" => "image", "src" => theme_image_path(source) }.update(options.stringify_keys) ", I am using theme_image_path rather that path_to_image. Do you need some extra info? I am ready to provide it (I have neve submit patch before, but ready if it is necessary some help will be provided if necessary). Are you planning to include this code into gem?

Artem.

lucasefe commented 12 years ago

Done. Its on master. Wanna give a try?

arufanov commented 12 years ago

Hello,

I have tested, all is ok (at least for me). Thank you very much for this implementation.

Sincerely yours, Artem Rufanov