From 727a2e09f27cf48ef11db7b166acf6d57acd414b Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 23 Apr 2016 16:30:45 -0400 Subject: [PATCH] update library menu --- .../bower_components/iron-icon/.bower.json | 6 +- dashboard-ui/components/scrollthreshold.js | 72 +++++++++++++++++++ dashboard-ui/scripts/librarymenu.js | 3 +- dashboard-ui/scripts/site.js | 1 + 4 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 dashboard-ui/components/scrollthreshold.js diff --git a/dashboard-ui/bower_components/iron-icon/.bower.json b/dashboard-ui/bower_components/iron-icon/.bower.json index 9784e3a3b7..f0167baf13 100644 --- a/dashboard-ui/bower_components/iron-icon/.bower.json +++ b/dashboard-ui/bower_components/iron-icon/.bower.json @@ -32,14 +32,14 @@ "web-component-tester": "^4.0.0", "webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0" }, - "homepage": "https://github.com/PolymerElements/iron-icon", + "homepage": "https://github.com/polymerelements/iron-icon", "_release": "1.0.8", "_resolution": { "type": "version", "tag": "v1.0.8", "commit": "f36b38928849ef3853db727faa8c9ef104d611eb" }, - "_source": "git://github.com/PolymerElements/iron-icon.git", + "_source": "git://github.com/polymerelements/iron-icon.git", "_target": "^1.0.0", - "_originalSource": "PolymerElements/iron-icon" + "_originalSource": "polymerelements/iron-icon" } \ No newline at end of file diff --git a/dashboard-ui/components/scrollthreshold.js b/dashboard-ui/components/scrollthreshold.js new file mode 100644 index 0000000000..5ad3de7ef5 --- /dev/null +++ b/dashboard-ui/components/scrollthreshold.js @@ -0,0 +1,72 @@ +define(['events'], function (events) { + + function thresholdMonitor(elem, horizontal, lowerTolerance, upperTolerance) { + + var defaultTolerance = horizontal ? (screen.availWidth / 2) : (screen.availHeight / 2); + lowerTolerance = lowerTolerance || defaultTolerance; + upperTolerance = upperTolerance || defaultTolerance; + + var self = this; + var upperTriggered = false; + var lowerTriggered = false; + + var scrollSize; + + function getScrollSize() { + + if (!scrollSize) { + scrollSize = horizontal ? (elem.scrollWidth - elem.clientWidth) : (elem.scrollHeight - elem.clientHeight); + } + return scrollSize; + } + + function onScroll(e) { + + if (lowerTriggered && upperTriggered) { + return; + } + + var position = horizontal ? elem.scrollLeft : elem.scrollTop; + + // Detect upper threshold + if (!upperTriggered && position < upperTolerance) { + upperTriggered = true; + events.trigger(self, 'upper-threshold'); + } + // Detect lower threshold + if (!lowerTriggered && position >= (getScrollSize() - lowerTolerance)) { + lowerTriggered = false; + events.trigger(self, 'lower-threshold'); + } + } + + self.reset = function () { + self.resetSize(); + upperTriggered = false; + lowerTriggered = false; + }; + + self.resetSize = function () { + scrollSize = null; + }; + + self.enabled = function (enabled) { + + self.reset(); + + if (enabled) { + elem.addEventListener('scroll', onScroll, true); + } else { + elem.removeEventListener('scroll', onScroll, true); + } + }; + + self.enabled(true); + + self.destroy = function () { + self.enabled(false); + }; + } + + return thresholdMonitor; +}); \ No newline at end of file diff --git a/dashboard-ui/scripts/librarymenu.js b/dashboard-ui/scripts/librarymenu.js index 3e45fb493b..59b0a5d1e7 100644 --- a/dashboard-ui/scripts/librarymenu.js +++ b/dashboard-ui/scripts/librarymenu.js @@ -1133,7 +1133,8 @@ renderHeader(); headerCreated = true; - if (userRequiresUpdateAfterHeader) { + var user = userRequiresUpdateAfterHeader; + if (user) { updateUserInHeader(user); } userRequiresUpdateAfterHeader = null; diff --git a/dashboard-ui/scripts/site.js b/dashboard-ui/scripts/site.js index 3e464c7473..1c6040ccce 100644 --- a/dashboard-ui/scripts/site.js +++ b/dashboard-ui/scripts/site.js @@ -1607,6 +1607,7 @@ var AppInfo = {}; velocity: bowerPath + "/velocity/velocity.min", tvguide: 'components/tvguide/tvguide', ironCardList: 'components/ironcardlist', + scrollThreshold: 'components/scrollthreshold', directorybrowser: 'components/directorybrowser/directorybrowser', collectioneditor: 'components/collectioneditor/collectioneditor', playlisteditor: 'components/playlisteditor/playlisteditor',