1414$ ( function ( ) {
1515 'use strict'
1616
17- var result = $ ( '#result' )
17+ var resultNode = $ ( '#result' )
1818 var metaNode = $ ( '#meta' )
1919 var thumbNode = $ ( '#thumbnail' )
2020 var actionsNode = $ ( '#actions' )
@@ -110,11 +110,13 @@ $(function () {
110110 */
111111 function updateResults ( img , data ) {
112112 if ( ! ( img . src || img instanceof HTMLCanvasElement ) ) {
113- result . children ( ) . replaceWith ( $ ( '<span>Loading image file failed</span>' ) )
113+ resultNode
114+ . children ( )
115+ . replaceWith ( $ ( '<span>Loading image file failed</span>' ) )
114116 return
115117 }
116118 var content = $ ( '<a></a>' ) . append ( img )
117- result . children ( ) . replaceWith ( content )
119+ resultNode . children ( ) . replaceWith ( content )
118120 if ( data ) {
119121 if ( img . getContext ) {
120122 actionsNode . show ( )
@@ -146,7 +148,7 @@ $(function () {
146148 */
147149 function displayImage ( file ) {
148150 var options = {
149- maxWidth : result . width ( ) ,
151+ maxWidth : resultNode . width ( ) ,
150152 canvas : true ,
151153 pixelRatio : window . devicePixelRatio ,
152154 downsamplingRatio : 0.5 ,
@@ -157,7 +159,7 @@ $(function () {
157159 metaNode . hide ( ) . removeData ( ) . find ( 'table' ) . remove ( )
158160 thumbNode . hide ( ) . empty ( )
159161 if ( ! loadImage ( file , updateResults , options ) ) {
160- result
162+ resultNode
161163 . children ( )
162164 . replaceWith (
163165 $ (
@@ -200,9 +202,9 @@ $(function () {
200202 window . webkitURL ||
201203 window . FileReader
202204 ) {
203- result . children ( ) . remove ( )
205+ resultNode . children ( ) . hide ( )
204206 } else {
205- result . children ( ) . show ( )
207+ resultNode . children ( ) . show ( )
206208 }
207209
208210 $ ( document )
@@ -217,11 +219,11 @@ $(function () {
217219 $ ( '#url' ) . on ( 'change paste input' , urlChangeHandler )
218220
219221 orientationNode . on ( 'change' , function ( ) {
220- var img = result . find ( 'img, canvas' ) [ 0 ]
222+ var img = resultNode . find ( 'img, canvas' ) [ 0 ]
221223 if ( img ) {
222224 updateResults (
223225 loadImage . scale ( img , {
224- maxWidth : result . width ( ) * ( window . devicePixelRatio || 1 ) ,
226+ maxWidth : resultNode . width ( ) * ( window . devicePixelRatio || 1 ) ,
225227 pixelRatio : window . devicePixelRatio ,
226228 orientation : Number ( orientationNode . val ( ) ) || true ,
227229 imageSmoothingEnabled : imageSmoothingNode . is ( ':checked' )
@@ -232,7 +234,7 @@ $(function () {
232234
233235 $ ( '#edit' ) . on ( 'click' , function ( event ) {
234236 event . preventDefault ( )
235- var imgNode = result . find ( 'img, canvas' )
237+ var imgNode = resultNode . find ( 'img, canvas' )
236238 var img = imgNode [ 0 ]
237239 var pixelRatio = window . devicePixelRatio || 1
238240 var margin = img . width / pixelRatio >= 140 ? 40 : 0
@@ -265,7 +267,7 @@ $(function () {
265267
266268 $ ( '#crop' ) . on ( 'click' , function ( event ) {
267269 event . preventDefault ( )
268- var img = result . find ( 'img, canvas' ) [ 0 ]
270+ var img = resultNode . find ( 'img, canvas' ) [ 0 ]
269271 var pixelRatio = window . devicePixelRatio || 1
270272 if ( img && coordinates ) {
271273 updateResults (
@@ -274,7 +276,7 @@ $(function () {
274276 top : coordinates . y * pixelRatio ,
275277 sourceWidth : coordinates . w * pixelRatio ,
276278 sourceHeight : coordinates . h * pixelRatio ,
277- maxWidth : result . width ( ) * pixelRatio ,
279+ maxWidth : resultNode . width ( ) * pixelRatio ,
278280 contain : true ,
279281 pixelRatio : pixelRatio ,
280282 imageSmoothingEnabled : imageSmoothingNode . is ( ':checked' )
0 commit comments