coords.html
5.8 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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dimensions | Jcrop Demos</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="../js/Jcrop.js"></script>
<script src="/Jcrop/js/jquery.color.js"></script>
<script type="text/javascript">
var cb, filter;
jQuery(function($){
// Create a new Selection object extended from Selection
var CoordsSel = function(){ };
// Set the custom selection's prototype object to be an instance
// of the built-in Selection object
CoordsSel.prototype = new $.Jcrop.component.Selection;
// Then we can continue extending it
$.extend(CoordsSel.prototype,{
attach: function(){
// Prepend an element to Selection.element (selection container)
this.coords = $('<div> x </div>').addClass('jcrop-coords');
this.element.prepend(this.coords);
},
redraw: function(b){
// Call original redraw() method first, with arguments
$.Jcrop.component.Selection.prototype.redraw.call(this,b);
// Update coordinates
this.coords.html(this.last.w+' × '+this.last.h);
return this;
}
});
// Now set it as the component that is used for new selections
$('#target').Jcrop({
selectionComponent: CoordsSel,
bgColor: 'rgb(145,176,241)',
bgOpacity: 0.5
},function(){
this.container.addClass('jcrop-hl-active');
interface_load(this);
});
function interface_load(obj){
cb = obj;
cb.newSelection().update($.Jcrop.wrapFromXywh([ 147, 55, 456, 390 ])).refresh();
//cb.ui.selection.removeFilter(cb.filter.shader);
cb.ui.selection.refresh();
function random_coords() {
return [
Math.random()*300,
Math.random()*200,
(Math.random()*540)+50,
(Math.random()*340)+60
];
}
// Animate button event
$(document.body).on('click','[data-action]',function(e){
var $targ = $(e.target);
var action = $targ.data('action');
switch(action){
case 'random-move':
cb.ui.selection.animateTo(random_coords());
break;
}
cb.ui.selection.refresh();
}).on('selectstart',function(e){
e.preventDefault();
}).on('click','a[data-action]',function(e){
e.preventDefault();
});
}
$.Jcrop.component.CoordsSel = CoordsSel;
});
</script>
<link rel="stylesheet" href="demo_files/main.css">
<link rel="stylesheet" href="demo_files/demos.css">
<link rel="stylesheet" href="../css/Jcrop.css">
<style type="text/css">
.jcrop-border {
background: rgba(0,0,0,0.8);
}
.jcrop-handle {
border-color: rgba(0,0,0,0.8);
}
.jcrop-coords {
display: none;
position: absolute;
bottom: -24px;
right: 7px;
color: rgba(255, 255, 255, 0.8);
padding: 1px 4px 0;
font-size: 10px;
white-space: nowrap;
font-family: "Lucida Console", Monaco, monospace;
background: rgba(0, 0, 0, 0.8);
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}
.jcrop-current .jcrop-coords {
display: block;
}
</style>
</head>
<body>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<button type="button" data-toggle="collapse" data-target="nav-collapse" class="btn btn-navbar"><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button><a href="../" class="brand">Jcrop</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li class="active"><a href="./basic.html">Demos</a>
</li>
<li><a href="http://beta.jcrop.org/doc/">Docs</a>
</li>
<li><a href="http://beta.jcrop.org/contact/">Contact</a>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="span12">
<div class="jc-demo-box">
<div class="page-header">
<h1>Dimensions</h1>
</div>
<div class="demo-nav menu-box">
<h3>Jcrop Demos</h3>
<ul class="links">
<li><a href="basic.html">Hello World</a></li>
<li><a href="thumbnail.html">Thumbnail Preview</a></li>
<li><a href="panel.html">Feature Panel</a></li>
<li><b>Dimensions</b></li>
<li><a href="circle.html">Circles</a></li>
</ul>
</div>
<div class="page-interface"><img src="http://jcrop-cdn.tapmodo.com/assets/images/sierra-750.jpg" id="target">
<div class="btn-toolbar"><a href="#" data-action="random-move" id="moveselection" class="btn btn-small">Move</a></div>
</div>
<div class="tapmodo-footer"><a href="http://tapmodo.com" class="tapmodo-logo segment">tapmodo.com</a>
<div class="segment"><b>© 2008-2013 Tapmodo Interactive LLC</b>
<div>Jcrop is free software released under <a href="../MIT-LICENSE.txt">MIT License</a></div>
</div>
</div>
<div class="clearfix"></div>
</div>
</div>
</div>
</div>
</body>
</html>