Skip to content

Commit

Permalink
Merge pull request #5031 from braze-inc/developer_nav_expand_update
Browse files Browse the repository at this point in the history
Adjust left nav expand level
  • Loading branch information
KellieHawks authored Mar 15, 2023
2 parents 6d14933 + 7dd93e3 commit 4ba42e5
Showing 1 changed file with 34 additions and 12 deletions.
46 changes: 34 additions & 12 deletions assets/js/developer_nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ $(document).ready(function () {
if (site_language != 'en') {
url_selected = (location.pathname.split("/")[5] || "").replace(/_/g, "");
}
var dev_selected = url_selected
var dev_selected = (url_selected
? `parent_nav_top_platformintegrationguides_${url_selected}`
: Cookies.get("__dev_selected") || "";
: Cookies.get("__dev_selected") || "").toLowerCase();
var platform_objects = $("#nav_top_platformintegrationguides > div.nav-item");
var platform_list = [];
var hide_list = [];
var show_list = [];
var select_html =
'<div id="dev_select_div"><select id="dev_select"><option value="">Select Platform</option>';
platform_objects.each(function (k) {
Expand All @@ -30,21 +32,40 @@ $(document).ready(function () {
select_html += `>${$this.text().trim()}</option>`;
if (exclusion_list.indexOf(dev_selected) === -1) {
if (dev_selected !== obj_id) {
hide(obj_id);
} else {
show(obj_id);
hide_list.push(obj_id);
}
else {
show_list.push(obj_id);
}
}
}
});

// if no platform is selected, or in the discolure menu, show all platforms
if ( !dev_selected && !url_selected || (location.pathname.indexOf('disclosures') > -1) || (location.pathname.indexOf('platform_wide') > -1) ) {
platform_objects.each(function () {
var id = $(this).attr('id');
show(id);
});
// if no platform is selected, or in the discolure menu, show all platforms
if ( !dev_selected && !url_selected || (location.pathname.indexOf('disclosures') > -1) || (location.pathname.indexOf('platform_wide') > -1) ) {
platform_objects.each(function (nav_index,nav_item) {
// var id = $(this).attr('id');
var cur_nav = $(nav_item);
if (cur_nav.length) {
var id = cur_nav.first().attr('id');
var navigation_item = $("#" + id + " a");
if (navigation_item.attr("aria-expanded") === "true"){
$('#' + navigation_item.attr('id')).trigger("click");
}
}
});
}
else {
for (let hl = 0; hl < hide_list.length; hl++) {
hide(hide_list[hl]);
}
});
for (let sl = 0; sl < show_list.length; sl++) {
show(show_list[sl]);
}
}



$("#parent_nav_top").css("width", "100%");
select_html += "</select></div>";
$("#parent_nav_home div .nav_block").append(select_html);
Expand Down Expand Up @@ -94,4 +115,5 @@ $(document).ready(function () {
navigation_id.trigger("click");
}
}

});

0 comments on commit 4ba42e5

Please sign in to comment.