99 * https://opensource.org/licenses/MIT
1010 */
1111
12- /* global loadImage, HTMLCanvasElement, $ */
12+ /* global loadImage, $ */
1313
14- $ ( function ( ) {
14+ $ ( function ( ) {
1515 'use strict'
1616
1717 var result = $ ( '#result' )
@@ -23,13 +23,19 @@ $(function () {
2323 var coordinates
2424 var jcropAPI
2525
26- function displayTagData ( node , tags ) {
26+ /**
27+ * Displays tag data
28+ *
29+ * @param {* } node jQuery node
30+ * @param {object } tags Tags object
31+ */
32+ function displayTagData ( node , tags ) {
2733 var table = node . find ( 'table' ) . empty ( )
2834 var row = $ ( '<tr></tr>' )
2935 var cell = $ ( '<td></td>' )
3036 var prop
3137 for ( prop in tags ) {
32- if ( tags . hasOwnProperty ( prop ) ) {
38+ if ( Object . prototype . hasOwnProperty . call ( tags , prop ) ) {
3339 table . append (
3440 row
3541 . clone ( )
@@ -41,20 +47,32 @@ $(function () {
4147 node . show ( )
4248 }
4349
44- function displayThumbnailImage ( node , thumbnail , options ) {
50+ /**
51+ * Displays the thumbnal image
52+ *
53+ * @param {* } node jQuery node
54+ * @param {string } thumbnail Thumbnail URL
55+ * @param {object } [options] Options object
56+ */
57+ function displayThumbnailImage ( node , thumbnail , options ) {
4558 if ( thumbnail ) {
4659 thumbNode . empty ( )
4760 loadImage (
4861 thumbnail ,
49- function ( img ) {
62+ function ( img ) {
5063 node . append ( img ) . show ( )
5164 } ,
5265 options
5366 )
5467 }
5568 }
5669
57- function displayMetaData ( data ) {
70+ /**
71+ * Displays meta data
72+ *
73+ * @param {object } [data] Meta data object
74+ */
75+ function displayMetaData ( data ) {
5876 if ( ! data ) return
5977 var exif = data . exif
6078 var iptc = data . iptc
@@ -69,7 +87,13 @@ $(function () {
6987 }
7088 }
7189
72- function updateResults ( img , data ) {
90+ /**
91+ * Updates the results view
92+ *
93+ * @param {* } img Image or canvas element
94+ * @param {object } [data] Meta data object
95+ */
96+ function updateResults ( img , data ) {
7397 var fileName = currentFile . name
7498 var href = img . src
7599 var dataURLStart
@@ -97,7 +121,13 @@ $(function () {
97121 displayMetaData ( data )
98122 }
99123
100- function displayImage ( file , options ) {
124+ /**
125+ * Displays the image
126+ *
127+ * @param {File|Blob|string } file File or Blob object or image URL
128+ * @param {object } [options] Options object
129+ */
130+ function displayImage ( file , options ) {
101131 currentFile = file
102132 if ( ! loadImage ( file , updateResults , options ) ) {
103133 result
@@ -112,10 +142,15 @@ $(function () {
112142 }
113143 }
114144
115- function dropChangeHandler ( e ) {
116- e . preventDefault ( )
117- e = e . originalEvent
118- var target = e . dataTransfer || e . target
145+ /**
146+ * Handles drop and file selection change events
147+ *
148+ * @param {event } event Drop or file selection change event
149+ */
150+ function dropChangeHandler ( event ) {
151+ event . preventDefault ( )
152+ var originalEvent = event . originalEvent
153+ var target = originalEvent . dataTransfer || originalEvent . target
119154 var file = target && target . files && target . files [ 0 ]
120155 var options = {
121156 maxWidth : result . width ( ) ,
@@ -144,21 +179,22 @@ $(function () {
144179 }
145180
146181 $ ( document )
147- . on ( 'dragover' , function ( e ) {
182+ . on ( 'dragover' , function ( e ) {
148183 e . preventDefault ( )
149- e = e . originalEvent
150- e . dataTransfer . dropEffect = 'copy'
184+ var originalEvent = event . originalEvent
185+ originalEvent . dataTransfer . dropEffect = 'copy'
151186 } )
152187 . on ( 'drop' , dropChangeHandler )
153188
154189 $ ( '#file-input' ) . on ( 'change' , dropChangeHandler )
155190
156- $ ( '#edit' ) . on ( 'click' , function ( event ) {
191+ $ ( '#edit' ) . on ( 'click' , function ( event ) {
157192 event . preventDefault ( )
158193 var imgNode = result . find ( 'img, canvas' )
159194 var img = imgNode [ 0 ]
160195 var pixelRatio = window . devicePixelRatio || 1
161196 imgNode
197+ // eslint-disable-next-line new-cap
162198 . Jcrop (
163199 {
164200 setSelect : [
@@ -167,24 +203,24 @@ $(function () {
167203 img . width / pixelRatio - 40 ,
168204 img . height / pixelRatio - 40
169205 ] ,
170- onSelect : function ( coords ) {
206+ onSelect : function ( coords ) {
171207 coordinates = coords
172208 } ,
173- onRelease : function ( ) {
209+ onRelease : function ( ) {
174210 coordinates = null
175211 }
176212 } ,
177- function ( ) {
213+ function ( ) {
178214 jcropAPI = this
179215 }
180216 )
181217 . parent ( )
182- . on ( 'click' , function ( event ) {
218+ . on ( 'click' , function ( event ) {
183219 event . preventDefault ( )
184220 } )
185221 } )
186222
187- $ ( '#crop' ) . on ( 'click' , function ( event ) {
223+ $ ( '#crop' ) . on ( 'click' , function ( event ) {
188224 event . preventDefault ( )
189225 var img = result . find ( 'img, canvas' ) [ 0 ]
190226 var pixelRatio = window . devicePixelRatio || 1
@@ -205,7 +241,7 @@ $(function () {
205241 }
206242 } )
207243
208- $ ( '#cancel' ) . on ( 'click' , function ( event ) {
244+ $ ( '#cancel' ) . on ( 'click' , function ( event ) {
209245 event . preventDefault ( )
210246 if ( jcropAPI ) {
211247 jcropAPI . release ( )
0 commit comments