From b7c57a7ebcd735f5c37f574bed62f271fdc4fbf5 Mon Sep 17 00:00:00 2001
From: ulrich <not disclosed>
Date: Sat, 30 Dec 2017 08:44:42 +0000
Subject: [PATCH] Selector hinzugenommen

---
 app-menu.js |   76 +++++++++++++++-----------------------
 1 files changed, 30 insertions(+), 46 deletions(-)

diff --git a/app-menu.js b/app-menu.js
index 14a974e..f0cfad4 100644
--- a/app-menu.js
+++ b/app-menu.js
@@ -1,42 +1,25 @@
-
 /*
- * die nachfolgenden Funktionen steuern das ein- und 
+ * die nachfolgenden Funktionen steuern das ein- und
  * ausblenden des menues
  */
-function app_menu_init(url_prefix, mdesc, mtpl) {
+function app_menu_init(url_prefix, mdesc, mtpl, mselector) {
+  _app_menu_selector = mselector;
   document.querySelector( "#nav-toggle" ).addEventListener("click", function() {
-    /*
-    this.classList.toggle( "active" );
-    this.blur();
     app_menu_toggle();
-    */
-    //app_menu_do_toggle(this);
-    app_menu_toggle();
-  });   
-  document.getElementsByClassName('west')[0].style.flexBasis = "0em";
-  $('.ost').hide();
+  });
+  $(_app_menu_selector).css("flex-basis", "0em");
   _app_menu_url_prefix = url_prefix;
-  app_menu_template_laden(mtpl);
-  
-  var menuDiv = $("<div/>");
-  $(menuDiv).addClass('app-menu-content');  
-  $(menuDiv).css('position', "relative");
-  $(menuDiv).css('left', '-300px');
-  $(menuDiv).css('right', '0px');
-  $('.west').append(menuDiv);
-  
-  app_menu_laden(mdesc);
-}
-
-function app_menu_template_laden(tpl) {
-  $.ajax({
-    // url: _app_menu_url_prefix + "app-menu.tpl",
-    url: tpl,
-    type: "GET",
-    dataType : "text"
-  }).done(function( template ) {
-    _app_menu_template = template;  
+  $.get(mtpl, function(template) {
+    _app_menu_template = template;
     Mustache.parse(_app_menu_template);   // optional, speeds up future uses
+    var menuDiv = $("<div/>");
+    $(menuDiv).addClass('app-menu-content');
+    $(menuDiv).css('position', "relative");
+    $(menuDiv).css('left', '-300px');
+    $(menuDiv).css('right', '0px');
+    $(_app_menu_selector).append(menuDiv);
+
+    app_menu_laden(mdesc);
   });
 }
 
@@ -49,13 +32,13 @@
 function app_menu_toggle() {
   document.querySelector( "#nav-toggle" ).classList.toggle( "active" );
   document.querySelector( "#nav-toggle" ).blur();
-  var westDiv = document.getElementsByClassName('west')[0];
-  if(westDiv.classList.contains('app-menu-open')) {
-    westDiv.classList.remove('app-menu-open');
-    westDiv.style.flexBasis = "0em";
+  var westDiv = $(_app_menu_selector);
+  if($(westDiv).hasClass('app-menu-open')) {
+    $(westDiv).removeClass('app-menu-open');
+    $(westDiv).css("flex-basis", "0em");
   } else {
-    westDiv.classList.add('app-menu-open');
-    westDiv.style.flexBasis = "16em";
+    $(westDiv).addClass('app-menu-open');
+    $(westDiv).css("flex-basis", "16em");
   }
 }
 
@@ -65,6 +48,7 @@
 
 var _app_menu_url_prefix = "";
 var _app_menu_template;
+var _app_menu_selector;
 
 /*
  * mdesc: der URL einer JSON-Datei mit einer Menuebeschreibung
@@ -77,7 +61,7 @@
   }).done(function( json ) {
     app_menu_bauen(json, richtung);
   });
-  
+
 }
 
 function app_menu_bauen(menuejs, richtung) {
@@ -91,7 +75,7 @@
   // Endposition des neuen Menues beim Wechsel herauf
   var linksEndeNeu = "0px";
   var rechtsEndeNeu = "300px";
-  
+
   if(richtung === 'herunter') {
     // Endposition des bestehenden Menues beim Wechsel herunter
     linksEndeAlt = "-300px";
@@ -103,15 +87,15 @@
     linksEndeNeu = "0px";
     rechtsEndeNeu = "300px";
   }
-  
+
   var menuDiv = $("<div/>");
   $(menuDiv).addClass('app-menu-content');
 
   $(menuDiv).css('position', "relative");
   $(menuDiv).css('left', linksAnfangNeu);
   $(menuDiv).css('right', rechtsAnfangNeu);
-  $(menuDiv).html(Mustache.render(_app_menu_template, menuejs));  
-  
+  $(menuDiv).html(Mustache.render(_app_menu_template, menuejs));
+
   $('.app-menu-content').delay(100).animate(
     {left: linksEndeAlt },
     100,
@@ -119,9 +103,9 @@
       $('.smenu').attr('onclick','').unbind('click');
       $('.bitem').attr('onclick','').unbind('click');
       $('.mitem').attr('onclick','').unbind('click');
-      $('.west').empty();
+      $(_app_menu_selector).empty();
 
-      $('.west').append(menuDiv);
+      $(_app_menu_selector).append(menuDiv);
       $('.smenu').on('click', app_menu_klick_herunter);
       $('.bitem').on('click', app_menu_klick_herauf);
       $('.mitem').on('click', app_menu_ausfuehren);
@@ -152,4 +136,4 @@
 
 function app_menu_test_2() {
   alert("Test 2");
-}
\ No newline at end of file
+}

--
Gitblit v1.9.3