From fb100c08f428b92b7844010cedafc5061fb13d37 Mon Sep 17 00:00:00 2001 From: ulrich <not disclosed> Date: Sun, 07 Jan 2018 16:05:40 +0000 Subject: [PATCH] Doku angepasst --- app-menu.js | 88 ++++++++++++++++++------------------------- 1 files changed, 37 insertions(+), 51 deletions(-) diff --git a/app-menu.js b/app-menu.js index 14a974e..1a0723f 100644 --- a/app-menu.js +++ b/app-menu.js @@ -1,61 +1,45 @@ - /* - * 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) { - document.querySelector( "#nav-toggle" ).addEventListener("click", function() { - /* - this.classList.toggle( "active" ); - this.blur(); +function app_menu_init(url_prefix, mdesc, mtpl, mselector, mbreite) { + _app_menu_selector = mselector; + _app_menu_mbreite = mbreite; + /*document.querySelector( "#nav-toggle" ).addEventListener("click", function() { 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); }); } function app_menu_do_toggle(elem) { - document.querySelector( "#nav-toggle" ).classList.toggle( "active" ); - document.querySelector( "#nav-toggle" ).blur(); + /*document.querySelector( "#nav-toggle" ).classList.toggle( "active" ); + document.querySelector( "#nav-toggle" ).blur();*/ app_menu_toggle(); } 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"; + /*document.querySelector( "#nav-toggle" ).classList.toggle( "active" ); + document.querySelector( "#nav-toggle" ).blur();*/ + 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", _app_menu_mbreite); // z.B. "16em" } } @@ -65,6 +49,8 @@ var _app_menu_url_prefix = ""; var _app_menu_template; +var _app_menu_selector; +var _app_menu_mbreite; /* * mdesc: der URL einer JSON-Datei mit einer Menuebeschreibung @@ -77,7 +63,7 @@ }).done(function( json ) { app_menu_bauen(json, richtung); }); - + } function app_menu_bauen(menuejs, richtung) { @@ -91,7 +77,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 +89,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 +105,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 +138,4 @@ function app_menu_test_2() { alert("Test 2"); -} \ No newline at end of file +} -- Gitblit v1.9.3