Class: DHTMLConfirm
- Defined in:
- lib/six-updater-web/vendor/plugins/active_scaffold/lib/dhtml_confirm.rb
Overview
Matt Mower <[email protected]>
A base class for creating DHTML confirmation types.
The real work is done by the onclick_function and onclick_handler methods. In general it should only be required to override the default onclick_handler method and provide the specific Javascript required to invoke the DHTML confirm dialog of your choice.
It is up to this dialog, if the user confirms the intended action, to invoke the function window.gFireModalLink() to trigger the intended action of the link. For example, using the Modalbox library, you would use something like:
Modalbox.hide( {
afterHide: function() {
window.gFireModalLink();
} } );
By default the only action recognized is :value which is used to add a dhtml_confirm attribute to the link <a> tag. This value is detected by the ActiveScaffold link and triggers the DHTML confirmation logic.
Instance Attribute Summary collapse
-
#message ⇒ Object
Returns the value of attribute message.
-
#options ⇒ Object
Returns the value of attribute options.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ DHTMLConfirm
constructor
A new instance of DHTMLConfirm.
- #onclick_function(controller, link_id) ⇒ Object
- #onclick_handler(controller, link_id) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ DHTMLConfirm
Returns a new instance of DHTMLConfirm.
26 27 28 29 30 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/dhtml_confirm.rb', line 26 def initialize( = {} ) @options = @value = @options.delete(:value) { |key| "yes" } @message = @options.delete(:message) { |key| "Are you sure?" } end |
Instance Attribute Details
#message ⇒ Object
Returns the value of attribute message.
24 25 26 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/dhtml_confirm.rb', line 24 def @message end |
#options ⇒ Object
Returns the value of attribute options.
24 25 26 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/dhtml_confirm.rb', line 24 def @options end |
#value ⇒ Object
Returns the value of attribute value.
24 25 26 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/dhtml_confirm.rb', line 24 def value @value end |
Instance Method Details
#onclick_function(controller, link_id) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/dhtml_confirm.rb', line 32 def onclick_function( controller, link_id ) script = <<-END window.gFireModalLink = function() { var link = $('#{link_id}').action_link; link.open_action.call( link ); }; #{ensure_termination(onclick_handler(controller,link_id))} return false; END # script = "window.gModalLink = $('#{link_id}').action_link;#{onclick_handler(controller,link_id)}return false;" end |
#onclick_handler(controller, link_id) ⇒ Object
44 45 46 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/dhtml_confirm.rb', line 44 def onclick_handler( controller, link_id ) "" end |