From 33712949277582a826eee5b6eeb95636caebd8a3 Mon Sep 17 00:00:00 2001
From: Marius Cramer <m.cramer@pixcept.de>
Date: Wed, 07 Jan 2015 10:07:02 -0500
Subject: [PATCH] - Responsive menu improved

---
 interface/web/themes/default/assets/javascripts/responsive.js |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/interface/web/themes/default/assets/javascripts/responsive.js b/interface/web/themes/default/assets/javascripts/responsive.js
index dd64ff9..abdf1ec 100644
--- a/interface/web/themes/default/assets/javascripts/responsive.js
+++ b/interface/web/themes/default/assets/javascripts/responsive.js
@@ -9,9 +9,11 @@
   // Hauptnavigation
   $('<ul />').appendTo($responsiveNavigation);
 
+  var $addto = false;
   $($mainNavigation).find('a').each(function () {
     var $item = $(this);
     var $activeClass = $item.hasClass('active') ? ' class="active"' : '';
+    var isactive = $activeClass != '' ? true : false;
     
     var capp = $item.attr('data-capp');
     if(capp) $activeClass += ' data-capp="' + capp + '"';
@@ -19,11 +21,14 @@
 	capp = $item.attr('data-load-content');
     if(capp) $activeClass += ' data-load-content="' + capp + '"';
 
-    $responsiveNavigation.find('ul').append($('<li><a href="' + $item.attr('href') + '"' + $activeClass + '><i class="icon ' + $item.data('icon-class') + '"></i>' + $item.text() + '</a></li>'));
+	var $newel = $('<li><a href="' + $item.attr('href') + '"' + $activeClass + '><i class="icon ' + $item.data('icon-class') + '"></i>' + $item.text() + '</a></li>');
+	if(isactive != '') $addto = $newel;
+    $responsiveNavigation.find('ul').append($newel);
   });
 
   // Subnavigation
-  $('<ul class="subnavi" />').appendTo($responsiveNavigation);
+  if(!$addto) $addto = $responsiveNavigation;
+  $('<ul class="subnavi" />').appendTo($addto);
 
   $($subNavigation).find('a').each(function () {
     var $item = $(this);
@@ -35,6 +40,9 @@
 	capp = $item.attr('data-load-content');
     if(capp) addattr += ' data-load-content="' + capp + '"';
 
+	capp = $item.hasClass('subnav-header');
+	if(capp) addattr += ' class="subnav-header"';
+	
     $responsiveNavigation.find('ul.subnavi').append($('<li><a href="' + $item.attr('href') + '"' + addattr + '>' + $item.text() + '</a></li>'));
   });
 };

--
Gitblit v1.9.1