Skip to content

Commit

Permalink
Pull that click handler out to its own method
Browse files Browse the repository at this point in the history
  • Loading branch information
tekkub committed Aug 26, 2013
1 parent bbe097d commit ff602c9
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions coffee/button.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,7 @@ class Button

renderLink: ->
@link = $('<a>')
@link.click (e) ->
if @link.data('pinned')
if e.which == 1 && !e.metaKey && !e.shiftKey
# We have a normal click, pin this tab
chrome.tabs.getCurrent (tab) ->
chrome.tabs.update tab.id, {'pinned': true}
return

# Mod-click or middle, don't lose focus or kill this tab
chrome.tabs.create
'pinned': true
'selected': false
'url': $(this).attr("href")

return false

@link.click @onClick
@li.append @link


Expand All @@ -50,6 +35,23 @@ class Button
@link.append @img_div


onClick: (event) ->
if $(this).data('pinned')
if event.which == 1 && !event.metaKey && !event.shiftKey
# We have a normal click, pin this tab
chrome.tabs.getCurrent (tab) ->
chrome.tabs.update tab.id, {'pinned': true}
return

# Mod-click or middle, don't lose focus or kill this tab
chrome.tabs.create
'pinned': true
'selected': false
'url': $(this).attr("href")

return false


onDragEnter: (event) ->
# Update the drop zone class on drag enter/leave
$(event.target).addClass('dragover')
Expand Down

0 comments on commit ff602c9

Please sign in to comment.