js: reduce number of jquery calls (#47550)
This commit is contained in:
parent
5b5c2ae7e7
commit
9b54798315
|
@ -23,9 +23,10 @@ $(function() {
|
|||
$('#sidepage-menu').remove();
|
||||
var menu_links = $('<ul id="sidepage-menu">');
|
||||
if (PUBLIK_PORTAL_AGENT_URL && PUBLIK_PORTAL_AGENT_TITLE) {
|
||||
var li = $('<li id="portal-agent-home"><a>' + PUBLIK_PORTAL_AGENT_TITLE + '</a></li>').appendTo(menu_links);
|
||||
$(li).find('a').attr('href', PUBLIK_PORTAL_AGENT_URL).addClass('icon-home');
|
||||
$(li).find('a').attr('href', PUBLIK_PORTAL_AGENT_URL).prop('title', PUBLIK_PORTAL_AGENT_TITLE);
|
||||
var $li = $('<li id="portal-agent-home"><a>' + PUBLIK_PORTAL_AGENT_TITLE + '</a></li>').appendTo(menu_links);
|
||||
var $li_a = $li.find('a');
|
||||
$li_a.attr('href', PUBLIK_PORTAL_AGENT_URL).addClass('icon-home');
|
||||
$li_a.attr('href', PUBLIK_PORTAL_AGENT_URL).prop('title', PUBLIK_PORTAL_AGENT_TITLE);
|
||||
}
|
||||
var more_entries = Array();
|
||||
var service_order = Array('authentic', 'welco', 'wcs', 'bijoe', 'chrono', 'corbo', 'combo', 'passerelle', 'hobo');
|
||||
|
@ -44,25 +45,26 @@ $(function() {
|
|||
return;
|
||||
}
|
||||
$(service.data).each(function(idx, element) {
|
||||
var li = $('<li><a href="#">' + element.label + '</a></li>').appendTo(menu_links);
|
||||
$(li).find('a').attr('href', element.url);
|
||||
$(li).find('a').attr('title', element.label);
|
||||
var $li = $('<li><a href="#">' + element.label + '</a></li>').appendTo(menu_links);
|
||||
var $li_a = $li.find('a');
|
||||
$li_a.attr('href', element.url);
|
||||
$li_a.attr('title', element.label);
|
||||
if (element.icon !== undefined) {
|
||||
$(li).find('a').addClass('icon-' + element.icon);
|
||||
$li_a.addClass('icon-' + element.icon);
|
||||
} else if (element.slug !== undefined) {
|
||||
$(li).find('a').addClass('icon-' + element.slug);
|
||||
$li_a.addClass('icon-' + element.slug);
|
||||
}
|
||||
if (element.sub === true) {
|
||||
$(li).addClass('sub');
|
||||
$li.addClass('sub');
|
||||
}
|
||||
if (window.location.href.indexOf(element.url) == 0) {
|
||||
$(li).addClass('active');
|
||||
$li.addClass('active');
|
||||
}
|
||||
});
|
||||
});
|
||||
$(more_entries).each(function(index, entry) {
|
||||
var li = $('<li><a href="#">' + entry.title + '</a></li>').appendTo(menu_links);
|
||||
$(li).find('a').attr('href', entry.url);
|
||||
var $li = $('<li><a href="#">' + entry.title + '</a></li>').appendTo(menu_links);
|
||||
$li.find('a').attr('href', entry.url);
|
||||
});
|
||||
menu_links.appendTo('#sidepage');
|
||||
$(document).trigger('publik:menu-loaded');
|
||||
|
@ -77,18 +79,19 @@ $(function() {
|
|||
$sidepage_menu = $('<ul id="sidepage-menu">');
|
||||
}
|
||||
$(PUBLIK_MENU_ITEMS).each(function(index, element) {
|
||||
var li = $('<li><a href="#">' + element.label + '</a></li>').appendTo($sidepage_menu);
|
||||
$(li).find('a').attr('href', element.url);
|
||||
$(li).find('a').attr('title', element.label);
|
||||
var $li = $('<li><a href="#">' + element.label + '</a></li>').appendTo($sidepage_menu);
|
||||
var $li_a = $li.find('a');
|
||||
$li_a.attr('href', element.url);
|
||||
$li_a.attr('title', element.label);
|
||||
if (element.icon) {
|
||||
$(li).find('a').css('background-image', 'url(' + element.icon + ')');
|
||||
$li_a.css('background-image', 'url(' + element.icon + ')');
|
||||
}
|
||||
$(li).find('a').addClass('icon-' + element.slug);
|
||||
$li_a.addClass('icon-' + element.slug);
|
||||
if (element.sub === true) {
|
||||
$(li).addClass('sub');
|
||||
$li.addClass('sub');
|
||||
}
|
||||
if (window.location.href.indexOf(element.url) == 0) {
|
||||
$(li).addClass('active');
|
||||
$li.addClass('active');
|
||||
}
|
||||
});
|
||||
if (!has_menu) {
|
||||
|
|
Loading…
Reference in New Issue