223cb672e7a65700bf516eb162971c30eea05ea3
[vnfsdk/refrepo.git] /
1 /*!
2  * Angular Material Design
3  * https://github.com/angular/material
4  * @license MIT
5  * v1.1.3
6  */
7 goog.provide('ngmaterial.components.swipe');
8 goog.require('ngmaterial.core');
9 /**
10  * @ngdoc module
11  * @name material.components.swipe
12  * @description Swipe module!
13  */
14 /**
15  * @ngdoc directive
16  * @module material.components.swipe
17  * @name mdSwipeLeft
18  *
19  * @restrict A
20  *
21  * @description
22  * The md-swipe-left directive allows you to specify custom behavior when an element is swiped
23  * left.
24  *
25  * @usage
26  * <hljs lang="html">
27  * <div md-swipe-left="onSwipeLeft()">Swipe me left!</div>
28  * </hljs>
29  */
30 /**
31  * @ngdoc directive
32  * @module material.components.swipe
33  * @name mdSwipeRight
34  *
35  * @restrict A
36  *
37  * @description
38  * The md-swipe-right directive allows you to specify custom behavior when an element is swiped
39  * right.
40  *
41  * @usage
42  * <hljs lang="html">
43  * <div md-swipe-right="onSwipeRight()">Swipe me right!</div>
44  * </hljs>
45  */
46 /**
47  * @ngdoc directive
48  * @module material.components.swipe
49  * @name mdSwipeUp
50  *
51  * @restrict A
52  *
53  * @description
54  * The md-swipe-up directive allows you to specify custom behavior when an element is swiped
55  * up.
56  *
57  * @usage
58  * <hljs lang="html">
59  * <div md-swipe-up="onSwipeUp()">Swipe me up!</div>
60  * </hljs>
61  */
62 /**
63  * @ngdoc directive
64  * @module material.components.swipe
65  * @name mdSwipeDown
66  *
67  * @restrict A
68  *
69  * @description
70  * The md-swipe-down directive allows you to specify custom behavior when an element is swiped
71  * down.
72  *
73  * @usage
74  * <hljs lang="html">
75  * <div md-swipe-down="onSwipDown()">Swipe me down!</div>
76  * </hljs>
77  */
78
79 angular.module('material.components.swipe', ['material.core'])
80     .directive('mdSwipeLeft', getDirective('SwipeLeft'))
81     .directive('mdSwipeRight', getDirective('SwipeRight'))
82     .directive('mdSwipeUp', getDirective('SwipeUp'))
83     .directive('mdSwipeDown', getDirective('SwipeDown'));
84
85 function getDirective(name) {
86     DirectiveFactory['$inject'] = ["$parse"];
87   var directiveName = 'md' + name;
88   var eventName = '$md.' + name.toLowerCase();
89
90   return DirectiveFactory;
91
92   /* ngInject */
93   function DirectiveFactory($parse) {
94       return { restrict: 'A', link: postLink };
95       function postLink(scope, element, attr) {
96         element.css('touch-action', 'none');
97
98         var fn = $parse(attr[directiveName]);
99         element.on(eventName, function(ev) {
100           scope.$applyAsync(function() { fn(scope, { $event: ev }); });
101         });
102       }
103     }
104 }
105
106
107
108 ngmaterial.components.swipe = angular.module("material.components.swipe");