Skip to content

Instantly share code, notes, and snippets.

@jakubstraka
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jakubstraka/c993180c4224eb603cec to your computer and use it in GitHub Desktop.
Save jakubstraka/c993180c4224eb603cec to your computer and use it in GitHub Desktop.
# ---------------------------------------------------------------
# Playground
class Playground
constructor: (playground) ->
@playground = $(playground)
@setEvents()
@getExamples()
setEvents: ->
$("[data-behavior='test-uppercase']").on 'click', @triggerUppercase
$("[data-behavior='test-lowercase']").on 'click', @triggerLowercase
$("[data-behavior='clear-tests']").on 'click', @clearTests
clearTests: ->
$('.tester').remove()
triggerUppercase: ->
$('.tester').toggleClass('uppercase')
triggerLowercase: ->
$('.tester').toggleClass('lowercase')
getExamples: ->
$.ajax(
url: "/examples",
method: "GET",
dataType: "JSON",
success: @setExamples
)
# ---------------------------------------------------------------
# Appendix
class Appendix
constructor: (item) ->
@item = $(item)
@setEvents()
setEvents: ->
@item.find("[data-behavior='close-appendix']").on 'click', @closeAppendix
closeAppendix: =>
@item.hide()
# ---------------------------------------------------------------
jQuery ($) ->
new Appendix($("[data-behavior='appendix']"))
new Playground($("[data-behavior='playground']"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment