Last active
August 29, 2015 14:22
-
-
Save jakubstraka/c993180c4224eb603cec to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# --------------------------------------------------------------- | |
# 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