-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
291 lines (230 loc) · 10.1 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>pat.js</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="career@pathful.com">
<link href="http://twitter.github.io/bootstrap/assets/css/bootstrap.css" rel="stylesheet">
<style type="text/css">
body {
padding-top: 60px;
padding-bottom: 40px;
}
.sidebar-nav {
padding: 9px 0;
}
@media (max-width: 980px) {
/* Enable use of floated navbar text */
.navbar-text.pull-right {
float: none;
padding-left: 5px;
padding-right: 5px;
}
}
</style>
<link href="http://twitter.github.io/bootstrap/assets/css/bootstrap-responsive.css" rel="stylesheet">
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://twitter.github.io/bootstrap/assets/js/html5shiv.js"></script>
<![endif]-->
<!-- Fav and touch icons -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="http://twitter.github.io/bootstrap/assets/ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="http://twitter.github.io/bootstrap/assets/ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="http://twitter.github.io/bootstrap/assets/ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="http://twitter.github.io/bootstrap/assets/ico/apple-touch-icon-57-precomposed.png">
<link rel="shortcut icon" href="http://twitter.github.io/bootstrap/assets/ico/favicon.png">
<!-- $JQ -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>
<!-- $.pat with a pinch of salt -->
<script src="pat.js" ></script>
<style>
/* give demo button a bit of space */
.demo-btn a {
margin : 5px;
}
</style>
</head>
<body>
<a href="https://github.com/sketchytechky/pat.js"><img style="position: absolute; top: 0; left: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_left_red_aa0000.png" alt="Fork me on GitHub"></a>
<div class="container">
<h1>Pat<small>.js</small> on a layer</h1>
<h3>
pat.js is a simple framework for injecting and highlight elements on a page.
</h3>
<h2>Demo</h2>
<div class="demo-btn">
<div>
<a class="btn btn-primary" rel="pat" data-pos="top">Demo: top box</a>
<a class="btn btn-primary" rel="pat" data-pos="bottom">Demo: bottom box</a>
<a class="btn btn-primary" rel="pat" data-pos="left">Demo: left box</a>
<a class="btn btn-primary" rel="pat" data-pos="right">Demo: right box</a>
</div>
<div>
<a class="btn btn-primary" rel="pat-bar" data-pos="top" data-size="250px">Demo: top bar (with external scripts and css)</a>
</div>
<div>
<a class="btn btn-primary" rel="pat-clear">Reset</a>
</div>
</div>
<!-- a href="btn" rel="pat-menu" data-pos="top" data-height="20%">Demo: top graph box</a -->
<h1> How to get started? </h1>
<p>Just include the tag on the page (require JQuery)</p>
<pre>
<script src="pat.js" ></script>
</pre>
<p>And these example scripts to create layers</p>
<pre>
<script>
$('body').pat('init', {});
// create one overlay
$('body').pat('newlayer', {
'id' : 'newlayer',
'css' : {
...
}
});
// highlight particular elements on page
$('body').pat('highlight', $("#test"),
{ ... }
)
</script>
</pre>
<p>
See <a href="http://sketchytechky.github.io/pat.js/tests/SpecRunner.html">tests</a> for examples
<div>
<small>weekend of time from <a href="http://www.pathful.com">Pathful</a> and lookging for a front end <a href="https://angel.co/pathful/jobs">UI engineer</a></small>
</div>
</div>
<script>
$(function () {
var isLayered = false;
// intialised
$('body').pat('init', {
script: [
// load the nvd3 script as example
"http://nvd3.org/lib/d3.v2.js",
"http://nvd3.org/nv.d3.js",
],
css: ["http://nvd3.org/src/nv.d3.css"]
});
$('body').on('click', '[rel="pat"]', function (e) {
if (!isLayered) {
$('body').pat('newlayer', {
'id' : 'newlayer'
});
isLayered = true;
}
if ($.isPatted($(this))) {
$(this).pat('noHighlight');
} else {
var pos = $(this).data('pos');
if (!pos) throw "No position specified!";
var hlOpts = {};
hlOpts[pos] = {
'h1' : 'This is a fat title',
'h2' : '+30%',
'h3' : 'of the overall',
'h4' : 'Explain some stuff'
};
$(this).pat('highlight', hlOpts );
}
});
$('body').on('click', '[rel="pat-bar"]', function (e) {
var pos = $(this).data('pos');
var size = $(this).data('size');
if (!pos) throw "No position defined!";
if (!isLayered) {
$('body').pat('newlayer', {
'id' : 'newlayer'
});
isLayered = true;
}
if ($.isPatted($(this))) {
$(this).pat('noHighlight');
} else {
// adding a bit of hi to the page
$(this).pat('menu', {
'pos' : pos,
'size' : size,
'content': '<h2>Example chart</h2><div id="chart"> <svg></svg> </div>'
});
loadNVd3();
}
});
$('body').on('click', '[rel="pat-clear"]', function (e) {
if (isLayered) {
$('body').pat('clear');
isLayered = false;
}
});
/**
An example function to load NVd3
*/
function loadNVd3() {
if (typeof(nv) === 'undefined' || typeof(d3) === 'undefined') {
// nvd3 scripts might take time to load
setTimeout(function () {
loadNVd3();
}, 500);
return;
}
nv.addGraph(function() {
var chart = nv.models.lineChart();
chart.xAxis
.axisLabel('Time (ms)')
.tickFormat(function(d) { return d3.time.format('%b %d')(new Date(d)); });
//.tickFormat(d3.format(',r'));
chart.yAxis
.axisLabel('Voltage (v)')
.tickFormat(d3.format('.02f'));
d3.select('#chart svg')
.datum(sinAndCos())
.transition().duration(500)
.call(chart);
nv.utils.windowResize(function() { d3.select('#chart svg').call(chart) });
return chart;
});
/**************************************
* Simple test data generator
*/
function sinAndCos() {
var sin = [],
cos = [];
for (var i = 1; i < 30; i++) {
sin.push({x: new Date('2012-05-'+i), y: Math.sin(i/10)});
cos.push({x: new Date('2012-05-'+i), y: .5 * Math.cos(i/10)});
}
return [
{
values: sin,
key: 'Sine Wave',
color: '#ff7f0e'
},
{
values: cos,
key: 'Cosine Wave',
color: '#2ca02c'
}
];
}
}
});
</script>
<!-- Le javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="http://twitter.github.io/bootstrap/assets/js/bootstrap-transition.js"></script>
<script src="http://twitter.github.io/bootstrap/assets/js/bootstrap-alert.js"></script>
<script src="http://twitter.github.io/bootstrap/assets/js/bootstrap-modal.js"></script>
<script src="http://twitter.github.io/bootstrap/assets/js/bootstrap-dropdown.js"></script>
<script src="http://twitter.github.io/bootstrap/assets/js/bootstrap-scrollspy.js"></script>
<script src="http://twitter.github.io/bootstrap/assets/js/bootstrap-tab.js"></script>
<script src="http://twitter.github.io/bootstrap/assets/js/bootstrap-tooltip.js"></script>
<script src="http://twitter.github.io/bootstrap/assets/js/bootstrap-button.js"></script>
<script src="http://twitter.github.io/bootstrap/assets/js/bootstrap-collapse.js"></script>
<script src="http://twitter.github.io/bootstrap/assets/js/bootstrap-carousel.js"></script>
<script src="http://twitter.github.io/bootstrap/assets/js/bootstrap-typeahead.js"></script>
</body>
</html>