Lungo.Router.Article.coffee 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. ###
  2. Initialize the <articles> layout of a certain <section>
  3. @namespace Lungo
  4. @class Article
  5. @author Javier Jimenez Villar <javi@tapquo.com> || @soyjavi
  6. @author Guillermo Pascual <pasku@tapquo.com> || @pasku1
  7. ###
  8. Lungo.Article = do(lng = Lungo) ->
  9. C = lng.Constants
  10. ###
  11. @todo Describe method
  12. @method title
  13. ###
  14. title = (value) -> lng.Element.Cache.section.find(C.QUERY.TITLE).text value if value
  15. ###
  16. @todo Describe method
  17. @method switchNavItems
  18. ###
  19. switchNavItems = (article_id) ->
  20. lng.Element.Cache.section.find(C.QUERY.NAVIGATION_ITEM).removeClass C.CLASS.ACTIVE
  21. active_nav_items = "a[href=\"" + article_id + "\"][data-router=\"article\"]"
  22. lng.Element.Cache.section.find(active_nav_items).addClass C.CLASS.ACTIVE
  23. if lng.Element.Cache.aside
  24. aside = lng.Element.Cache.aside
  25. aside.find(C.QUERY.ACTIVE_LIST_ITEM).removeClass C.CLASS.ACTIVE
  26. aside.find(active_nav_items).addClass(C.CLASS.ACTIVE).parent().addClass C.CLASS.ACTIVE
  27. ###
  28. @todo Describe method
  29. @method switchReferenceItems
  30. ###
  31. switchReferenceItems = (article_id, section) ->
  32. reference = "[data-article=" + article_id.replace("#", "") + "]"
  33. section.find(C.QUERY.REFERENCE_LINK).hide().siblings(reference).show()
  34. title: title
  35. switchReferenceItems: switchReferenceItems
  36. switchNavItems: switchNavItems