2
2
< html lang ="en ">
3
3
< head >
4
4
< meta charset ="utf-8 ">
5
- < title > Angular Timer Directive , a simple AngularJS directive demonstrating its usefulness </ title >
5
+ < title > Angular Timer, a simple, inter-operable AngularJS directive</ title >
6
6
< meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
7
7
< meta name ="description " content ="">
8
8
9
9
<!-- Le styles -->
10
10
< link href ="bootstrap/css/bootstrap.css " rel ="stylesheet ">
11
+ < link href ="bootstrap/css/bootstrap-responsive.css " rel ="stylesheet ">
12
+
11
13
< link href ="docs/css/docs.css " rel ="stylesheet ">
12
14
< link href ="docs/css/prettify.css " rel ="stylesheet ">
13
15
14
16
< style type ="text/css ">
15
- body {
16
- padding-top : 60px ;
17
- padding-bottom : 40px ;
17
+ .page-content {
18
+ padding-top : 15px ;
19
+ }
20
+ .navbar .brand {
21
+ padding-left : 75px ;
22
+ }
23
+
24
+ # fork-me {
25
+ position : absolute;
26
+ }
27
+
28
+ @media (max-width : 979px ) {
29
+ # fork-me {
30
+ display : none;
31
+ }
18
32
}
19
33
</ style >
20
- < link href ="bootstrap/css/bootstrap-responsive.css " rel ="stylesheet ">
21
34
< script src ="jquery/jquery-1.9.1.min.js "> </ script >
22
35
< script src ="bootstrap/js/bootstrap.min.js "> </ script >
23
36
< script src ="angular/angular.min.js "> </ script >
38
51
</ head >
39
52
40
53
< body ng-app ="timer ">
41
-
42
54
< div class ="navbar navbar-inverse navbar-fixed-top ">
43
55
< div class ="navbar-inner ">
56
+ < div id ="fork-me "> < a href ="https://github.com/siddii/angular-timer/fork " title ="Fork me on GitHub "> < img alt ="Fork me on GitHub " src ="images/icon-fork-me.png "> </ a > </ div >
44
57
< div class ="container ">
45
58
< button type ="button " class ="btn btn-navbar " data-toggle ="collapse " data-target =".nav-collapse ">
46
59
< span class ="icon-bar "> </ span >
50
63
< a class ="brand " href ="# "> Angular Timer</ a >
51
64
< div class ="nav-collapse collapse ">
52
65
< ul class ="nav ">
53
- < li class ="active "> < a href ="#introduction "> Home</ a > </ li >
66
+ <!--< li class="active"><a href="#introduction">Home</a></li>-- >
54
67
< li class ="dropdown ">
55
68
< a href ="# " class ="dropdown-toggle " data-toggle ="dropdown "> Examples < b class ="caret "> </ b > </ a >
56
69
< ul class ="dropdown-menu ">
59
72
< li > < a href ="#formatted-timer "> Formatted Timer</ a > </ li >
60
73
</ ul >
61
74
</ li >
75
+ < li > < a href ="#introduction "> Markup Reference</ a > </ li >
62
76
< li class ="dropdown ">
63
77
< a href ="# " class ="dropdown-toggle " data-toggle ="dropdown "> Usage < b class ="caret "> </ b > </ a >
64
78
< ul class ="dropdown-menu ">
73
87
</ div >
74
88
</ div >
75
89
76
- < div class ="container ">
90
+ < div class ="container page-content ">
77
91
< section id ="introduction ">
78
92
< h1 > Introduction</ h1 >
79
93
< p > Directives in < a target ="_new " href ="http://angularjs.org "> AngularJS</ a > is a powerful way of building reusable < em > UI components</ em > .
80
94
This simple project will serve as a sample/reference implementation demonstrating its
81
- flexibilities by making it usable across runtime (AngularJS, plain simple JavaScript & jQuery)</ p >
82
-
95
+ flexibilities by making it < em > inter-operable</ em > across runtime (AngularJS, plain simple JavaScript & jQuery)</ p >
83
96
</ section >
97
+
84
98
< section id ="basic-example ">
85
99
< h3 > Basic Example</ h3 >
86
100
< div class ="bs-docs-example ">
87
- < p > This simple directive < code > <timer /></ code > markup code will start the timer with the default option of ticking every 1 millisecond</ p >
88
- < div > < timer id ="timer1 "/> </ div >
101
+ < p > This simple directive < code > <timer /></ code > will start the timer with the default option of ticking every 1 millisecond</ p >
102
+ < h3 > < timer id ="timer1 "/> </ h3 >
89
103
< button type ="button " class ="btn " onclick ="startTimer('timer1', this) "> Start</ button >
90
104
< button type ="button " class ="btn " onclick ="stopTimer('timer1', this) "> Stop</ button >
91
105
</ div >
@@ -95,7 +109,7 @@ <h3>Basic Example</h3>
95
109
< h3 > Timer with interval example</ h3 >
96
110
< div class ="bs-docs-example ">
97
111
< p > This directive < code > <timer interval="1000" id="timer2"/></ code > markup code will run the timer tick every second</ p >
98
- < div > < timer interval ="1000 " id ="timer2 "/> </ div >
112
+ < h3 > < timer interval ="1000 " id ="timer2 "/> </ h3 >
99
113
< button type ="button " class ="btn " onclick ="startTimer('timer1', this) "> Start</ button >
100
114
< button type ="button " class ="btn " onclick ="stopTimer('timer1', this) "> Stop</ button >
101
115
</ div >
@@ -105,16 +119,14 @@ <h3>Timer with interval example</h3>
105
119
< h3 > Formatted timer</ h3 >
106
120
< div class ="bs-docs-example ">
107
121
< p > This directive < code > <timer interval="1000" id="timer3"/></ code > markup code will run the timer tick every second</ p >
108
- < div > < timer id ="timer3 "/ > {{minutes}} minutes, {{seconds}} seconds.</ div >
122
+ < h3 > < timer id ="timer3 "> {{minutes}} minutes, {{seconds}} seconds.</ timer > </ h3 >
109
123
< button type ="button " class ="btn " onclick ="startTimer('timer3', this) "> Start</ button >
110
124
< button type ="button " class ="btn " onclick ="stopTimer('timer3', this) "> Stop</ button >
111
125
</ div >
112
126
</ section >
113
-
114
- < hr >
115
- < h2 > Examples</ h2 >
127
+ < h3 > Examples</ h3 >
116
128
< section id ="angularjs-example ">
117
- < h3 > Using timer directive from Angular</ h3 >
129
+ < h4 > Using timer directive from Angular</ h4 >
118
130
< ul class ="nav nav-tabs " id ="myTab ">
119
131
< li class ="active "> < a data-toggle ="tab " href ="#angularjs-example-source "> index.html</ a > </ li >
120
132
< li > < a data-toggle ="tab " href ="#angularjs-example-demo "> Demo</ a > </ li >
@@ -123,13 +135,50 @@ <h3>Using timer directive from Angular</h3>
123
135
< div class ="tab-content ">
124
136
< div class ="tab-pane active " id ="angularjs-example-source ">
125
137
< pre class ="prettyprint linenums ">
126
- < code >
127
- <a data-toggle="modal" href="remote.html" data-target="#modal">click me</a>
128
- </ code >
129
- </ pre >
138
+ <!DOCTYPE html>
139
+ <html>
140
+ <head>
141
+ <title>Timer Directive used from AngularJS</title>
142
+ <script src="angular/angular.min.js"></script>
143
+ <script src="app/js/timer.js"></script>
144
+ <script>
145
+ angular.module('MyApp', ['timer']);
146
+ function MyAppController($scope) {
147
+ $scope.timerRunning = true;
148
+
149
+ $scope.startTimer = function (){
150
+ $scope.$broadcast('timer-start');
151
+ $scope.timerRunning = true;
152
+ };
153
+
154
+ $scope.stopTimer = function (){
155
+ $scope.$broadcast('timer-stop');
156
+ $scope.timerRunning = false;
157
+ };
158
+ }
159
+ MyAppController.$inject = ['$scope'];
160
+ </script>
161
+ </head>
162
+ <body ng-app="MyApp">
163
+ <div ng-controller="MyAppController" style="border: 1px solid gainsboro; text-align: center;">
164
+ <h2>Single Timer</h2>
165
+ <h3><timer/></h3>
166
+ <button ng-click="startTimer()" ng-disabled="timerRunning">Start Timer</button>
167
+ <button ng-click="stopTimer()" ng-disabled="!timerRunning">Stop Timer</button>
168
+ </div>
169
+ <br/>
170
+ <div ng-controller="MyAppController" style="border: 1px solid gainsboro; text-align: center;">
171
+ <h2>Multiple Timers</h2>
172
+ <h3>Timer 1: <timer interval="2000"/></h3>
173
+ <h3>Timer 2: <timer>{{minutes}} minutes, {{seconds}} seconds.</timer></h3>
174
+ <button ng-click="startTimer()" ng-disabled="timerRunning">Start Timers</button>
175
+ <button ng-click="stopTimer()" ng-disabled="!timerRunning">Stop Timers</button>
176
+ </div>
177
+ </body>
178
+ </html></ pre >
130
179
</ div >
131
180
< div class ="tab-pane " id ="angularjs-example-demo ">
132
- < h1 > Demo </ h1 >
181
+ < iframe src =" examples/angular-js-example.html " width =" 100% " height =" 350px " > </ iframe >
133
182
</ div >
134
183
</ div >
135
184
</ section >
0 commit comments