1
1
$ ( function ( ) {
2
-
3
2
'use strict' ;
4
3
5
4
var console = window . console || { log : function ( ) { } } ;
@@ -14,28 +13,26 @@ $(function () {
14
13
var $dataScaleX = $ ( '#dataScaleX' ) ;
15
14
var $dataScaleY = $ ( '#dataScaleY' ) ;
16
15
var options = {
17
- aspectRatio : 16 / 9 ,
18
- preview : '.img-preview' ,
19
- crop : function ( e ) {
20
- $dataX . val ( Math . round ( e . detail . x ) ) ;
21
- $dataY . val ( Math . round ( e . detail . y ) ) ;
22
- $dataHeight . val ( Math . round ( e . detail . height ) ) ;
23
- $dataWidth . val ( Math . round ( e . detail . width ) ) ;
24
- $dataRotate . val ( e . detail . rotate ) ;
25
- $dataScaleX . val ( e . detail . scaleX ) ;
26
- $dataScaleY . val ( e . detail . scaleY ) ;
27
- }
28
- } ;
16
+ aspectRatio : 16 / 9 ,
17
+ preview : '.img-preview' ,
18
+ crop : function ( e ) {
19
+ $dataX . val ( Math . round ( e . detail . x ) ) ;
20
+ $dataY . val ( Math . round ( e . detail . y ) ) ;
21
+ $dataHeight . val ( Math . round ( e . detail . height ) ) ;
22
+ $dataWidth . val ( Math . round ( e . detail . width ) ) ;
23
+ $dataRotate . val ( e . detail . rotate ) ;
24
+ $dataScaleX . val ( e . detail . scaleX ) ;
25
+ $dataScaleY . val ( e . detail . scaleY ) ;
26
+ }
27
+ } ;
29
28
var originalImageURL = $image . attr ( 'src' ) ;
30
29
var uploadedImageName = 'cropped.jpg' ;
31
30
var uploadedImageType = 'image/jpeg' ;
32
31
var uploadedImageURL ;
33
32
34
-
35
33
// Tooltip
36
34
$ ( '[data-toggle="tooltip"]' ) . tooltip ( ) ;
37
35
38
-
39
36
// Cropper
40
37
$image . on ( {
41
38
ready : function ( e ) {
@@ -58,7 +55,6 @@ $(function () {
58
55
}
59
56
} ) . cropper ( options ) ;
60
57
61
-
62
58
// Buttons
63
59
if ( ! $ . isFunction ( document . createElement ( 'canvas' ) . getContext ) ) {
64
60
$ ( 'button[data-method="getCroppedCanvas"]' ) . prop ( 'disabled' , true ) ;
@@ -69,13 +65,11 @@ $(function () {
69
65
$ ( 'button[data-method="scale"]' ) . prop ( 'disabled' , true ) ;
70
66
}
71
67
72
-
73
68
// Download
74
69
if ( typeof $download [ 0 ] . download === 'undefined' ) {
75
70
$download . addClass ( 'disabled' ) ;
76
71
}
77
72
78
-
79
73
// Options
80
74
$ ( '.docs-toggles' ) . on ( 'change' , 'input' , function ( ) {
81
75
var $this = $ ( this ) ;
@@ -104,7 +98,6 @@ $(function () {
104
98
$image . cropper ( 'destroy' ) . cropper ( options ) ;
105
99
} ) ;
106
100
107
-
108
101
// Methods
109
102
$ ( '.docs-buttons' ) . on ( 'click' , '[data-method]' , function ( ) {
110
103
var $this = $ ( this ) ;
@@ -204,11 +197,9 @@ $(function () {
204
197
}
205
198
} ) ;
206
199
207
-
208
200
// Keyboard
209
201
$ ( document . body ) . on ( 'keydown' , function ( e ) {
210
-
211
- if ( ! $image . data ( 'cropper' ) || this . scrollTop > 300 ) {
202
+ if ( e . target !== this || ! $image . data ( 'cropper' ) || this . scrollTop > 300 ) {
212
203
return ;
213
204
}
214
205
@@ -236,7 +227,6 @@ $(function () {
236
227
237
228
} ) ;
238
229
239
-
240
230
// Import image
241
231
var $inputImage = $ ( '#inputImage' ) ;
242
232
@@ -271,5 +261,4 @@ $(function () {
271
261
} else {
272
262
$inputImage . prop ( 'disabled' , true ) . parent ( ) . addClass ( 'disabled' ) ;
273
263
}
274
-
275
264
} ) ;
0 commit comments