From: Sven Schöling Date: Tue, 13 Feb 2018 13:03:45 +0000 (+0100) Subject: HTML Menü: Javascript ausgelagert in eigene Datei X-Git-Tag: release-3.5.4~464 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=15eda163ebc5f28f19161d567afdf03e37cf516a;p=kivitendo-erp.git HTML Menü: Javascript ausgelagert in eigene Datei --- diff --git a/SL/Layout/MenuLeft.pm b/SL/Layout/MenuLeft.pm index 25119fed2..d365210c9 100644 --- a/SL/Layout/MenuLeft.pm +++ b/SL/Layout/MenuLeft.pm @@ -3,25 +3,22 @@ package SL::Layout::MenuLeft; use strict; use parent qw(SL::Layout::Base); -use URI; - use List::MoreUtils qw(apply); +use SL::JSON qw(to_json); +use URI; sub stylesheets { qw(icons16.css icons24.css menu.css) } sub javascripts_inline { - my $self = shift; - my $sections = [ section_menu($self->menu) ]; - $self->presenter->render('menu/menu', - sections => $sections, - ) + "\$(function(){kivi.LeftMenu.init(@{[ to_json([ section_menu($_[0]->menu) ]) ]})});" } sub javascripts { qw( js/jquery.cookie.js + js/kivi.LeftMenu.js ); } diff --git a/js/kivi.LeftMenu.js b/js/kivi.LeftMenu.js new file mode 100644 index 000000000..537974e72 --- /dev/null +++ b/js/kivi.LeftMenu.js @@ -0,0 +1,22 @@ +namespace('kivi.LeftMenu', function(ns) { + 'use strict'; + ns.init = function(sections) { + sections.forEach(function(b,i){ + var a=$('').append($('').append($('
').addClass(b[3])),$('').append(b[0])); + if(b[5])a.attr('href', b[5]); + if(b[6])a.attr('target', b[6]); + $('#html-menu').append($('
').addClass(b[4]).addClass(b[1]).attr('id','mi'+b[2]).append(a)) + }); + $('#html-menu div.i, #html-menu div.sm').not('[id^='+$.cookie('html-menu-selection')+'_]').hide(); + $('#html-menu div.m#'+$.cookie('html-menu-selection')).addClass('menu-open'); + $('#html-menu div.m').each(function(){ + $(this).click(function(){ + $.cookie('html-menu-selection',$(this).attr('id')); + $('#html-menu div.mi').not('div.m').not('[id^='+$(this).attr('id')+'_]').hide(); + $('#html-menu div.mi[id^='+$(this).attr('id')+'_]').toggle(); + $('#html-menu div.m').not('[id^='+$(this).attr('id')+']').removeClass('menu-open'); + $(this).toggleClass('menu-open'); + }); + }); + }; +}); diff --git a/templates/webpages/menu/menu.html b/templates/webpages/menu/menu.html deleted file mode 100644 index b37574271..000000000 --- a/templates/webpages/menu/menu.html +++ /dev/null @@ -1,20 +0,0 @@ -[%- USE JSON %] -$(function(){$([% JSON.json(sections) %]).each(function(i,b){ - var a=$('').append($('').append($('
').addClass(b[3])),$('').append(b[0])); - if(b[5])a.attr('href', b[5]); - if(b[6])a.attr('target', b[6]); - $('#html-menu').append($('
').addClass(b[4]).addClass(b[1]).attr('id','mi'+b[2]).append(a)) -}); -$('#html-menu div.i, #html-menu div.sm').not('[id^='+$.cookie('html-menu-selection')+'_]').hide(); -$('#html-menu div.m#'+$.cookie('html-menu-selection')).addClass('menu-open'); -$('#html-menu div.m').each(function(){ - $(this) - .click(function(){ - $.cookie('html-menu-selection',$(this).attr('id')); - $('#html-menu div.mi').not('div.m').not('[id^='+$(this).attr('id')+'_]').hide(); - $('#html-menu div.mi[id^='+$(this).attr('id')+'_]').toggle(); - $('#html-menu div.m').not('[id^='+$(this).attr('id')+']').removeClass('menu-open'); - $(this).toggleClass('menu-open'); - }) -}) -})