aboutsummaryrefslogtreecommitdiff
path: root/p/scripts
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2018-12-16 15:04:46 +0100
committerGravatar GitHub <noreply@github.com> 2018-12-16 15:04:46 +0100
commite0e96d6a13788c539be1bcce3cde0a1d614ff2c3 (patch)
treec95761c1858b3624c7f1c829f83c8374a9c146d0 /p/scripts
parent49869882e6f68ccf54f86567c56a1ab90829090b (diff)
Remove simple-scrollbar fallback (#2182)
https://github.com/FreshRSS/FreshRSS/pull/2181#issuecomment-447636787
Diffstat (limited to 'p/scripts')
-rw-r--r--p/scripts/main.js71
-rw-r--r--p/scripts/simple-scrollbar.min.js2
2 files changed, 4 insertions, 69 deletions
diff --git a/p/scripts/main.js b/p/scripts/main.js
index c8d520ef7..4ba329dc1 100644
--- a/p/scripts/main.js
+++ b/p/scripts/main.js
@@ -1,5 +1,5 @@
"use strict";
-/* globals $, jQuery, context, i18n, shortcut, shortcuts, SimpleScrollbar, url */
+/* globals $, jQuery, context, i18n, shortcut, shortcuts, url */
/* jshint strict:global */
var $stream = null,
@@ -527,14 +527,6 @@ function init_posts() {
}
}
-function inject_script(name) {
- var script = document.createElement('script');
- script.async = 'async';
- script.defer = 'defer';
- script.src = '../scripts/' + name;
- document.head.appendChild(script);
-}
-
function init_column_categories() {
if (context.current_view !== 'normal' && context.current_view !== 'reader') {
return;
@@ -551,15 +543,13 @@ function init_column_categories() {
}
});
$(this).parent().next(".tree-folder-items").slideToggle(300, function () {
- if (!useJsScrollbar && //Workaround for Gecko bug in Firefox 64-65(+?):
- sidebar.scrollHeight > sidebar.clientHeight && //if needs scrollbar
+ //Workaround for Gecko bug in Firefox 64-65(+?):
+ var sidebar = document.getElementById('sidebar');
+ if (sidebar && sidebar.scrollHeight > sidebar.clientHeight && //if needs scrollbar
sidebar.scrollWidth >= sidebar.offsetWidth) { //but no scrollbar
sidebar.style['overflow-y'] = 'scroll'; //then force scrollbar
setTimeout(function () { sidebar.style['overflow-y'] = ''; }, 0);
}
- if (useJsScrollbar && typeof(Event) === 'function') { //Refresh JS scrollbar
- sidebar.querySelector('.ss-content').dispatchEvent(new Event('scroll'));
- }
});
return false;
});
@@ -1280,58 +1270,6 @@ function init_crypto_form() {
}
//</crypto form (Web login)>
-var sidebar = document.getElementById('sidebar');
-var useJsScrollbar = true;
-try {
- /*jshint -W018 */
- useJsScrollbar = sidebar && !CSS.supports('scrollbar-color: auto') &&
- !(parseInt(getComputedStyle(sidebar, '::-webkit-scrollbar').width) < sidebar.scrollWidth);
- /*jshint +W018 */
-} catch (ex) {
-}
-if (useJsScrollbar) {
- inject_script('simple-scrollbar.min.js');
-}
-
-function sticky_recalc() {
- var h = 0;
- if ($nav_entries && $nav_entries.length > 0) {
- h = $(window).height() - sidebar.getBoundingClientRect().top - $nav_entries.height();
- } else {
- h = $(window).height() - sidebar.getBoundingClientRect().top;
- }
- if (h > 0) {
- $(sidebar).height(h);
- }
-}
-
-function init_simple_scrollbar() {
- if (!window.SimpleScrollbar) {
- if (window.console) {
- console.log('FreshRSS waiting for simple-scrollbar…');
- }
- window.setTimeout(init_simple_scrollbar, 100);
- } else {
- SimpleScrollbar.initEl(sidebar);
- }
-}
-
-var scrollTimeout;
-function init_sticky_sidebar(){
- if (!useJsScrollbar) {
- return;
- }
- init_simple_scrollbar();
- $(window).scroll(function () {
- if (scrollTimeout) {
- clearTimeout(scrollTimeout);
- scrollTimeout = null;
- }
- scrollTimeout = setTimeout(sticky_recalc, 200);
- });
- window.onresize = sticky_recalc;
-}
-
function init_confirm_action() {
$('body').on('click', '.confirm', function () {
var str_confirmation = $(this).attr('data-str-confirm');
@@ -1597,7 +1535,6 @@ function init_afterDOM() {
$stream = $('#stream');
if ($stream.length > 0) {
init_load_more($stream);
- init_sticky_sidebar();
init_posts();
init_nav_entries();
init_dynamic_tags();
diff --git a/p/scripts/simple-scrollbar.min.js b/p/scripts/simple-scrollbar.min.js
deleted file mode 100644
index 36b7df0b8..000000000
--- a/p/scripts/simple-scrollbar.min.js
+++ /dev/null
@@ -1,2 +0,0 @@
-// https://github.com/buzinas/simple-scrollbar
-!function(t,e){"object"==typeof exports?module.exports=e(window,document):t.SimpleScrollbar=e(window,document)}(this,function(t,e){function s(t){Object.prototype.hasOwnProperty.call(t,"data-simple-scrollbar")||Object.defineProperty(t,"data-simple-scrollbar",{value:new o(t)})}function i(t,s){function i(t){var e=t.pageY-a;a=t.pageY,n(function(){s.el.scrollTop+=e/s.scrollRatio})}function r(){t.classList.remove("ss-grabbed"),e.body.classList.remove("ss-grabbed"),e.removeEventListener("mousemove",i),e.removeEventListener("mouseup",r)}var a;t.addEventListener("mousedown",function(s){return a=s.pageY,t.classList.add("ss-grabbed"),e.body.classList.add("ss-grabbed"),e.addEventListener("mousemove",i),e.addEventListener("mouseup",r),!1})}function r(t){for(this.target=t,this.direction=window.getComputedStyle(this.target).direction,this.bar='<div class="ss-scroll">',this.wrapper=e.createElement("div"),this.wrapper.setAttribute("class","ss-wrapper"),this.el=e.createElement("div"),this.el.setAttribute("class","ss-content"),"rtl"===this.direction&&this.el.classList.add("rtl"),this.wrapper.appendChild(this.el);this.target.firstChild;)this.el.appendChild(this.target.firstChild);this.target.appendChild(this.wrapper),this.target.insertAdjacentHTML("beforeend",this.bar),this.bar=this.target.lastChild,i(this.bar,this),this.moveBar(),this.el.addEventListener("scroll",this.moveBar.bind(this)),this.el.addEventListener("mouseenter",this.moveBar.bind(this)),this.target.classList.add("ss-container");var s=window.getComputedStyle(t);"0px"===s.height&&"0px"!==s["max-height"]&&(t.style.height=s["max-height"])}function a(){for(var t=e.querySelectorAll("*[ss-container]"),i=0;i<t.length;i++)s(t[i])}var n=t.requestAnimationFrame||t.setImmediate||function(t){return setTimeout(t,0)};r.prototype={moveBar:function(t){var e=this.el.scrollHeight,s=this.el.clientHeight,i=this;this.scrollRatio=s/e;var r="rtl"===i.direction,a=r?i.target.clientWidth-i.bar.clientWidth+18:-1*(i.target.clientWidth-i.bar.clientWidth);n(function(){i.scrollRatio>=1?i.bar.classList.add("ss-hidden"):(i.bar.classList.remove("ss-hidden"),i.bar.style.cssText="height:"+Math.max(100*i.scrollRatio,10)+"%; top:"+i.el.scrollTop/e*100+"%;right:"+a+"px;")})}},e.addEventListener("DOMContentLoaded",a),r.initEl=s,r.initAll=a;var o=r;return o}); \ No newline at end of file