Class: Lapillus::Pager
- Defined in:
- lib/lapillus/pager.rb
Defined Under Namespace
Classes: FirstButton, LastButton, NextButton, PagerButton, PreviousButton
Instance Attribute Summary collapse
-
#current ⇒ Object
Returns the value of attribute current.
-
#first_button ⇒ Object
Returns the value of attribute first_button.
-
#last_button ⇒ Object
Returns the value of attribute last_button.
-
#navigation ⇒ Object
Returns the value of attribute navigation.
-
#next_button ⇒ Object
Returns the value of attribute next_button.
-
#page_container ⇒ Object
readonly
Returns the value of attribute page_container.
-
#pages ⇒ Object
Returns the value of attribute pages.
-
#position ⇒ Object
Returns the value of attribute position.
-
#previous_button ⇒ Object
Returns the value of attribute previous_button.
Attributes inherited from Container
Attributes inherited from Component
#behaviours, #identifier, #model, #property, #visible
Instance Method Summary collapse
-
#build_hierarchy ⇒ Object
TODO: this is not so handy components are recreated and stuff; split in constructor/on_render also parent and path do not work.
-
#initialize(id, pages, &block) ⇒ Pager
constructor
A new instance of Pager.
- #page_content ⇒ Object
Methods inherited from Container
#[], #add, add_component, #component, fileuploadfield, image, label, listview, panel, password_textfield, #post, #render_container, textarea, textfield
Methods inherited from Component
#add_behaviour, #behaviour, #has_behaviour?, #has_model?, #has_parent?, #on_render, #parent, #path, #render_component, #response_page=, #session, #value, #visible?, #webpage
Constructor Details
#initialize(id, pages, &block) ⇒ Pager
Returns a new instance of Pager.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/lapillus/pager.rb', line 9 def initialize(id, pages, &block) super(id) raise "no block given!" if !block_given? @pages = pages @current = 1 @block = block = Lapillus::Container.new("navigation") = FirstButton.new("first", self) = PreviousButton.new("previous", self) = NextButton.new("next", self) = LastButton.new("last", self) @position = Label.new("position") .add() .add() .add() .add() .add(position) build_hierarchy end |
Instance Attribute Details
#current ⇒ Object
Returns the value of attribute current.
6 7 8 |
# File 'lib/lapillus/pager.rb', line 6 def current @current end |
#first_button ⇒ Object
Returns the value of attribute first_button.
7 8 9 |
# File 'lib/lapillus/pager.rb', line 7 def end |
#last_button ⇒ Object
Returns the value of attribute last_button.
8 9 10 |
# File 'lib/lapillus/pager.rb', line 8 def end |
#navigation ⇒ Object
Returns the value of attribute navigation.
7 8 9 |
# File 'lib/lapillus/pager.rb', line 7 def end |
#next_button ⇒ Object
Returns the value of attribute next_button.
8 9 10 |
# File 'lib/lapillus/pager.rb', line 8 def end |
#page_container ⇒ Object (readonly)
Returns the value of attribute page_container.
6 7 8 |
# File 'lib/lapillus/pager.rb', line 6 def page_container @page_container end |
#pages ⇒ Object
Returns the value of attribute pages.
7 8 9 |
# File 'lib/lapillus/pager.rb', line 7 def pages @pages end |
#position ⇒ Object
Returns the value of attribute position.
8 9 10 |
# File 'lib/lapillus/pager.rb', line 8 def position @position end |
#previous_button ⇒ Object
Returns the value of attribute previous_button.
7 8 9 |
# File 'lib/lapillus/pager.rb', line 7 def end |
Instance Method Details
#build_hierarchy ⇒ Object
TODO: this is not so handy components are recreated and stuff; split in constructor/on_render also parent and path do not work
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/lapillus/pager.rb', line 32 def build_hierarchy @page_container = ListItem.new("page") @page_container.parent = self #NOTE: I could do this in the constructor! if !@pages.empty? @page_container.instance_exec(page_content, &@block) # @components << @page_container ??? .visible= .visible = current > 1 .visible= .visible = current < pages.size position.model = "#{@current} van #{@pages.size}" page_container.visible = true .visible = true else page_container.visible = false .visible = false end @components = [] add(page_container) add() end |
#page_content ⇒ Object
84 85 86 |
# File 'lib/lapillus/pager.rb', line 84 def page_content @pages[@current-1] end |