/** * Handles the and to show * * @namespace Lungo * @class Router * * @author Javier Jimenez Villar || @soyjavi * @author Guillermo Pascual || @pasku1 */ Lungo.Router = (function(lng, undefined) { var CLASS = lng.Constants.CLASS; var ELEMENT = lng.Constants.ELEMENT; var ERROR = lng.Constants.ERROR; var TRIGGER = lng.Constants.TRIGGER; var ATTRIBUTE = lng.Constants.ATTRIBUTE; var HASHTAG_CHARACTER = '#'; /** * Navigate to a
. * * @method section * * @param {string} Id of the
*/ var section = function(section_id) { section_id = lng.Core.parseUrl(section_id); var current = lng.Element.Cache.section; if (_notCurrentTarget(section_id, current)) { var target = lng.Element.Cache.sections.siblings(ELEMENT.SECTION + section_id); if (target.length > 0) { target_transition = target.data('transition'); if (target_transition) { _assignTransitionOrigin(current); _assignTransition(current, target_transition); } current.removeClass(CLASS.SHOW).addClass(CLASS.HIDE); target.addClass(CLASS.SHOW); lng.Element.Cache.section = target; lng.Element.Cache.article = target.find(ELEMENT.ARTICLE + '.' + CLASS.CURRENT); lng.Router.History.add(section_id); _sectionTriggers(current, target); } } }; /** * Displays the
in a particular
. * * @method article * * @param {string}
Id * @param {string}
Id */ var article = function(section_id, article_id, element) { article_id = lng.Core.parseUrl(article_id); var current = lng.Element.Cache.article; if (_notCurrentTarget(article_id, current)) { section(section_id); var target = lng.Element.Cache.section.find(ELEMENT.ARTICLE + article_id); if (target.length > 0) { if (_sectionId(current) === _sectionId(target)) { current.removeClass(CLASS.CURRENT); } else { lng.Element.Cache.section.children(ELEMENT.ARTICLE).removeClass(CLASS.CURRENT); } target.addClass(CLASS.CURRENT); lng.Element.Cache.article = target; lng.View.Article.switchNavItems(article_id); lng.View.Article.switchReferenceItems(article_id, lng.Element.Cache.section); if (element) lng.View.Article.title(element.data(ATTRIBUTE.TITLE)); } } }; /** * Displays the