Module: ViewMixins::Link
- Defined in:
- lib/view_mixins/link.rb
Instance Method Summary collapse
- #ajax_link_to(*args, &block) ⇒ Object
- #ajax_post_link_to(*args, &block) ⇒ Object
- #convert_settings_to_url(settings_json) ⇒ Object
-
#link_tree(*args, &block) ⇒ Object
used only in jstree.
Instance Method Details
#ajax_link_to(*args, &block) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/view_mixins/link.rb', line 3 def ajax_link_to(*args, &block) if block_given? = args.first || {} = args.second ######### additional logic by ladas ############## ||= {} ['onclick'] = "parse_link_and_load_page($(this)); return false;" ######################################### link_to(capture(&block), , ) else name = args[0] = args[1] || {} = args[2] ######### additional logic by ladas ############## ||= {} ['onclick'] = "parse_link_and_load_page($(this)); return false;" ######################################### = (, ) url = url_for() href = ['href'] = () href_attr = "href=\"#{ERB::Util.html_escape(url)}\"" unless href "<a #{href_attr}#{tag_options}>#{ERB::Util.html_escape(name || url)}</a>".html_safe end end |
#ajax_post_link_to(*args, &block) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/view_mixins/link.rb', line 31 def ajax_post_link_to(*args, &block) if block_given? = args.first || {} = args.second ######### additional logic by ladas ############## ||= {} ['onclick'] = "parse_link_and_post($(this)); return false;" ######################################### link_to(capture(&block), , ) else name = args[0] = args[1] || {} = args[2] ######### additional logic by ladas ############## ||= {} ['onclick'] = "parse_link_and_post($(this)); return false;" ######################################### = (, ) url = url_for() href = ['href'] = () href_attr = "href=\"#{ERB::Util.html_escape(url)}\"" unless href "<a #{href_attr}#{tag_options}>#{ERB::Util.html_escape(name || url)}</a>".html_safe end end |
#convert_settings_to_url(settings_json) ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/view_mixins/link.rb', line 88 def convert_settings_to_url settings_json # make sure its the same as build_url in ladas_loading.js settings = JSON.parse(settings_json) url = "" unless settings['url'].to_s.blank? url += settings['url'].to_s else unless settings['symlink_outer_controller'].to_s.blank? url += "/" + settings['symlink_outer_controller'].to_s end unless settings['symlink_outer_id'].to_s.blank? url += "/" + settings['symlink_outer_id'].to_s end unless settings['symlink_controller'].to_s.blank? url += "/" + settings['symlink_controller'].to_s end unless settings['symlink_id'].to_s.blank? url += "/" + settings['symlink_id'].to_s end unless settings['symlink_action'].to_s.blank? url += "/" + settings['symlink_action'].to_s end unless settings['symlink_params'].to_s.blank? url += settings['symlink_params'].to_s end end url end |
#link_tree(*args, &block) ⇒ Object
used only in jstree
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/view_mixins/link.rb', line 60 def link_tree(*args, &block) if block_given? = args.first || {} = args.second ######### additional logic by ladas ############## ||= {} ['onclick'] = "parse_link_and_load_page($(this)); return false;" ######################################### link_to(capture(&block), , ) else name = args[0] = args[1] || {} = args[2] ######### additional logic by ladas ############## ||= {} ['onclick'] = "parse_link_and_load_page($(this)); return false;" ######################################### = (, ) url = url_for() href = ['href'] = () href_attr = "href=\"#{ERB::Util.html_escape(url)}\"" unless href "<a #{href_attr}#{tag_options}>#{ERB::Util.html_escape(name || url)}</a>".html_safe end end |