diff --git a/source/javascripts/classify.coffee b/source/javascripts/classify.coffee index 014b6af..f1a2961 100644 --- a/source/javascripts/classify.coffee +++ b/source/javascripts/classify.coffee @@ -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 diff --git a/source/javascripts/shared/shared.coffee b/source/javascripts/shared/shared.coffee index fc86727..877d46e 100644 --- a/source/javascripts/shared/shared.coffee +++ b/source/javascripts/shared/shared.coffee @@ -23,7 +23,7 @@ template = """ {{#symbols}} -
  • +
  • diff --git a/source/stylesheets/_symbol-list.sass b/source/stylesheets/_symbol-list.sass index 4eefa43..fdfef2f 100644 --- a/source/stylesheets/_symbol-list.sass +++ b/source/stylesheets/_symbol-list.sass @@ -12,6 +12,9 @@ ul.symbol-list padding: 0 overflow: hidden + &.flash + animation: flash 1s linear + .info display: table-cell vertical-align: middle @@ -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