Class: UnderOs::UI::Select
Constant Summary
Constants included from Wrap
Wrap::INSTANCES_CACHE, Wrap::RAW_WRAPS_MAP, Wrap::WRAPS_TAGS_MAP
Instance Method Summary collapse
- #hide ⇒ Object
-
#initialize(options = {}) ⇒ Select
constructor
A new instance of Select.
-
#numberOfComponentsInPickerView(picker) ⇒ Object
UIPickerView delegate.
- #optgroups ⇒ Object
- #optgroups=(list) ⇒ Object
- #options ⇒ Object
- #options=(value) ⇒ Object
- #pickerView(picker, didSelectRow: index, inComponent: group) ⇒ Object
- #show ⇒ Object
- #value ⇒ Object
- #value=(value) ⇒ Object
Methods inherited from View
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
Methods included from Wrap
Constructor Details
#initialize(options = {}) ⇒ Select
Returns a new instance of Select.
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/under_os/ui/select.rb', line 4 def initialize(={}) super self. = .delete(:options) if [:options] self.value = .delete(:value) if [:value] #@_.showsSelectionIndicator = true if options[:lense] @_.delegate = self @_.dataSource = self end |
Instance Method Details
#hide ⇒ Object
71 72 73 74 75 |
# File 'lib/under_os/ui/select.rb', line 71 def hide animate bottom: -size.y, complete: -> { style.display = :none } end |
#numberOfComponentsInPickerView(picker) ⇒ Object
UIPickerView delegate
80 81 82 |
# File 'lib/under_os/ui/select.rb', line 80 def numberOfComponentsInPickerView(picker) optgroups.size end |
#optgroups ⇒ Object
16 17 18 |
# File 'lib/under_os/ui/select.rb', line 16 def optgroups @optgroups ||= [{}] end |
#optgroups=(list) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/under_os/ui/select.rb', line 20 def optgroups=(list) @optgroups = list.map do |hash| {}.tap do |clean_hash| hash.each do |key, value| clean_hash[key.to_s] = value if key && value end end end end |
#options ⇒ Object
30 31 32 |
# File 'lib/under_os/ui/select.rb', line 30 def optgroups.size == 1 ? optgroups[0] : optgroups end |
#options=(value) ⇒ Object
34 35 36 37 |
# File 'lib/under_os/ui/select.rb', line 34 def (value) self.optgroups = value.is_a?(Array) ? value : [value] @_.reloadAllComponents end |
#pickerView(picker, didSelectRow: index, inComponent: group) ⇒ Object
84 85 86 |
# File 'lib/under_os/ui/select.rb', line 84 def pickerView(picker, numberOfRowsInComponent: group) optgroups[group].size end |
#show ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'lib/under_os/ui/select.rb', line 61 def show page.find('select').each do |select| select.hide if select.visible && select != self end self.style = {bottom: -size.y, display: :block} animate bottom: 0 end |
#value ⇒ Object
39 40 41 42 |
# File 'lib/under_os/ui/select.rb', line 39 def value @value ||= [] optgroups.size == 1 ? @value[0] : @value end |
#value=(value) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/under_os/ui/select.rb', line 44 def value=(value) prev_val = @value @value = Array(value).map(&:to_s) emit :change if @value != prev_val @value.each_with_index do |value, group| i = 0; optgroups[group].each do |v, label| if value == v @_.selectRow i, inComponent: group, animated: false else i += 1 end end end end |