Class: Card::LazyTab

Inherits:
Tab show all
Defined in:
mod/tabs/lib/card/lazy_tab.rb

Overview

lazy-loading tabs. Tab panel content doesn’t load until tab is visited.

Instance Attribute Summary

Attributes inherited from Tab

#format, #name

Instance Method Summary collapse

Methods inherited from Tab

#initialize, #label, tab_objects

Constructor Details

This class inherits a constructor from Card::Tab

Instance Method Details

#button_attribObject



20
21
22
# File 'mod/tabs/lib/card/lazy_tab.rb', line 20

def button_attrib
  @button_attrib ||= super.merge("data-url" => url.html_safe)
end

#contentObject



29
30
31
# File 'mod/tabs/lib/card/lazy_tab.rb', line 29

def content
  @content ||= ""
end

#tab_buttonObject



12
13
14
15
16
17
18
# File 'mod/tabs/lib/card/lazy_tab.rb', line 12

def tab_button
  if url
    super
  else
    wrap_with(:li, label, role: "presentation")
  end
end


24
25
26
27
# File 'mod/tabs/lib/card/lazy_tab.rb', line 24

def tab_button_link
  add_class button_attrib, "load" unless active?
  super
end

#tab_pane(args = nil, &block) ⇒ Object



33
34
35
36
# File 'mod/tabs/lib/card/lazy_tab.rb', line 33

def tab_pane args=nil, &block
  @content = yield if active? && block_given?
  super
end

#urlObject



4
5
6
# File 'mod/tabs/lib/card/lazy_tab.rb', line 4

def url
  @url ||= (config_hash? && @config[:path]) || format.path(view: view)
end

#viewObject



8
9
10
# File 'mod/tabs/lib/card/lazy_tab.rb', line 8

def view
  @view ||= (config_hash? && @config[:view]) || @config
end