Sha256: 862c4eda0d0d614c325ce6bf288a759a4d3ac38b014c4e3ffc1755779e981603

Contents?: true

Size: 751 Bytes

Versions: 4

Compression:

Stored size: 751 Bytes

Contents

class Link
  constructor: (@page, @$link) -> 
  
  allows_process: (event) ->
    !(this._cross_origin_link(event.currentTarget) || this._non_standard_click(event))

  process: -> 
    type = if (@$link.attr("data-push") == 'partial') then 'partial' else 'template'
    @page.load(@$link.attr("href"), @$link.attr("data-target"), type)

  # We split host because IE returns host with port and other browsers not
  # 
  _cross_origin_link: (link) ->  
    (location.protocol != link.protocol) || (location.host.split(':')[0] != link.host.split(':')[0])    

  _non_standard_click: (event) ->
    event.metaKey || event.ctrlKey || event.shiftKey || event.altKey

window._Wiselinks = {} if window._Wiselinks == undefined
window._Wiselinks.Link = Link    

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
wiselinks-0.6.3 lib/assets/javascripts/_link.js.coffee
wiselinks-0.6.2 lib/assets/javascripts/_link.js.coffee
wiselinks-0.6.1 lib/assets/javascripts/_link.js.coffee
wiselinks-0.6.0 lib/assets/javascripts/_link.js.coffee