-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpassbook.html
244 lines (217 loc) · 7.7 KB
/
passbook.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
<!DOCTYPE html>
<html>
<head>
<title>Passbook</title>
<script src="//code.jquery.com/jquery-2.0.3.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
<script src="lib/slider/js/bootstrap-slider.js"></script>
<script src="lib/barcodes.min.js" type="text/javascript"></script>
<script src="passbook.min.js" type="text/javascript"></script>
<style>
body {
padding: 50px 0px;
}
h4 {
margin-top: 20px;
}
table.api {
border-collapse: collapse;
width: 90%;
}
table.api th,
table.api td {
padding: 5px;
border: 2px solid white;
}
table.api th {
background-color: #ccc;
}
table.api td {
background-color: #eee;
}
table.api td.code {
font-family: Menlo,Monaco,Consolas,"Courier New",monospace;
white-space: nowrap;
font-size: 90%;
}
table.api thead,
table.api tbody {
border-top: 5px solid white;
border-bottom: 5px solid white;
}
table.api code {
background: none;
}
pre {
width: 90%;
}
</style>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
<link href="lib/slider/css/slider.css" rel="stylesheet" type="text/css">
<link href="passbook.min.css" rel="stylesheet" type="text/css" />
<script>
var passbook;
$(document).ready(function() {
passbook = $('#passbook').passbook();
passbook.passbook('edit');
});
</script>
</head>
<body style="padding: 50px 0px;">
<a href="https://github.com/usrz/bootstrap-passbook">
<img style="position: fixed; top: 0; right: 0; border: 0; z-index: 9999" src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub">
</a>
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="#">Passbook for Bootstrap</a>
</div>
</div>
</div>
<div class="container">
<h1>A IOS Passbook editor for Bootstrap</h1>
<p class="lead">
A fully editable IOS <a href="http://en.wikipedia.org/wiki/Passbook_(application)">Passbook</a>
implementation which can be used to generate data in a visual way to be loaded into your iPhone.
</p>
<p>
This is still in the early stages, but this editor allows to edit
in a fashion much similar to the native <em>Passbook</em> app all
sort of information related to passes.
</p>
<h2>An example</h2>
<p>
The passbook below is created for you in <strong>edit</strong> mode.
Click around, fill in some text, play with barcodes, and at the end hit
the little <i class="fa fa-check-square-o"></i> <em>save</em> button
to preview the final pass.
</p>
<p>
Images can be pasted directly from your clipboard, barcodes are generated
on-the-fly using our <a href="https://github.com/usrz/javascript-barcodes">JavaScript
library</a>, and clicking on the background of the card allows you to
select the pass type and colors.
</p>
<p><div id="passbook" style="position:relative;"></div></center>
<h2>API and use</h2>
<p>
The API is still rudimentary... This implementation relies on a couple
of components:
</p>
<ul>
<li><a href="http://www.eyecon.ro/bootstrap-slider/">Slider for Bootstrap</a>:
This is used to implement our color picker.</li>
<li><a href="https://github.com/usrz/javascript-barcodes">JavaScript Barcodes</a>:
To dynamically render barcodes in the pass.</li>
</ul>
<p>
To create a Passbook editor, use the usual jQuery/Boostrap way by calling
<code>$('<em>myElement</em>').passbook();</code>. The element supports a
couple of data points, namely <code>data-passbook-type</code> and
<code>data-passbook-transport</code>:
</p>
<table class="api">
<thead>
<tr>
<th>Name</th>
<th>Value</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="code" rowspan=5>passbook-type</td>
<td class="code">boarding-pass</td>
<td>Used to edit a boarding pass</td>
</tr>
<tr>
<td class="code">coupon</td>
<td>Display a coupon pass</td>
</tr>
<tr>
<td class="code">event</td>
<td>Display a ticket or an event pass</td>
</tr>
<tr>
<td class="code">store card</td>
<td>Display a store card pass</td>
</tr>
<tr>
<td class="code">generic</td>
<td>Display a generic pass</td>
</tr>
</tbody>
<tbody>
<tr>
<td class="code" rowspan=5>passbook-transpoet</td>
<td class="code">air</td>
<td>Indicates a boarding pass for a plane</td>
</tr>
<tr>
<td class="code">boat</td>
<td>Indicates a boarding pass for a boat</td>
</tr>
<tr>
<td class="code">bus</td>
<td>Indicates a boarding pass for a bus</td>
</tr>
<tr>
<td class="code">train</td>
<td>Indicates a boarding pass for a train</td>
</tr>
<tr>
<td class="code">generic</td>
<td>Indicates a generic boarding pass</td>
</tr>
</tbody>
</table>
<h4>Interaction with passes</h4>
<p>
The <code>$('<em>myElement</em>').passbook(…);</code> function
can also be used to interact (minimally) with the pass:
</p>
<table class="api">
<thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="code">edit</td>
<td>Force the pass to be in "edit mode".</td>
</tr>
<tr>
<td class="code">save</td>
<td>When in edit mode, save the changes and return in view mode.</td>
</tr>
<tr>
<td class="code">flip</td>
<td>Flip the pass around.</td>
</tr>
<tr>
<td class="code">data</td>
<td>Return the internal structure of the pass (the internal API - not for the fainthearted).</td>
</tr>
</tbody>
</table>
<h4>Future enhancements</h4>
<p>
Hoping we can get some much needed finishing touches:
</p>
<ul>
<li><strong>import/export</strong>: it shouldn't be difficult to implement,
quickly loading JSON on creation, and saving the results out.</li>
<li><strong>events</strong>: again, should be trivial to implement, but hopefully
we will have events for <code>flipped</code> (when the pass is
flipped), <code>saved</code> (after hitting the save button) and
<code>editing</code> (when entering in edit mode).</li>
<li><strong>read-only mode</strong>: meh, self-explanatory.</li>
<li><strong>varcode pasting</strong>: allow barcodes to be pasted like
images, parsed (possibly by a backend) and re-rendered on the pass.</li>
</ul>
</div> <!-- .container -->
</body>
</html>