Extract link click callback to method

This commit is contained in:
Kevin Sawicki & Nathan Sobo
2013-05-16 15:04:30 -07:00
parent 83e6a4a57e
commit a29015551c

View File

@@ -25,14 +25,16 @@ class WindowEventHandler
e.preventDefault()
e.stopPropagation()
@subscribe $(document), 'click', 'a', (e) ->
location = $(e.target).attr('href')
return unless location
return if location[0] is '#'
@subscribe $(document), 'click', 'a', @openLink
if location.indexOf('https://') is 0 or location.indexOf('http://') is 0
require('child_process').spawn('open', [location])
false
openLink: (event) =>
location = $(event.target).attr('href')
return unless location
return if location[0] is '#'
if location.indexOf('https://') is 0 or location.indexOf('http://') is 0
require('child_process').spawn('open', [location])
false
eachTabIndexedElement: (callback) ->
for element in $('[tabindex]')