forked from ionic-team/ionic-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtabs-active.html
More file actions
198 lines (165 loc) · 6.29 KB
/
tabs-active.html
File metadata and controls
198 lines (165 loc) · 6.29 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<!DOCTYPE html>
<html ng-app="tabsTest">
<head>
<meta charset="utf-8">
<title>Tab Bars</title>
<meta name="viewport" content="width=device-width,initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="stylesheet" href="../../../../dist/css/ionic.css">
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="../../../../dist/js/ionic.bundle.js"></script>
</head>
<body ng-controller="RootCtrl">
<ion-tabs
class="tabs-color-active-positive tabs-icon-top"
animation="fade-in-out"
controller-changed="onControllerChanged(oldController, oldIndex, newController, newIndex)">
<ion-tab title="<img src='http://placekitten.com/40/40'>" ng-controller="HomeCtrl">
<header class="bar bar-header bar-positive">
<h1 class="title">Tasks</h1>
</header>
<ion-content class="has-header has-subheader" on-refresh="onRefresh()" on-scroll="scroll(scrollTop, scrollLeft)">
<ion-refresher></ion-refresher>
<ion-list>
<ion-item ng-repeat="item in items">
{{item.title}}
</list-item>
</ion-list>
<button ng-click="goTop()">Go Top</button>
</ion-content>
</ion-tab>
<ion-tab title="Deadlines" icon-on="icon ion-ios7-clock" icon-off="icon ion-ios7-clock-outline" badge-style="badge-light" badge="unreadDeadlines">
<header class="bar bar-header bar-positive">
<h1 class="title">Deadlines</h1>
</header>
<ion-content clsas="has-header" padding="true">
<h1>Deadlines</h1>
</ion-content>
</ion-tab>
<ion-tab title="Settings" icon-on="icon ion-ios7-gear" icon-off="icon ion-ios7-gear-outline">
<header class="bar bar-header bar-positive">
<h1 class="title">Settings</h1>
</header>
<ion-content class="has-header" padding="true">
<h1>Settings</h1>
</ion-content>
</ion-tab>
<ion-tab title="Settings" icon-on="icon ion-ios7-gear" icon-off="icon ion-ios7-gear-outline">
<header class="bar bar-header bar-positive">
<h1 class="title">Settings</h1>
</header>
<ion-content class="has-header" padding="true">
<h1>Settings</h1>
</ion-content>
</ion-tab>
<ion-tab title="Hidden" icon-on="icon ion-ionic" icon-off="icon ion-ionic" hidden="true">
<header class="bar bar-header bar-positive">
<h1 class="title">Hidden Tab</h1>
</header>
<ion-content class="has-header" padding="true">
<h1>This tab should be hidden</h1>
</ion-content>
</ion-tab>
</ion-tabs>
<script id="newTask.html" type="text/ng-template">
<div id="task-view" class="modal slide-in-up" ng-controller="TaskCtrl">
<header class="bar bar-header bar-secondary">
<h1 class="title">New Task</h1>
<button class="button button-clear button-primary" ng-click="close()">Done</button>
</header>
<main class="content padding has-header">
<input type="text" placeholder="I need to do this...">
</main>
</div>
</script>
<script type="text/javascript">
angular.module('tabsTest', ['ionic'])
.controller('RootCtrl', function($scope, $timeout) {
$scope.$on('tab.shown', function() { console.error('tab.shown Root this should not happen'); });
$scope.$on('tab.hidden', function() { console.error('tab.hidden Root this should not happen'); });
$scope.controllerChanged = function(event) {
console.log('Controller changed', event);
// Tab badge demo
if (event.newIndex == 1) {
$scope.unreadDeadlines = false;
} else {
if (!$scope.unreadDeadlines)
$scope.unreadDeadlines = 1;
updateRandomDeadlines();
}
};
$scope.scroll = function(scrollTop, scrollLeft) {
console.log('Scroll', scrollTop, scrollLeft);
};
// Tab badge demo
$scope.unreadDeadlines = false;
function updateRandomDeadlines() {
$timeout(function() {
if (!$scope.unreadDeadlines)
return;
$scope.unreadDeadlines += 1;
updateRandomDeadlines();
}, Math.random() * 10000);
}
updateRandomDeadlines();
})
.controller('HomeCtrl', function($scope, $timeout, $ionicModal, $ionicActionSheet) {
$ionicModal.fromTemplateUrl('newTask.html', function(modal) {
$scope.settingsModal = modal;
});
$scope.$on('tab.shown', function() { console.log('tab.shown Home'); });
$scope.$on('tab.hidden', function() { console.log('tab.hidden Home'); });
var removeItem = function(item, button) {
$ionicActionSheet.show({
buttons: [],
destructiveText: 'Delete Task',
cancelText: 'Cancel',
cancel: function() {
return true;
},
destructiveButtonClicked: function() {
$scope.items.splice($scope.items.indexOf(item), 1);
return true;
}
});
};
var completeItem = function(item, button) {
item.isCompleted = true;
};
$scope.onReorder = function(el, start, end) {
ionic.Utils.arrayMove($scope.items, start, end);
};
$scope.onRefresh = function() {
console.log('ON REFRESH');
$timeout(function() {
buildMockData();
$scope.$broadcast('scroll.refreshComplete');
}, 1000);
}
$scope.deleteItem = function(item) {
removeItem(item);
};
$scope.newTask = function() {
$scope.settingsModal.show();
};
function buildMockData() {
// Create the items
$scope.items = [];
for(var i = 0; i < 25; i++) {
$scope.items.push({
title: 'Task ' + (i + 1)
});
}
}
buildMockData();
$scope.goTop = function() {
$scope.$broadcast('scroll.scrollTop', false);
};
})
.controller('TaskCtrl', function($scope) {
$scope.close = function() {
$scope.modal.hide();
}
});
</script>
</body>
</html>