Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d4d62a0

Browse files
committed
Use blueimp+jsdoc+prettier config for eslint.
Move eslint configs to package.json. Use package.json files property instead of .npmignore.
1 parent 5498571 commit d4d62a0

18 files changed

+591
-811
lines changed

.eslintignore

Lines changed: 0 additions & 4 deletions
This file was deleted.

.eslintrc.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
.DS_Store
21
node_modules

.npmignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

js/demo/demo.js

Lines changed: 59 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
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()

js/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* global module, require */
2+
13
module.exports = require('./load-image')
24

35
require('./load-image-scale')

js/load-image-exif-map.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
* https://opensource.org/licenses/MIT
1313
*/
1414

15-
/* global define */
15+
/* global define, module, require */
1616

17-
;(function (factory) {
17+
;(function(factory) {
1818
'use strict'
1919
if (typeof define === 'function' && define.amd) {
2020
// Register as an anonymous AMD module:
@@ -25,7 +25,7 @@
2525
// Browser globals:
2626
factory(window.loadImage)
2727
}
28-
})(function (loadImage) {
28+
})(function(loadImage) {
2929
'use strict'
3030

3131
loadImage.ExifMap.prototype.tags = {
@@ -321,7 +321,7 @@
321321
}
322322
}
323323

324-
loadImage.ExifMap.prototype.getText = function (id) {
324+
loadImage.ExifMap.prototype.getText = function(id) {
325325
var value = this.get(id)
326326
switch (id) {
327327
case 'LightSource':
@@ -359,24 +359,24 @@
359359
}
360360
return String(value)
361361
}
362-
;(function (exifMapPrototype) {
362+
;(function(exifMapPrototype) {
363363
var tags = exifMapPrototype.tags
364364
var map = exifMapPrototype.map
365365
var prop
366366
// Map the tag names to tags:
367367
for (prop in tags) {
368-
if (tags.hasOwnProperty(prop)) {
368+
if (Object.prototype.hasOwnProperty.call(tags, prop)) {
369369
map[tags[prop]] = prop
370370
}
371371
}
372372
})(loadImage.ExifMap.prototype)
373373

374-
loadImage.ExifMap.prototype.getAll = function () {
374+
loadImage.ExifMap.prototype.getAll = function() {
375375
var map = {}
376376
var prop
377377
var id
378378
for (prop in this) {
379-
if (this.hasOwnProperty(prop)) {
379+
if (Object.prototype.hasOwnProperty.call(this, prop)) {
380380
id = this.tags[prop]
381381
if (id) {
382382
map[id] = this.getText(id)

0 commit comments

Comments
 (0)