Class: Wedge::Plugins::Popover

Inherits:
Component show all
Defined in:
lib/wedge/plugins/popover.rb

Instance Attribute Summary

Attributes inherited from Component

#wedge_method_called

Instance Method Summary collapse

Methods inherited from Component

config, dom, html, html!, #method_missing, method_missing, plugin, set_dom, store, tmpl, #to_js, #wedge, #wedge_class_store, wedge_config, #wedge_config, #wedge_dom, wedge_dom, #wedge_from_client?, #wedge_from_server?, #wedge_function, wedge_html, #wedge_html, #wedge_javascript, #wedge_method_url, wedge_name, wedge_new, wedge_on, wedge_on_server, #wedge_plugin, #wedge_scope, #wedge_store, #wedge_tmpl, wedge_tmpl, #wedge_trigger

Methods included from Methods

#client?, included, #server?

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Wedge::Component

Instance Method Details

#ajax(el, options = {}, &block) ⇒ Object



32
33
34
35
# File 'lib/wedge/plugins/popover.rb', line 32

def ajax el, options = {}, &block
  options = { content: 'loading' }.merge options
  display el, options, &block
end

#display(el, options = {}, &block) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/wedge/plugins/popover.rb', line 8

def display el, options = {}, &block
  return if el.data 'wedge-popover'

  el.data 'wedge-popover', true
  el = el.to_n

  options = {
    content: 'Loading...',
    position: 'right middle',
    openOn: 'hover'
  }.merge(options)

  options[:classes] = "drop-theme-arrows #{options[:classes]}"

  options = options.to_n

  opts = `$.extend(options, { target: el[0] })`
  drop = Native(`new Drop(opts)`)

  block.call(Native(opts)) if block_given?

  drop
end