Created
August 30, 2017 16:07
-
-
Save andrewchee/232e163710628e311ab0c78cdd362205 to your computer and use it in GitHub Desktop.
This file contains 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
# External stylesheets ------------------------- | |
Utils.insertStylesheet = (url, callback) -> | |
styleElement = document.createElement("link") | |
styleElement.rel = "stylesheet" | |
styleElement.type = "text/css" | |
styleElement.href = url | |
styleElement.addEventListener "load", -> | |
callback(url) if callback | |
Utils.domComplete -> | |
document.body.appendChild(styleElement) | |
# Console feedback | |
confirm = (url) -> #optional | |
print "successfully added #{url}" | |
# Insert it | |
Utils.insertStylesheet("https://fonts.googleapis.com/icon?family=Material+Icons") #hosted | |
Utils.insertStylesheet("mdl/material.css", confirm) # local | |
# Test it | |
layer = new Layer | |
width: 128, height: 128 | |
backgroundColor: "" | |
ignoreEvents: false | |
html: '<button class="mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect mdl-button--colored"> <i class="material-icons">add</i> </button>' | |
style: | |
padding: '36px' | |
layer.center() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment