<commit_before>/**
 * @author <NAME> from Ubrainians for imCode
 * 04.05.18
 */
Imcms.define(
    "imcms-top-panel-visibility-initiator",
    ["imcms-events", "imcms-admin-panel-settings-builder", "jquery"],
    function (events, panelSettings, $) {

        var panelSensitivePixels = 15;

        var isPanelAppearanceEnabled = true;

        events.on("enable admin panel", function () {
            isPanelAppearanceEnabled = true;
        });
        events.on("disable admin panel", function () {
            isPanelAppearanceEnabled = false;
        });

        function onPanelShown() {
            var bodyCss = ($(window).scrollTop() === 0)
                ? {"top": $("#imcms-admin").height() || $("#imcms-admin-panel").height()}
                : {"padding-top": "0"};

            $("body").css(bodyCss);
        }

        function hidePanel($panel) {
            setAdminPanelTop($panel, "-" + $panel.css('height'));
        }

        function showPanel($panel) {
            setAdminPanelTop($panel, 0);
            onPanelShown();
        }

        function setAdminPanelTop($panel, px) {
            $panel.css({"top": px});
        }

        function setEventListeners() {
            listenersNotSet = false;
            var $body = $("body");

            $(document).mousemove(function (event) {

                var isPanelDisabledOrMouseNotInSensitiveArea = !isPanelAppearanceEnabled
                    || (event.clientY < 0)
                    || (event.clientY > panelSensitivePixels);

                if (isPanelDisabledOrMouseNotInSensitiveArea) return;

                panels$.filter(function ($panel) {
                        return !$panel.hasClass('imcms-special-hidden');
                    })
                    .forEach(showPanel);
            });

            $(document).click(function (event) {

                if (!isPanelAppearanceEnabled || $(event.target).closest(".imcms-admin").length) return;

                panelSettings.hideSettings();
                $body.css({"top": 0});
                panels$.forEach(hidePanel);
            });
        }

        var panels$ = [];
        var listenersNotSet = true;
<commit_msg>IMCMS-290 - Add a "pin" icon to imCMS's panel: - Closing settings on click on surrounding elements.<commit_after>/**
 * @author <NAME> from Ubrainians for imCode
 * 04.05.18
 */
Imcms.define(
    "imcms-top-panel-visibility-initiator",
    ["imcms-events", "imcms-admin-panel-settings-builder", "jquery"],
    function (events, panelSettings, $) {

        var panelSensitivePixels = 15;

        var isPanelAppearanceEnabled = true;

        events.on("enable admin panel", function () {
            isPanelAppearanceEnabled = true;
        });
        events.on("disable admin panel", function () {
            isPanelAppearanceEnabled = false;
        });

        function onPanelShown() {
            var bodyCss = ($(window).scrollTop() === 0)
                ? {"top": $("#imcms-admin").height() || $("#imcms-admin-panel").height()}
                : {"padding-top": "0"};

            $("body").css(bodyCss);
        }

        function hidePanel($panel) {
            setAdminPanelTop($panel, "-" + $panel.css('height'));
        }

        function showPanel($panel) {
            setAdminPanelTop($panel, 0);
            onPanelShown();
        }

        function setAdminPanelTop($panel, px) {
            $panel.css({"top": px});
        }

        function setEventListeners() {
            listenersNotSet = false;
            var $body = $("body");

            $(document).mousemove(function (event) {

                var isPanelDisabledOrMouseNotInSensitiveArea = !isPanelAppearanceEnabled
                    || (event.clientY < 0)
                    || (event.clientY > panelSensitivePixels);

                if (isPanelDisabledOrMouseNotInSensitiveArea) return;

                panels$.filter(function ($panel) {
                        return !$panel.hasClass('imcms-special-hidden');
                    })
                    .forEach(showPanel);
            });

            $(document).click(function (event) {
                if (!$(event.target).closest(".admin-panel-settings-list").length
                    && !$(event.target).closest(".imcms-panel__item--settings").length)
                {
                    panelSettings.hideSettings();
                }

                if (!isPanelAppearanceEnabled || $(event.target).closest(".imcms-admin").length) return;

                $body.css({"top": 0});
                panels$.forEach(hidePanel);
            });
        }

        var panels$ = [];
        var listenersNotSet = true;

{'fraction_non_alphanumeric': 0.14255045083726922, 'fraction_numerical': 0.00622584800343495, 'mean_word_length': 1.7715645449137418, 'pattern_counts': {'":': 8, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '21256', 'n_tokens_mistral': 1308, 'n_tokens_neox': 1213, 'n_words': 215}