| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- ###
- Initialize the <articles> layout of a certain <section>
- @namespace Lungo.View
- @class Article
- @author Javier Jimenez Villar <javi@tapquo.com> || @soyjavi
- @author Guillermo Pascual <pasku@tapquo.com> || @pasku1
- ###
- Lungo.View.Article = do(lng = Lungo) ->
- ELEMENT = lng.Constants.ELEMENT
- CLASS = lng.Constants.CLASS
- ATTRIBUTE = lng.Constants.ATTRIBUTE
- SELECTORS =
- NAVIGATION_ITEM: "a[href][data-router=\"article\"]"
- REFERENCE_LINK: " a[href][data-article]"
- TITLE_OF_ARTICLE: "header .title, footer .title"
- ASIDE_REFERENCE_LIST: "li a.active, li.active"
- ###
- ?
- @method show
- ###
- title = (value) ->
- lng.Element.Cache.section.find(SELECTORS.TITLE_OF_ARTICLE).text value if value
- switchNavItems = (article_id) ->
- lng.Element.Cache.section.find(SELECTORS.NAVIGATION_ITEM).removeClass CLASS.ACTIVE
- active_nav_items = "a[href=\"" + article_id + "\"][data-router=\"article\"]"
- lng.Element.Cache.section.find(active_nav_items).addClass CLASS.ACTIVE
- if lng.Element.Cache.aside
- aside = lng.Element.Cache.aside
- aside.find(SELECTORS.ASIDE_REFERENCE_LIST).removeClass CLASS.ACTIVE
- aside.find(active_nav_items).addClass(CLASS.ACTIVE).parent().addClass CLASS.ACTIVE
- switchReferenceItems = (article_id, section) ->
- reference = "[data-article=" + article_id.replace("#", "") + "]"
- section.find(SELECTORS.REFERENCE_LINK).hide().siblings(reference).show()
- title: title
- switchReferenceItems: switchReferenceItems
- switchNavItems: switchNavItems
|