Class: UnderOs::UI::Locker

Inherits:
View show all
Defined in:
lib/under_os/ui/locker.rb

Constant Summary

Constants included from Wrap

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

Instance Attribute Summary collapse

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=, #hidden, #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 = {}) ⇒ Locker

Returns a new instance of Locker.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/under_os/ui/locker.rb', line 6

def initialize(options={})
  super options

  @dialog  = UnderOs::UI::View.new(class: 'locker-dialog')
  @spinner = UnderOs::UI::Spinner.new
  @label   = UnderOs::UI::Label.new(text: options[:text] || '')

  append @dialog.append(@spinner, @label)

  addClass 'with-label' if options[:text]
end

Instance Attribute Details

#labelObject (readonly)

Returns the value of attribute label.



4
5
6
# File 'lib/under_os/ui/locker.rb', line 4

def label
  @label
end

#spinnerObject (readonly)

Returns the value of attribute spinner.



4
5
6
# File 'lib/under_os/ui/locker.rb', line 4

def spinner
  @spinner
end

Instance Method Details

#hideObject



23
24
25
# File 'lib/under_os/ui/locker.rb', line 23

def hide
  remove
end

#showObject



18
19
20
21
# File 'lib/under_os/ui/locker.rb', line 18

def show
  insertTo(UnderOs::App.history.current_page.view) if ! parent
  repaint
end

#show_for(&block) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/under_os/ui/locker.rb', line 35

def show_for(&block)
  show
  1.ms.later do
    block.call
    1.ms.later { hide }
  end
end

#textObject



27
28
29
# File 'lib/under_os/ui/locker.rb', line 27

def text
  @label.text
end

#text=(text) ⇒ Object



31
32
33
# File 'lib/under_os/ui/locker.rb', line 31

def text=(text)
  @label.text = text
end