Parcourir la source

Tablet routering

For sections without childrens
piniphone il y a 13 ans
Parent
commit
4e30433f9e

+ 1 - 1
example/navigation.tablet.html

@@ -119,7 +119,7 @@
         Lungo.init({
             name: 'Flexbox',
             version: '2.2',
-            history: true
+            history: false
         });
         $$("[data-router=back]").tap(function(event) { Lungo.Router.back();});
     </script>

+ 19 - 6
example/navigation.tablet2.html

@@ -80,13 +80,26 @@
         </footer>
     </section>
 
-    <section id="mail">
-        mail 1
-    </section>
     <section id="mail2">
-        mail 2
+        <header data-title="First mail">
+            <nav class="left">
+                <button data-view-section="back">BaCk</button>
+            </nav>
+        </header>
+        <article id="art_2">
+            mail 1
+        </article>
+    </section>
+    <section id="mail">
+        <header data-title="Second mail">
+            <nav class="left">
+                <button data-view-section="back">BaCk</button>
+            </nav>
+        </header>
+        <article id="art_1">
+            mail 2
+        </article>
     </section>
-
 
     <script src="components/quojs/quo.js"></script>
     <script src="components/lungo.brownie/lungo.debug.js"></script>
@@ -94,7 +107,7 @@
         Lungo.init({
             name: 'Flexbox',
             version: '2.2',
-            history: true
+            history: false
         });
         $$("[data-router=back]").tap(function(event) { Lungo.Router.back(); });
     </script>

+ 0 - 1
src/modules/Lungo.Aside.coffee

@@ -44,7 +44,6 @@ Lungo.Aside = do (lng = Lungo) ->
   @method hide
   ###
   hide = (callback, fromX) ->
-    console.error fromX
     if lng.Element.Cache.aside
       _callback = callback
       aside_transition = lng.Element.Cache.aside.data(C.TRANSITION.ATTR) or "left"

+ 17 - 0
src/modules/Lungo.Section.coffee

@@ -31,6 +31,23 @@ Lungo.Section = do (lng = Lungo) ->
 
   _tablet = (current, target, backward) ->
     target.addClass(C.CLASS.SHOW)
+    if not _targetIsChildren target
+      same_aside = _targetHasSameAside target
+      # console.error "Same aside --> ", same_aside
+      current?.removeClass(C.CLASS.SHOW)
+      lng.Element.Cache.aside?.removeClass("show").removeClass("box")
+      lng.Element.Cache.aside = undefined
+
+  _targetIsChildren = (target) ->
+    children = lng.Element.Cache.section?.data("children")
+    return false unless children
+    target_id = target.attr "id"
+    return children.indexOf(target_id) isnt -1
+
+  _targetHasSameAside = (target) ->
+    current_aside_id = lng.Element.Cache.aside?.attr("id")
+    return false unless current_aside_id
+    return current_aside_id is target.data("aside")
 
 
   show: show

+ 2 - 0
src/stylesheets/lungo.media.tablet.styl

@@ -23,6 +23,8 @@
         &.show
           ordinal-group(1)
           display-box()
+        &.right
+          ordinal-group(3)
 
       &:not(.box)
         position: absolute