Skip to content

Instantly share code, notes, and snippets.

@skvggor
Created January 6, 2015 21:06
Show Gist options
  • Save skvggor/26c312d35b6a25801ab6 to your computer and use it in GitHub Desktop.
Save skvggor/26c312d35b6a25801ab6 to your computer and use it in GitHub Desktop.
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