Class: Tungsten::TableHelper::TableDrawer
- Defined in:
- app/helpers/tungsten/table_helper.rb
Instance Method Summary collapse
- #close(&block) ⇒ Object
- #display(body) ⇒ Object
- #drawer(options = {}, &block) ⇒ Object
- #drawer_id ⇒ Object
- #id ⇒ Object
-
#initialize(options = {}) ⇒ TableDrawer
constructor
A new instance of TableDrawer.
- #open(&block) ⇒ Object
- #toggle(&block) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ TableDrawer
Returns a new instance of TableDrawer.
20 21 22 23 24 |
# File 'app/helpers/tungsten/table_helper.rb', line 20 def initialize( = {} ) @options = @id = "handle-#{SecureRandom.hex(5)}" @drawer_id = "drawer-#{SecureRandom.hex(5)}" end |
Instance Method Details
#close(&block) ⇒ Object
45 46 47 48 49 50 |
# File 'app/helpers/tungsten/table_helper.rb', line 45 def close( &block ) capture(&block).sub(/>/, " role='button' \ data-hide=\"##{@drawer_id}\" \ data-remove-class=\"open; ##{@id}\" \ data-add-class=\"closed; ##{@id}\">").html_safe end |
#display(body) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/helpers/tungsten/table_helper.rb', line 26 def display( body ) = { class: 'table-drawer-handle', id: @id, } [:data] ||= {} [:data]['toggle-class'] = 'open closed' [:data]['toggle'] = "##{@drawer_id}" [:role] = 'button' [:class] << ' toggle-handle closed' content_tag(:tr, ) { body } end |
#drawer(options = {}, &block) ⇒ Object
40 41 42 43 |
# File 'app/helpers/tungsten/table_helper.rb', line 40 def drawer(={}, &block) [:animate] = 'drawer' tr_drawer(@drawer_id, , &block) end |
#drawer_id ⇒ Object
65 66 67 |
# File 'app/helpers/tungsten/table_helper.rb', line 65 def drawer_id @id end |
#id ⇒ Object
69 70 71 |
# File 'app/helpers/tungsten/table_helper.rb', line 69 def id @id end |
#open(&block) ⇒ Object
58 59 60 61 62 63 |
# File 'app/helpers/tungsten/table_helper.rb', line 58 def open( &block ) capture(&block).sub(/>/, " role='button' \ data-show=\"##{@drawer_id}\" \ data-add-class=\"open; ##{@id}\" \ data-remove-class=\"closed; ##{@id}\">").html_safe end |
#toggle(&block) ⇒ Object
52 53 54 55 56 |
# File 'app/helpers/tungsten/table_helper.rb', line 52 def toggle( &block ) capture(&block).sub(/>/, " role='button' \ data-toggle=\"##{@drawer_id}\" \ data-toggle-class=\"open closed; ##{@id}\">").html_safe end |