From c73fc4b3805ee06dd437037acb2a0da1e7cc3444 Mon Sep 17 00:00:00 2001 From: dizzy Date: Wed, 24 Nov 2021 01:32:47 -0800 Subject: [Vue] in site selector execute search on searchTerm change rather than keydown (#18367) * execute search on searchTerm change rather than keydown so special keys dont have an effect * couple more improvements: only do limit request once, only highlight site name when finished loading sites, make sure search term wasnt changed when search site request finishes * build vue files * built vue files Co-authored-by: sgiehl Co-authored-by: sgiehl --- plugins/CoreHome/vue/dist/CoreHome.umd.js | 108 +++++++++++---------- plugins/CoreHome/vue/dist/CoreHome.umd.min.js | 24 ++--- .../CoreHome/vue/src/SiteSelector/SiteSelector.vue | 32 ++++-- .../CoreHome/vue/src/SiteSelector/SitesStore.ts | 5 - 4 files changed, 89 insertions(+), 80 deletions(-) (limited to 'plugins/CoreHome') diff --git a/plugins/CoreHome/vue/dist/CoreHome.umd.js b/plugins/CoreHome/vue/dist/CoreHome.umd.js index a0f4f9060b..97cb94508e 100644 --- a/plugins/CoreHome/vue/dist/CoreHome.umd.js +++ b/plugins/CoreHome/vue/dist/CoreHome.umd.js @@ -4819,34 +4819,34 @@ PeriodDatePickervue_type_script_lang_ts.render = PeriodDatePickervue_type_templa directiveName: 'piwikPeriodDatePicker', restrict: 'E' })); -// CONCATENATED MODULE: ./node_modules/@vue/cli-plugin-babel/node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/@vue/cli-plugin-babel/node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist/templateLoader.js??ref--6!./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist??ref--0-1!./plugins/CoreHome/vue/src/SiteSelector/SiteSelector.vue?vue&type=template&id=0804f097 +// CONCATENATED MODULE: ./node_modules/@vue/cli-plugin-babel/node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/@vue/cli-plugin-babel/node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist/templateLoader.js??ref--6!./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist??ref--0-1!./plugins/CoreHome/vue/src/SiteSelector/SiteSelector.vue?vue&type=template&id=13a2e0c0 -var SiteSelectorvue_type_template_id_0804f097_hoisted_1 = ["value", "name"]; -var SiteSelectorvue_type_template_id_0804f097_hoisted_2 = ["title"]; -var SiteSelectorvue_type_template_id_0804f097_hoisted_3 = ["textContent"]; -var SiteSelectorvue_type_template_id_0804f097_hoisted_4 = { +var SiteSelectorvue_type_template_id_13a2e0c0_hoisted_1 = ["value", "name"]; +var SiteSelectorvue_type_template_id_13a2e0c0_hoisted_2 = ["title"]; +var SiteSelectorvue_type_template_id_13a2e0c0_hoisted_3 = ["textContent"]; +var SiteSelectorvue_type_template_id_13a2e0c0_hoisted_4 = { key: 1, class: "placeholder" }; -var SiteSelectorvue_type_template_id_0804f097_hoisted_5 = { +var SiteSelectorvue_type_template_id_13a2e0c0_hoisted_5 = { class: "dropdown" }; -var SiteSelectorvue_type_template_id_0804f097_hoisted_6 = { +var SiteSelectorvue_type_template_id_13a2e0c0_hoisted_6 = { class: "custom_select_search" }; -var SiteSelectorvue_type_template_id_0804f097_hoisted_7 = ["placeholder"]; -var SiteSelectorvue_type_template_id_0804f097_hoisted_8 = { +var SiteSelectorvue_type_template_id_13a2e0c0_hoisted_7 = ["placeholder"]; +var SiteSelectorvue_type_template_id_13a2e0c0_hoisted_8 = { key: 0 }; -var SiteSelectorvue_type_template_id_0804f097_hoisted_9 = { +var SiteSelectorvue_type_template_id_13a2e0c0_hoisted_9 = { class: "custom_select_container" }; -var SiteSelectorvue_type_template_id_0804f097_hoisted_10 = ["onClick"]; -var SiteSelectorvue_type_template_id_0804f097_hoisted_11 = ["innerHTML", "href", "title"]; -var SiteSelectorvue_type_template_id_0804f097_hoisted_12 = { +var SiteSelectorvue_type_template_id_13a2e0c0_hoisted_10 = ["onClick"]; +var SiteSelectorvue_type_template_id_13a2e0c0_hoisted_11 = ["innerHTML", "href", "title"]; +var SiteSelectorvue_type_template_id_13a2e0c0_hoisted_12 = { class: "ui-autocomplete ui-front ui-menu ui-widget ui-widget-content ui-corner-all\n siteSelect" }; -var SiteSelectorvue_type_template_id_0804f097_hoisted_13 = { +var SiteSelectorvue_type_template_id_13a2e0c0_hoisted_13 = { class: "ui-menu-item" }; var _hoisted_14 = { @@ -4856,7 +4856,7 @@ var _hoisted_14 = { var _hoisted_15 = { key: 1 }; -function SiteSelectorvue_type_template_id_0804f097_render(_ctx, _cache, $props, $setup, $data, $options) { +function SiteSelectorvue_type_template_id_13a2e0c0_render(_ctx, _cache, $props, $setup, $data, $options) { var _ctx$selectedSite, _ctx$selectedSite2, _ctx$selectedSite3, _ctx$selectedSite4; var _component_AllSitesLink = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveComponent"])("AllSitesLink"); @@ -4875,7 +4875,7 @@ function SiteSelectorvue_type_template_id_0804f097_render(_ctx, _cache, $props, type: "hidden", value: (_ctx$selectedSite = _ctx.selectedSite) === null || _ctx$selectedSite === void 0 ? void 0 : _ctx$selectedSite.id, name: _ctx.name - }, null, 8, SiteSelectorvue_type_template_id_0804f097_hoisted_1)) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("a", { + }, null, 8, SiteSelectorvue_type_template_id_13a2e0c0_hoisted_1)) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("a", { ref: "selectorLink", onClick: _cache[0] || (_cache[0] = function () { return _ctx.onClickSelector && _ctx.onClickSelector.apply(_ctx, arguments); @@ -4897,7 +4897,7 @@ function SiteSelectorvue_type_template_id_0804f097_render(_ctx, _cache, $props, }, null, 2), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", null, [(_ctx$selectedSite2 = _ctx.selectedSite) !== null && _ctx$selectedSite2 !== void 0 && _ctx$selectedSite2.name || !_ctx.placeholder ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("span", { key: 0, textContent: Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(((_ctx$selectedSite3 = _ctx.selectedSite) === null || _ctx$selectedSite3 === void 0 ? void 0 : _ctx$selectedSite3.name) || _ctx.firstSiteName) - }, null, 8, SiteSelectorvue_type_template_id_0804f097_hoisted_3)) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true), !((_ctx$selectedSite4 = _ctx.selectedSite) !== null && _ctx$selectedSite4 !== void 0 && _ctx$selectedSite4.name) && _ctx.placeholder ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("span", SiteSelectorvue_type_template_id_0804f097_hoisted_4, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.placeholder), 1)) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true)])], 42, SiteSelectorvue_type_template_id_0804f097_hoisted_2), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", SiteSelectorvue_type_template_id_0804f097_hoisted_5, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", SiteSelectorvue_type_template_id_0804f097_hoisted_6, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("input", { + }, null, 8, SiteSelectorvue_type_template_id_13a2e0c0_hoisted_3)) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true), !((_ctx$selectedSite4 = _ctx.selectedSite) !== null && _ctx$selectedSite4 !== void 0 && _ctx$selectedSite4.name) && _ctx.placeholder ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("span", SiteSelectorvue_type_template_id_13a2e0c0_hoisted_4, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.placeholder), 1)) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true)])], 42, SiteSelectorvue_type_template_id_13a2e0c0_hoisted_2), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", SiteSelectorvue_type_template_id_13a2e0c0_hoisted_5, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", SiteSelectorvue_type_template_id_13a2e0c0_hoisted_6, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("input", { type: "text", onClick: _cache[2] || (_cache[2] = function ($event) { _ctx.searchTerm = ''; @@ -4907,30 +4907,27 @@ function SiteSelectorvue_type_template_id_0804f097_render(_ctx, _cache, $props, "onUpdate:modelValue": _cache[3] || (_cache[3] = function ($event) { return _ctx.searchTerm = $event; }), - onKeydown: _cache[4] || (_cache[4] = function ($event) { - return _ctx.onSearchInputKeydown(); - }), tabindex: "4", class: "websiteSearch inp browser-default", placeholder: _ctx.translate('General_Search') - }, null, 40, SiteSelectorvue_type_template_id_0804f097_hoisted_7), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vModelText"], _ctx.searchTerm], [_directive_focus_if, {}, _ctx.shouldFocusOnSearch]]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("img", { + }, null, 8, SiteSelectorvue_type_template_id_13a2e0c0_hoisted_7), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vModelText"], _ctx.searchTerm], [_directive_focus_if, {}, _ctx.shouldFocusOnSearch]]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("img", { title: "Clear", - onClick: _cache[5] || (_cache[5] = function ($event) { + onClick: _cache[4] || (_cache[4] = function ($event) { _ctx.searchTerm = ''; _ctx.loadInitialSites(); }), class: "reset", src: "plugins/CoreHome/images/reset_search.png" - }, null, 512), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], _ctx.searchTerm]])], 512), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], _ctx.autocompleteMinSites <= _ctx.sites.length || _ctx.searchTerm]]), _ctx.allSitesLocation === 'top' && _ctx.showAllSitesItem ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("div", SiteSelectorvue_type_template_id_0804f097_hoisted_8, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_AllSitesLink, { + }, null, 512), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], _ctx.searchTerm]])], 512), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], _ctx.autocompleteMinSites <= _ctx.sites.length || _ctx.searchTerm]]), _ctx.allSitesLocation === 'top' && _ctx.showAllSitesItem ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("div", SiteSelectorvue_type_template_id_13a2e0c0_hoisted_8, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_AllSitesLink, { href: _ctx.urlAllSites, "all-sites-text": _ctx.allSitesText, - onClick: _cache[6] || (_cache[6] = function ($event) { + onClick: _cache[5] || (_cache[5] = function ($event) { return _ctx.onAllSitesClick($event); }) - }, null, 8, ["href", "all-sites-text"])])) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", SiteSelectorvue_type_template_id_0804f097_hoisted_9, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("ul", { + }, null, 8, ["href", "all-sites-text"])])) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", SiteSelectorvue_type_template_id_13a2e0c0_hoisted_9, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("ul", { class: "custom_select_ul_list", - onClick: _cache[8] || (_cache[8] = function ($event) { + onClick: _cache[7] || (_cache[7] = function ($event) { return _ctx.showSitesList = false; }) }, [(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(true), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])(external_commonjs_vue_commonjs2_vue_root_Vue_["Fragment"], null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderList"])(_ctx.sites, function (site) { @@ -4940,25 +4937,25 @@ function SiteSelectorvue_type_template_id_0804f097_render(_ctx, _cache, $props, }, key: site.idsite }, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("a", { - onClick: _cache[7] || (_cache[7] = function ($event) { + onClick: _cache[6] || (_cache[6] = function ($event) { return $event.preventDefault(); }), innerHTML: _ctx.$sanitize(_ctx.getMatchedSiteName(site.name)), tabindex: "4", href: _ctx.getUrlForSiteId(site.idsite), title: site.name - }, null, 8, SiteSelectorvue_type_template_id_0804f097_hoisted_11)], 8, SiteSelectorvue_type_template_id_0804f097_hoisted_10)), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], !(!_ctx.showSelectedSite && _ctx.activeSiteId === site.idsite)]]); - }), 128))]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("ul", SiteSelectorvue_type_template_id_0804f097_hoisted_12, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("li", SiteSelectorvue_type_template_id_0804f097_hoisted_13, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("a", _hoisted_14, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('SitesManager_NotFound') + ' ' + _ctx.searchTerm), 1)])], 512), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], !_ctx.sites.length && _ctx.searchTerm]])]), _ctx.allSitesLocation === 'bottom' && _ctx.showAllSitesItem ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("div", _hoisted_15, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_AllSitesLink, { + }, null, 8, SiteSelectorvue_type_template_id_13a2e0c0_hoisted_11)], 8, SiteSelectorvue_type_template_id_13a2e0c0_hoisted_10)), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], !(!_ctx.showSelectedSite && _ctx.activeSiteId === site.idsite)]]); + }), 128))]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("ul", SiteSelectorvue_type_template_id_13a2e0c0_hoisted_12, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("li", SiteSelectorvue_type_template_id_13a2e0c0_hoisted_13, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("a", _hoisted_14, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('SitesManager_NotFound') + ' ' + _ctx.searchTerm), 1)])], 512), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], !_ctx.sites.length && _ctx.searchTerm]])]), _ctx.allSitesLocation === 'bottom' && _ctx.showAllSitesItem ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("div", _hoisted_15, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_AllSitesLink, { href: _ctx.urlAllSites, "all-sites-text": _ctx.allSitesText, - onClick: _cache[9] || (_cache[9] = function ($event) { + onClick: _cache[8] || (_cache[8] = function ($event) { return _ctx.onAllSitesClick($event); }) }, null, 8, ["href", "all-sites-text"])])) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true)], 512), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], _ctx.showSitesList]])], 2)), [[_directive_focus_anywhere_but_here, { blur: _ctx.onBlur }]]); } -// CONCATENATED MODULE: ./plugins/CoreHome/vue/src/SiteSelector/SiteSelector.vue?vue&type=template&id=0804f097 +// CONCATENATED MODULE: ./plugins/CoreHome/vue/src/SiteSelector/SiteSelector.vue?vue&type=template&id=13a2e0c0 // CONCATENATED MODULE: ./node_modules/@vue/cli-plugin-babel/node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/@vue/cli-plugin-babel/node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist/templateLoader.js??ref--6!./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist??ref--0-1!./plugins/CoreHome/vue/src/SiteSelector/AllSitesLink.vue?vue&type=template&id=45607d28 @@ -5095,11 +5092,6 @@ var SitesStore_SitesStore = /*#__PURE__*/function () { this.currentRequest.abort(); } - if (this.limitRequest) { - this.limitRequest.abort(); - this.limitRequest = null; - } - if (!this.limitRequest) { this.limitRequest = AjaxHelper_AjaxHelper.fetch({ method: 'SitesManager.getNumWebsitesToDisplayPerPage' @@ -5242,6 +5234,9 @@ function SiteSelectorvue_type_script_lang_ts_defineProperty(obj, key, value) { i FocusIf: FocusIf }, watch: { + searchTerm: function searchTerm() { + this.onSearchTermChanged(); + }, modelValue: { handler: function handler(newValue) { this.selectedSite = SiteSelectorvue_type_script_lang_ts_objectSpread({}, newValue); @@ -5294,9 +5289,6 @@ function SiteSelectorvue_type_script_lang_ts_defineProperty(obj, key, value) { i _this.$refs.selectorLink.focus(); }); }, - created: function created() { - this.onSearchInputKeydown = debounce(this.onSearchInputKeydown.bind(this)); - }, computed: { shouldFocusOnSearch: function shouldFocusOnSearch() { return this.showSitesList && this.autocompleteMinSites <= this.sites.length || this.searchTerm; @@ -5322,7 +5314,19 @@ function SiteSelectorvue_type_script_lang_ts_defineProperty(obj, key, value) { i return "?".concat(newQuery); } }, + created: function created() { + this.searchSite = debounce(this.searchSite.bind(this)); + }, methods: { + onSearchTermChanged: function onSearchTermChanged() { + if (!this.searchTerm) { + this.isLoading = false; + this.loadInitialSites(); + } else { + this.isLoading = true; + this.searchSite(this.searchTerm); + } + }, onAllSitesClick: function onAllSitesClick(event) { this.switchSite({ idsite: 'all', @@ -5376,17 +5380,11 @@ function SiteSelectorvue_type_script_lang_ts_defineProperty(obj, key, value) { i this.loadInitialSites(); } }, - onSearchInputKeydown: function onSearchInputKeydown() { - var _this2 = this; - - setTimeout(function () { - _this2.searchSite(_this2.searchTerm); - }); - }, getMatchedSiteName: function getMatchedSiteName(siteName) { var index = siteName.toUpperCase().indexOf(this.searchTerm.toUpperCase()); - if (index === -1) { + if (index === -1 || this.isLoading // only highlight when we know the displayed results are for a search + ) { return Matomo_Matomo.helper.htmlEntities(siteName); } @@ -5395,22 +5393,26 @@ function SiteSelectorvue_type_script_lang_ts_defineProperty(obj, key, value) { i return "".concat(previousPart, "").concat(this.searchTerm, "").concat(lastPart); }, loadInitialSites: function loadInitialSites() { - var _this3 = this; + var _this2 = this; return SiteSelector_SitesStore.loadInitialSites().then(function (sites) { - _this3.sites = sites || []; + _this2.sites = sites || []; }); }, searchSite: function searchSite(term) { - var _this4 = this; + var _this3 = this; this.isLoading = true; SiteSelector_SitesStore.searchSite(term, this.onlySitesWithAdminAccess).then(function (sites) { + if (term !== _this3.searchTerm) { + return; // search term changed in the meantime + } + if (sites) { - _this4.sites = sites; + _this3.sites = sites; } }).finally(function () { - _this4.isLoading = false; + _this3.isLoading = false; }); }, getUrlForSiteId: function getUrlForSiteId(idSite) { @@ -5432,7 +5434,7 @@ function SiteSelectorvue_type_script_lang_ts_defineProperty(obj, key, value) { i -SiteSelectorvue_type_script_lang_ts.render = SiteSelectorvue_type_template_id_0804f097_render +SiteSelectorvue_type_script_lang_ts.render = SiteSelectorvue_type_template_id_13a2e0c0_render /* harmony default export */ var SiteSelector = (SiteSelectorvue_type_script_lang_ts); // CONCATENATED MODULE: ./plugins/CoreHome/vue/src/SiteSelector/SiteSelector.adapter.ts diff --git a/plugins/CoreHome/vue/dist/CoreHome.umd.min.js b/plugins/CoreHome/vue/dist/CoreHome.umd.min.js index 0edd13cf44..56cb01e86b 100644 --- a/plugins/CoreHome/vue/dist/CoreHome.umd.min.js +++ b/plugins/CoreHome/vue/dist/CoreHome.umd.min.js @@ -4,7 +4,7 @@ * * @link https://matomo.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later - */window.hasBlockedContent=!1},"8bbf":function(t,n){t.exports=e},fae3:function(e,t,n){"use strict";if(n.r(t),n.d(t,"debounce",(function(){return Ur})),n.d(t,"createAngularJsAdapter",(function(){return wt})),n.d(t,"activityIndicatorAdapter",(function(){return ki})),n.d(t,"ActivityIndicator",(function(){return Oi})),n.d(t,"translate",(function(){return D})),n.d(t,"alertAdapter",(function(){return Ei})),n.d(t,"AjaxHelper",(function(){return Ne})),n.d(t,"setCookie",(function(){return Pi})),n.d(t,"getCookie",(function(){return Ti})),n.d(t,"deleteCookie",(function(){return Ii})),n.d(t,"MatomoUrl",(function(){return Oe})),n.d(t,"Matomo",(function(){return j})),n.d(t,"Periods",(function(){return f})),n.d(t,"Day",(function(){return z})),n.d(t,"Week",(function(){return X})),n.d(t,"Month",(function(){return re})),n.d(t,"Year",(function(){return se})),n.d(t,"Range",(function(){return _})),n.d(t,"format",(function(){return C})),n.d(t,"getToday",(function(){return E})),n.d(t,"parseDate",(function(){return P})),n.d(t,"todayIsInRange",(function(){return T})),n.d(t,"Dropdown",(function(){return Me})),n.d(t,"FocusAnywhereButHere",(function(){return _e})),n.d(t,"FocusIf",(function(){return qe})),n.d(t,"MatomoDialog",(function(){return ut})),n.d(t,"ExpandOnClick",(function(){return Xe})),n.d(t,"ExpandOnHover",(function(){return at})),n.d(t,"EnrichedHeadline",(function(){return Vt})),n.d(t,"ContentBlock",(function(){return Gt})),n.d(t,"Comparisons",(function(){return Nn})),n.d(t,"MenuDropdown",(function(){return zn})),n.d(t,"DatePicker",(function(){return rr})),n.d(t,"DateRangePicker",(function(){return sr})),n.d(t,"PeriodDatePicker",(function(){return pr})),n.d(t,"Notification",(function(){return _i})),n.d(t,"NotificationGroup",(function(){return ta})),n.d(t,"NotificationsStore",(function(){return Wi})),n.d(t,"SiteSelector",(function(){return Qr})),n.d(t,"QuickAccess",(function(){return vi})),"undefined"!==typeof window){var r=window.document.currentScript,i=r&&r.src.match(/(.+\/)[^/]+\.js(\?.*)?$/);i&&(n.p=i[1])}n("2342");var a=n("8bbf");function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){for(var n=0;n1?t-1:0),r=1;re.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.selectedDateStart&&n<=e.selectedDateEnd?t.addClass("ui-datepicker-current-period"):t.removeClass("ui-datepicker-current-period"),e.highlightedDateStart&&e.highlightedDateEnd&&n>=e.highlightedDateStart&&n<=e.highlightedDateEnd){var i=r.length?r:t;i.addClass("ui-state-hover")}else t.removeClass("ui-state-hover"),r.removeClass("ui-state-hover")}function i(e,t,n){if(e.hasClass("ui-datepicker-other-month"))return o(e,t,n);var r=parseInt(e.children("a,span").text(),10);return new Date(n,t,r)}function o(e,t,n){var r,a=e.parent(),o=a.children("td");if(a.is(":first-child")){var c=a.children("td:not(.ui-datepicker-other-month)").first();return r=i(c,t,n),r.setDate(o.index(e)-o.index(c)+1),r}var s=a.children("td:not(.ui-datepicker-other-month)").last();return r=i(s,t,n),r.setDate(r.getDate()+o.index(e)-o.index(s)),r}function c(){var e=tr(n.value),t=e.find("td[data-month]"),r=parseInt(t.attr("data-month"),10),i=parseInt(t.attr("data-year"),10);return[r,i]}function s(){var e=tr(n.value),t=e.find(".ui-datepicker-calendar"),a=c(),o=t.find("td"),s=o.first(),l=i(s,a[0],a[1]);o.each((function(){r(tr(this),l),l.setDate(l.getDate()+1)}))}function l(){var t=e.viewDate;if(!t)return!1;if(!(t instanceof Date))try{t=P(t)}catch(a){return!1}var r=tr(n.value),i=c();return(i[0]!==t.getMonth()||i[1]!==t.getFullYear())&&(r.datepicker("setDate",t),!0)}function u(){var e=tr(n.value);e.find("td[data-event]").off("click"),e.find(".ui-state-active").removeClass("ui-state-active"),e.find(".ui-datepicker-current-day").removeClass("ui-datepicker-current-day"),e.find(".ui-datepicker-prev,.ui-datepicker-next").attr("href","")}function d(){var t=tr(n.value),r=e.stepMonths||Zn;if(t.datepicker("option","stepMonths")===r)return!1;var i=tr(".ui-datepicker-month",t).val(),a=tr(".ui-datepicker-year",t).val();return t.datepicker("option","stepMonths",r).datepicker("setDate",new Date(a,i)),u(),!0}function f(){var t=tr(n.value);t.find(".ui-datepicker-month").attr("disabled",e.disableMonthDropdown)}function p(){if(tr(this).hasClass("ui-state-hover")){var e=tr(this).parent(),t=e.parent();e.is(":first-child")?t.find("a").first().click():t.find("a").last().click()}}function m(){f(),s()}return Object(a["watch"])((function(){return Yn({},e)}),(function(e,t){var n=!1;["selectedDateStart","selectedDateEnd","highlightedDateStart","highlightedDateEnd"].forEach((function(r){n||(!e[r]&&t[r]&&(n=!0),e[r]&&!t[r]&&(n=!0),e[r]&&t[r]&&e[r].getTime()!==t[r].getTime()&&(n=!0))})),e.viewDate!==t.viewDate&&l()&&(n=!0),e.stepMonths!==t.stepMonths&&d(),e.enableDisableMonthDropdown!==t.enableDisableMonthDropdown&&f(),n&&s()})),Object(a["onMounted"])((function(){var r=tr(n.value),a=e.options||{},o=Yn(Yn(Yn({},j.getBaseDatePickerOptions()),a),{},{onChangeMonthYear:function(){setTimeout((function(){u()}))}});r.datepicker(o),r.on("mouseover","tbody td a",(function(e){e.originalEvent&&s()})),r.on("mouseenter","tbody td",(function(){var e=c(),n=tr(this),r=i(n,e[0],e[1]);t.emit("cellHover",{date:r,$cell:n})})),r.on("mouseout","tbody td a",(function(){s()})),r.on("mouseleave","table",(function(){return t.emit("cellHoverLeave")})).on("mouseenter","thead",(function(){return t.emit("cellHoverLeave")})),r.on("click","tbody td.ui-datepicker-other-month",(function(){return p()})),r.on("click",(function(e){e.preventDefault();var t=tr(e.target).closest("a");(t.is(".ui-datepicker-next")||t.is(".ui-datepicker-prev"))&&m()})),r.on("click","td[data-month]",(function(e){var n=tr(e.target).closest("td"),r=parseInt(n.attr("data-month"),10),i=parseInt(n.attr("data-year"),10),a=parseInt(n.children("a,span").text(),10);t.emit("dateSelect",{date:new Date(i,r,a)})}));var h=d();l(),f(),h||u(),s()})),{root:n}}});nr.render=Kn;var rr=nr,ir=(wt({component:rr,scope:{selectedDateStart:{angularJsBind:"<"},selectedDateEnd:{angularJsBind:"<"},highlightedDateStart:{angularJsBind:"<"},highlightedDateEnd:{angularJsBind:"<"},viewDate:{angularJsBind:"<"},stepMonths:{angularJsBind:"<"},disableMonthDropdown:{angularJsBind:"<"},options:{angularJsBind:"<"},cellHover:{angularJsBind:"&"},cellHoverLeave:{angularJsBind:"&"},dateSelect:{angularJsBind:"&"}},directiveName:"piwikDatePicker",events:{"cell-hover":function(e,t,n,r,i){i()},"cell-hover-leave":function(e,t,n,r,i){i()},"date-select":function(e,t,n,r,i){i()}},$inject:["$timeout"]}),{id:"calendarRangeFrom"}),ar={id:"calendarRangeTo"}; + */function Wn(e,t,n,r,i,o){return Object(a["openBlock"])(),Object(a["createElementBlock"])("div",Qn,null,512)}function Yn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Kn(e){for(var t=1;t=e.selectedDateStart&&n<=e.selectedDateEnd?t.addClass("ui-datepicker-current-period"):t.removeClass("ui-datepicker-current-period"),e.highlightedDateStart&&e.highlightedDateEnd&&n>=e.highlightedDateStart&&n<=e.highlightedDateEnd){var i=r.length?r:t;i.addClass("ui-state-hover")}else t.removeClass("ui-state-hover"),r.removeClass("ui-state-hover")}function i(e,t,n){if(e.hasClass("ui-datepicker-other-month"))return o(e,t,n);var r=parseInt(e.children("a,span").text(),10);return new Date(n,t,r)}function o(e,t,n){var r,a=e.parent(),o=a.children("td");if(a.is(":first-child")){var c=a.children("td:not(.ui-datepicker-other-month)").first();return r=i(c,t,n),r.setDate(o.index(e)-o.index(c)+1),r}var s=a.children("td:not(.ui-datepicker-other-month)").last();return r=i(s,t,n),r.setDate(r.getDate()+o.index(e)-o.index(s)),r}function c(){var e=tr(n.value),t=e.find("td[data-month]"),r=parseInt(t.attr("data-month"),10),i=parseInt(t.attr("data-year"),10);return[r,i]}function s(){var e=tr(n.value),t=e.find(".ui-datepicker-calendar"),a=c(),o=t.find("td"),s=o.first(),l=i(s,a[0],a[1]);o.each((function(){r(tr(this),l),l.setDate(l.getDate()+1)}))}function l(){var t=e.viewDate;if(!t)return!1;if(!(t instanceof Date))try{t=P(t)}catch(a){return!1}var r=tr(n.value),i=c();return(i[0]!==t.getMonth()||i[1]!==t.getFullYear())&&(r.datepicker("setDate",t),!0)}function u(){var e=tr(n.value);e.find("td[data-event]").off("click"),e.find(".ui-state-active").removeClass("ui-state-active"),e.find(".ui-datepicker-current-day").removeClass("ui-datepicker-current-day"),e.find(".ui-datepicker-prev,.ui-datepicker-next").attr("href","")}function d(){var t=tr(n.value),r=e.stepMonths||Zn;if(t.datepicker("option","stepMonths")===r)return!1;var i=tr(".ui-datepicker-month",t).val(),a=tr(".ui-datepicker-year",t).val();return t.datepicker("option","stepMonths",r).datepicker("setDate",new Date(a,i)),u(),!0}function f(){var t=tr(n.value);t.find(".ui-datepicker-month").attr("disabled",e.disableMonthDropdown)}function p(){if(tr(this).hasClass("ui-state-hover")){var e=tr(this).parent(),t=e.parent();e.is(":first-child")?t.find("a").first().click():t.find("a").last().click()}}function m(){f(),s()}return Object(a["watch"])((function(){return Kn({},e)}),(function(e,t){var n=!1;["selectedDateStart","selectedDateEnd","highlightedDateStart","highlightedDateEnd"].forEach((function(r){n||(!e[r]&&t[r]&&(n=!0),e[r]&&!t[r]&&(n=!0),e[r]&&t[r]&&e[r].getTime()!==t[r].getTime()&&(n=!0))})),e.viewDate!==t.viewDate&&l()&&(n=!0),e.stepMonths!==t.stepMonths&&d(),e.enableDisableMonthDropdown!==t.enableDisableMonthDropdown&&f(),n&&s()})),Object(a["onMounted"])((function(){var r=tr(n.value),a=e.options||{},o=Kn(Kn(Kn({},j.getBaseDatePickerOptions()),a),{},{onChangeMonthYear:function(){setTimeout((function(){u()}))}});r.datepicker(o),r.on("mouseover","tbody td a",(function(e){e.originalEvent&&s()})),r.on("mouseenter","tbody td",(function(){var e=c(),n=tr(this),r=i(n,e[0],e[1]);t.emit("cellHover",{date:r,$cell:n})})),r.on("mouseout","tbody td a",(function(){s()})),r.on("mouseleave","table",(function(){return t.emit("cellHoverLeave")})).on("mouseenter","thead",(function(){return t.emit("cellHoverLeave")})),r.on("click","tbody td.ui-datepicker-other-month",(function(){return p()})),r.on("click",(function(e){e.preventDefault();var t=tr(e.target).closest("a");(t.is(".ui-datepicker-next")||t.is(".ui-datepicker-prev"))&&m()})),r.on("click","td[data-month]",(function(e){var n=tr(e.target).closest("td"),r=parseInt(n.attr("data-month"),10),i=parseInt(n.attr("data-year"),10),a=parseInt(n.children("a,span").text(),10);t.emit("dateSelect",{date:new Date(i,r,a)})}));var h=d();l(),f(),h||u(),s()})),{root:n}}});nr.render=Wn;var rr=nr,ir=(wt({component:rr,scope:{selectedDateStart:{angularJsBind:"<"},selectedDateEnd:{angularJsBind:"<"},highlightedDateStart:{angularJsBind:"<"},highlightedDateEnd:{angularJsBind:"<"},viewDate:{angularJsBind:"<"},stepMonths:{angularJsBind:"<"},disableMonthDropdown:{angularJsBind:"<"},options:{angularJsBind:"<"},cellHover:{angularJsBind:"&"},cellHoverLeave:{angularJsBind:"&"},dateSelect:{angularJsBind:"&"}},directiveName:"piwikDatePicker",events:{"cell-hover":function(e,t,n,r,i){i()},"cell-hover-leave":function(e,t,n,r,i){i()},"date-select":function(e,t,n,r,i){i()}},$inject:["$timeout"]}),{id:"calendarRangeFrom"}),ar={id:"calendarRangeTo"}; /*! * Matomo - free/libre analytics platform * @@ -232,19 +232,19 @@ function ot(){return{restrict:"A",link:function(e,t){var n={instance:null,value: * * @link https://matomo.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later - */function Tr(e,t,n,r,i,o){var c,s,l,u,d=Object(a["resolveComponent"])("AllSitesLink"),f=Object(a["resolveDirective"])("focus-if"),p=Object(a["resolveDirective"])("focus-anywhere-but-here");return Object(a["withDirectives"])((Object(a["openBlock"])(),Object(a["createElementBlock"])("div",{class:Object(a["normalizeClass"])(["siteSelector piwikSelector borderedControl",{expanded:e.showSitesList,disabled:!e.hasMultipleSites}])},[e.name?(Object(a["openBlock"])(),Object(a["createElementBlock"])("input",{key:0,type:"hidden",value:null===(c=e.selectedSite)||void 0===c?void 0:c.id,name:e.name},null,8,mr)):Object(a["createCommentVNode"])("",!0),Object(a["createElementVNode"])("a",{ref:"selectorLink",onClick:t[0]||(t[0]=function(){return e.onClickSelector&&e.onClickSelector.apply(e,arguments)}),onKeydown:t[1]||(t[1]=function(t){return e.onPressEnter(t)}),href:"javascript:void(0)",class:Object(a["normalizeClass"])([{loading:e.isLoading},"title"]),tabindex:"4",title:e.selectorLinkTitle},[Object(a["createElementVNode"])("span",{class:Object(a["normalizeClass"])(["icon icon-arrow-bottom",{iconHidden:e.isLoading,collapsed:!e.showSitesList}])},null,2),Object(a["createElementVNode"])("span",null,[null!==(s=e.selectedSite)&&void 0!==s&&s.name||!e.placeholder?(Object(a["openBlock"])(),Object(a["createElementBlock"])("span",{key:0,textContent:Object(a["toDisplayString"])((null===(l=e.selectedSite)||void 0===l?void 0:l.name)||e.firstSiteName)},null,8,vr)):Object(a["createCommentVNode"])("",!0),null!==(u=e.selectedSite)&&void 0!==u&&u.name||!e.placeholder?Object(a["createCommentVNode"])("",!0):(Object(a["openBlock"])(),Object(a["createElementBlock"])("span",gr,Object(a["toDisplayString"])(e.placeholder),1))])],42,hr),Object(a["withDirectives"])(Object(a["createElementVNode"])("div",br,[Object(a["withDirectives"])(Object(a["createElementVNode"])("div",yr,[Object(a["withDirectives"])(Object(a["createElementVNode"])("input",{type:"text",onClick:t[2]||(t[2]=function(t){e.searchTerm="",e.loadInitialSites()}),"onUpdate:modelValue":t[3]||(t[3]=function(t){return e.searchTerm=t}),onKeydown:t[4]||(t[4]=function(t){return e.onSearchInputKeydown()}),tabindex:"4",class:"websiteSearch inp browser-default",placeholder:e.translate("General_Search")},null,40,wr),[[a["vModelText"],e.searchTerm],[f,{},e.shouldFocusOnSearch]]),Object(a["withDirectives"])(Object(a["createElementVNode"])("img",{title:"Clear",onClick:t[5]||(t[5]=function(t){e.searchTerm="",e.loadInitialSites()}),class:"reset",src:"plugins/CoreHome/images/reset_search.png"},null,512),[[a["vShow"],e.searchTerm]])],512),[[a["vShow"],e.autocompleteMinSites<=e.sites.length||e.searchTerm]]),"top"===e.allSitesLocation&&e.showAllSitesItem?(Object(a["openBlock"])(),Object(a["createElementBlock"])("div",Or,[Object(a["createVNode"])(d,{href:e.urlAllSites,"all-sites-text":e.allSitesText,onClick:t[6]||(t[6]=function(t){return e.onAllSitesClick(t)})},null,8,["href","all-sites-text"])])):Object(a["createCommentVNode"])("",!0),Object(a["createElementVNode"])("div",kr,[Object(a["createElementVNode"])("ul",{class:"custom_select_ul_list",onClick:t[8]||(t[8]=function(t){return e.showSitesList=!1})},[(Object(a["openBlock"])(!0),Object(a["createElementBlock"])(a["Fragment"],null,Object(a["renderList"])(e.sites,(function(n){return Object(a["withDirectives"])((Object(a["openBlock"])(),Object(a["createElementBlock"])("li",{onClick:function(t){return e.switchSite(n,t)},key:n.idsite},[Object(a["createElementVNode"])("a",{onClick:t[7]||(t[7]=function(e){return e.preventDefault()}),innerHTML:e.$sanitize(e.getMatchedSiteName(n.name)),tabindex:"4",href:e.getUrlForSiteId(n.idsite),title:n.name},null,8,jr)],8,Sr)),[[a["vShow"],!(!e.showSelectedSite&&e.activeSiteId===n.idsite)]])})),128))]),Object(a["withDirectives"])(Object(a["createElementVNode"])("ul",Dr,[Object(a["createElementVNode"])("li",Cr,[Object(a["createElementVNode"])("a",Er,Object(a["toDisplayString"])(e.translate("SitesManager_NotFound")+" "+e.searchTerm),1)])],512),[[a["vShow"],!e.sites.length&&e.searchTerm]])]),"bottom"===e.allSitesLocation&&e.showAllSitesItem?(Object(a["openBlock"])(),Object(a["createElementBlock"])("div",Pr,[Object(a["createVNode"])(d,{href:e.urlAllSites,"all-sites-text":e.allSitesText,onClick:t[9]||(t[9]=function(t){return e.onAllSitesClick(t)})},null,8,["href","all-sites-text"])])):Object(a["createCommentVNode"])("",!0)],512),[[a["vShow"],e.showSitesList]])],2)),[[p,{blur:e.onBlur}]])}var Ir=["innerHTML","href"];function xr(e,t,n,r,i,o){var c=this;return Object(a["openBlock"])(),Object(a["createElementBlock"])("div",{onClick:t[1]||(t[1]=function(e){return c.onClick(e)}),class:"custom_select_all"},[Object(a["createElementVNode"])("a",{onClick:t[0]||(t[0]=function(e){return e.preventDefault()}),innerHTML:e.$sanitize(e.allSitesText),tabindex:"4",href:e.href},null,8,Ir)])}var Nr=Object(a["defineComponent"])({props:{href:String,allSitesText:String},emits:["click"],methods:{onClick:function(e){this.$emit("click",e)}}});Nr.render=xr;var Br=Nr;function Mr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Ar(e){for(var t=1;t1&&void 0!==arguments[1]&&arguments[1];return e?(this.currentRequest&&this.currentRequest.abort(),this.limitRequest&&(this.limitRequest.abort(),this.limitRequest=null),this.limitRequest||(this.limitRequest=Ne.fetch({method:"SitesManager.getNumWebsitesToDisplayPerPage"})),this.limitRequest.then((function(r){var i=r.value,a="SitesManager.getPatternMatchSites";return n&&(a="SitesManager.getSitesWithAdminAccess"),t.currentRequest=Ne.fetch({method:a,limit:i,pattern:e}),t.currentRequest})).then((function(e){return e?t.processWebsitesList(e):null})).finally((function(){t.currentRequest=null}))):this.loadInitialSites()}},{key:"processWebsitesList",value:function(e){var t=e;return t&&t.length?(t=t.map((function(e){return Ar(Ar({},e),{},{name:e.group?"[".concat(e.group,"] ").concat(e.name):e.name})})),t.sort((function(e,t){return e.name.toLowerCase()t.name.toLowerCase()?1:0})),t):[]}}]),e}(),_r=new Fr,Rr=300;function Ur(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Rr;return function(){for(var r=arguments.length,i=new Array(r),a=0;a1},firstSiteName:function(){return this.sites&&this.sites.length>0?this.sites[0].name:""},urlAllSites:function(){var e=Oe.stringify(Jr(Jr({},Oe.urlParsed.value),{},{module:"MultiSites",action:"index",date:Oe.parsed.value.date,period:Oe.parsed.value.period}));return"?".concat(e)}},methods:{onAllSitesClick:function(e){this.switchSite({idsite:"all",name:this.allSitesText},e),this.showSitesList=!1},switchSite:function(e,t){var n=-1!==navigator.userAgent.indexOf("Mac OS X")?t.metaKey:t.ctrlKey;t&&n&&t.target&&t.target.href?window.open(t.target.href,"_blank"):(this.selectedSite={id:e.idsite,name:e.name},this.$emit("update:modelValue",Jr({},this.selectedSite)),this.switchSiteOnSelect&&this.activeSiteId!==e.idsite&&_r.loadSite(e.idsite))},onBlur:function(){this.showSitesList=!1,this.$emit("blur")},onClickSelector:function(){this.hasMultipleSites&&(this.showSitesList=!this.showSitesList,this.isLoading||this.searchTerm||this.loadInitialSites())},onPressEnter:function(e){"Enter"===e.key&&(e.preventDefault(),this.showSitesList=!this.showSitesList,this.showSitesList&&!this.isLoading&&this.loadInitialSites())},onSearchInputKeydown:function(){var e=this;setTimeout((function(){e.searchSite(e.searchTerm)}))},getMatchedSiteName:function(e){var t=e.toUpperCase().indexOf(this.searchTerm.toUpperCase());if(-1===t)return j.helper.htmlEntities(e);var n=j.helper.htmlEntities(e.substring(0,t)),r=j.helper.htmlEntities(e.substring(t+this.searchTerm.length));return"".concat(n,'').concat(this.searchTerm,"").concat(r)},loadInitialSites:function(){var e=this;return _r.loadInitialSites().then((function(t){e.sites=t||[]}))},searchSite:function(e){var t=this;this.isLoading=!0,_r.searchSite(e,this.onlySitesWithAdminAccess).then((function(e){e&&(t.sites=e)})).finally((function(){t.isLoading=!1}))},getUrlForSiteId:function(e){var t=Oe.stringify(Jr(Jr({},Oe.urlParsed.value),{},{segment:"",idSite:e})),n=Oe.stringify(Jr(Jr({},Oe.hashParsed.value),{},{segment:"",idSite:e}));return"?".concat(t,"#?").concat(n)}}});zr.render=Tr;var Qr=zr;function Kr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Wr(e){for(var t=1;t1&&void 0!==arguments[1]&&arguments[1];return e?(this.currentRequest&&this.currentRequest.abort(),this.limitRequest||(this.limitRequest=Ne.fetch({method:"SitesManager.getNumWebsitesToDisplayPerPage"})),this.limitRequest.then((function(r){var i=r.value,a="SitesManager.getPatternMatchSites";return n&&(a="SitesManager.getSitesWithAdminAccess"),t.currentRequest=Ne.fetch({method:a,limit:i,pattern:e}),t.currentRequest})).then((function(e){return e?t.processWebsitesList(e):null})).finally((function(){t.currentRequest=null}))):this.loadInitialSites()}},{key:"processWebsitesList",value:function(e){var t=e;return t&&t.length?(t=t.map((function(e){return Ar(Ar({},e),{},{name:e.group?"[".concat(e.group,"] ").concat(e.name):e.name})})),t.sort((function(e,t){return e.name.toLowerCase()t.name.toLowerCase()?1:0})),t):[]}}]),e}(),_r=new Fr,Rr=300;function Ur(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Rr;return function(){for(var r=arguments.length,i=new Array(r),a=0;a1},firstSiteName:function(){return this.sites&&this.sites.length>0?this.sites[0].name:""},urlAllSites:function(){var e=Oe.stringify(Jr(Jr({},Oe.urlParsed.value),{},{module:"MultiSites",action:"index",date:Oe.parsed.value.date,period:Oe.parsed.value.period}));return"?".concat(e)}},created:function(){this.searchSite=Ur(this.searchSite.bind(this))},methods:{onSearchTermChanged:function(){this.searchTerm?(this.isLoading=!0,this.searchSite(this.searchTerm)):(this.isLoading=!1,this.loadInitialSites())},onAllSitesClick:function(e){this.switchSite({idsite:"all",name:this.allSitesText},e),this.showSitesList=!1},switchSite:function(e,t){var n=-1!==navigator.userAgent.indexOf("Mac OS X")?t.metaKey:t.ctrlKey;t&&n&&t.target&&t.target.href?window.open(t.target.href,"_blank"):(this.selectedSite={id:e.idsite,name:e.name},this.$emit("update:modelValue",Jr({},this.selectedSite)),this.switchSiteOnSelect&&this.activeSiteId!==e.idsite&&_r.loadSite(e.idsite))},onBlur:function(){this.showSitesList=!1,this.$emit("blur")},onClickSelector:function(){this.hasMultipleSites&&(this.showSitesList=!this.showSitesList,this.isLoading||this.searchTerm||this.loadInitialSites())},onPressEnter:function(e){"Enter"===e.key&&(e.preventDefault(),this.showSitesList=!this.showSitesList,this.showSitesList&&!this.isLoading&&this.loadInitialSites())},getMatchedSiteName:function(e){var t=e.toUpperCase().indexOf(this.searchTerm.toUpperCase());if(-1===t||this.isLoading)return j.helper.htmlEntities(e);var n=j.helper.htmlEntities(e.substring(0,t)),r=j.helper.htmlEntities(e.substring(t+this.searchTerm.length));return"".concat(n,'').concat(this.searchTerm,"").concat(r)},loadInitialSites:function(){var e=this;return _r.loadInitialSites().then((function(t){e.sites=t||[]}))},searchSite:function(e){var t=this;this.isLoading=!0,_r.searchSite(e,this.onlySitesWithAdminAccess).then((function(n){e===t.searchTerm&&n&&(t.sites=n)})).finally((function(){t.isLoading=!1}))},getUrlForSiteId:function(e){var t=Oe.stringify(Jr(Jr({},Oe.urlParsed.value),{},{segment:"",idSite:e})),n=Oe.stringify(Jr(Jr({},Oe.hashParsed.value),{},{segment:"",idSite:e}));return"?".concat(t,"#?").concat(n)}}});zr.render=Tr;var Qr=zr;function Wr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Yr(e){for(var t=1;t0||e.sites.length)]]),(Object(a["openBlock"])(!0),Object(a["createElementBlock"])(a["Fragment"],null,Object(a["renderList"])(e.menuItems,(function(t){return Object(a["openBlock"])(),Object(a["createElementBlock"])("ul",{key:t.title},[Object(a["createElementVNode"])("li",{class:"quick-access-category",onClick:function(n){e.searchTerm=t.title,e.searchMenu(e.searchTerm)}},Object(a["toDisplayString"])(t.title),9,ni),(Object(a["openBlock"])(!0),Object(a["createElementBlock"])(a["Fragment"],null,Object(a["renderList"])(t.items,(function(t){return Object(a["openBlock"])(),Object(a["createElementBlock"])("li",{class:Object(a["normalizeClass"])(["result",{selected:t.menuIndex===e.searchIndex}]),onMouseenter:function(n){return e.searchIndex=t.menuIndex},onClick:function(n){return e.selectMenuItem(t.index)},key:t.index},[Object(a["createElementVNode"])("a",null,Object(a["toDisplayString"])(t.name.trim()),1)],42,ri)})),128))])})),128)),Object(a["createElementVNode"])("ul",ii,[Object(a["withDirectives"])(Object(a["createElementVNode"])("li",{class:"quick-access-category websiteCategory"},Object(a["toDisplayString"])(e.translate("SitesManager_Sites")),513),[[a["vShow"],e.hasSitesSelector&&e.sites.length||e.isLoading]]),Object(a["withDirectives"])(Object(a["createElementVNode"])("li",{class:"no-result"},Object(a["toDisplayString"])(e.translate("MultiSites_LoadingWebsites")),513),[[a["vShow"],e.hasSitesSelector&&e.isLoading]]),(Object(a["openBlock"])(!0),Object(a["createElementBlock"])(a["Fragment"],null,Object(a["renderList"])(e.sites,(function(t,n){return Object(a["withDirectives"])((Object(a["openBlock"])(),Object(a["createElementBlock"])("li",{class:Object(a["normalizeClass"])(["result",{selected:e.numMenuItems+n===e.searchIndex}]),onMouseenter:function(t){return e.searchIndex=e.numMenuItems+n},onClick:function(n){return e.selectSite(t.idsite)},key:t.idsite},[Object(a["createElementVNode"])("a",{textContent:Object(a["toDisplayString"])(t.name)},null,8,oi)],42,ai)),[[a["vShow"],e.hasSitesSelector&&!e.isLoading]])})),128))]),Object(a["createElementVNode"])("ul",null,[Object(a["createElementVNode"])("li",ci,Object(a["toDisplayString"])(e.translate("General_HelpResources")),1),Object(a["createElementVNode"])("li",{class:Object(a["normalizeClass"])([{selected:"help"===e.searchIndex},"quick-access-help"]),onMouseenter:t[4]||(t[4]=function(t){return e.searchIndex="help"})},[Object(a["createElementVNode"])("a",{href:"https://matomo.org?s=".concat(encodeURIComponent(e.searchTerm)),target:"_blank"},Object(a["toDisplayString"])(e.translate("CoreHome_SearchOnMatomo",e.searchTerm)),9,si)],34)])],512),[[a["vShow"],e.searchTerm&&e.searchActive]])],512)),[[s,{blur:e.onBlur}]])}function ui(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function di(e){for(var t=1;t=0&&t.left>=0&&t.bottom<=window.$(window).height()&&t.right<=window.$(window).width()}function mi(e){e&&e.scrollIntoView&&e.scrollIntoView()}var hi=Object(a["defineComponent"])({props:{},directives:{FocusAnywhereButHere:_e,FocusIf:qe},watch:{searchActive:function(e){var t=this.$refs.root.parentElement.classList;t.toggle("active",e),t.toggle("expanded",e)}},mounted:function(){var e=this;this.$refs.root.parentElement.classList.add("quick-access","piwikSelector"),"undefined"!==typeof window.initTopControls&&window.initTopControls&&window.initTopControls(),j.helper.registerShortcut("f",D("CoreHome_ShortcutSearch"),(function(t){t.altKey||(t.preventDefault(),mi(e.$refs.root),e.activateSearch())}))},data:function(){var e=!!document.querySelector(".segmentEditorPanel");return{menuItems:[],numMenuItems:0,searchActive:!1,searchTerm:"",searchIndex:0,menuIndexCounter:-1,topMenuItems:null,leftMenuItems:null,segmentItems:null,hasSegmentSelector:e,sites:[],isLoading:!1}},created:function(){this.searchMenu=Ur(this.searchMenu.bind(this))},computed:{hasSitesSelector:function(){return!!document.querySelector(".top_controls [piwik-siteselector]")},quickAccessTitle:function(){var e="",t=[D("CoreHome_MenuEntries")];this.hasSegmentSelector&&t.push(D("CoreHome_Segments")),this.hasSitesSelector&&t.push(D("SitesManager_Sites"));while(t.length)e+=t.shift(),t.length>=2?e+=", ":1===t.length&&(e+=" ".concat(D("General_And")," "));return D("CoreHome_QuickAccessTitle",e)}},emits:["itemSelected","blur"],methods:{onKeypress:function(e){var t=this,n=this.searchTerm&&this.searchActive,r=9===e.which,i=27===e.which;38===e.which?(this.highlightPreviousItem(),e.preventDefault()):40===e.which?(this.highlightNextItem(),e.preventDefault()):13===e.which?this.clickQuickAccessMenuItem():r&&n||i&&n?this.deactivateSearch():setTimeout((function(){t.searchActive=!0,t.searchMenu(t.searchTerm)}))},highlightPreviousItem:function(){this.searchIndex-1<0?this.searchIndex=0:this.searchIndex-=1,this.makeSureSelectedItemIsInViewport()},highlightNextItem:function(){var e=this.$refs.root.querySelectorAll("li.result").length;e<=this.searchIndex+1?this.searchIndex=e-1:this.searchIndex+=1,this.makeSureSelectedItemIsInViewport()},clickQuickAccessMenuItem:function(){var e=this,t=this.getCurrentlySelectedElement();t&&setTimeout((function(){t.click(),e.$emit("itemSelected",t)}),20)},deactivateSearch:function(){this.searchTerm="",this.searchActive=!1,this.$refs.root.querySelector("input").blur()},makeSureSelectedItemIsInViewport:function(){var e=this.getCurrentlySelectedElement();e&&!pi(e)&&mi(e)},getCurrentlySelectedElement:function(){var e=this.$refs.root.querySelectorAll("li.result");return e&&e.length&&e.item(this.searchIndex)?e.item(this.searchIndex):null},searchMenu:function(e){var t=this,n=e.toLowerCase(),r=-1,i={},a=[],o=function(e){var t=di({},e);r+=1,t.menuIndex=r;var n=t.category;n in i||(a.push({title:n,items:[]}),i[n]=a.length-1);var o=i[n];a[o].items.push(t)};this.resetSearchIndex(),this.hasSitesSelector&&(this.isLoading=!0,_r.searchSite(n).then((function(e){t.sites=e})).finally((function(){t.isLoading=!1})));var c=function(e){return-1!==e.name.toLowerCase().indexOf(n)||-1!==e.category.toLowerCase().indexOf(n)};null===this.topMenuItems&&(this.topMenuItems=this.getTopMenuItems()),null===this.leftMenuItems&&(this.leftMenuItems=this.getLeftMenuItems()),null===this.segmentItems&&(this.segmentItems=this.getSegmentItems());var s=this.topMenuItems.filter(c),l=this.leftMenuItems.filter(c),u=this.segmentItems.filter(c);s.forEach(o),l.forEach(o),u.forEach(o),this.numMenuItems=s.length+l.length+u.length,this.menuItems=a},resetSearchIndex:function(){this.searchIndex=0,this.makeSureSelectedItemIsInViewport()},selectSite:function(e){_r.loadSite(e)},selectMenuItem:function(e){var t=document.querySelector("[quick_access='".concat(e,"']"));if(t){this.deactivateSearch();var n=t.getAttribute("href");if(n&&n.length>10&&t&&t.click)try{t.click()}catch(r){window.$(t).click()}else window.$(t).click()}},onBlur:function(){this.searchActive=!1,this.$emit("blur")},activateSearch:function(){this.searchActive=!0},getTopMenuItems:function(){var e=this,t=D("CoreHome_Menu"),n=[];return document.querySelectorAll("nav .sidenav li > a").forEach((function(r){var i=r.textContent.trim();i||(i=r.getAttribute("title").trim()),i&&(n.push({name:i,index:e.menuIndexCounter+=1,category:t}),r.setAttribute("quick_access","".concat(e.menuIndexCounter)))})),n},getLeftMenuItems:function(){var e=this,t=[];return document.querySelectorAll("#secondNavBar .menuTab").forEach((function(n){var r=window.$(n).find("> .item").text().trim();r&&-1!==r.lastIndexOf("\n")&&(r=r.substr(0,r.lastIndexOf("\n")).trim()),window.$(n).find("li .item").each((function(n,i){var a=i.textContent.trim();a&&(t.push({name:a,category:r,index:e.menuIndexCounter+=1}),i.setAttribute("quick_access","".concat(e.menuIndexCounter)))}))})),t},getSegmentItems:function(){var e=this;if(!this.hasSegmentSelector)return[];var t=D("CoreHome_Segments"),n=[];return document.querySelectorAll(".segmentList [data-idsegment]").forEach((function(r){var i=r.querySelector(".segname").textContent.trim();i&&(n.push({name:i,category:t,index:e.menuIndexCounter+=1}),r.setAttribute("quick_access","".concat(e.menuIndexCounter)))})),n}}});hi.render=li;var vi=hi,gi=(wt({component:vi,directiveName:"piwikQuickAccess",events:{itemSelected:function(e,t,n,r,i,a,o){o()},blur:function(e,t,n){setTimeout((function(){return n.$apply()}))}}}),{class:"loadingPiwik"}),bi=Object(a["createElementVNode"])("img",{src:"plugins/Morpheus/images/loading-blue.gif",alt:""},null,-1); + */wt({component:Qr,require:"?ngModel",scope:{showSelectedSite:{angularJsBind:"="},showAllSitesItem:{angularJsBind:"="},switchSiteOnSelect:{angularJsBind:"="},onlySitesWithAdminAccess:{angularJsBind:"="},name:{angularJsBind:"@"},allSitesText:{angularJsBind:"@"},allSitesLocation:{angularJsBind:"@"},placeholder:{angularJsBind:"@"},modelValue:{}},$inject:["$timeout"],directiveName:"piwikSiteselector",events:{"update:modelValue":function(e,t,n,r,i,a){(e&&!t.modelValue||!e&&t.modelValue||e.id!==t.modelValue.id)&&(r.attr("siteid",e.id),r.trigger("change",e),a&&a.$setViewValue(e))},blur:function(e,t,n){setTimeout((function(){return n.$apply()}))}},postCreate:function(e,t,n,r,i,a){var o=i;o&&(o.$setViewValue(e.modelValue),o.$render=function(){angular.isString(o.$viewValue)?e.modelValue=JSON.parse(o.$viewValue):e.modelValue=o.$viewValue}),a((function(){r.siteid&&r.sitename&&(e.modelValue={id:r.siteid,name:j.helper.htmlDecode(r.sitename)},o.$setViewValue(Yr({},e.modelValue)))}))}});var Xr={ref:"root",class:"quickAccessInside"},Zr=["title"],ei={class:"dropdown"},ti={class:"no-result"},ni=["onClick"],ri=["onMouseenter","onClick"],ii={class:"quickAccessMatomoSearch"},ai=["onMouseenter","onClick"],oi=["textContent"],ci={class:"quick-access-category helpCategory"},si=["href"];function li(e,t,n,r,i,o){var c=Object(a["resolveDirective"])("focus-if"),s=Object(a["resolveDirective"])("focus-anywhere-but-here");return Object(a["withDirectives"])((Object(a["openBlock"])(),Object(a["createElementBlock"])("div",Xr,[Object(a["withDirectives"])(Object(a["createElementVNode"])("span",{class:"icon-search",onMouseenter:t[0]||(t[0]=function(t){return e.searchActive=!0})},null,544),[[a["vShow"],!(e.searchTerm||e.searchActive)]]),Object(a["withDirectives"])(Object(a["createElementVNode"])("input",{class:"s",onKeydown:t[1]||(t[1]=function(t){return e.onKeypress(t)}),onFocus:t[2]||(t[2]=function(t){return e.searchActive=!0}),"onUpdate:modelValue":t[3]||(t[3]=function(t){return e.searchTerm=t}),type:"text",tabindex:"2",title:e.quickAccessTitle},null,40,Zr),[[a["vModelText"],e.searchTerm],[c,{},e.searchActive]]),Object(a["withDirectives"])(Object(a["createElementVNode"])("div",ei,[Object(a["withDirectives"])(Object(a["createElementVNode"])("ul",null,[Object(a["createElementVNode"])("li",ti,Object(a["toDisplayString"])(e.translate("General_SearchNoResults")),1)],512),[[a["vShow"],!(e.numMenuItems>0||e.sites.length)]]),(Object(a["openBlock"])(!0),Object(a["createElementBlock"])(a["Fragment"],null,Object(a["renderList"])(e.menuItems,(function(t){return Object(a["openBlock"])(),Object(a["createElementBlock"])("ul",{key:t.title},[Object(a["createElementVNode"])("li",{class:"quick-access-category",onClick:function(n){e.searchTerm=t.title,e.searchMenu(e.searchTerm)}},Object(a["toDisplayString"])(t.title),9,ni),(Object(a["openBlock"])(!0),Object(a["createElementBlock"])(a["Fragment"],null,Object(a["renderList"])(t.items,(function(t){return Object(a["openBlock"])(),Object(a["createElementBlock"])("li",{class:Object(a["normalizeClass"])(["result",{selected:t.menuIndex===e.searchIndex}]),onMouseenter:function(n){return e.searchIndex=t.menuIndex},onClick:function(n){return e.selectMenuItem(t.index)},key:t.index},[Object(a["createElementVNode"])("a",null,Object(a["toDisplayString"])(t.name.trim()),1)],42,ri)})),128))])})),128)),Object(a["createElementVNode"])("ul",ii,[Object(a["withDirectives"])(Object(a["createElementVNode"])("li",{class:"quick-access-category websiteCategory"},Object(a["toDisplayString"])(e.translate("SitesManager_Sites")),513),[[a["vShow"],e.hasSitesSelector&&e.sites.length||e.isLoading]]),Object(a["withDirectives"])(Object(a["createElementVNode"])("li",{class:"no-result"},Object(a["toDisplayString"])(e.translate("MultiSites_LoadingWebsites")),513),[[a["vShow"],e.hasSitesSelector&&e.isLoading]]),(Object(a["openBlock"])(!0),Object(a["createElementBlock"])(a["Fragment"],null,Object(a["renderList"])(e.sites,(function(t,n){return Object(a["withDirectives"])((Object(a["openBlock"])(),Object(a["createElementBlock"])("li",{class:Object(a["normalizeClass"])(["result",{selected:e.numMenuItems+n===e.searchIndex}]),onMouseenter:function(t){return e.searchIndex=e.numMenuItems+n},onClick:function(n){return e.selectSite(t.idsite)},key:t.idsite},[Object(a["createElementVNode"])("a",{textContent:Object(a["toDisplayString"])(t.name)},null,8,oi)],42,ai)),[[a["vShow"],e.hasSitesSelector&&!e.isLoading]])})),128))]),Object(a["createElementVNode"])("ul",null,[Object(a["createElementVNode"])("li",ci,Object(a["toDisplayString"])(e.translate("General_HelpResources")),1),Object(a["createElementVNode"])("li",{class:Object(a["normalizeClass"])([{selected:"help"===e.searchIndex},"quick-access-help"]),onMouseenter:t[4]||(t[4]=function(t){return e.searchIndex="help"})},[Object(a["createElementVNode"])("a",{href:"https://matomo.org?s=".concat(encodeURIComponent(e.searchTerm)),target:"_blank"},Object(a["toDisplayString"])(e.translate("CoreHome_SearchOnMatomo",e.searchTerm)),9,si)],34)])],512),[[a["vShow"],e.searchTerm&&e.searchActive]])],512)),[[s,{blur:e.onBlur}]])}function ui(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function di(e){for(var t=1;t=0&&t.left>=0&&t.bottom<=window.$(window).height()&&t.right<=window.$(window).width()}function mi(e){e&&e.scrollIntoView&&e.scrollIntoView()}var hi=Object(a["defineComponent"])({props:{},directives:{FocusAnywhereButHere:_e,FocusIf:qe},watch:{searchActive:function(e){var t=this.$refs.root.parentElement.classList;t.toggle("active",e),t.toggle("expanded",e)}},mounted:function(){var e=this;this.$refs.root.parentElement.classList.add("quick-access","piwikSelector"),"undefined"!==typeof window.initTopControls&&window.initTopControls&&window.initTopControls(),j.helper.registerShortcut("f",D("CoreHome_ShortcutSearch"),(function(t){t.altKey||(t.preventDefault(),mi(e.$refs.root),e.activateSearch())}))},data:function(){var e=!!document.querySelector(".segmentEditorPanel");return{menuItems:[],numMenuItems:0,searchActive:!1,searchTerm:"",searchIndex:0,menuIndexCounter:-1,topMenuItems:null,leftMenuItems:null,segmentItems:null,hasSegmentSelector:e,sites:[],isLoading:!1}},created:function(){this.searchMenu=Ur(this.searchMenu.bind(this))},computed:{hasSitesSelector:function(){return!!document.querySelector(".top_controls [piwik-siteselector]")},quickAccessTitle:function(){var e="",t=[D("CoreHome_MenuEntries")];this.hasSegmentSelector&&t.push(D("CoreHome_Segments")),this.hasSitesSelector&&t.push(D("SitesManager_Sites"));while(t.length)e+=t.shift(),t.length>=2?e+=", ":1===t.length&&(e+=" ".concat(D("General_And")," "));return D("CoreHome_QuickAccessTitle",e)}},emits:["itemSelected","blur"],methods:{onKeypress:function(e){var t=this,n=this.searchTerm&&this.searchActive,r=9===e.which,i=27===e.which;38===e.which?(this.highlightPreviousItem(),e.preventDefault()):40===e.which?(this.highlightNextItem(),e.preventDefault()):13===e.which?this.clickQuickAccessMenuItem():r&&n||i&&n?this.deactivateSearch():setTimeout((function(){t.searchActive=!0,t.searchMenu(t.searchTerm)}))},highlightPreviousItem:function(){this.searchIndex-1<0?this.searchIndex=0:this.searchIndex-=1,this.makeSureSelectedItemIsInViewport()},highlightNextItem:function(){var e=this.$refs.root.querySelectorAll("li.result").length;e<=this.searchIndex+1?this.searchIndex=e-1:this.searchIndex+=1,this.makeSureSelectedItemIsInViewport()},clickQuickAccessMenuItem:function(){var e=this,t=this.getCurrentlySelectedElement();t&&setTimeout((function(){t.click(),e.$emit("itemSelected",t)}),20)},deactivateSearch:function(){this.searchTerm="",this.searchActive=!1,this.$refs.root.querySelector("input").blur()},makeSureSelectedItemIsInViewport:function(){var e=this.getCurrentlySelectedElement();e&&!pi(e)&&mi(e)},getCurrentlySelectedElement:function(){var e=this.$refs.root.querySelectorAll("li.result");return e&&e.length&&e.item(this.searchIndex)?e.item(this.searchIndex):null},searchMenu:function(e){var t=this,n=e.toLowerCase(),r=-1,i={},a=[],o=function(e){var t=di({},e);r+=1,t.menuIndex=r;var n=t.category;n in i||(a.push({title:n,items:[]}),i[n]=a.length-1);var o=i[n];a[o].items.push(t)};this.resetSearchIndex(),this.hasSitesSelector&&(this.isLoading=!0,_r.searchSite(n).then((function(e){t.sites=e})).finally((function(){t.isLoading=!1})));var c=function(e){return-1!==e.name.toLowerCase().indexOf(n)||-1!==e.category.toLowerCase().indexOf(n)};null===this.topMenuItems&&(this.topMenuItems=this.getTopMenuItems()),null===this.leftMenuItems&&(this.leftMenuItems=this.getLeftMenuItems()),null===this.segmentItems&&(this.segmentItems=this.getSegmentItems());var s=this.topMenuItems.filter(c),l=this.leftMenuItems.filter(c),u=this.segmentItems.filter(c);s.forEach(o),l.forEach(o),u.forEach(o),this.numMenuItems=s.length+l.length+u.length,this.menuItems=a},resetSearchIndex:function(){this.searchIndex=0,this.makeSureSelectedItemIsInViewport()},selectSite:function(e){_r.loadSite(e)},selectMenuItem:function(e){var t=document.querySelector("[quick_access='".concat(e,"']"));if(t){this.deactivateSearch();var n=t.getAttribute("href");if(n&&n.length>10&&t&&t.click)try{t.click()}catch(r){window.$(t).click()}else window.$(t).click()}},onBlur:function(){this.searchActive=!1,this.$emit("blur")},activateSearch:function(){this.searchActive=!0},getTopMenuItems:function(){var e=this,t=D("CoreHome_Menu"),n=[];return document.querySelectorAll("nav .sidenav li > a").forEach((function(r){var i=r.textContent.trim();i||(i=r.getAttribute("title").trim()),i&&(n.push({name:i,index:e.menuIndexCounter+=1,category:t}),r.setAttribute("quick_access","".concat(e.menuIndexCounter)))})),n},getLeftMenuItems:function(){var e=this,t=[];return document.querySelectorAll("#secondNavBar .menuTab").forEach((function(n){var r=window.$(n).find("> .item").text().trim();r&&-1!==r.lastIndexOf("\n")&&(r=r.substr(0,r.lastIndexOf("\n")).trim()),window.$(n).find("li .item").each((function(n,i){var a=i.textContent.trim();a&&(t.push({name:a,category:r,index:e.menuIndexCounter+=1}),i.setAttribute("quick_access","".concat(e.menuIndexCounter)))}))})),t},getSegmentItems:function(){var e=this;if(!this.hasSegmentSelector)return[];var t=D("CoreHome_Segments"),n=[];return document.querySelectorAll(".segmentList [data-idsegment]").forEach((function(r){var i=r.querySelector(".segname").textContent.trim();i&&(n.push({name:i,category:t,index:e.menuIndexCounter+=1}),r.setAttribute("quick_access","".concat(e.menuIndexCounter)))})),n}}});hi.render=li;var vi=hi,gi=(wt({component:vi,directiveName:"piwikQuickAccess",events:{itemSelected:function(e,t,n,r,i,a,o){o()},blur:function(e,t,n){setTimeout((function(){return n.$apply()}))}}}),{class:"loadingPiwik"}),bi=Object(a["createElementVNode"])("img",{src:"plugins/Morpheus/images/loading-blue.gif",alt:""},null,-1); /*! * Matomo - free/libre analytics platform * @@ -274,14 +274,14 @@ function ot(){return{restrict:"A",link:function(e,t){var n={instance:null,value: * * @link https://matomo.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later - */var Qi=function(){function e(){qi(this,e),zi(this,"privateState",Object(a["reactive"])({notifications:[]})),zi(this,"nextNotificationId",0)}return Gi(e,[{key:"state",get:function(){return this.privateState}},{key:"appendNotification",value:function(e){this.checkMessage(e.message),e.id&&this.remove(e.id),this.privateState.notifications.push(e)}},{key:"prependNotification",value:function(e){this.checkMessage(e.message),e.id&&this.remove(e.id),this.privateState.notifications.unshift(e)}},{key:"remove",value:function(e){this.privateState.notifications=this.privateState.notifications.filter((function(t){return t.id!==e}))}},{key:"parseNotificationDivs",value:function(){var e=this,t=$('[data-role="notification"]'),n=[];t.each((function(e,r){var i=$(r),a=i.data(),o=i.html();o&&n.push(Ui(Ui({},a),{},{message:o,animate:!1})),t.remove()})),n.forEach((function(t){return e.show(t)}))}},{key:"clearTransientNotifications",value:function(){this.privateState.notifications=this.privateState.notifications.filter((function(e){return"transient"!==e.type}))}},{key:"show",value:function(e){this.checkMessage(e.message);var t=this.appendNotification,n="#notificationContainer";if(e.placeat)n=e.placeat;else{var r=".modal.open .modal-content";document.querySelector(r)&&(n=r,t=this.prependNotification)}var i=e.group||(e.placeat?e.placeat.toString():"");this.initializeNotificationContainer(n,i);var a=(this.nextNotificationId+=1).toString();return t.call(this,Ui(Ui({},e),{},{noclear:!!e.noclear,group:i,notificationId:e.id,notificationInstanceId:a,type:e.type||"transient"})),a}},{key:"scrollToNotification",value:function(e){setTimeout((function(){var t=document.querySelector("[data-notification-instance-id='".concat(e,"']"));t&&j.helper.lazyScrollTo(t,250)}))}},{key:"toast",value:function(e){this.checkMessage(e.message);var t=$(e.placeat);if(!t.length)throw new Error("A valid selector is required for the placeat option when using Notification.toast().");var n=document.createElement("div");n.style.position="absolute",n.style.top="".concat(t.offset().top,"px"),n.style.left="".concat(t.offset().left,"px"),n.style.zIndex="1000",document.body.appendChild(n);var r=Object(a["createApp"])({render:function(){return Object(a["createVNode"])(_i,Ui(Ui({},e),{},{notificationId:e.id,type:"toast",onClosed:function(){r.unmount()}}))}});r.config.globalProperties.$sanitize=window.vueSanitize,r.config.globalProperties.translate=D,r.mount(n)}},{key:"initializeNotificationContainer",value:function(e,t){var n=window.$(e);if(!n.children(".notification-group").length){var r=window.CoreHome.NotificationGroup,i=Object(a["createApp"])({template:'',data:function(){return{group:t}}});i.config.globalProperties.$sanitize=window.vueSanitize,i.config.globalProperties.translate=D,i.component("NotificationGroup",r),i.mount(n[0])}}},{key:"checkMessage",value:function(e){if(!e)throw new Error("No message given, cannot display notification")}}]),e}(),Ki=new Qi,Wi=Ki;$((function(){return Ki.parseNotificationDivs()})), + */var Qi=function(){function e(){qi(this,e),zi(this,"privateState",Object(a["reactive"])({notifications:[]})),zi(this,"nextNotificationId",0)}return Gi(e,[{key:"state",get:function(){return this.privateState}},{key:"appendNotification",value:function(e){this.checkMessage(e.message),e.id&&this.remove(e.id),this.privateState.notifications.push(e)}},{key:"prependNotification",value:function(e){this.checkMessage(e.message),e.id&&this.remove(e.id),this.privateState.notifications.unshift(e)}},{key:"remove",value:function(e){this.privateState.notifications=this.privateState.notifications.filter((function(t){return t.id!==e}))}},{key:"parseNotificationDivs",value:function(){var e=this,t=$('[data-role="notification"]'),n=[];t.each((function(e,r){var i=$(r),a=i.data(),o=i.html();o&&n.push(Ui(Ui({},a),{},{message:o,animate:!1})),t.remove()})),n.forEach((function(t){return e.show(t)}))}},{key:"clearTransientNotifications",value:function(){this.privateState.notifications=this.privateState.notifications.filter((function(e){return"transient"!==e.type}))}},{key:"show",value:function(e){this.checkMessage(e.message);var t=this.appendNotification,n="#notificationContainer";if(e.placeat)n=e.placeat;else{var r=".modal.open .modal-content";document.querySelector(r)&&(n=r,t=this.prependNotification)}var i=e.group||(e.placeat?e.placeat.toString():"");this.initializeNotificationContainer(n,i);var a=(this.nextNotificationId+=1).toString();return t.call(this,Ui(Ui({},e),{},{noclear:!!e.noclear,group:i,notificationId:e.id,notificationInstanceId:a,type:e.type||"transient"})),a}},{key:"scrollToNotification",value:function(e){setTimeout((function(){var t=document.querySelector("[data-notification-instance-id='".concat(e,"']"));t&&j.helper.lazyScrollTo(t,250)}))}},{key:"toast",value:function(e){this.checkMessage(e.message);var t=$(e.placeat);if(!t.length)throw new Error("A valid selector is required for the placeat option when using Notification.toast().");var n=document.createElement("div");n.style.position="absolute",n.style.top="".concat(t.offset().top,"px"),n.style.left="".concat(t.offset().left,"px"),n.style.zIndex="1000",document.body.appendChild(n);var r=Object(a["createApp"])({render:function(){return Object(a["createVNode"])(_i,Ui(Ui({},e),{},{notificationId:e.id,type:"toast",onClosed:function(){r.unmount()}}))}});r.config.globalProperties.$sanitize=window.vueSanitize,r.config.globalProperties.translate=D,r.mount(n)}},{key:"initializeNotificationContainer",value:function(e,t){var n=window.$(e);if(!n.children(".notification-group").length){var r=window.CoreHome.NotificationGroup,i=Object(a["createApp"])({template:'',data:function(){return{group:t}}});i.config.globalProperties.$sanitize=window.vueSanitize,i.config.globalProperties.translate=D,i.component("NotificationGroup",r),i.mount(n[0])}}},{key:"checkMessage",value:function(e){if(!e)throw new Error("No message given, cannot display notification")}}]),e}(),Wi=new Qi,Yi=Wi;$((function(){return Wi.parseNotificationDivs()})), /*! * Matomo - free/libre analytics platform * * @link https://matomo.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ -angular.module("piwikApp").factory("notifications",(function(){return Wi}));var Yi={class:"notification-group"},Xi=["innerHTML"];function Zi(e,t,n,r,i,o){var c=Object(a["resolveComponent"])("Notification");return Object(a["openBlock"])(),Object(a["createElementBlock"])("div",Yi,[(Object(a["openBlock"])(!0),Object(a["createElementBlock"])(a["Fragment"],null,Object(a["renderList"])(e.notifications,(function(t,n){return Object(a["openBlock"])(),Object(a["createBlock"])(c,{key:t.id||"no-id-".concat(n),"notification-id":t.id,title:t.title,context:t.context,type:t.type,noclear:t.noclear,"toast-length":t.toastLength,style:Object(a["normalizeStyle"])(t.style),animate:t.animate,message:t.message,"notification-instance-id":t.notificationInstanceId,"css-class":t.class,onClosed:function(n){return e.removeNotification(t.id)}},{default:Object(a["withCtx"])((function(){return[Object(a["createElementVNode"])("div",{innerHTML:e.$sanitize(t.message)},null,8,Xi)]})),_:2},1032,["notification-id","title","context","type","noclear","toast-length","style","animate","message","notification-instance-id","css-class","onClosed"])})),128))])}var ea=Object(a["defineComponent"])({props:{group:String},components:{Notification:_i},computed:{notifications:function(){var e=this;return Wi.state.notifications.filter((function(t){return e.group?e.group===t.group:!t.group}))}},methods:{removeNotification:function(e){Wi.remove(e)}}});ea.render=Zi;var ta=ea; +angular.module("piwikApp").factory("notifications",(function(){return Yi}));var Ki={class:"notification-group"},Xi=["innerHTML"];function Zi(e,t,n,r,i,o){var c=Object(a["resolveComponent"])("Notification");return Object(a["openBlock"])(),Object(a["createElementBlock"])("div",Ki,[(Object(a["openBlock"])(!0),Object(a["createElementBlock"])(a["Fragment"],null,Object(a["renderList"])(e.notifications,(function(t,n){return Object(a["openBlock"])(),Object(a["createBlock"])(c,{key:t.id||"no-id-".concat(n),"notification-id":t.id,title:t.title,context:t.context,type:t.type,noclear:t.noclear,"toast-length":t.toastLength,style:Object(a["normalizeStyle"])(t.style),animate:t.animate,message:t.message,"notification-instance-id":t.notificationInstanceId,"css-class":t.class,onClosed:function(n){return e.removeNotification(t.id)}},{default:Object(a["withCtx"])((function(){return[Object(a["createElementVNode"])("div",{innerHTML:e.$sanitize(t.message)},null,8,Xi)]})),_:2},1032,["notification-id","title","context","type","noclear","toast-length","style","animate","message","notification-instance-id","css-class","onClosed"])})),128))])}var ea=Object(a["defineComponent"])({props:{group:String},components:{Notification:_i},computed:{notifications:function(){var e=this;return Yi.state.notifications.filter((function(t){return e.group?e.group===t.group:!t.group}))}},methods:{removeNotification:function(e){Yi.remove(e)}}});ea.render=Zi;var ta=ea; /*! * Matomo - free/libre analytics platform * diff --git a/plugins/CoreHome/vue/src/SiteSelector/SiteSelector.vue b/plugins/CoreHome/vue/src/SiteSelector/SiteSelector.vue index 52884f6815..32369de3bb 100644 --- a/plugins/CoreHome/vue/src/SiteSelector/SiteSelector.vue +++ b/plugins/CoreHome/vue/src/SiteSelector/SiteSelector.vue @@ -53,7 +53,6 @@ type="text" @click="searchTerm = '';loadInitialSites()" v-model="searchTerm" - @keydown="onSearchInputKeydown()" tabindex="4" class="websiteSearch inp browser-default" v-focus-if:[shouldFocusOnSearch]="{}" @@ -193,6 +192,9 @@ export default defineComponent({ FocusIf, }, watch: { + searchTerm() { + this.onSearchTermChanged(); + }, modelValue: { handler(newValue) { this.selectedSite = { ...newValue }; @@ -238,9 +240,6 @@ export default defineComponent({ this.$refs.selectorLink.focus(); }); }, - created() { - this.onSearchInputKeydown = debounce(this.onSearchInputKeydown.bind(this)); - }, computed: { shouldFocusOnSearch() { return (this.showSitesList && this.autocompleteMinSites <= this.sites.length) @@ -268,7 +267,19 @@ export default defineComponent({ return `?${newQuery}`; }, }, + created() { + this.searchSite = debounce(this.searchSite.bind(this)); + }, methods: { + onSearchTermChanged() { + if (!this.searchTerm) { + this.isLoading = false; + this.loadInitialSites(); + } else { + this.isLoading = true; + this.searchSite(this.searchTerm); + } + }, onAllSitesClick(event: MouseEvent) { this.switchSite({ idsite: 'all', name: this.allSitesText }, event); this.showSitesList = false; @@ -316,14 +327,11 @@ export default defineComponent({ this.loadInitialSites(); } }, - onSearchInputKeydown() { - setTimeout(() => { - this.searchSite(this.searchTerm); - }); - }, getMatchedSiteName(siteName: string) { const index = siteName.toUpperCase().indexOf(this.searchTerm.toUpperCase()); - if (index === -1) { + if (index === -1 + || this.isLoading // only highlight when we know the displayed results are for a search + ) { return Matomo.helper.htmlEntities(siteName); } @@ -343,6 +351,10 @@ export default defineComponent({ this.isLoading = true; SitesStore.searchSite(term, this.onlySitesWithAdminAccess).then((sites) => { + if (term !== this.searchTerm) { + return; // search term changed in the meantime + } + if (sites) { this.sites = sites; } diff --git a/plugins/CoreHome/vue/src/SiteSelector/SitesStore.ts b/plugins/CoreHome/vue/src/SiteSelector/SitesStore.ts index 655803843c..120df541c1 100644 --- a/plugins/CoreHome/vue/src/SiteSelector/SitesStore.ts +++ b/plugins/CoreHome/vue/src/SiteSelector/SitesStore.ts @@ -70,11 +70,6 @@ class SitesStore { this.currentRequest.abort(); } - if (this.limitRequest) { - this.limitRequest.abort(); - this.limitRequest = null; - } - if (!this.limitRequest) { this.limitRequest = AjaxHelper.fetch({ method: 'SitesManager.getNumWebsitesToDisplayPerPage' }); } -- cgit v1.2.3