forked from ionic-team/ionic-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviewState.html
399 lines (349 loc) · 16.4 KB
/
viewState.html
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
<html ng-app="navState">
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
<title>navViews and ion-tabs w/ nested navViews</title>
<link rel="stylesheet" href="../../../../dist/css/ionic.css">
<script src="../../../../dist/js/ionic.bundle.js"></script>
<script src="dom-trace.js"></script>
</head>
<body>
<div ng-controller="AppCtrl">
<ion-nav-bar class="nav-title-slide-ios7 bar-positive">
<ion-nav-back-button class="button-icon icon ion-arrow-left-c">
Back
</ion-nav-back-button>
</ion-nav-bar>
<ion-nav-view animation="slide-left-right"></ion-nav-view>
</div>
<script id="sign-in.html" type="text/ng-template">
<ion-view title="Sign-In">
<ion-nav-buttons side="left">
<button class="button button-icon icon ion-home" ng-click="foo()">
Home
</button>
</ion-nav-buttons>
<ion-nav-buttons side="right">
<button class="button button-icon ion-navicon"></button>
</ion-nav-buttons>
<ion-content>
<div class="list">
<label class="item item-input">
<span class="input-label">Username</span>
<input type="text">
</label>
<label class="item item-input">
<span class="input-label">Password</span>
<input type="password">
</label>
</div>
<div class="padding">
<button class="button button-block button-positive" ng-click="signIn(user)">
Sign-In
</button>
<form ng-submit="something()">
<input type="text">
<button type="submit"></button>
</form>
<p class="text-center">
<a href="#/sign-in">Sign-In</a> -
<a href="#/forgot-password">Forgot password</a> -
<a ui-sref="contact">Contact</a>
</p>
<p>
Current View: {{ $viewHistory.currentView }}<br>
Back View: {{ $viewHistory.backView }}<br>
Forward View: {{ $viewHistory.forwardView }}
</p>
</div>
</ion-content>
</ion-view>
</script>
<script id="forgot-password.html" type="text/ng-template">
<ion-view title="Forgot Password" hide-nav-bar="true">
<ion-content padding="true">
<p>This ion-view hides the nav bar using the hideNavBar attribute.</p>
<p>
<button ng-click="hideNavBar()">Hide Nav Bar</button>
<button ng-click="showNavBar()">Show Nav Bar</button>
</p>
<p>
<button ng-click="clearViewHistory()">Clear View History</button>
</p>
<p class="text-center">
<a href="#/sign-in">Sign-In</a> -
<a href="#/forgot-password">Forgot password</a> -
<a href="#/contact">Contact</a>
</p>
<p>
Current View: {{ $viewHistory.currentView }}<br>
Back View: {{ $viewHistory.backView }}<br>
Forward View: {{ $viewHistory.forwardView }}
</p>
</ion-content>
</ion-view>
</script>
<script id="contact.html" type="text/ng-template">
<ion-view hide-back-button="true">
<ion-content padding="true">
<p>The views title is blank on purpose.</p>
<p>The hideBackButton attribute is "true" for this view.</p>
<p>@drifty</p>
<p class="text-center">
<a href="#/sign-in">Sign-In</a> -
<a href="#/forgot-password">Forgot password</a> -
<a href="#/contact">Contact</a>
</p>
<p>
Current View: {{ $viewHistory.currentView }}<br>
Back View: {{ $viewHistory.backView }}<br>
Forward View: {{ $viewHistory.forwardView }}
</p>
</ion-content>
</ion-view>
</script>
<script id="tabs.html" type="text/ng-template">
<ion-tabs class="tabs-icon-top tabs-positive">
<ion-tab title="Automobiles" icon="ion-model-s" href="#/tabs/autos">
<ion-nav-view name="auto-nav-view"></ion-nav-view>
</ion-tab>
<ion-tab title="Add" icon="ion-plus-circled" href="#/tabs/add-auto">
<ion-nav-view name="add-autos-nav-view"></ion-nav-view>
</ion-tab>
<ion-tab title="About" icon="ion-ios7-world" ui-sref="tabs.about">
<ion-nav-view name="about-nav-view"></ion-nav-view>
</ion-tab>
<ion-tab title="Info" icon="ion-information-circled">
<ion-view title="Information">
<ion-content padding="true">
<h3>Information</h3>
<p>
This is a sample seed project for the Ionic Framework. Please change it to match your needs.
</p>
<p>
Current View: {{ $viewHistory.currentView }}<br>
Back View: {{ $viewHistory.backView }}<br>
Forward View: {{ $viewHistory.forwardView }}
</p>
</ion-content>
</ion-view>
</ion-tab>
<ion-tab title="Sign-Out" icon="ion-log-out" href="#/sign-in">
</ion-tab>
</ion-tabs>
</script>
<script id="auto-list.html" type="text/ng-template">
<ion-view title="Auto List">
<ion-content padding="true">
<ion-list>
<ion-item ng-repeat="auto in autos" ng-href="#/tabs/autos/{{ $index }}" ion-nav-animation="{{$index === 0 ? 'slide-in-up' : 'slide-left-right'}}">
{{ auto.year }} {{ auto.make }} {{ auto.model }}
</ion-item>
</ion-list>
<p>
<button ng-click="testStateGo()">Test State Go</button>
</p>
<p>
Current View: {{ $viewHistory.currentView }}<br>
Back View: {{ $viewHistory.backView }}<br>
Forward View: {{ $viewHistory.forwardView }}
</p>
</ion-content>
</ion-view>
</script>
<script id="auto-detail.html" type="text/ng-template">
<ion-view title="Auto Details">
<ion-nav-buttons side="left">
<button class="button button-icon icon ion-refresher">
</button>
</ion-nav-buttons>
<ion-content padding="true">
<h2>{{ auto.year }} {{ auto.make }} {{ auto.model }}</h2>
<p ng-bind="auto.desc"></p>
<p><a class="button" ng-href="{{ auto.url }}">Read More</a></p>
<ul>
<li>
<a ng-href="#/tabs/autos/0" class="ng-binding" href="#/tabs/autos/0">1936 Cord 810</a>
</li><li>
<a ng-href="#/tabs/autos/1" class="ng-binding" href="#/tabs/autos/1">1981 DeLorean DMC-12</a>
</li><li>
<a ng-href="#/tabs/autos/2" class="ng-binding" href="#/tabs/autos/2">1933 Duesenberg Model SJ</a>
</li><li>
<a ng-href="#/tabs/autos/3" class="ng-binding" href="#/tabs/autos/3">1951 Hudson Hornet</a>
</li><li>
<a ng-href="#/tabs/autos/4" class="ng-binding" href="#/tabs/autos/4">1965 Shelby Cobra</a>
</li><li>
<a ng-href="#/tabs/autos/5" class="ng-binding" href="#/tabs/autos/5">2008 Tesla Roadster</a>
</li><li>
<a ng-href="#/tabs/autos/6" class="ng-binding" href="#/tabs/autos/6">1948 Tucker 48</a>
</li>
</ul>
<p>
<button ng-click="hideBackButton()">Hide Back Button</button>
<button ng-click="showBackButton()">Show Back Button</button>
</p>
<p><a class="button" href="#/tabs/autos">Auto List</a></p>
<p>
Current View: {{ $viewHistory.currentView }}<br>
Back View: {{ $viewHistory.backView }}<br>
Forward View: {{ $viewHistory.forwardView }}
</p>
</ion-content>
</ion-view>
</script>
<script id="add-auto.html" type="text/ng-template">
<ion-view title="Add Auto">
<ion-content padding="true">
<div class="list">
<label class="item item-input">
<input type="text" placeholder="Make">
</label>
<label class="item item-input">
<input type="text" placeholder="Model">
</label>
<label class="item item-input">
<input type="text" placeholder="Year">
</label>
<label class="item item-input">
<textarea placeholder="Description"></textarea>
</label>
</div>
<div class="padding">
<p>
Current View: {{ $viewHistory.currentView }}<br>
Back View: {{ $viewHistory.backView }}<br>
Forward View: {{ $viewHistory.forwardView }}
</p>
</div>
</ion-content>
</ion-view>
</script>
<script id="about.html" type="text/ng-template">
<ion-view title="About">
<ion-content padding="true">
<h3>About this app!</h3>
<p>
Current View: {{ $viewHistory.currentView }}<br>
Back View: {{ $viewHistory.backView }}<br>
Forward View: {{ $viewHistory.forwardView }}
</p>
</ion-content>
</ion-view>
</script>
<script>
angular.module('navState', ['ionic'])
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('signin', {
url: "/sign-in",
templateUrl: "sign-in.html",
controller: 'SignInCtrl'
})
.state('forgotpassword', {
url: "/forgot-password",
templateUrl: "forgot-password.html",
controller: 'ForgotPasswordCtrl'
})
.state('contact', {
url: "/contact",
templateUrl: "contact.html"
})
.state('tabs', {
url: "/tabs",
abstract: true,
templateUrl: "tabs.html"
})
.state('tabs.autolist', {
url: "/autos",
views: {
'auto-nav-view': {
templateUrl: "auto-list.html",
controller: 'AutoListCtrl'
}
}
})
.state('tabs.addauto', {
url: "/add-auto",
views: {
'add-autos-nav-view': {
templateUrl: "add-auto.html",
controller: 'AutoAddCtrl'
}
}
})
.state('tabs.autodetail', {
url: "/autos/:id",
views: {
'auto-nav-view': {
templateUrl: "auto-detail.html",
controller: 'AutoDetailCtrl'
}
}
})
.state('tabs.about', {
url: "/about",
views: {
'about-nav-view': {
templateUrl: "about.html"
}
}
});
$urlRouterProvider.otherwise("/sign-in");
})
.controller('SignInCtrl', function($scope, $state) {
$scope.foo = function() {
alert('foo');
};
$scope.something = function() {
alert('something');
};
$scope.signIn = function(user) {
$state.go('tabs.autolist');
};
})
.controller('ForgotPasswordCtrl', function($ionicViewService, $rootScope, $scope, $state) {
$scope.clearViewHistory = function() {
$ionicViewService.clearHistory();
};
$scope.hideNavBar = function() {
$rootScope.$broadcast('viewState.showNavBar', false);
};
$scope.showNavBar = function() {
$rootScope.$broadcast('viewState.showNavBar', true);
};
})
.controller('AutoListCtrl', function($scope, $state) {
$scope.autoListData = "AutoListCtrl Data";
$scope.testStateGo = function() {
var toParams = { id: 4 };
$state.go('tabs.autodetail', toParams);
};
})
.controller('AutoDetailCtrl', function($scope, $state, $stateParams, $ionicNavBarDelegate) {
$scope.autoDetailData = "AutoDetailCtrl Data";
$scope.hideBackButton = function() {
$ionicNavBarDelegate.showBackButton(false);
};
$scope.showBackButton = function() {
$ionicNavBarDelegate.showBackButton(true);
};
$scope.auto = $scope.autos[$stateParams.id];
})
.controller('AutoAddCtrl', function($scope) {
$scope.newAutoData = "AutoAddCtrl Data";
})
.controller('AppCtrl', function($scope, $state) {
$scope.autos = [
{ make: 'Cord', model: '810', year: '1936', desc: 'Styled by Gordon M. Buehrig, it featured front-wheel drive and independent front suspension;[ the front drive enabled the 810 to be so low, runningboards were unnecessary. Powered by a 4,739 cc (289 cu in) Lycoming V8 of the same 125 hp (93 kW) as the L-29, The 810 had a four-speed electrically-selected semi-automatic transmission, among other innovative features.', url: 'http://en.wikipedia.org/wiki/Cord_810/812' },
{ make: 'DeLorean', model: 'DMC-12', year: '1981', desc: 'The DeLorean DMC-12 is a sports car manufactured by John DeLorean\'s DeLorean Motor Company for the American market in 1981–82. Featuring gull-wing doors with a fiberglass "underbody", to which non-structural brushed stainless steel panels are affixed, the car became iconic for its appearance as a modified time machine in the Back to the Future film trilogy.', url: 'http://en.wikipedia.org/wiki/DeLorean_DMC-12' },
{ make: 'Duesenberg', model: 'Model SJ', year: '1933', desc: 'The rare supercharged Model J version, with 320 hp (239 kW) was also created by Fred Duesenberg and introduced in May 1932, only 36 units were built. Special-bodied models, such as the later "Mormon Meteor" chassis, achieved an average speed of over 135 mph (217 km/h)[17] and a one-hour average of over 152 mph (245 km/h) at Bonneville Salt Flats, Utah.', url: 'http://en.wikipedia.org/wiki/Duesenberg_Model_J' },
{ make: 'Hudson', model: 'Hornet', year: '1951', desc: 'The Hornet, introduced for the 1951 model year, was based on Hudson\'s "step-down" design that was first seen in the 1948 model year on the Commodore. The design merged body and chassis frame into a single structure, with the floor pan recessed between the car\'s chassis rails instead of sitting on top of them. Thus one "stepped down" into a Hudson. The step-down chassis\'s "lower center of gravity...was both functional and stylish. The car not only handled well, but treated its six passengers to a sumptuous ride. The low-slung look also had a sleekness about it that was accentuated by the nearly enclosed rear wheels.', url: 'http://en.wikipedia.org/wiki/Hudson_Hornet' },
{ make: 'Shelby', model: 'Cobra', year: '1965', desc: 'Shelby wanted the AC Cobras to be "Corvette-Beaters" and at nearly 500 lb (227 kg) less than the Chevrolet Corvette, the lightweight roadster accomplished that goal at Riverside International Raceway on 2 February 1963. Driver Dave MacDonald piloted CSX2026 past a field of Corvettes, Jaguars, Porsches, and Maseratis and recorded the Cobra\'s historic first-ever victory.', url: 'http://en.wikipedia.org/wiki/Shelby_Cobra' },
{ make: 'Tesla', model: 'Roadster', year: '2008', desc: 'Tesla Motors\' first production vehicle, the Tesla Roadster, was an all-electric sports car. The Roadster was the first highway-capable all-electric vehicle in serial production for sale in the United States in the modern era. The Roadster was also the first production automobile to use lithium-ion battery cells and the first production BEV (all-electric) to travel more than 200 miles (320 km) per charge.', url: 'http://en.wikipedia.org/wiki/Tesla_Roadster' },
{ make: 'Tucker', model: '48', year: '1948', desc: 'The Tucker 48 (named after its model year) was an advanced automobile conceived by Preston Tucker and briefly produced in Chicago in 1948. Only 51 cars were made before the company folded on March 3, 1949, due to negative publicity initiated by the news media, a Securities and Exchange Commission investigation and a heavily publicized stock fraud trial (in which allegations were proven baseless in court with a full acquittal). Speculation exists that the Big Three automakers and Michigan senator Homer S. Ferguson also had a role in the Tucker Corporation\'s demise.', url: 'http://en.wikipedia.org/wiki/Tucker_Torpedo' },
];
});
domTrace.observe();
</script>
</body>
</html>