Guest User

Untitled

a guest
Jun 19th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. *** form_tag_helper.rb 2010-10-22 10:24:55.000000000 +0900
  2. --- form_tag_helper_jishiha.rb 2010-10-22 11:16:43.000000000 +0900
  3. ***************
  4. *** 409,414 ****
  5. --- 409,415 ----
  6. # prompt with the question specified. If the user accepts, the form is
  7. # processed normally, otherwise no action is taken.
  8. # * <tt>:disabled</tt> - If set to true, the user will not be able to use this input.
  9. + # * <tt>:disable</tt> - If set to true, the submit button is disabled when the form is submitted.
  10. # * Any other key creates standard HTML options for the tag.
  11. #
  12. # ==== Examples
  13. ***************
  14. *** 423,428 ****
  15. --- 424,432 ----
  16. #
  17. # image_submit_tag("agree.png", :disabled => true, :class => "agree_disagree_button")
  18. # # => <input class="agree_disagree_button" disabled="disabled" src="/images/agree.png" type="image" />
  19. + #
  20. + # image_submit_tag("purchase.png", :disable => true)
  21. + # # => <input onclick="this.disabled = true;result = (this.form.onsubmit ? (this.form.onsubmit() ? this.form.submit() : false) : this.form.submit());if (result == false) { this.disabled = false; }return result;"src="/images/purchase.png" type="image" />
  22. def image_submit_tag(source, options = {})
  23. options.stringify_keys!
  24.  
  25. ***************
  26. *** 430,435 ****
  27. --- 434,447 ----
  28. add_confirm_to_attributes!(options, confirm)
  29. end
  30.  
  31. + if disable = options.delete("disable")
  32. + onclick = "#{options.delete('onclick')};" if options['onclick']
  33. +
  34. + options["onclick"] = "this.setAttribute('originalValue', this.value);this.disabled = true;#{onclick}"
  35. + options["onclick"] << "result = (this.form.onsubmit ? (this.form.onsubmit() ? this.form.submit() : false) : this.form.submit());"
  36. + options["onclick"] << "if (result == false) { this.disabled = false; }return result;"
  37. + end
  38. +
  39. tag :input, { "type" => "image", "src" => path_to_image(source) }.update(options.stringify_keys)
  40. end
Add Comment
Please, Sign In to add comment