Skip to content
This repository was archived by the owner on Feb 4, 2025. It is now read-only.

Commit 1b8dc50

Browse files
committed
Demo: Use variables for option nodes.
1 parent 6a718cc commit 1b8dc50

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

js/demo/demo.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ $(function () {
1818
var metaNode = $('#meta')
1919
var thumbNode = $('#thumbnail')
2020
var actionsNode = $('#actions')
21+
var orientationNode = $('#orientation')
22+
var imageSmoothingNode = $('#image-smoothing')
2123
var coordinates
2224
var jcropAPI
2325

@@ -148,8 +150,8 @@ $(function () {
148150
canvas: true,
149151
pixelRatio: window.devicePixelRatio,
150152
downsamplingRatio: 0.5,
151-
orientation: Number($('#orientation').val()) || true,
152-
imageSmoothingEnabled: $('#image-smoothing').is(':checked'),
153+
orientation: Number(orientationNode.val()) || true,
154+
imageSmoothingEnabled: imageSmoothingNode.is(':checked'),
153155
meta: true
154156
}
155157
metaNode.hide().find('table').remove()
@@ -213,15 +215,15 @@ $(function () {
213215

214216
$('#url').on('change paste input', urlChangeHandler)
215217

216-
$('#orientation').on('change', function () {
218+
orientationNode.on('change', function () {
217219
var img = result.find('img, canvas')[0]
218220
if (img) {
219221
updateResults(
220222
loadImage.scale(img, {
221223
maxWidth: result.width() * (window.devicePixelRatio || 1),
222224
pixelRatio: window.devicePixelRatio,
223-
orientation: Number($('#orientation').val()) || true,
224-
imageSmoothingEnabled: $('#image-smoothing').is(':checked')
225+
orientation: Number(orientationNode.val()) || true,
226+
imageSmoothingEnabled: imageSmoothingNode.is(':checked')
225227
})
226228
)
227229
}
@@ -274,7 +276,7 @@ $(function () {
274276
maxWidth: result.width() * pixelRatio,
275277
contain: true,
276278
pixelRatio: pixelRatio,
277-
imageSmoothingEnabled: $('#image-smoothing').is(':checked')
279+
imageSmoothingEnabled: imageSmoothingNode.is(':checked')
278280
})
279281
)
280282
coordinates = null

0 commit comments

Comments
 (0)