Class: Mack::JavaScript::Framework::Jquery
- Defined in:
- lib/mack-javascript/helpers/jquery_helper.rb
Class Method Summary collapse
- .hide(*ids) ⇒ Object
- .insert_html(position, id, html) ⇒ Object
-
.remote_function(options) ⇒ Object
def draggable(id, options = {}) record @context.send(:draggable_element_js, id, options) end.
- .remove(*ids) ⇒ Object
- .replace(id, html) ⇒ Object
- .replace_html(id, html) ⇒ Object
- .show(*ids) ⇒ Object
- .toggle(*ids) ⇒ Object
Class Method Details
.hide(*ids) ⇒ Object
29 30 31 |
# File 'lib/mack-javascript/helpers/jquery_helper.rb', line 29 def hide(*ids) "$(\'##{ids.join(',#')}\').hide()" end |
.insert_html(position, id, html) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/mack-javascript/helpers/jquery_helper.rb', line 6 def insert_html(position, id, html) insertion = position.to_s.downcase insertion = 'append' if insertion == 'bottom' insertion = 'prepend' if insertion == 'top' "$(\'##{id}\').#{insertion}('#{html}')" end |
.remote_function(options) ⇒ Object
def draggable(id, options = {})
record @context.send(:draggable_element_js, id, )
end
def visual_effect(name, id = nil, options = {})
record @context.send(:visual_effect, name, id, )
end
def drop_receiving(id, options = {})
record @context.send(:drop_receiving_element_js, id, )
end
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/mack-javascript/helpers/jquery_helper.rb', line 50 def remote_function() = () update = '' if [:update] && [:update].is_a?(Hash) update = [] update << "success:'#{options[:update][:success]}'" if [:update][:success] update << "failure:'#{options[:update][:failure]}'" if [:update][:failure] update = '{' + update.join(',') + '}' elsif [:update] update << "'#{options[:update]}'" end function = "$.ajax(#{javascript_options})" function = "#{options[:before]}; #{function}" if [:before] function = "#{function}; #{options[:after]}" if [:after] function = "if (#{options[:condition]}) { #{function}; }" if [:condition] function = "if (confirm('#{escape_javascript(options[:confirm])}')) { #{function}; }" if [:confirm] return function end |
.remove(*ids) ⇒ Object
21 22 23 |
# File 'lib/mack-javascript/helpers/jquery_helper.rb', line 21 def remove(*ids) "$(\'##{ids.join(',#')}\').remove()" end |
.replace(id, html) ⇒ Object
17 18 19 |
# File 'lib/mack-javascript/helpers/jquery_helper.rb', line 17 def replace(id, html) "$(\'##{id}\').replaceWith('#{html}')" end |
.replace_html(id, html) ⇒ Object
13 14 15 |
# File 'lib/mack-javascript/helpers/jquery_helper.rb', line 13 def replace_html(id, html) insert_html(:html, id, html) end |
.show(*ids) ⇒ Object
25 26 27 |
# File 'lib/mack-javascript/helpers/jquery_helper.rb', line 25 def show(*ids) "$(\'##{ids.join(',#')}\').show()" end |
.toggle(*ids) ⇒ Object
33 34 35 |
# File 'lib/mack-javascript/helpers/jquery_helper.rb', line 33 def toggle(*ids) "$(\'##{ids.join(',#')}\').toggle()" end |