-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
45 lines (40 loc) · 1.19 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
var DemoApp = angular.module('DemoApp', ['mobile-navigate']);
DemoApp.config(function($routeProvider) {
$routeProvider
.when("/page/:page", { templateUrl: "/partials/page.html", controller: 'PageController'})
.when("/modal", {
templateUrl: "/partials/modal.html",
transition: 'modal'
})
.when("/", {
templateUrl: "/partials/home.html"
}).otherwise({
redirectTo: "/"
});
});
DemoApp.controller('PageController', function($scope, $navigate, $route) {
// infinite pages
$scope.page = +($route.current.params.page);
});
DemoApp.controller('MainCtrl', function($scope, $navigate, $route) {
$scope.$navigate = $navigate;
$scope.range = 25;
$scope.clicks = 0;
});
DemoApp.directive('ngTap', function() {
var isTouchDevice = !!("ontouchstart" in window);
return function(scope, elm, attrs) {
if (isTouchDevice) {
var tapping = false;
elm.bind('touchstart', function() { tapping = true; });
elm.bind('touchmove', function() { tapping = false; });
elm.bind('touchend', function() {
tapping && scope.$apply(attrs.ngTap);
});
} else {
elm.bind('click', function() {
scope.$apply(attrs.ngTap);
});
}
};
});