]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - js/jquery.Jcrop.go.js
SMS settings markup and styles. Minor check with twitter settings form_datas
[quix0rs-gnu-social.git] / js / jquery.Jcrop.go.js
1                 $(function(){
2                         jQuery("#photo_original img").Jcrop({
3                                 onChange: showPreview,
4                                 setSelect: [ 0, 0, $("#photo_original img").attr("width"), $("#photo_original img").attr("height") ],
5                                 onSelect: updateCoords,
6                                 aspectRatio: 1,
7                                 boxWidth: 480,
8                                 boxHeight: 480,
9                                 bgColor: '#000',
10                                 bgOpacity: .4
11                         });
12                 });
13
14                 function showPreview(coords) {
15                         var rx = 96 / coords.w;
16                         var ry = 96 / coords.h;
17
18                         var img_width = $("#photo_original img").attr("width");
19                         var img_height = $("#photo_original img").attr("height");
20
21                         $('#photo_preview img').css({
22                                 width: Math.round(rx *img_width) + 'px',
23                                 height: Math.round(ry * img_height) + 'px',
24                                 marginLeft: '-' + Math.round(rx * coords.x) + 'px',
25                                 marginTop: '-' + Math.round(ry * coords.y) + 'px'
26                         });
27                 };
28
29                 function updateCoords(c) {
30                         $('#photo_crop_x').val(c.x);
31                         $('#photo_crop_y').val(c.y);
32                         $('#photo_crop_w').val(c.w);
33                         $('#photo_crop_h').val(c.h);
34                 };
35
36                 function checkCoords() {
37                         if (parseInt($('#photo_crop_w').val())) return true;
38                         alert('Please select a crop region then press submit.');
39                         return false;
40                 };
41