-
Notifications
You must be signed in to change notification settings - Fork 236
/
index.html
440 lines (387 loc) · 16.5 KB
/
index.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
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
<!doctype html>
<html ng-app="progressApp">
<head>
<meta name="HandheldFriendly" content="True">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
<title>ngProgress - A slim, site-wide progressbar for AngularJS</title>
<style>
body {
margin: 0px;
padding: 0px;
font-family: sans-serif;
font-weight: lighter;
letter-spacing: 1px;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
}
html {
overflow-y: scroll;
}
#title {
text-align: center;
font-size: 1.5em;
font-family: sans-serif;
font-weight: lighter;
letter-spacing: 1px;
}
@media screen and (min-width:800px){
#title {
font-size:2em;
}
}
p {
margin: 1em 0 1em 1em;
line-height: 1.5em;
}
pre {
margin: 0 0 0 1em;
}
div {
margin: 1em 0;
}
#header a, #demo a, #demo_contained a, pre {
display: inline-block;
padding: 6px 12px;
margin-bottom: 0;
font-size: 14px;
font-weight: normal;
line-height: 1.428571429;
border: 1px solid #CCC;
border-radius: 4px;
color: #333333;
background-color: #ffffff;
white-space: pre-wrap;
}
#demo_contained {
position: relative;
background-color: rgba(0,0,0,0.1);
padding: 5px;
}
#header a, #demo a, #demo_contained a {
text-align: center;
vertical-align: middle;
cursor: pointer;
text-decoration: none;
}
#header a, #demo a:hover, #demo_contained a:hover {
background: #1abc9c;
color: #fff;
border: 1px solid #1abc9c;
-webkit-transition: all 0.3s ease-in;
-moz-transition: all 0.3s ease-in;
-o-transition: all 0.3s ease-in;
transition: all 0.3s ease-in;
}
a:hover {
color: #333333;
text-decoration: none;
}
.container {
max-width: 600px;
margin: 1em auto;
padding: 0 0.5em;
}
.container hr {
border: 1px solid #999;
}
.value {
float: right;
}
#api p {
border-bottom: 1px solid lightgrey;
padding-bottom: 1em;
}
a:-webkit-any-link {
color: #E2835D;
text-decoration: none;
}
h1,h2,h3,h4,h5 {
color: #545454;
font-weight: lighter;
letter-spacing: 2px;
}
#license p {
font-size: .7em;
}
</style>
<link rel="stylesheet" href="ngProgress.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.js"></script>
</head>
<body ng-controller="MainCtrl">
<style>#forkongithub a{background:#000;color:#fff;text-decoration:none;font-family:arial, sans-serif;text-align:center;font-weight:bold;padding:5px 0;font-size:1rem;line-height:2rem;position:relative;transition:0.5s;display:block;width:100%;}#forkongithub a:hover{background:#060;color:#fff;}#forkongithub a::before,#forkongithub a::after{content:"";width:100%;display:block;position:absolute;top:1px;left:0;height:1px;background:#fff;}#forkongithub a::after{bottom:1px;top:auto;}@media screen and (min-width:800px){#forkongithub{position:absolute;display:block;top:0;right:0;width:200px;overflow:hidden;height:200px;}#forkongithub a{width:200px;padding:5px 40px;position:absolute;top:60px;right:-60px;transform:rotate(45deg);-webkit-transform:rotate(45deg);box-shadow:4px 4px 10px rgba(0,0,0,0.8);}}</style><span id="forkongithub"><a href="https://github.com/victorbjelkholm/ngprogress" target="_blank">Fork me on GitHub</a></span>
<div id="title">
<strong>ngProgress</strong>
<br>
A slim, site-wide progressbar for AngularJS
</div>
<div class="container" ng-show="show">
<div id="header">
<center>
<a href="#installation">Installation</a>
<a href="#demo">Demo</a>
<a href="#api">API</a>
</center>
</div>
<p>
I recently saw Youtube's and Medium's new loading bars (and Medium don't get it)
and was interested in implementing it on my own. In comes <a href="https://github.com/rstacruz/nprogress" target="_blank">NProgress</a>, a jQuery dependent plugin that creates this effect.
</p>
<p>
I didn't think the plugin needed a jQuery dependency, so I created my own AngularJS Provider that I can use for my heavy-applications. Try it out, fork it and submit a pull request if you want!
</p>
<p>
Right now, the plugin weighs 8kb, contains 12 different methods and has a dependency on Angular (duh).
</p>
<p>
Reach out to me on Twitter ( <a href="https://twitter.com/VictorBjelkholm" target="_blank">@VictorBjelkholm</a> ) if you have feedback, criticisms
or just want someone to blame for your problems. Or, visit the <a href="https://github.com/VictorBjelkholm/ngProgress/" target="_blank">Github repository</a>
</p>
<div id="installation">
<h2>
Installation
</h2>
<p>
<strong>Manual:</strong> Download <a href="https://raw.github.com/VictorBjelkholm/ngProgress/master/build/ngProgress.js" target="_blank">ngProgress.js</a> or <a href="https://raw.github.com/VictorBjelkholm/ngProgress/master/build/ngProgress.min.js" target="_blank">ngProgress.min.js</a>
</p>
<p><strong>Automatic:</strong> Install using bower:
<pre>bower install ngprogress</pre>
</p>
<h3>Usage</h3>
<p>
Include ngProgress.js ( or ngProgress.min.js) and ngProgress.css in your website.
<pre>
<script src="app/components/ngProgress/ngProgress.js"></script>
<link rel="stylesheet" href="ngProgress.css">
</pre>
</p>
<p>
Set ngProgress as a dependency in your module
<pre>
var app = angular.module('progressApp', ['ngProgress']);
</pre>
</p>
<p>
Inject ngProgressFactory in the controller where you plan to use it
<pre>
var MainCtrl = function($scope, ngProgressFactory) {
}
</pre>
</p>
<p>
Create a new instance of ngProgress and start showing the progress of things!
<pre>
$scope.progressbar = ngProgressFactory.createInstance();
$scope.progressbar.start();
</pre>
</p>
<p>
Use this command to start the progress bar. The <a href="#api">ngProgress API</a> will show you how to manipulate ngProgress.
<pre>
ngProgress.start();
</pre>
</p>
</div>
<div id="demo">
<h2>
Demo
</h2>
<div>
<div class="value">Progress: <input type="number" ng-model="counter"></div>
<a href="#demo" ng-click="setWidth(counter, $event)">Set progress</a>
</div>
<hr>
<div>
<a href="#demo" ng-click="startProgress($event)">Start progressbar</a>
</div>
<hr>
<div>
<a href="#demo" ng-click="completeProgress($event)">Complete progressbar</a>
</div>
<hr>
<div>
<a href="#demo" ng-click="stopProgress($event)">Stop progressbar</a>
</div>
<hr>
<div>
<a href="#demo" ng-click="resetProgress($event)">Reset progressbar</a>
</div>
<hr>
<div>
<a href="#demo" ng-click="increment($event)">Increment</a>
</div>
<hr>
<div>
<div class="value">
Height: <input type="text" ng-model="height">
</div>
<a href="#demo" ng-click="new_height($event, height)">Change height</a>
</div>
<hr>
<div>
<div class="value">
Color: <input type="text" ng-model="color">
</div>
<a href="#demo" ng-click="new_color($event, color)">Change color</a>
</div>
</div>
<div id="demo_contained">
<h3>Contained</h3>
<div>
<a href="#demo_contained" ng-click="start_contained($event)">Start progressbar</a>
<a href="#demo_contained" ng-click="complete_contained($event)">Complete progressbar</a>
<a href="#demo_contained" ng-click="reset_contained($event)">Reset progressbar</a>
</div>
</div>
<div id="share">
<h2>Share</h2>
<p>Since the providers quality depends on peer-review, please review it yourself or share it to people that like to review stuff. I would be forever grateful and buy you a coffee if you are in Barcelona.</p>
<div>
<iframe src="http://ghbtns.com/github-btn.html?user=victorbjelkholm&repo=ngprogress&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="100" height="20"></iframe>
<iframe src="http://ghbtns.com/github-btn.html?user=victorbjelkholm&type=follow&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="175" height="20"></iframe><br/>
<a href="http://news.ycombinator.com/submit" class="hn-share-button">Vote on HN</a>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="VictorBjelkholm" data-hashtags="angularjs">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
<div style="margin:0;padding:0;display:inline;" class="g-plusone" data-action="share" data-annotation="inline" data-width="200"></div>
</div>
</div>
<div id="api">
<h2>
API
</h2>
<pre>ngProgressFactory.createInstance()</pre>
<p>REQUIRED TO USE! Creates a new instance of ngProgress that you can use the methods below with.</p>
<pre>ngProgress.start();</pre>
<p>Starts the animation and adds between 0 - 5 percent to the loading percentage every 400 milliseconds. Should always be finished with progressbar.complete() to hide it.</p>
<pre>ngProgress.setHeight('10px');</pre>
<p>Sets the height of the progressbar. Use any valid CSS value Eg '10px', '1em' or '1%'.</p>
<pre>ngProgress.setColor('#fff');</pre>
<p>Sets the color of the progressbar and it's shadow. Use any valid HTML color</p>
<pre>ngProgress.status();</pre>
<p>Returns the current percent value the progressbar is at. Should'nt be needed.</p>
<pre>ngProgress.stop();</pre>
<p>Stops the progressbar at its current location.</p>
<pre>ngProgress.set();</pre>
<p>Sets the progressbar percentage value. Use a number between 0 - 100. If 100 is provided, complete will be called.</p>
<pre>ngProgress.reset();</pre>
<p>Resets the progressbar to percentage 0 and will be hiden after it's rolled back.</p>
<pre>ngProgress.complete();</pre>
<p>Jumps to 100% progress and fades away progressbar.</p>
</div>
<div id="license">
<h2>License</h2>
<p>The MIT License (MIT)</p>
<p>Copyright (c) 2013 Victor Bjelkholm</p>
<p>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
</p>
<p>
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
</p>
<p>
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
</p>
</div>
</div>
<!-- <script src="src/module.js"></script>
<script src="src/directive.js"></script>
<script src="src/provider.js"></script> -->
<script src="build/ngprogress.js"></script>
<script>
var app = angular.module('progressApp', ['ngProgress']);
var MainCtrl = function($scope, $timeout, ngProgressFactory) {
$scope.name = 'Lars';
$scope.show = false;
$scope.progressbar = ngProgressFactory.createInstance();
$scope.color = 'firebrick';
$scope.height = '3px';
$scope.contained_progressbar = ngProgressFactory.createInstance();
$scope.contained_progressbar.setParent(document.getElementById('demo_contained'));
$scope.contained_progressbar.setAbsolute();
$scope.progressbar.start();
$timeout(function(){
$scope.progressbar.complete();
$scope.show = true;
}, 2000);
$scope.setWidth = function(new_width, $event) {
$scope.progressbar.set(new_width);
$event.preventDefault();
}
$scope.startProgress = function($event) {
$event.preventDefault();
$scope.progressbar.start();
}
$scope.increment = function($event) {
$event.preventDefault();
$scope.progressbar.set($scope.progressbar.status() + 9);
}
$scope.new_color = function($event, color) {
$event.preventDefault();
$scope.progressbar.setColor(color);
}
$scope.new_height = function($event, new_height) {
$event.preventDefault();
$scope.progressbar.setHeight(new_height);
}
$scope.completeProgress = function($event) {
$event.preventDefault();
$scope.progressbar.complete();
}
$scope.stopProgress = function($event) {
$event.preventDefault();
$scope.progressbar.stop();
}
$scope.resetProgress = function($event) {
$scope.progressbar.reset();
$event.preventDefault();
}
$scope.start_contained = function($event) {
$scope.contained_progressbar.start();
$event.preventDefault();
}
$scope.complete_contained = function($event) {
$scope.contained_progressbar.complete();
$event.preventDefault();
}
$scope.reset_contained = function($event) {
$scope.contained_progressbar.reset();
$event.preventDefault();
}
}
</script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-20806824-13', 'victorbjelkholm.github.io');
ga('send', 'pageview');
</script>
<script>
(function(d, t) {
var g = d.createElement(t),
s = d.getElementsByTagName(t)[0];
g.src = '//hnbutton.appspot.com/static/hn.min.js';
s.parentNode.insertBefore(g, s);
}(document, 'script'));
</script>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</body>
</html>