PageSourceSearch

https://cbtmss.edu.hk/template/app/js/jquery-accordion-menu.js

js cbtmss.edu.hk collected 2026-10-01 03:25:11 UTC 5,648 bytes, 137 lines download raw bytes

1;
2(function($, window, document, undefined) {
3    var pluginName = "jqueryAccordionMenu";
4    var defaults = {
5        speed: 300,
6        showDelay: 100,
7        hideDelay: 200,
8        singleOpen: false,
9        clickEffect: true
10    };
11
12    var nodes = [];
13
14    function Plugin(element, options) {
15        this.element = element;
16        this.settings = $.extend({},
17            defaults, options);
18        this._defaults = defaults;
19        this._name = pluginName;
20        this.init()
21    };
22    $.extend(Plugin.prototype, {
23        init: function() {
24            this.openSubmenu();
25            this.submenuIndicators();
26            if (defaults.clickEffect) {
27                this.addClickEffect()
28            }
29
30            this.expanded();
31        },
32        expandMenu: function(submenu) {
33            if (submenu.length > 0) {
34                submenu.delay(defaults.showDelay).slideDown(defaults.speed);
35                submenu.siblings("a").addClass("submenu-indicator-minus");
36                // if (defaults.singleOpen) {
37                //     m.siblings().children(".submenu").slideUp(defaults.speed);
38                //     m.siblings().children(".submenu").siblings("a").removeClass("submenu-indicator-minus")
39                // }
40            }
41        },
42        traceParent: function(parentUl) {
43            var submenu = parentUl.parent().parent('ul');
44            if (submenu.length > 0) {
45                let indicator = submenu.parent().children('a').children('.submenu-indicator');
46                indicator.toggleClass("rotate45");
47                nodes.push(submenu);
48                this.traceParent(submenu);
49            }
50        },
51        expanded: function() {
52            var self = this;
53            var targetId = $('#target_menu').data('id');
54            var targetEle = $("#" + targetId);
55            targetEle.addClass("active");
56            console.log("run expanded targetID=%o , ele=%o", targetId, targetEle);
57            var parentUl = targetEle.parent().parent("ul");
58
59            let indicator = parentUl.parent().children('a').children('.submenu-indicator');
60            indicator.toggleClass("rotate45");
61
62            if (parentUl.length > 0) {
63                nodes.push(parentUl);
64                this.traceParent(parentUl);
65                nodes.slice().reverse().forEach(e => {
66                    self.expandMenu(e);
67                });
68            }
69        },
70
71        openSubmenu: function() {
72            $(this.element).children("ul").find("li").bind("click touchstart",
73                function(e) {
74                    e.stopPropagation();
75                    e.preventDefault();
76                    if ($(this).children(".submenu").length > 0) {
77                        if ($(this).children(".submenu").css("display") == "none") {
78                            $(this).children(".submenu").delay(defaults.showDelay).slideDown(defaults.speed);
79                            $(this).children(".submenu").siblings("a").addClass("submenu-indicator-minus");
80                            if (defaults.singleOpen) {
81                                $(this).siblings().children(".submenu").slideUp(defaults.speed);
82                                $(this).siblings().children(".submenu").siblings("a").removeClass("submenu-indicator-minus")
83                            }
84                            return false
85                        } else {
86                            $(this).children(".submenu").delay(defaults.hideDelay).slideUp(defaults.speed)
87                        }
88                        if ($(this).children(".submenu").hasClass("submenu-indicator-minus")) {
89                            $(this).children(".submenu").siblings("a").removeClass("submenu-indicator-minus")
90                        }
91                    }
92                    window.location.href = $(this).children("a").attr("href")
93                })
94        },
95        submenuIndicators: function() {
96            if ($(this.element).find(".submenu").length > 0) {
97                $(this.element).find(".submenu").siblings("a").append("<span class='submenu-indicator'>+</span>")
98            }
99        },
100        addClickEffect: function() {
101            var ink, d, x, y;
102            $(this.element).find("a").bind("click touchstart",
103                function(e) {
104                    let indicator = $(this).children('.submenu-indicator');
105                    indicator.toggleClass("rotate45");
106                    $(".ink").remove();
107                    if ($(this).children(".ink").length === 0) {
108                        $(this).prepend("<span class='ink'></span>")
109                    }
110                    ink = $(this).find(".ink");
111                    ink.removeClass("animate-ink");
112                    if (!ink.height() && !ink.width()) {
113                        d = Math.max($(this).outerWidth(), $(this).outerHeight());
114                        ink.css({
115                            height: d,
116                            width: d
117                        })
118                    }
119                    x = e.pageX - $(this).offset().left - ink.width() / 2;
120                    y = e.pageY - $(this).offset().top - ink.height() / 2;
121                    ink.css({
122                        top: y + 'px',
123                        left: x + 'px'
124                    }).addClass("animate-ink")
125
126                })
127        }
128    });
129    $.fn[pluginName] = function(options) {
130        this.each(function() {
131            if (!$.data(this, "plugin_" + pluginName)) {
132                $.data(this, "plugin_" + pluginName, new Plugin(this, options))
133            }
134        });
135        return this
136    }
137})(jQuery, window, 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.