diff options
| author | 2016-08-13 23:39:52 +0200 | |
|---|---|---|
| committer | 2016-08-13 23:39:52 +0200 | |
| commit | a180485f9146f22d48470f3ba541317dbc2ee076 (patch) | |
| tree | 0edf2ffa9170084b9b87bd3ecb6c48ce25892261 | |
| parent | 0c4add69132ac69bba76091e4301b949e5428914 (diff) | |
sticky-kit fix, and compatible async defer
And set correct parent option
https://github.com/FreshRSS/FreshRSS/pull/1172
| -rw-r--r-- | CHANGELOG.md | 1 | ||||
| -rw-r--r-- | app/FreshRSS.php | 3 | ||||
| -rw-r--r-- | p/scripts/main.js | 37 |
3 files changed, 31 insertions, 10 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c8655bca..50498da99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ * Fixed Apache Etag issue that prevented caching [#1199](https://github.com/FreshRSS/FreshRSS/pull/1199) * Fixed OPML import of categories [#1202](https://github.com/FreshRSS/FreshRSS/issues/1202) * UI + * Use sticky category column [#1172](https://github.com/FreshRSS/FreshRSS/pull/1172) * Updated to jQuery 3.1.0 and several JavaScript fixes (e.g. drag & drop) [#1197](https://github.com/FreshRSS/FreshRSS/pull/1197) * API * Add API link in FreshRSS profile settings to ease set-up [#1186](https://github.com/FreshRSS/FreshRSS/pull/1186) diff --git a/app/FreshRSS.php b/app/FreshRSS.php index 6b36c87f4..f9c371d27 100644 --- a/app/FreshRSS.php +++ b/app/FreshRSS.php @@ -95,8 +95,7 @@ class FreshRSS extends Minz_FrontController { } } - Minz_View::appendScript(Minz_Url::display('/scripts/jquery.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/jquery.min.js')),false,false,false); - Minz_View::appendScript(Minz_Url::display('/scripts/jquery.sticky-kit.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/jquery.sticky-kit.min.js'))); + Minz_View::appendScript(Minz_Url::display('/scripts/jquery.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/jquery.min.js'))); Minz_View::appendScript(Minz_Url::display('/scripts/shortcut.js?' . @filemtime(PUBLIC_PATH . '/scripts/shortcut.js'))); Minz_View::appendScript(Minz_Url::display('/scripts/main.js?' . @filemtime(PUBLIC_PATH . '/scripts/main.js'))); } diff --git a/p/scripts/main.js b/p/scripts/main.js index 9bf0c6dd3..b0ea40965 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -493,6 +493,27 @@ 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_sticky_column() { + if (!window.$ || !window.$.fn.stick_in_parent) { + if (window.console) { + console.log('FreshRSS waiting for Sticky-kit…'); + } + window.setTimeout(init_sticky_column, 200); + return; + } + if ($('.toggle_aside').css('display') === 'none') { + $('#aside_feed .tree').stick_in_parent({parent:'#aside_feed'}); + } +} + function init_column_categories() { if (context.current_view !== 'normal') { return; @@ -508,7 +529,7 @@ function init_column_categories() { this.alt = '▽'; } }); - $(this).parent().next(".tree-folder-items").slideToggle( 400 , function() { $(document.body).trigger("sticky_kit:recalc"); } ); + $(this).parent().next(".tree-folder-items").slideToggle(300 , function() { $(document.body).trigger("sticky_kit:recalc"); }); return false; }); $('#aside_feed').on('click', '.tree-folder-items .item .dropdown-toggle', function () { @@ -519,9 +540,8 @@ function init_column_categories() { $(this).attr('href', '#dropdown-' + feed_id).prev('.dropdown-target').attr('id', 'dropdown-' + feed_id).parent().append(template); } }); - if( $('.toggle_aside').css('display')=='none') { - $('#aside_feed .tree').stick_in_parent(); - } + + init_sticky_column(); } function init_shortcuts() { @@ -529,7 +549,7 @@ function init_shortcuts() { if (window.console) { console.log('FreshRSS waiting for sortcut.js…'); } - window.setTimeout(init_shortcuts, 50); + window.setTimeout(init_shortcuts, 200); return; } // Touches de manipulation @@ -1313,7 +1333,7 @@ function init_normal() { if (window.console) { console.log('FreshRSS waiting for content…'); } - window.setTimeout(init_normal, 50); + window.setTimeout(init_normal, 100); return; } init_column_categories(); @@ -1328,11 +1348,12 @@ function init_beforeDOM() { if (window.console) { console.log('FreshRSS waiting for jQuery…'); } - window.setTimeout(init_beforeDOM, 50); + window.setTimeout(init_beforeDOM, 100); return; } init_confirm_action(); if (['normal', 'reader', 'global'].indexOf(context.current_view) >= 0) { + inject_script('jquery.sticky-kit.min.js'); init_normal(); } } @@ -1342,7 +1363,7 @@ function init_afterDOM() { if (window.console) { console.log('FreshRSS waiting again for jQuery…'); } - window.setTimeout(init_afterDOM, 50); + window.setTimeout(init_afterDOM, 100); return; } init_notifications(); |
