Files
old-svijetlastrana-front/public/bower_components/messenger/docs/welcome/javascripts/execute.coffee

20 lines
413 B
CoffeeScript
Raw Normal View History

2018-05-07 16:07:00 +02:00
$.fn.executr = (opts) ->
defaults =
codeSelector: 'code[executable]'
opts = $.extend {}, defaults, opts
this.on 'click', opts.codeSelector, (e) ->
$target = $ e.target
$code = $target.parents(opts.codeSelector)
ctx = window
if opts.setUp?
CoffeeScript.run opts.setUp, ctx
CoffeeScript.run $code.text(), ctx
if opts.tearDown?
CoffeeScript.run opts.tearDown, ctx