Created
January 6, 2015 21:06
-
-
Save skvggor/26c312d35b6a25801ab6 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
JumpMania = {} | |
JumpMania.apps = | |
# Converte NodeList para Array | |
convertToArray: (object) -> | |
[].map.call object, (element) -> | |
element | |
# Adiciona classe 'one-line' aos elementos da Galeria que contenham títulos | |
# com apenas uma linha. Os títulos são localidades. | |
addClassOneLine_gallery: -> | |
galleryItems = document.querySelectorAll '.gallery-item' | |
if galleryItems[0] | |
# todo: to use Array.prototype.map(); | |
galleryItems = JumpMania.apps.convertToArray galleryItems | |
for item, i in galleryItems by 1 | |
if !galleryItems[i].innerHTML.match '<br>' | |
oldClasses = galleryItems[i].getAttribute 'class' | |
galleryItems[i].setAttribute 'class', oldClasses + ' one-line' | |
do -> | |
JumpMania.apps.addClassOneLine_gallery() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment