Skip to content
This repository has been archived by the owner on Jul 6, 2020. It is now read-only.

Commit

Permalink
only scroll to active navigation entry when it is not in view, if deb…
Browse files Browse the repository at this point in the history
…ug mode is defined, dont included minified scripts
  • Loading branch information
Bernhard Posselt committed Nov 18, 2014
1 parent b164a27 commit 29df1ec
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 15 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
owncloud-news (4.1.1)
* **Enhancement**: shortcut **a** scrolls to the currently active feed in the navigation
* **Enhancement**: next/previous feed/folder shortcuts now scroll to the active entry
* **Enhancement**: next/previous feed/folder shortcuts now scroll to the active entry if it is not fully in view

owncloud-news (4.1.0)
* **Backwards incompatible change**: Time used for updating when using the Python updater is now subtracted from the given interval meaning: if you specify 30 seconds as interval and the update takes 25 seconds, it will sleep for 5 seconds before running the next update
Expand Down
17 changes: 15 additions & 2 deletions js/build/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1767,15 +1767,28 @@ app.service('SettingsResource', ["$http", "BASE_URL", function ($http, BASE_URL)
);
};

var scrollToNavigationElement = function (elem, scrollArea) {
var isInScrollView = function (elem, scrollArea) {
// offset().top adds the navigation bar too so we have to subract it
var elemTop = elem.offset().top - scrollArea.offset().top;
var elemBottom = elemTop + elem.height();

var areaBottom = scrollArea.height();

return elemTop >= 0 && elemBottom < areaBottom;
};

var scrollToNavigationElement = function (elem, scrollArea, toTop) {
if (elem.length === 0 || (!toTop && isInScrollView(elem, scrollArea))) {
return;
}
scrollArea.scrollTop(
elem.offset().top - scrollArea.offset().top + scrollArea.scrollTop()
);
};

var scrollToActiveNavigationEntry = function (navigationArea) {
var element = navigationArea.find('.active');
scrollToNavigationElement(element, navigationArea.children('ul'));
scrollToNavigationElement(element, navigationArea.children('ul'), true);
};

var reloadFeed = function (navigationArea) {
Expand Down
2 changes: 1 addition & 1 deletion js/build/app.min.js

Large diffs are not rendered by default.

17 changes: 15 additions & 2 deletions js/gui/KeyboardShortcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,28 @@
);
};

var scrollToNavigationElement = function (elem, scrollArea) {
var isInScrollView = function (elem, scrollArea) {
// offset().top adds the navigation bar too so we have to subract it
var elemTop = elem.offset().top - scrollArea.offset().top;
var elemBottom = elemTop + elem.height();

var areaBottom = scrollArea.height();

return elemTop >= 0 && elemBottom < areaBottom;
};

var scrollToNavigationElement = function (elem, scrollArea, toTop) {
if (elem.length === 0 || (!toTop && isInScrollView(elem, scrollArea))) {
return;
}
scrollArea.scrollTop(
elem.offset().top - scrollArea.offset().top + scrollArea.scrollTop()
);
};

var scrollToActiveNavigationEntry = function (navigationArea) {
var element = navigationArea.find('.active');
scrollToNavigationElement(element, navigationArea.children('ul'));
scrollToNavigationElement(element, navigationArea.children('ul'), true);
};

var reloadFeed = function (navigationArea) {
Expand Down
37 changes: 28 additions & 9 deletions templates/index.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,38 @@
<?php
// backports
if (version_compare(implode('.', \OCP\Util::getVersion()), '7.8', '<=')) {
style('news', 'news-owncloud7.min');
} else {
style('news', 'news.min');
}

script('news', [
'vendor/es6-shim/es6-shim.min',
'vendor/angular/angular.min',
'vendor/angular-route/angular-route.min',
'vendor/angular-sanitize/angular-sanitize.min',
'vendor/momentjs/min/moment-with-locales.min',
'build/app.min',
'vendor/momentjs/min/moment-with-locales.min'
]);

if (defined('DEBUG') && DEBUG === true) {
if (version_compare(implode('.', \OCP\Util::getVersion()), '7.8', '<=')) {
style('news', '7');
}

style('news', [
'app',
'custom',
'content',
'mobile',
'navigation',
'settings',
'shortcuts'
]);

script('news', 'build/app');

} else {
if (version_compare(implode('.', \OCP\Util::getVersion()), '7.8', '<=')) {
style('news', 'news-owncloud7.min');
} else {
style('news', 'news.min');
}

script('news', 'build/app.min');
}
?>

<div id="app" ng-app="News" ng-cloak ng-strict-di
Expand Down

0 comments on commit 29df1ec

Please sign in to comment.