Class: Formotion::RowType::WebLinkRow
- Defined in:
- lib/formotion/row_type/web_link_row.rb
Constant Summary
Constants inherited from StringRow
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #after_build(cell) ⇒ Object
- #is_url? ⇒ Boolean
- #on_select(tableView, tableViewDelegate) ⇒ Object
- #warn ⇒ Object
Methods inherited from ObjectRow
#build_cell, #row_value, #update_text_field
Methods inherited from StringRow
#add_callbacks, #build_cell, #done_editing, #keyboardType, #on_change, #row_value, #update_text_field
Methods inherited from Base
#_on_select, #after_delete, #break_with_semaphore, #build_cell, #button?, #cellEditingStyle, #cell_style, #delete_row, #done_editing, field_buffer, #indentWhileEditing?, #initialize, #input_accessory_view, #on_delete, #update_cell, #with_semaphore
Constructor Details
This class inherits a constructor from Formotion::RowType::Base
Instance Method Details
#after_build(cell) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/formotion/row_type/web_link_row.rb', line 7 def after_build(cell) super cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator self.row.text_field.hidden = true end |
#is_url? ⇒ Boolean
26 27 28 |
# File 'lib/formotion/row_type/web_link_row.rb', line 26 def is_url? (row.value.is_a?(String) && row.value[0..3] == "http") || row.value.is_a?(NSURL) end |
#on_select(tableView, tableViewDelegate) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/formotion/row_type/web_link_row.rb', line 14 def on_select(tableView, tableViewDelegate) if is_url? if row.warn.nil? || row.warn == false App.open_url row.value else warn end else raise StandardError, "Row value for WebLinkRow should be a URL string or instance of NSURL." end end |
#warn ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/formotion/row_type/web_link_row.rb', line 30 def warn row.warn = {} unless row.warn.is_a? Hash #Convert value from true to a hash row.warn = { title: "Leaving #{App.name}", message: "This action will leave #{App.name} and open Safari.", buttons: ["Cancel", "OK"] }.merge(row.warn) BW::UIAlertView.new({ title: row.warn[:title], message: row.warn[:message], buttons: row.warn[:buttons], cancel_button_index: 0 }) do |alert| App.open_url(row.value) unless alert..cancel? end.show end |