Class: Mack::JavaScript::Framework::Prototype
- Inherits:
-
Object
- Object
- Mack::JavaScript::Framework::Prototype
- Defined in:
- lib/mack-javascript/helpers/prototype_helper.rb
Constant Summary collapse
- @@callbacks =
[:uninitialized, :loading, :loaded, :interactive, :complete, :failure, :success ] + [100,101] + (200..206).to_a + (300..307).to_a + (400..417).to_a + (500..505).to_a
Class Method Summary collapse
- .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
.insert_html(position, id, html) ⇒ Object
8 9 10 11 |
# File 'lib/mack-javascript/helpers/prototype_helper.rb', line 8 def insert_html(position, id, html) insertion = position.to_s.camelcase "new Insertion.#{insertion}('#{id}', '#{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
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/mack-javascript/helpers/prototype_helper.rb', line 45 def remote_function() = () "new Ajax.Request('#{[:url]}', #{.to_json})" update = '' if [:update] && [:update].is_a?(Hash) update = [] update << "success:'#{[:update][:success]}'" if [:update][:success] update << "failure:'#{[:update][:failure]}'" if [:update][:failure] update = '{' + update.join(',') + '}' elsif [:update] update << "'#{[:update]}'" end function = update.empty? ? "new Ajax.Request(" : "new Ajax.Updater(#{update}, " = [:url] = .merge(:escape => false) if .is_a?(Hash) function << "'#{}'" function << ", #{})" function = "#{[:before]}; #{function}" if [:before] function = "#{function}; #{[:after]}" if [:after] function = "if (#{[:condition]}) { #{function}; }" if [:condition] function = "if (confirm('#{escape_javascript([:confirm])}')) { #{function}; }" if [:confirm] return function end |
.remove(*ids) ⇒ Object
21 22 23 |
# File 'lib/mack-javascript/helpers/prototype_helper.rb', line 21 def remove(*ids) "#{ids.to_json}.each(Element.remove)" end |
.replace(id, html) ⇒ Object
17 18 19 |
# File 'lib/mack-javascript/helpers/prototype_helper.rb', line 17 def replace(id, html) "Element.replace('#{id}', '#{html}')" end |
.replace_html(id, html) ⇒ Object
13 14 15 |
# File 'lib/mack-javascript/helpers/prototype_helper.rb', line 13 def replace_html(id, html) "Element.update('#{id}', '#{html}')" end |
.show(*ids) ⇒ Object
25 26 27 |
# File 'lib/mack-javascript/helpers/prototype_helper.rb', line 25 def show(*ids) "#{ids.to_json}.each(Element.show)" end |
.toggle(*ids) ⇒ Object
29 30 31 |
# File 'lib/mack-javascript/helpers/prototype_helper.rb', line 29 def toggle(*ids) "#{ids.to_json}.each(Element.toggle)" end |