API reference
Coupdoeil::Popover
Class methods
.with
Allows to set params for a popover.
ProjectPopover.with(project: @project).summary
.default_options
-> [Coupdoeil::Popover::OptionsSet]
Sets or returns default options for all popover actions. Specific action options will inherit from default options.
class ProjectPopover < ApplicationPopover
default_options placement: :top, offset: "1rem"
end
ProjectPopover.default_options
# => #<Coupdoeil::Popover::OptionsSet:0x0000000127df8db0
# @options={:offset=>"1rem", :placement=>:top, :animation=>"slide-in", :cache=>true, :loading=>:async, :trigger=>"hover"}
# >
.default_options_for(*action_names, **option_values)
-> [Coupdoeil::Popover::OptionsSet]
Sets or returns default options for one or many actions. Options inherit from default options.
class ProjectPopover < ApplicationPopover
default_options_for :summary, placement: :top
default_options_for :tooltip, :summary, loading: :preload, opening_delay: false
end
ProjectPopover.default_options_for :summary
# => #<Coupdoeil::Popover::OptionsSet:0x0000000127df8db0
# @options={:placement=>:top, :loading=>:preload, :offset=>0, :animation=>"slide-in", :cache=>true, :trigger=>"hover"}
# >
ProjectPopover.default_options_for :tooltip
# => #<Coupdoeil::Popover::OptionsSet:0x0000000127df8db0
# @options={:placement=>"auto", :loading=>:preload, :offset=>0, :animation=>"slide-in", :cache=>true, :trigger=>"hover"}
# >
Instance methods
#params
-> [HashWithIndifferentAccess]
Returns deserialized params initially passed to .with
method.
ProjectPopover.with(project: @project).summary
class ProjectPopover < ApplicationPopover
def summary
@project = params[:project]
end
end
#context_controller
-> [ActionController::Base]
Returns the controller that triggers the popover rendering, a Coupdoeil::PopoversController
instance when loading the popover asynchronously or the current controller when preloading. Note that this controller is not the one rendering the popover template as popovers are controller on their own. context_controller
is used internally to retrieve request, session, helpers and allow forgery protection in forms.
Coupdoeil::ApplicationHelper
Instance methods
#coupdoeil_popover_tag(popover, popover_options = nil, tag_attributes = nil, &block)
-> [ActiveSupport::SafeBuffer]
Returns a
coupdoeil_popover_tag ProjectPopover.with(project: @project).summary
You can pass specific options that will override default options for the popover action.
coupdoeil_popover_tag ProjectPopover.with(project: @project).summary, placement: "top", animation: false
You can also pass attributes for tag.
coupdoeil_popover_tag ProjectPopover.with(project: @project).summary, nil, class: "inline-block"
Passing attributes to tag and options to popover
coupdoeil_popover_tag ProjectPopover.with(project: @project).summary, { placement: "top", animation: false }, class: "inline-block"