ソースを参照

New controller for aside element

@soyjavi 14 年 前
コミット
5329ee4310
2 ファイル変更10 行追加7 行削除
  1. 2 1
      src/boot/Lungo.Boot.Events.js
  2. 8 6
      src/view/Lungo.View.Aside.js

+ 2 - 1
src/boot/Lungo.Boot.Events.js

@@ -70,6 +70,7 @@ LUNGO.Boot.Events = (function(lng, undefined) {
     };
 
     var _goSection = function(id) {
+        _hideAsideIfNecesary();
         id = lng.Core.parseUrl(id);
         if (id === '#back') {
             lng.Router.back();
@@ -95,7 +96,7 @@ LUNGO.Boot.Events = (function(lng, undefined) {
     var _hideAsideIfNecesary = function(event) {
         if (window.innerWidth < 768) lng.View.Aside.hide();
 
-        event.preventDefault();
+        if (event) event.preventDefault();
     };
 
     return {

+ 8 - 6
src/view/Lungo.View.Aside.js

@@ -62,13 +62,15 @@ LUNGO.View.Aside = (function(lng, undefined) {
      */
     var hide = function() {
         var aside = lng.Element.Current.aside;
-        var aside_stylesheet = _asideStylesheet(aside);
-        lng.Element.Current.section.removeClass(CLASS.ASIDE).removeClass(aside_stylesheet);
+        if (aside) {
+            var aside_stylesheet = _asideStylesheet(aside);
+            lng.Element.Current.section.removeClass(CLASS.ASIDE).removeClass(aside_stylesheet);
 
-        setTimeout(function() {
-            aside.removeClass(CLASS.CURRENT);
-            lng.Element.Current.aside = null;
-        }, 300);
+            setTimeout(function() {
+                aside.removeClass(CLASS.CURRENT);
+                lng.Element.Current.aside = null;
+            }, 300);
+        }
     };
 
     var _asideStylesheet = function(aside) {