Sha256: b3a7cf6e53d05e95be131d209b3ed0bb17f8b7e7e1d035707085ac2d8a3adcf7

Contents?: true

Size: 789 Bytes

Versions: 1

Compression:

Stored size: 789 Bytes

Contents

class MobileIntent
  @detect: (ua) ->
    if ua.match /Android/
      "android"
    else if ua.match /iPhone/ || ua.match /iPad/
      "ios"

<% MobileIntent.config.apps.each_pair do |name, app| %>
  @<%= name %> = {
    <% [:ios, :android].map do |platform| %>
      <%= "#{platform}: '#{app.market_url(platform)}'" if app.send("#{platform}?") %>
    <% end %>
  }
<% end %>


$(document).ready ->
  $(".launch_app").on 'click', (e) ->
    target = $(e.target)
    app = target.attr "data-app-scheme"
    platform = MobileIntent.detect window.navigator.userAgent

    if market_url = MobileIntent[app][platform]
      e.stopPropagation()
      e.preventDefault()
      setTimeout ->
        window.location = market_url
      , 500
      window.location = target.attr "href"
      false

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mobile_intent-0.0.1 lib/assets/javascripts/mobile_intent.js.coffee.erb