PageSourceSearch

https://www.hurlinghamschool.co.uk/js/website/base.js?v=1.161.6.12

js hurlinghamschool.co.uk collected 2026-10-03 20:00:49 UTC 7,910 bytes, 210 lines download raw bytes

1$(document).ready(function () {
2    initializeSiteWidePopup();
3    initializeTableMobileStack();
4    initializeGridSystem();
5});
6
7
8function initializeSiteWidePopup() {
9    var popupsInitialized = {
10        siteWide: false
11    };
12
13    //Zone clean up
14    function cleanupZoneContainer(containerId) {
15        const container = document.getElementById(containerId);
16        if (!container) return;
17
18        //editing-related classes
19        container.classList.remove('feature-zone', 'page-is-in-edit-mode');
20
21        //clean up zones
22        const zoneMainDiv = container.querySelector('.zone-main-div');
23        const addFeatureDiv = container.querySelector('.fp-add-feature');
24        if (zoneMainDiv) zoneMainDiv.remove();
25        if (addFeatureDiv) addFeatureDiv.remove();
26
27        //clean any remaining
28        container.removeAttribute('ondrop');
29        container.removeAttribute('ondragover');
30        container.removeAttribute('zoneid');
31    }
32
33    //Mode cleanup
34    function cleanupEditMode(element) {
35        //clean up editable areas
36        if (element.classList.contains('cms-feature-datablock')) {
37            element.removeAttribute('contenteditable');
38            element.removeAttribute('spellcheck');
39            element.removeAttribute('role');
40            element.removeAttribute('aria-multiline');
41            element.removeAttribute('aria-label');
42            element.removeAttribute('title');
43            element.removeAttribute('aria-describedby');
44            element.classList.remove('cke_editable', 'cke_editable_inline', 'cke_contents_ltr', 'cke_show_borders');
45        }
46
47        //clean up any remaining edit mode classes and elements
48        element.querySelectorAll('.cms-feature-bar-wrapper, .modal, .cms-feature-block, .fp-add-feature').forEach(el => el.remove());
49        element.querySelectorAll('.feature-zone').forEach(zone => {
50            zone.classList.remove('page-is-in-edit-mode');
51            zone.removeAttribute('ondrop');
52            zone.removeAttribute('ondragover');
53        });
54
55        //clean up feature wrappers
56        element.querySelectorAll('.cms-feature-wrapper').forEach(feature => {
57            feature.classList.remove('drop-target');
58            feature.removeAttribute('featureid');
59            feature.removeAttribute('ondrop');
60            feature.removeAttribute('ondragover');
61        });
62    }
63
64    function initializePopup(popupUrl, popupClass, popupContainerId, popupType) {
65        $.get(popupUrl, function (data) {
66            var $sidebarContent = $(data);
67            var $popup = $sidebarContent.find(popupClass);
68
69            if ($popup.length === 0) {
70                console.log("No popup content found for", popupType);
71                return;
72            }
73
74            //clean up edit
75            cleanupEditMode($popup[0]);
76
77            //clean up target
78            const containerId = popupContainerId.replace('#', '');
79            cleanupZoneContainer(containerId);
80
81            // Create a fresh popup wrapper
82            var $popupWrapper = $('<div class="popup-wrapper"></div>');
83
84            // Append the close button only within the popup
85            if ($popup.find('.site-popup-close').length === 0) {
86                $popup.prepend('<div class="site-popup-close"></div>');
87            }
88            // Check if the popup has the class site-desktop-hide
89            if ($popup.hasClass('site-desktop-hide')) {
90                // Add the class hide-desktop to .popup-wrapper
91                $popupWrapper.addClass('hide-desktop');
92            }
93            // Check if the popup has the class site-mobile-hide
94            if ($popup.hasClass('site-mobile-hide')) {
95                // Add the class hide-mobile to .popup-wrapper
96                $popupWrapper.addClass('hide-mobile');
97            }
98
99            // Add the popup to the wrapper
100            $popupWrapper.append($popup);
101
102            var $container = $(popupContainerId);
103            if ($container.length > 0) {
104                // Clear any existing content
105                $container.empty();
106                // Add the new popup
107                $container.append($popupWrapper);
108                popupsInitialized[popupType] = true;
109            }
110        }).fail(function () {
111            // console.log("Failed to load popup content for", popupType);
112        });
113    }
114
115    function initializePopups() {
116        if (!popupsInitialized.siteWide) {
117            initializePopup("/site-wide-popup", '.site-wide-popup', '#site-wide-popup', 'siteWide');
118        }
119    }
120
121    // Attach the click event handler only once for all popups
122    $("body").on("click", ".site-popup-close", function () {
123        $(this).closest(".popup-wrapper").fadeOut(500, function () {
124            $(this).hide();
125        });
126    });
127
128    // Call the function once to initialize the popups
129    initializePopups();
130}
131
132function initializeTableMobileStack() {
133    $(".site-table-mobile-stack").each(function (index) {
134        var array = [];
135
136        $(this)
137            .find("th")
138            .each(function (index) {
139                array.push($(this).text());
140            });
141
142        $(this)
143            .find("tbody tr td")
144            .each(function (index, element) {
145                var $this = $(this);
146
147                $this.attr("data-label", array[$this.index()]);
148            });
149    });
150}
151
152function initializeGridSystem() {
153    $('.site-row-wrapper').each(function () {
154        var $nextGroup = $(this).nextUntil('.site-row-wrapper').add(this);
155        $nextGroup.add($nextGroup).wrapAll('<div class="site-row-container">');
156    });
157
158    $("body.cms-page-is-in-edit-mode #site-main-content-wrapper .site-row-container").each(function (i) {
159        var $this = $(this);
160        var $items = $this.find(".cms-feature-wrapper");
161        var i = 0;
162
163        $items.each(function (i) {
164            $("<div class='site-feature-detail'><div class='site-feature-count'>No: " + ++i + "</div></div>").insertBefore($(this).find(".cms-feature-datablock"));
165            return true;
166        });
167    });
168
169    setTimeout(function () {
170        $("body.cms-page-is-in-edit-mode #site-main-content-wrapper .cms-feature-wrapper").each(function (i) {
171            if ($(this).hasClass("site-right-block-wrapper")) {
172                $("<div class='site-feature-align'>Right block</div>").insertAfter($(this).find(".site-feature-count"));
173            } else {
174                $("<div class='site-feature-align'>Left block</div>").insertAfter($(this).find(".site-feature-count"));
175            }
176
177            if ($(this).hasClass("site-row-wrapper")) {
178                $("<div class='site-feature-row'>Row</div>").insertAfter($(this).find(".site-feature-align"));
179            }
180
181        });
182    }, 1000);
183
184    if ($("body:not(.cms-page-is-in-edit-mode) .site-sidebar-menu").length) {
185        $(".site-sidebar-menu").appendTo(".custom-sidebar-wrapper");
186    }
187
188    setTimeout(function () {
189        if ($("body.cms-page-is-in-edit-mode .site-sidebar-menu").length) {
190            $(".site-sidebar-menu").appendTo(".custom-sidebar-wrapper");//moved to inside the wrapper to prevent it being edited
191        }
192    }, 1000);
193
194    var classNames = [];
195    $('div[class*="site-row-block-"]').each(function (i, el) {
196        var allClasses = Array.from(el.classList);
197
198        var nonWrapperClasses = allClasses.filter(function (c) {
199            return c.startsWith('site-row-block-') && !c.endsWith('-wrapper');
200        });
201
202        nonWrapperClasses.forEach(function (className) {
203            $(el).removeClass(className);
204        });
205
206        if (nonWrapperClasses.length > 0) {
207            $(el).parents(".site-row-container").addClass(nonWrapperClasses.join(' '));
208        }
209    });
210}

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.