nexus site path corrected
[portal.git] / ecomp-portal-FE / client / bower_components / angular-material / modules / closure / content / content.js
1 /*!
2  * Angular Material Design
3  * https://github.com/angular/material
4  * @license MIT
5  * v0.9.8
6  */
7 goog.provide('ng.material.components.content');
8 goog.require('ng.material.core');
9 /**
10  * @ngdoc module
11  * @name material.components.content
12  *
13  * @description
14  * Scrollable content
15  */
16 angular.module('material.components.content', [
17   'material.core'
18 ])
19   .directive('mdContent', mdContentDirective);
20
21 /**
22  * @ngdoc directive
23  * @name mdContent
24  * @module material.components.content
25  *
26  * @restrict E
27  *
28  * @description
29  * The `<md-content>` directive is a container element useful for scrollable content
30  *
31  * @usage
32  *
33  * - Add the `[layout-padding]` attribute to make the content padded.
34  *
35  * <hljs lang="html">
36  *  <md-content layout-padding>
37  *      Lorem ipsum dolor sit amet, ne quod novum mei.
38  *  </md-content>
39  * </hljs>
40  *
41  */
42
43 function mdContentDirective($mdTheming) {
44   return {
45     restrict: 'E',
46     controller: ['$scope', '$element', ContentController],
47     link: function(scope, element, attr) {
48       var node = element[0];
49
50       $mdTheming(element);
51       scope.$broadcast('$mdContentLoaded', element);
52
53       iosScrollFix(element[0]);
54     }
55   };
56
57   function ContentController($scope, $element) {
58     this.$scope = $scope;
59     this.$element = $element;
60   }
61 }
62 mdContentDirective.$inject = ["$mdTheming"];
63
64 function iosScrollFix(node) {
65   // IOS FIX:
66   // If we scroll where there is no more room for the webview to scroll,
67   // by default the webview itself will scroll up and down, this looks really
68   // bad.  So if we are scrolling to the very top or bottom, add/subtract one
69   angular.element(node).on('$md.pressdown', function(ev) {
70     // Only touch events
71     if (ev.pointer.type !== 't') return;
72     // Don't let a child content's touchstart ruin it for us.
73     if (ev.$materialScrollFixed) return;
74     ev.$materialScrollFixed = true;
75
76     if (node.scrollTop === 0) {
77       node.scrollTop = 1;
78     } else if (node.scrollHeight === node.scrollTop + node.offsetHeight) {
79       node.scrollTop -= 1;
80     }
81   });
82 }
83
84 ng.material.components.content = angular.module("material.components.content");