Skip to content

Commit c5e3077

Browse files
committed
docs: update links and code styles
1 parent 9cc8519 commit c5e3077

File tree

2 files changed

+16
-27
lines changed

2 files changed

+16
-27
lines changed

docs/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<a class="nav-link" href="https://github.com/fengyuanchen/jquery-cropper" data-toggle="tooltip" title="View the GitHub project">GitHub</a>
3636
<a class="nav-link" href="https://fengyuanchen.github.io/cropperjs" data-toggle="tooltip" title="JavaScript image cropper">Cropper.js</a>
3737
<a class="nav-link" href="https://fengyuanchen.github.io" data-toggle="tooltip" title="More projects">More</a>
38-
<a class="nav-link" href="http://chenfengyuan.com" data-toggle="tooltip" title="About the author">About</a>
38+
<a class="nav-link" href="https://chenfengyuan.com" data-toggle="tooltip" title="About the author">About</a>
3939
</nav>
4040
</div>
4141
</div>
@@ -51,7 +51,7 @@ <h1>jquery-cropper <small class="h6">v1.0.0</small></h1>
5151
</div>
5252
<div class="col-md">
5353
<div class="carbonads">
54-
<script id="_carbonads_js" src="//cdn.carbonads.com/carbon.js?zoneid=1673&serve=C6AILKT&placement=fengyuanchen" async></script>
54+
<script id="_carbonads_js" src="//cdn.carbonads.com/carbon.js?serve=CKYI55Q7&placement=fengyuanchengithubio" async></script>
5555
</div>
5656
</div>
5757
</div>
@@ -559,7 +559,7 @@ <h5 class="modal-title" id="getCroppedCanvasTitle">Cropped</h5>
559559
<nav class="nav flex-wrap justify-content-center mb-3">
560560
<a class="nav-link" href="https://github.com/fengyuanchen/jquery-cropper">GitHub</a>
561561
<a class="nav-link" href="https://github.com/fengyuanchen/jquery-cropper/blob/master/LICENSE">License</a>
562-
<a class="nav-link" href="http://chenfengyuan.com">About</a>
562+
<a class="nav-link" href="https://chenfengyuan.com">About</a>
563563
</nav>
564564
</div>
565565
</footer>

docs/js/main.js

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
$(function () {
2-
32
'use strict';
43

54
var console = window.console || { log: function () {} };
@@ -14,28 +13,26 @@ $(function () {
1413
var $dataScaleX = $('#dataScaleX');
1514
var $dataScaleY = $('#dataScaleY');
1615
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+
};
2928
var originalImageURL = $image.attr('src');
3029
var uploadedImageName = 'cropped.jpg';
3130
var uploadedImageType = 'image/jpeg';
3231
var uploadedImageURL;
3332

34-
3533
// Tooltip
3634
$('[data-toggle="tooltip"]').tooltip();
3735

38-
3936
// Cropper
4037
$image.on({
4138
ready: function (e) {
@@ -58,7 +55,6 @@ $(function () {
5855
}
5956
}).cropper(options);
6057

61-
6258
// Buttons
6359
if (!$.isFunction(document.createElement('canvas').getContext)) {
6460
$('button[data-method="getCroppedCanvas"]').prop('disabled', true);
@@ -69,13 +65,11 @@ $(function () {
6965
$('button[data-method="scale"]').prop('disabled', true);
7066
}
7167

72-
7368
// Download
7469
if (typeof $download[0].download === 'undefined') {
7570
$download.addClass('disabled');
7671
}
7772

78-
7973
// Options
8074
$('.docs-toggles').on('change', 'input', function () {
8175
var $this = $(this);
@@ -104,7 +98,6 @@ $(function () {
10498
$image.cropper('destroy').cropper(options);
10599
});
106100

107-
108101
// Methods
109102
$('.docs-buttons').on('click', '[data-method]', function () {
110103
var $this = $(this);
@@ -204,11 +197,9 @@ $(function () {
204197
}
205198
});
206199

207-
208200
// Keyboard
209201
$(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) {
212203
return;
213204
}
214205

@@ -236,7 +227,6 @@ $(function () {
236227

237228
});
238229

239-
240230
// Import image
241231
var $inputImage = $('#inputImage');
242232

@@ -271,5 +261,4 @@ $(function () {
271261
} else {
272262
$inputImage.prop('disabled', true).parent().addClass('disabled');
273263
}
274-
275264
});

0 commit comments

Comments
 (0)