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