forked from davidnewcomb/jquery-imgbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.html
More file actions
284 lines (239 loc) · 7.01 KB
/
example.html
File metadata and controls
284 lines (239 loc) · 7.01 KB
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
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<script src="//code.jquery.com/jquery-3.3.1.min.js"></script>
<link rel="stylesheet" href="//stackpath.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"/>
<script src="jquery.imgbox.js"></script>
<!--
Development
<link rel="stylesheet" href="/local/bootstrap.css"/>
<script src="/local/jquery-3.3.1.min.js"></script>
<script src="/jquery-imgbox/jquery.imgbox.js"></script>
-->
<style id="fest_style">
.fest_style {
background-color: white;
opacity: 0.2;
border: 4px dotted white;
}
</style>
<style id="arcadia_style">
.arcadia_style {
background-color: black;
opacity: 0.4;
border: 4px solid yellow;
}
</style>
</head>
<body>
<div class="container">
<h1>ImgBox</h1>
<div>
jQuery plugin that draws a box over an image. The box can be decorated with CSS.
</div>
<a href="https://github.com/davidnewcomb/jquery-imgbox">Project page</a>
<hr/>
<div class="row">
<div class="col-sm-6 col-lg-6">
<div class="panel panel-default">
<div class="panel-body">Use x and y co-ordinates with width and height.</div>
</div>
<pre id="jack_me_img_code"></pre>
<pre id="jack_me_js_code"></pre>
</div>
<div class="col-sm-6 col-lg-6">
<img id="jack_me" class="img-responsive" data-x="525" data-y="50" data-w="300" data-h="350"
src="//cdn.bigsoft.co.uk/projects/jquery-imgbox/img/jack_me.jpg"/>
</div>
</div>
<hr/>
<div class="row">
<div class="col-sm-6 col-lg-6">
<div class="panel panel-default">
<div class="panel-body">Use coordinates x,y and x2,y2 with a css class to define the marker's look.</div>
</div>
<pre id="fest_img_code"></pre>
<pre id="fest_style_code"></pre>
<pre id="fest_js_code"></pre>
</div>
<div class="col-sm-6 col-lg-6">
<img id="fest" class="img-responsive" data-x="830" data-y="600" data-x2="1220" data-y2="1050"
src="//cdn.bigsoft.co.uk/projects/jquery-imgbox/img/fest.jpg"/>
</div>
</div>
<hr/>
<div class="row">
<div class="col-sm-4 col-lg-4">
<div class="panel panel-default">
<div class="panel-body">Wrap your image in anything like an anchor link.</div>
</div>
<pre id="family_example_img_code"></pre>
<pre id="family_js_code"></pre>
</div>
<div class="col-sm-8 col-lg-8">
<a href="README.md" id="family_example">
<img id="family" class="img-responsive" data-x="15" data-y="110" data-w="70" data-h="80"
src="//cdn.bigsoft.co.uk/projects/jquery-imgbox/img/family.jpg"/>
</a>
</div>
</div>
<hr/>
<div class="row">
<div class="col-sm-6 col-lg-6">
<div class="panel panel-default">
<div class="panel-body">Use with clickables, like alerts, to your <code>IMG</code> in the normal way.</div>
</div>
<pre id="party_jack_img_code"></pre>
<pre id="party_jack_js_code"></pre>
</div>
<div class="col-sm-6 col-lg-6">
<img id="party_jack" class="img-responsive" data-x="125" data-y="250" data-x2="400" data-y2="650" onclick="alert('David is Ace!');"
src="//cdn.bigsoft.co.uk/projects/jquery-imgbox/img/party_jack.jpg"/>
</div>
</div>
<hr/>
<div class="row">
<div class="col-sm-6 col-lg-6">
<div class="panel panel-default">
<div class="panel-body">Adjust either of the boxes. Click once to start drawing, click again to save.</div>
</div>
<pre id="arcadia_big_img_code"></pre>
<pre id="arcadia_small_img_code"></pre>
<pre id="arcadia_style_code"></pre>
<pre id="arcadia_js_code"></pre>
</div>
<div class="col-sm-6 col-lg-6">
<div class="row">
<div class="col-sm-8 col-lg-8">
<img id="arcadia_big" data-x="660" data-y="560" data-w="340" data-h="430" class="img-responsive"
src="//cdn.bigsoft.co.uk/projects/jquery-imgbox/img/arcadia.jpg"/>
</div>
<div class="col-sm-4 col-lg-4">
<img id="arcadia_small" data-x="660" data-y="560" data-w="340" data-h="430" class="img-responsive"
src="//cdn.bigsoft.co.uk/projects/jquery-imgbox/img/arcadia.jpg"/>
</div>
</div>
<div class="row">
<input id="arcadia_out" type="text" value="Redraw the box around Arcadia's eyes in both pictures" style="width:100%;"/>
</div>
</div>
</div>
</div>
<script id="jack_me_js">
$(document).ready(function() {
$('#jack_me').imgbox({
name: '#jack_me',
markStyle : {
'border' : '4px solid red'
}
});
});
</script>
<script id="fest_js">
$(document).ready(function() {
$('#fest').imgbox({
name: '#fest',
markClass : 'fest_style'
});
});
</script>
<script id="family_js">
$(document).ready(function() {
$('#family').imgbox({
name: '#family',
markStyle : {
'background-color' : 'white',
'opacity' : '0.2',
'border' : '4px dotted white'
}
});
});
</script>
<script id="party_jack_js">
$(document).ready(function() {
$('#party_jack').imgbox({
name: '#party_jack',
markStyle : {
'border' : '5px dashed cyan'
}
});
});
</script>
<script id="arcadia_js">
$(document).ready(function() {
// For storing the callback objects
var arcadiaBigCallback = null;
var arcadiaSmallCallback = null;
// Callback for drawing a new box
function updateBig(data) {
$('#arcadia_out').val(JSON.stringify(data));
// data may be {x,y,w,h} or {x,y,x2,y2}
$('#arcadia_big').data(data);
// After we change the coordinates we can redraw the box
arcadiaBigCallback.redraw();
}
function updateSmall(data) {
$('#arcadia_out').val(JSON.stringify(data));
$('#arcadia_small').data(data);
arcadiaSmallCallback.redraw();
}
// Define the large image
arcadiaBigCallback = $('#arcadia_big').imgbox({
name: '#arcadia_big',
// Look at your console log!
debug: true,
// Define style using class
markClass : 'arcadia_style',
// We want to be able to edit the box
command : 'edit',
// When we save a new box this function is called
saveBox : updateSmall
});
arcadiaSmallCallback = $('#arcadia_small').imgbox({
name: '#arcadia_small',
debug: true,
// Define style of marker using css
markStyle : {
'border' : '2px solid blue'
},
// You can draw a new box on the smaller picture too!
command : 'edit',
saveBox : updateBig
});
});
</script>
<script>
// The Javascript below draws the example code on the screen
// and is not related to the examples.
function writeImgCode(id) {
var img = $('#' + id)[0].outerHTML;
var example = img.replace(/src=".*"/, 'src=".."').replace(/ /g, '\n ').replace(/\t/g, ' ');
$('#' + id + '_img_code').text(example);
}
function writeStyleCode(id) {
var sty = $('#' + id + '_style')[0].innerHTML.replace(/ /g, ' ');
$('#' + id + '_style_code').text(sty);
}
function writeJsCode(id) {
var js = $('#' + id + '_js').html().replace(/ /g, ' ');
$('#' + id + '_js_code').text(js);
}
writeImgCode('jack_me');
writeJsCode('jack_me');
writeImgCode('fest');
writeStyleCode('fest');
writeJsCode('fest');
writeImgCode('fest');
writeImgCode('family_example');
writeJsCode('family');
writeImgCode('party_jack');
writeJsCode('party_jack');
writeImgCode('arcadia_big');
writeImgCode('arcadia_small');
writeStyleCode('arcadia');
writeJsCode('arcadia');
</script>
</body>
</html>