PageSourceSearch

https://innobranch.com/resources/common/js/admin_menu.js

js innobranch.com collected 2026-10-08 08:26:19 UTC 3,014 bytes, 125 lines download raw bytes

1(function ($) {
2
3  let gUser;
4  let leftMenu;
5
6  $(document).ready(function () {
7    $.member((user) => {
8      gUser = user;
9      //$(".left_menu menuBox").hide();
10      menuManager.prepareMenu();
11    });
12  });
13
14
15  var menuManager = {
16
17    prepareMenu: function () {
18      this.leftMenu = $(".left_menu");
19
20      this.disableAllSubMenus();
21      this.readUserAuthority((list) => {
22        this.authorityList = list;
23
24        this.enableSubMenusByUserAuthority();
25
26        this.adjustMainMenus();
27
28        if (gUser.grade <= 1) {
29          this.makePartnerMenu();
30        }
31
32        this.initLeftMenu();
33      });
34
35    },
36
37    disableAllSubMenus: function () {
38      this.leftMenu.find("[data-menu-id]").each((index, item) => {
39        $(item).data("link", $(item).attr("href"));
40        $(item).removeAttr("href");
41        $(item).addClass("menuDisable");
42      });
43    },
44
45    readUserAuthority: function (callback) {
46      if (gUser && gUser.userIdx) {
47        $.rest("admin/api/administrator-authority", {idx: gUser.userIdx}, (list) => {
48          callback(list);
49        });
50      }
51    },
52
53    enableSubMenusByUserAuthority: function () {
54    for (let i in this.authorityList) {
55        let aTag = $("[data-menu-id=" + this.authorityList[i] + "]");
56        aTag.attr("href", aTag.data("link"));
57        aTag.removeClass("menuDisable");
58      }
59    },
60
61    adjustMainMenus: function () {
62      this.mainMenu = $(".gnb_menu");
63
64      this.leftMenu.find(".menuBox").each((index, item) => {
65        let menu = this.mainMenu.find("a:nth-child(" + (index + 1) + ")");
66
67        this.initMainMenu(menu, $(item));
68      });
69    },
70
71    initMainMenu: function (mainMenu, subMenus) {
72      let subMenu = subMenus.find("a[data-menu-id]");
73
74      let length = subMenu.length;
75      let disabled = 0;
76      let first = true;
77      subMenu.each((index, item) => {
78        if ($(item).hasClass("menuDisable")) {
79          disabled++;
80        } else {
81          if (first) {
82            mainMenu.attr("href", $(item).attr("href"));
83          }
84
85          first = false;
86        }
87      });
88
89      if (length <= disabled) {
90        mainMenu.addClass("menuDisable");
91        mainMenu.removeAttr("href");
92      }
93    },
94
95    makePartnerMenu: function () {
96      this.leftMenu.find(".menuBox:not(.menuPartner)").hide();
97      this.mainMenu.find("a:not(.menuPartner)").hide();
98    },
99
100
101    initLeftMenu: function () {
102      const active = $('#wrap #container').data('active');
103
104      if (active && active[0]) {
105        $('.menuBox').eq(active[0] - 1).show().siblings('.menuBox').remove();
106        $('.menuBox')
107          .find('.gnb > ul > li').eq(active[1] - 1).addClass('active')
108          .find('div > ul > li').eq(active[2] - 1).addClass('active');
109      }
110
111      $(".left_menu menuBox").show();
112    }
113
114  };
115
116
117  /*$.member((user) => {
118    gUser = user;
119
120    console.log(gUser);
121
122  })*/
123
124})(jQuery);
125

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.