PageSourceSearch

https://www.boston.gov/themes/custom/bos_theme/js/bos_theme.context_menu_link.js?tm6yxc

js boston.gov collected 2026-10-01 07:33:54 UTC 2,843 bytes, 75 lines download raw bytes

1/**
2 * @file
3 * Extends context_edit menu functionality.
4 *
5 * If there is only one menu item causes a click on the context edit button to trigger first menu item.
6 */
7
8(function ($, window, document) {
9  'use strict';
10  $(document).ready(function () {
11    // Var contextButtons are a list of context buttons on the page.
12    var rebuildPage = function () {
13      var contextButtons = $(".contextual button.trigger");
14      // Create a default type for dropdowns.
15      var type = "Element";
16      var links;
17      var entityType;
18
19      // Adds a tooltip to the button, changes the click funtion of the contextual button when
20      // only one link and adds the node type to the links list.
21      $(".main article.node").first().find(".contextual").first().addClass("parent-node");
22      contextButtons.each(function (key, button) {
23        links = $(button).parent().find("[class^=entitynode]");
24        if (links.length === 0) {
25          links = $(button).parent().find("[class^=paragraphs]");
26          entityType = "paragraph";
27        }
28        else {
29          entityType = "node";
30          if ($(button).parentsUntil("article").hasClass("parent-node")) {
31            entityType = "this page";
32          }
33        }
34        type = $(button).parents(".contextual-region").attr("bos_context_type")
35        if (typeof type === "undefined") {
36          type = "Element";
37        }
38        type = type + " (" + entityType + ")";
39
40        if (links.length !== 0) {
41          if (links.length === 1) {
42            links.parents("ul").hide();
43            links.parents(".contextual").attr({"title": "Click to Edit " + type + "."});
44            links.parent().parent().click(function () {
45              window.location.href = links.first().find("a").prop("href");
46            });
47          }
48          else if (links.length > 1) {
49            links.each(function (key, listItem) {
50              $(listItem).find("a").text($(listItem).find("a").text() + " " + type);
51            });
52            links.parents(".contextual").attr({"title": "Click for editor options (" + entityType + ")."});
53          }
54        }
55      });
56
57      // Adds a class to the main node article element on the page.
58      $(".main article.node").first().find(".contextual").first().addClass("parent-node");
59      $('.parent-node.contextual button.trigger').addClass("large");
60      $('.parent-node .contextual-links li').each(function (lkey, listItem) {
61        var anchorText = $(listItem).find("a").text();
62        $(listItem).find("a").text(anchorText);
63      });
64      $("#main-menu").addClass("contextual-region").append($(".parent-node"));
65    };
66
67    var interval = setInterval(function () {
68      if ($(".contextual button.trigger").length) {
69        clearInterval(interval);
70        rebuildPage();
71      }
72    }, 250);
73
74  });
75})(jQuery, this, this.document);

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.