Kaynağa Gözat

Async history only if config

Javi Jimenez Villar 13 yıl önce
ebeveyn
işleme
012363d38c

+ 1 - 0
src/Lungo.coffee

@@ -11,6 +11,7 @@ window.Lungo = Lungo = {}
 
 Lungo.VERSION = "2.1.0313"
 Lungo.DEVICE = null
+Lungo.Config or (Lungo.Config = {})
 Lungo.Element or (Lungo.Element = {})
 Lungo.Data or (Lungo.Data = {})
 Lungo.Sugar or (Lungo.Sugar = {})

+ 2 - 3
src/boot/Lungo.Boot.Layout.coffee

@@ -16,10 +16,9 @@ Lungo.Boot.Layout = do(lng = Lungo) ->
   Initializes all <section> & <article> of the project
   @method init
   ###
-  init = (config) ->
+  init = ->
     lng.Fallback.fixPositionInAndroid()
-
-    if config?.history? and config.history is true and window.location.hash?.length >= 2
+    if Lungo.Config.history and window.location.hash?.length >= 2
       do _initSectionbyUrl
     else
       do _initSection

+ 2 - 1
src/modules/Lungo.Init.coffee

@@ -7,8 +7,9 @@ Instance initializer
 @author Javier Jimenez Villar <javi@tapquo.com> || @soyjavi
 ###
 Lungo.init = (config) ->
+  Lungo.Config = config
   Lungo.Resource.load config.resources if config and config.resources
   do Lungo.Boot.Device.init
   do Lungo.Boot.Events.init
   do Lungo.Boot.Data.init
-  Lungo.Boot.Layout.init config
+  do Lungo.Boot.Layout.init

+ 4 - 4
src/modules/Lungo.Router.coffee

@@ -31,7 +31,7 @@ Lungo.Router = do(lng = Lungo) ->
 
         lng.Section.show current, target
         lng.Router.step section_id
-        do _url
+        do _url if Lungo.Config.history
         do _updateNavigationElements
 
 
@@ -50,7 +50,8 @@ Lungo.Router = do(lng = Lungo) ->
         lng.Element.Cache.article = target.addClass(C.CLASS.ACTIVE).trigger(C.TRIGGER.LOAD)
         if element?.data(C.ATTRIBUTE.TITLE)?
           lng.Element.Cache.section.find(C.QUERY.TITLE).text element.data(C.ATTRIBUTE.TITLE)
-        do _url
+        do _url if Lungo.Config.history
+        do _updateNavigationElements
 
 
   ###
@@ -70,7 +71,7 @@ Lungo.Router = do(lng = Lungo) ->
       if target.hasClass("aside") then lng.Aside.toggle()
 
     lng.Section.show current, target
-    do _url
+    do _url if Lungo.Config.history?
     do _updateNavigationElements
 
 
@@ -99,7 +100,6 @@ Lungo.Router = do(lng = Lungo) ->
     _hashed_url += "#{section}/" for section in _history
     _hashed_url += lng.Element.Cache.article.attr "id"
     setTimeout (-> window.location.hash = _hashed_url), 0
-    do _updateNavigationElements
 
   _updateNavigationElements = ->
     article_id = lng.Element.Cache.article.attr C.ATTRIBUTE.ID