Module: ProMotion::UIWebScreenModule

Included in:
WebScreenModule
Defined in:
lib/ProMotion/web/ui_web_screen_module.rb

Instance Method Summary collapse

Instance Method Details

#back_forward_listObject



34
35
36
37
38
# File 'lib/ProMotion/web/ui_web_screen_module.rb', line 34

def back_forward_list
  # self.webview.backForwardList
  PM.logger.warn "`back_forward_list` is not implemented with the older UIWebView, which doesn't support it."
  false
end

#evaluate(js) ⇒ Object



15
16
17
# File 'lib/ProMotion/web/ui_web_screen_module.rb', line 15

def evaluate(js)
  self.webview.stringByEvaluatingJavaScriptFromString(js)
end

#evaluate_async(js, &block) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/ProMotion/web/ui_web_screen_module.rb', line 19

def evaluate_async(js, &block)
  Dispatch::Queue.concurrent.async do
    result = evaluate(js)
    Dispatch::Queue.main.async do
      block.call result
    end
  end
end

#go_to_item(item) ⇒ Object



28
29
30
31
32
# File 'lib/ProMotion/web/ui_web_screen_module.rb', line 28

def go_to_item(item)
  # self.webview.goToBackForwardListItem(item)
  PM.logger.warn "`go_to_item` is not implemented with the older UIWebView, which doesn't support it."
  false
end

#progressObject



40
41
42
43
44
# File 'lib/ProMotion/web/ui_web_screen_module.rb', line 40

def progress
  # self.webview.estimatedProgress
  PM.logger.warn "`progress` is not implemented with the older UIWebView, which doesn't support it."
  false
end

#web_view_setupObject



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/ProMotion/web/ui_web_screen_module.rb', line 3

def web_view_setup
  self.webview = add UIWebView.new, {
    frame: CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height),
    delegate: self,
    data_detector_types: data_detector_types
  }

  self.webview.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight
  self.webview.scalesPageToFit = self.scale_to_fit
  self.webview.scrollView.decelerationRate = UIScrollViewDecelerationRateNormal
end

#webView(webView, didFailLoadWithError: error) ⇒ Object

CocoaTouch methods



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/ProMotion/web/ui_web_screen_module.rb', line 48

def webView(in_web, shouldStartLoadWithRequest:in_request, navigationType:in_type)
  if %w(http https).include?(in_request.URL.scheme)
    if self.external_links == true && in_type == UIWebViewNavigationTypeLinkClicked
      if defined?(OpenInChromeController)
        open_in_chrome in_request
      else
        open_in_safari in_request
      end
      return false # don't allow the web view to load the link.
    end
  end

  load_request_enable = true #return true on default for local file loading.
  load_request_enable = !!on_request(in_request, in_type) if self.respond_to?(:on_request)
  load_request_enable
end

#webViewDidFinishLoad(webView) ⇒ Object



69
70
71
# File 'lib/ProMotion/web/ui_web_screen_module.rb', line 69

def webViewDidFinishLoad(webView)
  load_finished if self.respond_to?(:load_finished)
end

#webViewDidStartLoad(webView) ⇒ Object



65
66
67
# File 'lib/ProMotion/web/ui_web_screen_module.rb', line 65

def webViewDidStartLoad(webView)
  load_started if self.respond_to?(:load_started)
end