Class: UnderOs::UI::Sidebar

Inherits:
View
  • Object
show all
Defined in:
lib/under_os/ui/sidebar.rb

Constant Summary collapse

LOCATIONS =
[:top, :left, :right, :bottom]

Constants included from Wrap

Wrap::INSTANCES_CACHE, Wrap::RAW_WRAPS_MAP, Wrap::WRAPS_TAGS_MAP

Instance Method Summary collapse

Methods inherited from View

#inspect

Methods included from Manipulation

#append, #clear, #insert, #insertTo, #prepend, #remove

Methods included from Traversing

#children, #empty?, #find, #first, #matches, #parent, #siblings

Methods included from Dimensions

#position, #position=, #size, #size=

Methods included from Animation

#animate, #fade_in, #fade_out, #highlight

Methods included from Commons

#data, #data=, #id, #id=, #page, #tagName, #toggle, #visible

Methods included from Styles

#addClass, #className, #className=, #classNames, #classNames=, #hasClass, #radioClass, #removeClass, #repaint, #style, #style=, #toggleClass

Methods included from Events

#emit, #off, #on, #on=

Methods included from Wrap

included

Constructor Details

#initialize(options = {}) ⇒ Sidebar

Returns a new instance of Sidebar.



6
7
8
9
10
# File 'lib/under_os/ui/sidebar.rb', line 6

def initialize(options={})
  super

  self.location = options.delete(:location) if options.has_key?(:location)
end

Instance Method Details

#hiddenObject



37
38
39
# File 'lib/under_os/ui/sidebar.rb', line 37

def hidden
  !classNames.include?('visible')
end

#hideObject



31
32
33
34
35
# File 'lib/under_os/ui/sidebar.rb', line 31

def hide
  @_class_names -= ['visible']

  animate location => -slide_distance
end

#locationObject



12
13
14
# File 'lib/under_os/ui/sidebar.rb', line 12

def location
  @location || :bottom
end

#location=(value) ⇒ Object



16
17
18
19
# File 'lib/under_os/ui/sidebar.rb', line 16

def location=(value)
  @location = value.to_sym
  @location = nil if ! LOCATIONS.include?(@location)
end

#showObject



21
22
23
24
25
26
27
28
29
# File 'lib/under_os/ui/sidebar.rb', line 21

def show
  class_names = self.classNames
  class_names.reject!{ |n| LOCATIONS.include?(n.to_sym) }

  self.classNames = class_names + [location, 'visible']
  self.style = {location => -slide_distance, display: :block}

  animate location => 0
end

#slide_distanceObject



41
42
43
# File 'lib/under_os/ui/sidebar.rb', line 41

def slide_distance
  [:top, :bottom].include?(location) ? size.y : size.x
end