PageSourceSearch

https://www.docs.o3de.org/js/app.863b66759929e723cc46032d2ee75a67d11d56d8d5e9717c213741d2af3b2b12.js

js o3de.org collected 2026-10-02 03:01:05 UTC 7,748 bytes, 274 lines download raw bytes

1const navbarBurger = () => {
2  const burger = $(".navbar-burger"),
3    menu = $(".navbar-menu");
4
5  burger.click(() => {
6
7
8    [burger, menu].forEach((el) => el.toggleClass('is-active'));
9  });
10}
11
12$(() => {
13  navbarBurger();
14});
15
16
17// active nav bar link
18
19$(() => {
20  const url = window.location.pathname;
21  $("ul.mr-auto.navbar-nav li a").each(function(){
22    if( $(this).attr("href")+"/" == url ) {
23      $("ul.navbar-nav li a").removeClass("active");
24      $("ul.navbar-nav li").removeClass("active");
25      $(this).addClass("active");
26      $(this).parents().addClass("active");
27    }
28  })
29});
30
31// Lightbox behavior
32
33$(function() {
34  $("a.lightbox-trigger").click(function(e) {
35    var lightboxId = $(this).data("lightbox");
36    if(lightboxId)
37    {
38      var lightboxObject = $("#" + lightboxId);
39      if(lightboxObject.hasClass("lightbox-content"))
40      {
41        e.preventDefault();
42        lightboxObject.fadeIn(500);
43      }
44    }
45  });
46  
47  $(".lightbox-content").click(function(e) {
48    $(this).fadeOut(500);
49  });
50  
51  $(".lightbox-content iframe").click(function(e) {
52    e.preventDefault();
53  });
54});
55
56// nav bar search
57
58$(() => {
59  $("#search").submit(function(event){
60    if($(".search-input-view").is(":hidden"))
61    {
62      event.preventDefault();
63      $(".search-input-view").show();
64    }
65  });
66});
67
68// --- Downloads page
69// Handle click to switch between download pages.
70$(function() {
71  $(".os-selector-button").click(function(event){
72    if($(this).hasClass("active"))
73    {
74      return;
75    }
76
77    // Switch enabled button
78    $(".os-selector-button.active").removeClass("active");
79    $(this).addClass("active");
80
81    // Switch content
82    $(".os-content.active").removeClass("active");
83    $("#content-" + $(this).data("os")).addClass("active");
84  });
85});
86
87// Detect anchor in URL on load and select appropriate tab.
88// This uses the click to switch function, so it must be defined after it.
89$(function() {
90  // Retrieve the hash from the url.
91  var hash = $(location).attr('hash').replace( /#/, "" );
92
93  // Try to click the appropriate button.
94  // If it doesn't exist, this will just do nothing.
95  $("#os-" + hash).trigger("click");
96});
97
98// Docs navigation
99
100$(function() {
101  const url = window.location.pathname;
102  $("#docs-nav a").each(function(){
103    if($(this).attr("href") == url) {
104      $(this).addClass("currentPage");
105
106      // Apply attributes to the parent pages/sections for styling.
107      $(this).parentsUntil("#docs-nav", "ul").each(function(){
108        $(this).addClass("currentAncestor");
109        $(this).siblings('a').each(function()
110        {
111          $(this).addClass("currentAncestor").addClass("open");          
112        });                  
113        $(this).parent('li').addClass("currentAncestorCategory");    
114      })
115      $(this).parent('li').addClass("currentAncestorCategory");    
116      
117    }
118  })
119});
120
121// Applies to the current page in the docs-nav.
122$(function() {
123  $("#docs-nav a.currentPage").each(function(e){
124
125    // Show children pages/sections in the docs-nav, if any.
126    if ($(this).hasClass('has-children')){
127      console.log("yes has children");
128
129      $(this).addClass("open");
130      showChildren(this);
131    }
132    $(this).siblings('.has-children-icon').each(function()
133    {
134      $(this).addClass("open");
135      $(this).addClass("currentPage");
136    });
137  })
138});
139
140// For sections in the docs-nav, this applies to the drop-down icon's click event.
141$(function() {
142  $("#docs-nav a.has-children-icon").click(function(e){
143    console.log("has-children-icon triggered");
144    $(this).toggleClass("open");
145    showChildren(this);
146  })
147});
148
149// A helper function to show the list of children in the docs-nav.
150function showChildren(e) {
151  $(e).siblings('ul').each(function()
152  {
153    $(this).slideToggle(300);
154  });
155}
156
157// A helper function to customize the dropdown for the version switcher.
158function updateSelectElement(currentOrigin) {
159    var originMatched = false;
160    
161    // Make the following modifications to the dropdown options:
162    // - Add "(latest)" to the production URL option.
163    // - Set the selected option and enhance its style.
164    $("#version-switcher").children("option").attr("value", function(i, currentValue) {
165        if (currentValue.includes("docs.o3de.org")) {
166            $(this).text($(this).text() + " (latest)");
167        }
168
169        if (currentValue == currentOrigin) {
170            originMatched = true;
171            $(this).attr("selected", "selected");
172            $(this).attr("class", "selectedVersion");
173        }
174    });
175
176    // Add the current host if it's not one of the standard published branches.
177    if (!originMatched) {
178        var newOption = '<option value="' + currentOrigin + '" selected="selected" class="selectedVersion">';
179        
180        if (currentOrigin.includes("localhost")) {
181            newOption += 'local</option>';
182        }
183        else if (currentOrigin.includes("deploy-preview")) {
184            newOption += 'preview</option>';
185        }
186        else {
187            newOption += new URL(currentOrigin).hostname + '</option>';
188        }
189
190        $("#version-switcher").append(newOption);
191    }
192}
193
194function updateSidebarAttributes() {
195    // If an info or warning banner is present, adjust the top and height of the left nav so that it doesn't scroll when scrolling the contents of the page.
196    if ($("#preview-info").length > 0 || $("#version-warning").length > 0) {
197        var bannerHeight = $("#docs-banners").height();
198        $(".docs-sidebar").css("top", bannerHeight);
199        $(".docs-sidebar").css("height", window.innerHeight - bannerHeight);
200    }
201}
202
203// For docs navbar, switch to a different published docset.
204$(function() {
205    // Update the dropdown for the version switcher, based on the origin part of the URL.
206    updateSelectElement(window.location.origin);
207
208    // Set up the onChange event handler for the version switcher to load the current page from the selected location.
209    $("#version-switcher").on("change", function(event) {
210        // Get new host from selected version.
211        const newHost = event.target.value;
212        
213        // Build a new URL using new host and old path.
214        const newURL = new URL(newHost + window.location.pathname);
215        var newHref = newURL.href;
216
217        // Load the new location.
218        if (newHref != window.location.href) {
219            window.location.href = newHref;
220        }
221    });
222
223    updateSidebarAttributes();
224});
225
226$(window).on("resize", function() {
227    updateSidebarAttributes();
228});
229
230$(function() {
231  $("body").append("<div id=\"docs-mobile-menu-overlay\" class=\"docs-mobile-menu-overlay\"></div>");
232
233  $("#docs-mobile-menu-overlay").click(function(){
234    $("body").removeClass("docs-mobile-menu-open");
235    $(this).removeClass("show");
236    setTimeout(function(){ $(this).hide(); }, 300);
237  });
238
239  $("#mobile-docs-toggler").click(function(){
240    var overlay = $("#docs-mobile-menu-overlay");
241    if(overlay.hasClass("show"))
242    {
243      $("body").removeClass("docs-mobile-menu-open");
244      overlay.removeClass("show");
245      setTimeout(function(){ overlay.hide(); }, 300);
246    }
247    else
248    {
249      $("body").addClass("docs-mobile-menu-open");
250      overlay.show();
251      setTimeout(function(){ overlay.addClass("show"); }, 10);
252    }
253  });
254});
255
256// Detect anchor links, add correct offset and scroll behavior.
257$(function() {
258  var scrollOffset = $(".main-navbar").height() + 32;
259
260  $("a[href^=\\#]").click(function(e) {
261    // Don't apply behavior to tabs
262    if($(this).data("toggle") == "tab")
263    {
264      return;
265    }
266
267    var dest = $(this).attr('href');
268    if(dest != "" && dest.length > 1 && $(dest).length > 0)
269    {
270      $('html,body').animate({ scrollTop: $(dest).offset().top - scrollOffset }, 'slow');
271    }
272  });
273});
274

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.