/
githubmirror
/
angular.js
Обзор
Документация
Войти
/
githubmirror
/
angular.js
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v1.6.9
src/ng/document.js
60 строк
2 KB
Michał Gołębiowski
chore(*): switch from JSHint/JSCS to ESLint
05 авг 2016, 23:18
05 авг 2016, 23:18
c322032
Код
Авторство
О чём код?
'use strict'; /** * @ngdoc service * @name $document * @requires $window * @this * * @description * A {@link angular.element jQuery or jqLite} wrapper for the browser's `window.document` object. * * @example <example module="documentExample" name="document"> <file name="index.html"> <div ng-controller="ExampleController"> <p>$document title: <b ng-bind="title"></b></p> <p>window.document title: <b ng-bind="windowTitle"></b></p> </div> </file> <file name="script.js"> angular.module('documentExample', []) .controller('ExampleController', ['$scope', '$document', function($scope, $document) { $scope.title = $document[0].title; $scope.windowTitle = angular.element(window.document)[0].title; }]); </file> </example> */ function $DocumentProvider() { this.$get = ['$window', function(window) { return jqLite(window.document); }]; } /** * @private * @this * Listens for document visibility change and makes the current status accessible. */ function $$IsDocumentHiddenProvider() { this.$get = ['$document', '$rootScope', function($document, $rootScope) { var doc = $document[0]; var hidden = doc && doc.hidden; $document.on('visibilitychange', changeListener); $rootScope.$on('$destroy', function() { $document.off('visibilitychange', changeListener); }); function changeListener() { hidden = doc.hidden; } return function() { return hidden; }; }]; }