// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPLv3-or-later var jotcache = ""; //The jot cache. We use it as cache to restore old/original jot content $(document).ready(function () { // Destroy unused perfect scrollbar in aside element $("aside").perfectScrollbar("destroy"); //fade in/out based on scrollTop value var scrollStart; $(window).scroll(function () { let currentScroll = $(this).scrollTop(); // Top of the page or going down = hide the button if (!scrollStart || !currentScroll || currentScroll > scrollStart) { $("#back-to-top").fadeOut(); scrollStart = currentScroll; } // Going up enough = show the button if (scrollStart - currentScroll > 100) { $("#back-to-top").fadeIn(); scrollStart = currentScroll; } }); // scroll body to 0px on click $("#back-to-top").click(function () { $("body,html").animate( { scrollTop: 0, }, 400, ); return false; }); // add the class "selected" to group widgets li if li > a does have the class group-selected if ($("#sidebar-group-ul li a").hasClass("group-selected")) { $("#sidebar-group-ul li a.group-selected").parent("li").addClass("selected"); } // add the class "selected" to forums widgets li if li > a does have the class forum-selected if ($("#forumlist-sidebar-ul li a").hasClass("forum-selected")) { $("#forumlist-sidebar-ul li a.forum-selected").parent("li").addClass("selected"); } // add the class "active" to tabmenuli if li > a does have the class active if ($("#tabmenu ul li a").hasClass("active")) { $("#tabmenu ul li a.active").parent("li").addClass("active"); } // give select fields Bootstrap classes // @todo: this needs to be changed in friendica core $(".field.select, .field.custom").addClass("form-group"); $(".field.select > select, .field.custom > select").addClass("form-control"); // move the tabbar to the second nav bar $("section .tabbar-wrapper").first().appendTo("#topbar-second > .container > #tabmenu"); // add mask css url to the logo-img container // // This is for firefox - we use a mask which looks like the friendica logo to apply user colors // to the friendica logo (the mask is in nav.tpl at the bottom). To make it work we need to apply the // correct url. The only way which comes to my mind was to do this with js // So we apply the correct url (with the link to the id of the mask) after the page is loaded. if ($("#logo-img").length) { var pageurl = "url('" + window.location.href + "#logo-mask')"; $("#logo-img").css({ mask: pageurl }); } // make responsive tabmenu with flexmenu.js // the menupoints which doesn't fit in the second nav bar will moved to a // dropdown menu. Look at common_tabs.tpl $("ul.tabs.flex-nav").flexMenu({ cutoff: 2, popupClass: "dropdown-menu pull-right", popupAbsolute: false, target: ".flex-target", }); // add Jot button to the second navbar let $jotButton = $("#jotOpen"); if ($jotButton.length) { $jotButton.appendTo("#topbar-second > .container > #navbar-button"); if ($("#jot-popup").is(":hidden")) { $jotButton.hide(); } if ($jotButton.hasClass('modal-open')) { $jotButton.on("click", function (e) { e.preventDefault(); jotShow(); }); } } let $body = $("body"); // show bulk deletion button at network page if checkbox is checked $body.change("input.item-select", function () { var checked = false; // We need to get all checked items, so it would close the delete button // if we uncheck one item and others are still checked. // So return checked = true if there is any checked item $("input.item-select").each(function () { if ($(this).is(":checked")) { checked = true; return false; } }); if (checked) { $("#item-delete-selected").fadeTo(400, 1); $("#item-delete-selected").show(); } else { $("#item-delete-selected").fadeTo(400, 0, function () { $("#item-delete-selected").hide(); }); } }); // initialize the Bootstrap tooltips $body.tooltip({ selector: '[data-toggle="tooltip"]', container: "body", animation: true, html: true, placement: "auto", trigger: "hover", delay: { show: 500, hide: 100, }, sanitizeFn: function (content) { return DOMPurify.sanitize(content); }, }); // initialize the bootstrap-select $(".selectpicker").selectpicker(); // add search-heading to the second navbar if ($(".search-heading").length) { $(".search-heading").appendTo("#topbar-second > .container > #tabmenu"); } // add search results heading to the second navbar // and insert the search value to the top nav search input if ($(".search-content-wrapper").length) { // get the text of the heading (we catch the plain text because we don't // want to have a h4 heading in the navbar var searchText = $(".section-title-wrapper > h2").html(); // temporary workaround to avoid 'undefined' being displayed (issue #9789) // https://github.com/friendica/friendica/issues/9789 // TODO: find a way to localize this string if (typeof searchText === "undefined") { searchText = "No results"; } // insert the plain text in a