# QuietLightwindow module QuietLightwindow mattr_accessor :default_options # Define the "uses_lightwindow" controller method. # module ClassMethods def uses_lightwindow( filter_options = {} ) # Work in conjunction with Quiet Prototype if present, so that multiple # quiet_... plugins can work together without potentially each including # prototype independently, so it ends up included over and over again. # # If you want to use Lightwindow and Prototype for different sets of # actions, call uses_lightwindow first, then uses_prototype, specifying # a union of the actions required for both Lightwindow and Prototype in # that second call. have_quiet_prototype = respond_to?( :uses_prototype ) uses_prototype( filter_options ) if ( have_quiet_prototype ) proc = Proc.new do | c | c.instance_variable_set( :@uses_lightwindow, true ) c.instance_variable_set( :@have_quiet_prototype, true ) end before_filter( proc, filter_options ) end end # Add in the class methods and establish the helper calls when the module # gets included. # def self.included( base ) base.extend( ClassMethods ) base.helper( QuietLightwindowHelper ) end # The helper module - methods for use within views. # module QuietLightwindowHelper # Include Lightwindow only if used for the current view, according to the # Controller. Invoke using "<%= include_quiet_lightwindow_if_used -%>" from # within the HEAD section of an XHTML view. If you want your HTML output # to be nice and tidy in terms of indentation :-) then pass a string in # the optional parameter - it will be inserted before each "