Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions source/javascripts/classify.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,27 @@ $ ->

return

$(".symbol-list").on "click", "li", ->
command = $("code.command", this)[0]

range = document.createRange()
range.selectNode(command)

selection = window.getSelection()
selection.removeAllRanges()
selection.addRange(range)

try
if document.execCommand("copy")
selection.collapse(null) # Remove selection if copy succeeded

$(this)
.addClass "flash"
.on "animationend", ->
$(this).removeClass("flash")
catch error
console.error("Your browser doesn't support the copy command. Use CTRL + C instead.", error)

# Canvas
c = $.canvassify("#tafel",
callback: classify
Expand Down
2 changes: 1 addition & 1 deletion source/javascripts/shared/shared.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

template = """
{{#symbols}}
<li id="{{id}}">
<li id="{{id}}" title="Click to copy the command">
<div class="symbol">
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="{{css_class}}">
</div>
Expand Down
12 changes: 12 additions & 0 deletions source/stylesheets/_symbol-list.sass
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ ul.symbol-list
padding: 0
overflow: hidden

&.flash
animation: flash 1s linear

.info
display: table-cell
vertical-align: middle
Expand Down Expand Up @@ -39,7 +42,16 @@ ul.symbol-list

&:hover
background-color: whitesmoke
cursor: pointer

&.active:hover,
&.active
background-color: cornsilk

@keyframes flash
0%
background-color: whitesmoke
10%
background-color: #EEE
100%
background-color: whitesmoke