You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
752 B
CoffeeScript

$ = require "jquery"
castBoolean = (value) ->
if value == true
return 1
else
return 0
updateEmbedCode = ->
showToolbar = $("#show_toolbar").prop("checked")
showDonationLink = $("#show_donation").prop("checked")
embedCode = embed_template
.replace "{SPARSE}", castBoolean(not showToolbar)
.replace "{DONATION}", castBoolean(showDonationLink)
$(".embed_code").val embedCode
$ ->
$ ".autoselect"
.on "click", (event) ->
$ this
.focus()
.select()
$ "#show_toolbar, #show_donation"
.on "change", (event) ->
updateEmbedCode()
# Linkify has a tendency of breaking our embed codes, so we re-set the embed code here to make sure that that doesn't happen.
if embed_template?
updateEmbedCode()
# do things and stuff