class Formotion::RowType::WebLinkRow

Public Instance Methods

after_build(cell) click to toggle source
Calls superclass method
# 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?() click to toggle source
# 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) click to toggle source
# 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() click to toggle source
# 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.clicked_button.cancel?
  end.show
end