Files
stf-DeviceFarmer/res/app/components/stf/page-visibility/page-visibility-directive.js
Gunther Brunner efed9aefce - Using new generator-stf.
- Refactored top bar to menu partial.
- Added new page-visibility directive.
2014-03-18 21:49:24 +09:00

24 lines
686 B
JavaScript

module.exports = function pageVisibilityDirective($document, $rootScope) {
return {
restrict: 'A',
link: function (scope, element, attrs) {
function pageVisibilityChanged() {
if (document.hidden) {
$rootScope.$broadcast('pageHidden')
} else {
$rootScope.$broadcast('pageVisible');
// Application is visible to the user
// Adjust polling rates and display update for active display mode
}
}
document.addEventListener('visibilitychange', pageVisibilityChanged, false)
scope.$on('$destroy', function () {
angular.element(document).unbind('visibilitychange');
})
}
}
}