Skip to content

Commit a180485

Browse files
committed
sticky-kit fix, and compatible async defer
And set correct parent option #1172
1 parent 0c4add6 commit a180485

File tree

3 files changed

+31
-10
lines changed

3 files changed

+31
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* Fixed Apache Etag issue that prevented caching [#1199](https://github.com/FreshRSS/FreshRSS/pull/1199)
2121
* Fixed OPML import of categories [#1202](https://github.com/FreshRSS/FreshRSS/issues/1202)
2222
* UI
23+
* Use sticky category column [#1172](https://github.com/FreshRSS/FreshRSS/pull/1172)
2324
* Updated to jQuery 3.1.0 and several JavaScript fixes (e.g. drag & drop) [#1197](https://github.com/FreshRSS/FreshRSS/pull/1197)
2425
* API
2526
* Add API link in FreshRSS profile settings to ease set-up [#1186](https://github.com/FreshRSS/FreshRSS/pull/1186)

app/FreshRSS.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ public static function loadStylesAndScripts() {
9595
}
9696
}
9797

98-
Minz_View::appendScript(Minz_Url::display('/scripts/jquery.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/jquery.min.js')),false,false,false);
99-
Minz_View::appendScript(Minz_Url::display('/scripts/jquery.sticky-kit.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/jquery.sticky-kit.min.js')));
98+
Minz_View::appendScript(Minz_Url::display('/scripts/jquery.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/jquery.min.js')));
10099
Minz_View::appendScript(Minz_Url::display('/scripts/shortcut.js?' . @filemtime(PUBLIC_PATH . '/scripts/shortcut.js')));
101100
Minz_View::appendScript(Minz_Url::display('/scripts/main.js?' . @filemtime(PUBLIC_PATH . '/scripts/main.js')));
102101
}

p/scripts/main.js

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,27 @@ function init_posts() {
493493
}
494494
}
495495

496+
function inject_script(name) {
497+
var script = document.createElement('script');
498+
script.async = 'async';
499+
script.defer = 'defer';
500+
script.src = '../scripts/' + name;
501+
document.head.appendChild(script);
502+
}
503+
504+
function init_sticky_column() {
505+
if (!window.$ || !window.$.fn.stick_in_parent) {
506+
if (window.console) {
507+
console.log('FreshRSS waiting for Sticky-kit…');
508+
}
509+
window.setTimeout(init_sticky_column, 200);
510+
return;
511+
}
512+
if ($('.toggle_aside').css('display') === 'none') {
513+
$('#aside_feed .tree').stick_in_parent({parent:'#aside_feed'});
514+
}
515+
}
516+
496517
function init_column_categories() {
497518
if (context.current_view !== 'normal') {
498519
return;
@@ -508,7 +529,7 @@ function init_column_categories() {
508529
this.alt = '▽';
509530
}
510531
});
511-
$(this).parent().next(".tree-folder-items").slideToggle( 400 , function() { $(document.body).trigger("sticky_kit:recalc"); } );
532+
$(this).parent().next(".tree-folder-items").slideToggle(300 , function() { $(document.body).trigger("sticky_kit:recalc"); });
512533
return false;
513534
});
514535
$('#aside_feed').on('click', '.tree-folder-items .item .dropdown-toggle', function () {
@@ -519,17 +540,16 @@ function init_column_categories() {
519540
$(this).attr('href', '#dropdown-' + feed_id).prev('.dropdown-target').attr('id', 'dropdown-' + feed_id).parent().append(template);
520541
}
521542
});
522-
if( $('.toggle_aside').css('display')=='none') {
523-
$('#aside_feed .tree').stick_in_parent();
524-
}
543+
544+
init_sticky_column();
525545
}
526546

527547
function init_shortcuts() {
528548
if (!(window.shortcut && window.shortcuts)) {
529549
if (window.console) {
530550
console.log('FreshRSS waiting for sortcut.js…');
531551
}
532-
window.setTimeout(init_shortcuts, 50);
552+
window.setTimeout(init_shortcuts, 200);
533553
return;
534554
}
535555
// Touches de manipulation
@@ -1313,7 +1333,7 @@ function init_normal() {
13131333
if (window.console) {
13141334
console.log('FreshRSS waiting for content…');
13151335
}
1316-
window.setTimeout(init_normal, 50);
1336+
window.setTimeout(init_normal, 100);
13171337
return;
13181338
}
13191339
init_column_categories();
@@ -1328,11 +1348,12 @@ function init_beforeDOM() {
13281348
if (window.console) {
13291349
console.log('FreshRSS waiting for jQuery…');
13301350
}
1331-
window.setTimeout(init_beforeDOM, 50);
1351+
window.setTimeout(init_beforeDOM, 100);
13321352
return;
13331353
}
13341354
init_confirm_action();
13351355
if (['normal', 'reader', 'global'].indexOf(context.current_view) >= 0) {
1356+
inject_script('jquery.sticky-kit.min.js');
13361357
init_normal();
13371358
}
13381359
}
@@ -1342,7 +1363,7 @@ function init_afterDOM() {
13421363
if (window.console) {
13431364
console.log('FreshRSS waiting again for jQuery…');
13441365
}
1345-
window.setTimeout(init_afterDOM, 50);
1366+
window.setTimeout(init_afterDOM, 100);
13461367
return;
13471368
}
13481369
init_notifications();

0 commit comments

Comments
 (0)