var jotcache = ''; //The jot cache. We use it as cache to restore old/original jot content $(document).ready(function(){ //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 widges 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 widges li if li > a does have the class forum-selected if( $("#forumlist-sidbar-ul li a").hasClass("forum-selected")) { $("#forumlist-sidbar-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 an boostrap 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 collers // to the friendica logo (the mask is in nav.tpl at the botom). 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(); } $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(); }); } }); //$('ul.flex-nav').flexMenu(); // 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 seccond 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").text(); // insert the plain text in a