Update assets

pull/2487/head
jmontoyaa 9 years ago
parent 23513de436
commit fb8a7802fc
  1. 2
      app/Resources/public/assets/MathJax/.bower.json
  2. 10
      app/Resources/public/assets/blueimp-canvas-to-blob/.bower.json
  3. 2
      app/Resources/public/assets/blueimp-canvas-to-blob/js/canvas-to-blob.js
  4. 13
      app/Resources/public/assets/blueimp-canvas-to-blob/package.json
  5. 2
      app/Resources/public/assets/blueimp-canvas-to-blob/test/index.html
  6. 18
      app/Resources/public/assets/blueimp-canvas-to-blob/test/test.js
  7. 8
      app/Resources/public/assets/blueimp-load-image/.bower.json
  8. 16
      app/Resources/public/assets/blueimp-load-image/README.md
  9. 2
      app/Resources/public/assets/blueimp-load-image/index.html
  10. 161
      app/Resources/public/assets/blueimp-load-image/js/demo.js
  11. 2
      app/Resources/public/assets/blueimp-load-image/js/load-image-exif-map.js
  12. 2
      app/Resources/public/assets/blueimp-load-image/js/load-image-exif.js
  13. 22
      app/Resources/public/assets/blueimp-load-image/js/load-image-meta.js
  14. 20
      app/Resources/public/assets/blueimp-load-image/js/load-image-orientation.js
  15. 2
      app/Resources/public/assets/blueimp-load-image/js/load-image.all.min.js
  16. 2
      app/Resources/public/assets/blueimp-load-image/js/load-image.all.min.js.map
  17. 60
      app/Resources/public/assets/blueimp-load-image/js/load-image.js
  18. 15
      app/Resources/public/assets/blueimp-load-image/package.json
  19. 4
      app/Resources/public/assets/blueimp-load-image/test/index.html
  20. 353
      app/Resources/public/assets/blueimp-load-image/test/test.js
  21. 8
      app/Resources/public/assets/blueimp-tmpl/.bower.json
  22. 2
      app/Resources/public/assets/blueimp-tmpl/js/compile.js
  23. 2
      app/Resources/public/assets/blueimp-tmpl/js/demo.js
  24. 4
      app/Resources/public/assets/blueimp-tmpl/js/runtime.js
  25. 4
      app/Resources/public/assets/blueimp-tmpl/js/tmpl.js
  26. 2
      app/Resources/public/assets/blueimp-tmpl/js/tmpl.min.js
  27. 2
      app/Resources/public/assets/blueimp-tmpl/js/tmpl.min.js.map
  28. 14
      app/Resources/public/assets/blueimp-tmpl/package.json
  29. 2
      app/Resources/public/assets/blueimp-tmpl/test/index.html
  30. 52
      app/Resources/public/assets/blueimp-tmpl/test/test.js
  31. 2
      app/Resources/public/assets/bootstrap-daterangepicker/.bower.json
  32. 2
      app/Resources/public/assets/ckeditor/.bower.json
  33. 2
      app/Resources/public/assets/cropper/.bower.json
  34. 2
      app/Resources/public/assets/fontawesome/.bower.json
  35. 2
      app/Resources/public/assets/fullcalendar/.bower.json
  36. 2
      app/Resources/public/assets/image-map-resizer/.bower.json
  37. 2
      app/Resources/public/assets/jquery-timeago/.bower.json
  38. 2
      app/Resources/public/assets/jquery-ui/.bower.json
  39. 2
      app/Resources/public/assets/jquery.scrollbar/.bower.json
  40. 2
      app/Resources/public/assets/jqueryui-timepicker-addon/.bower.json
  41. 2
      app/Resources/public/assets/modernizr/.bower.json
  42. 2
      app/Resources/public/assets/moment/.bower.json
  43. 2
      app/Resources/public/assets/simpleWebRTC/.bower.json

@ -21,7 +21,7 @@
"tag": "2.5.3", "tag": "2.5.3",
"commit": "ba9afeb5a743249acdea17540b48b14ebc95dbe4" "commit": "ba9afeb5a743249acdea17540b48b14ebc95dbe4"
}, },
"_source": "git://github.com/mathjax/MathJax.git", "_source": "https://github.com/mathjax/MathJax.git",
"_target": "2.5.*", "_target": "2.5.*",
"_originalSource": "MathJax" "_originalSource": "MathJax"
} }

@ -1,14 +1,14 @@
{ {
"name": "blueimp-canvas-to-blob", "name": "blueimp-canvas-to-blob",
"homepage": "https://github.com/blueimp/JavaScript-Canvas-to-Blob", "homepage": "https://github.com/blueimp/JavaScript-Canvas-to-Blob",
"version": "3.3.0", "version": "3.4.0",
"_release": "3.3.0", "_release": "3.4.0",
"_resolution": { "_resolution": {
"type": "version", "type": "version",
"tag": "v3.3.0", "tag": "v3.4.0",
"commit": "443806e20bf0cc6e5b812b0cf686f3109d791074" "commit": "ca0326180f984600aa25eab8a19c4be11b5f048c"
}, },
"_source": "git://github.com/blueimp/JavaScript-Canvas-to-Blob.git", "_source": "https://github.com/blueimp/JavaScript-Canvas-to-Blob.git",
"_target": ">=2.1.1", "_target": ">=2.1.1",
"_originalSource": "blueimp-canvas-to-blob" "_originalSource": "blueimp-canvas-to-blob"
} }

@ -12,7 +12,7 @@
* http://stackoverflow.com/q/4998908 * http://stackoverflow.com/q/4998908
*/ */
/*global window, atob, Blob, ArrayBuffer, Uint8Array, define, module */ /* global atob, Blob, define */
;(function (window) { ;(function (window) {
'use strict' 'use strict'

@ -1,6 +1,6 @@
{ {
"name": "blueimp-canvas-to-blob", "name": "blueimp-canvas-to-blob",
"version": "3.3.0", "version": "3.4.0",
"title": "JavaScript Canvas to Blob", "title": "JavaScript Canvas to Blob",
"description": "Canvas to Blob is a polyfill for the standard JavaScript canvas.toBlob method. It can be used to create Blob objects from an HTML canvas element.", "description": "Canvas to Blob is a polyfill for the standard JavaScript canvas.toBlob method. It can be used to create Blob objects from an HTML canvas element.",
"keywords": [ "keywords": [
@ -22,12 +22,15 @@
"license": "MIT", "license": "MIT",
"main": "./js/canvas-to-blob.js", "main": "./js/canvas-to-blob.js",
"devDependencies": { "devDependencies": {
"mocha-phantomjs": "4.0.1", "phantomjs-prebuilt": "2.1.13",
"standard": "6.0.7", "mocha-phantomjs-core": "1.3.1",
"uglify-js": "2.6.1" "standard": "8.3.0",
"uglify-js": "2.7.3"
}, },
"scripts": { "scripts": {
"test": "standard js/*.js test/*.js && mocha-phantomjs test/index.html", "lint": "standard js/*.js test/*.js",
"unit": "phantomjs node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js test/index.html",
"test": "npm run lint && npm run unit",
"build": "cd js && uglifyjs canvas-to-blob.js -c -m -o canvas-to-blob.min.js --source-map canvas-to-blob.min.js.map", "build": "cd js && uglifyjs canvas-to-blob.js -c -m -o canvas-to-blob.min.js --source-map canvas-to-blob.min.js.map",
"preversion": "npm test", "preversion": "npm test",
"version": "npm run build && git add -A js", "version": "npm run build && git add -A js",

@ -24,7 +24,7 @@
<body> <body>
<div id="mocha"></div> <div id="mocha"></div>
<script src="vendor/mocha.js"></script> <script src="vendor/mocha.js"></script>
<script src="vendor/expect.js"></script> <script src="vendor/chai.js"></script>
<script> <script>
window.initMochaPhantomJS && initMochaPhantomJS(); window.initMochaPhantomJS && initMochaPhantomJS();
mocha.setup('bdd'); mocha.setup('bdd');

@ -9,7 +9,7 @@
* http://www.opensource.org/licenses/MIT * http://www.opensource.org/licenses/MIT
*/ */
/*global window, describe, it, Blob */ /* global describe, it, Blob */
;(function (expect) { ;(function (expect) {
'use strict' 'use strict'
@ -26,7 +26,7 @@
window.loadImage(blob, function (canvas) { window.loadImage(blob, function (canvas) {
canvas.toBlob( canvas.toBlob(
function (newBlob) { function (newBlob) {
expect(newBlob).to.be.a(Blob) expect(newBlob).to.be.a.instanceOf(Blob)
done() done()
} }
) )
@ -37,7 +37,7 @@
window.loadImage(blob, function (canvas) { window.loadImage(blob, function (canvas) {
canvas.toBlob( canvas.toBlob(
function (newBlob) { function (newBlob) {
expect(newBlob.type).to.be('image/png') expect(newBlob.type).to.equal('image/png')
done() done()
}, },
'image/png' 'image/png'
@ -49,7 +49,7 @@
window.loadImage(blob, function (canvas) { window.loadImage(blob, function (canvas) {
canvas.toBlob( canvas.toBlob(
function (newBlob) { function (newBlob) {
expect(newBlob.type).to.be('image/jpeg') expect(newBlob.type).to.equal('image/jpeg')
done() done()
}, },
'image/jpeg' 'image/jpeg'
@ -62,8 +62,8 @@
canvas.toBlob( canvas.toBlob(
function (newBlob) { function (newBlob) {
window.loadImage(newBlob, function (img) { window.loadImage(newBlob, function (img) {
expect(img.width).to.be(canvas.width) expect(img.width).to.equal(canvas.width)
expect(img.height).to.be(canvas.height) expect(img.height).to.equal(canvas.height)
done() done()
}) })
} }
@ -80,8 +80,8 @@
.getImageData(0, 0, canvas.width, canvas.height) .getImageData(0, 0, canvas.width, canvas.height)
var newCanvasData = newCanvas.getContext('2d') var newCanvasData = newCanvas.getContext('2d')
.getImageData(0, 0, newCanvas.width, newCanvas.height) .getImageData(0, 0, newCanvas.width, newCanvas.height)
expect(canvasData.width).to.be(newCanvasData.width) expect(canvasData.width).to.equal(newCanvasData.width)
expect(canvasData.height).to.be(newCanvasData.height) expect(canvasData.height).to.equal(newCanvasData.height)
done() done()
}, {canvas: true}) }, {canvas: true})
} }
@ -89,4 +89,4 @@
}, {canvas: true}) }, {canvas: true})
}) })
}) })
}(this.expect)) }(this.chai.expect))

@ -1,12 +1,12 @@
{ {
"name": "blueimp-load-image", "name": "blueimp-load-image",
"homepage": "https://github.com/blueimp/JavaScript-Load-Image", "homepage": "https://github.com/blueimp/JavaScript-Load-Image",
"version": "2.6.2", "version": "2.7.0",
"_release": "2.6.2", "_release": "2.7.0",
"_resolution": { "_resolution": {
"type": "version", "type": "version",
"tag": "v2.6.2", "tag": "v2.7.0",
"commit": "d6fdf1575c2f0376d29750a626d096f997e9572a" "commit": "8ee49d987e6951db1c4db6c5270abaa66e6b6659"
}, },
"_source": "https://github.com/blueimp/JavaScript-Load-Image.git", "_source": "https://github.com/blueimp/JavaScript-Load-Image.git",
"_target": ">=1.13.0", "_target": ">=1.13.0",

@ -194,9 +194,15 @@ Requires `canvas: true`.
* **crop**: Crops the image to the maxWidth/maxHeight constraints if set to * **crop**: Crops the image to the maxWidth/maxHeight constraints if set to
`true`. `true`.
Enabling the `crop` option also enables the `canvas` option. Enabling the `crop` option also enables the `canvas` option.
* **orientation**: Allows to transform the canvas coordinates according to the * **orientation**: Transform the canvas according to the specified Exif
EXIF orientation specification. orientation, which can be an `integer` in the range of `1` to `8` or the boolean
value `true`.
When set to `true`, it will set the orientation value based on the EXIF data of
the image, which will be parsed automatically if the exif library is available.
Setting the `orientation` also enables the `canvas` option. Setting the `orientation` also enables the `canvas` option.
Setting `orientation` to `true` alsoe enables the `meta` option.
* **meta**: Automatically parses the image meta data if set to `true`.
The meta data is passed to the callback as second argument.
* **canvas**: Returns the image as * **canvas**: Returns the image as
[canvas](https://developer.mozilla.org/en/HTML/Canvas) element if set to `true`. [canvas](https://developer.mozilla.org/en/HTML/Canvas) element if set to `true`.
* **crossOrigin**: Sets the crossOrigin property on the img element for loading * **crossOrigin**: Sets the crossOrigin property on the img element for loading
@ -266,9 +272,9 @@ Blob objects of resized images can be created via
[canvas.toBlob()](https://github.com/blueimp/JavaScript-Canvas-to-Blob). [canvas.toBlob()](https://github.com/blueimp/JavaScript-Canvas-to-Blob).
### Exif parser ### Exif parser
If you include the Load Image Exif Parser extension, the **parseMetaData** If you include the Load Image Exif Parser extension, the argument passed to the
callback **data** contains the additional property **exif** if Exif data could callback for **parseMetaData** will contain the additional property **exif** if
be found in the given image. Exif data could be found in the given image.
The **exif** object stores the parsed Exif tags: The **exif** object stores the parsed Exif tags:
```js ```js

@ -57,10 +57,10 @@ It also provides a method to parse image meta data to extract <a href="https://e
</div> </div>
<br> <br>
<script src="js/load-image.js"></script> <script src="js/load-image.js"></script>
<script src="js/load-image-orientation.js"></script>
<script src="js/load-image-meta.js"></script> <script src="js/load-image-meta.js"></script>
<script src="js/load-image-exif.js"></script> <script src="js/load-image-exif.js"></script>
<script src="js/load-image-exif-map.js"></script> <script src="js/load-image-exif-map.js"></script>
<script src="js/load-image-orientation.js"></script>
<!-- jQuery and Jcrop are not required by JavaScript Load Image, but included for the demo --> <!-- jQuery and Jcrop are not required by JavaScript Load Image, but included for the demo -->
<script src="js/vendor/jquery.js"></script> <script src="js/vendor/jquery.js"></script>
<script src="js/vendor/jquery.Jcrop.js"></script> <script src="js/vendor/jquery.Jcrop.js"></script>

@ -9,7 +9,7 @@
* http://www.opensource.org/licenses/MIT * http://www.opensource.org/licenses/MIT
*/ */
/*global window, document, loadImage, HTMLCanvasElement, $ */ /* global loadImage, HTMLCanvasElement, $ */
$(function () { $(function () {
'use strict' 'use strict'
@ -20,32 +20,7 @@ $(function () {
var actionsNode = $('#actions') var actionsNode = $('#actions')
var currentFile var currentFile
var coordinates var coordinates
function replaceResults (img) {
var content
if (!(img.src || img instanceof HTMLCanvasElement)) {
content = $('<span>Loading image file failed</span>')
} else {
content = $('<a target="_blank">').append(img)
.attr('download', currentFile.name)
.attr('href', img.src || img.toDataURL())
}
result.children().replaceWith(content)
if (img.getContext) {
actionsNode.show()
}
}
function displayImage (file, options) {
currentFile = file
if (!loadImage(
file,
replaceResults,
options
)) {
result.children().replaceWith(
$('<span>Your browser does not support the URL or FileReader API.</span>')
)
}
}
function displayExifData (exif) { function displayExifData (exif) {
var thumbnail = exif.get('Thumbnail') var thumbnail = exif.get('Thumbnail')
var tags = exif.getAll() var tags = exif.getAll()
@ -70,6 +45,40 @@ $(function () {
} }
exifNode.show() exifNode.show()
} }
function updateResults (img, data) {
var content
if (!(img.src || img instanceof HTMLCanvasElement)) {
content = $('<span>Loading image file failed</span>')
} else {
content = $('<a target="_blank">').append(img)
.attr('download', currentFile.name)
.attr('href', img.src || img.toDataURL())
}
result.children().replaceWith(content)
if (img.getContext) {
actionsNode.show()
}
if (data && data.exif) {
displayExifData(data.exif)
}
}
function displayImage (file, options) {
currentFile = file
if (!loadImage(
file,
updateResults,
options
)) {
result.children().replaceWith(
$('<span>' +
'Your browser does not support the URL or FileReader API.' +
'</span>')
)
}
}
function dropChangeHandler (e) { function dropChangeHandler (e) {
e.preventDefault() e.preventDefault()
e = e.originalEvent e = e.originalEvent
@ -79,25 +88,23 @@ $(function () {
maxWidth: result.width(), maxWidth: result.width(),
canvas: true, canvas: true,
pixelRatio: window.devicePixelRatio, pixelRatio: window.devicePixelRatio,
downsamplingRatio: 0.5 downsamplingRatio: 0.5,
orientation: true
} }
if (!file) { if (!file) {
return return
} }
exifNode.hide() exifNode.hide()
thumbNode.hide() thumbNode.hide()
loadImage.parseMetaData(file, function (data) { displayImage(file, options)
if (data.exif) {
options.orientation = data.exif.get('Orientation')
displayExifData(data.exif)
}
displayImage(file, options)
})
} }
// Hide URL/FileReader API requirement message in capable browsers: // Hide URL/FileReader API requirement message in capable browsers:
if (window.createObjectURL || window.URL || window.webkitURL || window.FileReader) { if (window.createObjectURL || window.URL || window.webkitURL ||
window.FileReader) {
result.children().hide() result.children().hide()
} }
$(document) $(document)
.on('dragover', function (e) { .on('dragover', function (e) {
e.preventDefault() e.preventDefault()
@ -105,45 +112,51 @@ $(function () {
e.dataTransfer.dropEffect = 'copy' e.dataTransfer.dropEffect = 'copy'
}) })
.on('drop', dropChangeHandler) .on('drop', dropChangeHandler)
$('#file-input').on('change', dropChangeHandler)
$('#edit').on('click', function (event) { $('#file-input')
event.preventDefault() .on('change', dropChangeHandler)
var imgNode = result.find('img, canvas')
var img = imgNode[0] $('#edit')
var pixelRatio = window.devicePixelRatio || 1 .on('click', function (event) {
imgNode.Jcrop({ event.preventDefault()
setSelect: [ var imgNode = result.find('img, canvas')
40, var img = imgNode[0]
40, var pixelRatio = window.devicePixelRatio || 1
(img.width / pixelRatio) - 40, imgNode.Jcrop({
(img.height / pixelRatio) - 40 setSelect: [
], 40,
onSelect: function (coords) { 40,
coordinates = coords (img.width / pixelRatio) - 40,
}, (img.height / pixelRatio) - 40
onRelease: function () { ],
onSelect: function (coords) {
coordinates = coords
},
onRelease: function () {
coordinates = null
}
}).parent().on('click', function (event) {
event.preventDefault()
})
})
$('#crop')
.on('click', function (event) {
event.preventDefault()
var img = result.find('img, canvas')[0]
var pixelRatio = window.devicePixelRatio || 1
if (img && coordinates) {
updateResults(loadImage.scale(img, {
left: coordinates.x * pixelRatio,
top: coordinates.y * pixelRatio,
sourceWidth: coordinates.w * pixelRatio,
sourceHeight: coordinates.h * pixelRatio,
minWidth: result.width(),
maxWidth: result.width(),
pixelRatio: pixelRatio,
downsamplingRatio: 0.5
}))
coordinates = null coordinates = null
} }
}).parent().on('click', function (event) {
event.preventDefault()
}) })
})
$('#crop').on('click', function (event) {
event.preventDefault()
var img = result.find('img, canvas')[0]
var pixelRatio = window.devicePixelRatio || 1
if (img && coordinates) {
replaceResults(loadImage.scale(img, {
left: coordinates.x * pixelRatio,
top: coordinates.y * pixelRatio,
sourceWidth: coordinates.w * pixelRatio,
sourceHeight: coordinates.h * pixelRatio,
minWidth: result.width(),
maxWidth: result.width(),
pixelRatio: pixelRatio,
downsamplingRatio: 0.5
}))
coordinates = null
}
})
}) })

@ -12,7 +12,7 @@
* http://www.opensource.org/licenses/MIT * http://www.opensource.org/licenses/MIT
*/ */
/*global define, module, require, window */ /* global define */
;(function (factory) { ;(function (factory) {
'use strict' 'use strict'

@ -9,7 +9,7 @@
* http://www.opensource.org/licenses/MIT * http://www.opensource.org/licenses/MIT
*/ */
/*global define, module, require, window, console */ /* global define */
;(function (factory) { ;(function (factory) {
'use strict' 'use strict'

@ -13,7 +13,7 @@
* http://www.opensource.org/licenses/MIT * http://www.opensource.org/licenses/MIT
*/ */
/*global define, module, require, window, DataView, Blob, Uint8Array, console */ /* global define, Blob */
;(function (factory) { ;(function (factory) {
'use strict' 'use strict'
@ -49,12 +49,12 @@
// The options arguments accepts an object and supports the following properties: // The options arguments accepts an object and supports the following properties:
// * maxMetaDataSize: Defines the maximum number of bytes to parse. // * maxMetaDataSize: Defines the maximum number of bytes to parse.
// * disableImageHead: Disables creating the imageHead property. // * disableImageHead: Disables creating the imageHead property.
loadImage.parseMetaData = function (file, callback, options) { loadImage.parseMetaData = function (file, callback, options, data) {
options = options || {} options = options || {}
data = data || {}
var that = this var that = this
// 256 KiB should contain all EXIF/ICC/IPTC segments: // 256 KiB should contain all EXIF/ICC/IPTC segments:
var maxMetaDataSize = options.maxMetaDataSize || 262144 var maxMetaDataSize = options.maxMetaDataSize || 262144
var data = {}
var noMetaData = !(window.DataView && file && file.size >= 12 && var noMetaData = !(window.DataView && file && file.size >= 12 &&
file.type === 'image/jpeg' && loadImage.blobSlice) file.type === 'image/jpeg' && loadImage.blobSlice)
if (noMetaData || !loadImage.readFile( if (noMetaData || !loadImage.readFile(
@ -140,4 +140,20 @@
callback(data) callback(data)
} }
} }
// Determines if meta data should be loaded automatically:
loadImage.hasMetaOption = function (options) {
return options.meta
}
var originalTransform = loadImage.transform
loadImage.transform = function (img, options, callback, file, data) {
if (loadImage.hasMetaOption(options || {})) {
loadImage.parseMetaData(file, function (data) {
originalTransform.call(loadImage, img, options, callback, file, data)
}, options, data)
} else {
originalTransform.apply(loadImage, arguments)
}
}
})) }))

@ -9,7 +9,7 @@
* http://www.opensource.org/licenses/MIT * http://www.opensource.org/licenses/MIT
*/ */
/*global define, module, require, window */ /* global define */
;(function (factory) { ;(function (factory) {
'use strict' 'use strict'
@ -26,16 +26,22 @@
'use strict' 'use strict'
var originalHasCanvasOption = loadImage.hasCanvasOption var originalHasCanvasOption = loadImage.hasCanvasOption
var originalHasMetaOption = loadImage.hasMetaOption
var originalTransformCoordinates = loadImage.transformCoordinates var originalTransformCoordinates = loadImage.transformCoordinates
var originalGetTransformedOptions = loadImage.getTransformedOptions var originalGetTransformedOptions = loadImage.getTransformedOptions
// This method is used to determine if the target image // Determines if the target image should be a canvas element:
// should be a canvas element:
loadImage.hasCanvasOption = function (options) { loadImage.hasCanvasOption = function (options) {
return !!options.orientation || return !!options.orientation ||
originalHasCanvasOption.call(loadImage, options) originalHasCanvasOption.call(loadImage, options)
} }
// Determines if meta data should be loaded automatically:
loadImage.hasMetaOption = function (options) {
return options.orientation === true ||
originalHasMetaOption.call(loadImage, options)
}
// Transform image orientation based on // Transform image orientation based on
// the given EXIF orientation option: // the given EXIF orientation option:
loadImage.transformCoordinates = function (canvas, options) { loadImage.transformCoordinates = function (canvas, options) {
@ -97,11 +103,14 @@
// Transforms coordinate and dimension options // Transforms coordinate and dimension options
// based on the given orientation option: // based on the given orientation option:
loadImage.getTransformedOptions = function (img, opts) { loadImage.getTransformedOptions = function (img, opts, data) {
var options = originalGetTransformedOptions.call(loadImage, img, opts) var options = originalGetTransformedOptions.call(loadImage, img, opts)
var orientation = options.orientation var orientation = options.orientation
var newOptions var newOptions
var i var i
if (orientation === true && data && data.exif) {
orientation = data.exif.get('Orientation')
}
if (!orientation || orientation > 8 || orientation === 1) { if (!orientation || orientation > 8 || orientation === 1) {
return options return options
} }
@ -111,7 +120,8 @@
newOptions[i] = options[i] newOptions[i] = options[i]
} }
} }
switch (options.orientation) { newOptions.orientation = orientation
switch (orientation) {
case 2: case 2:
// horizontal flip // horizontal flip
newOptions.left = options.right newOptions.left = options.right

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -9,7 +9,7 @@
* http://www.opensource.org/licenses/MIT * http://www.opensource.org/licenses/MIT
*/ */
/*global define, module, window, document, URL, webkitURL, FileReader */ /* global define, URL, webkitURL, FileReader */
;(function ($) { ;(function ($) {
'use strict' 'use strict'
@ -17,26 +17,20 @@
// Loads an image for a given File object. // Loads an image for a given File object.
// Invokes the callback with an img or optional canvas // Invokes the callback with an img or optional canvas
// element (if supported by the browser) as parameter: // element (if supported by the browser) as parameter:
var loadImage = function (file, callback, options) { function loadImage (file, callback, options) {
var img = document.createElement('img') var img = document.createElement('img')
var url var url
var oUrl img.onerror = function (event) {
img.onerror = callback return loadImage.onerror(img, event, file, callback, options)
img.onload = function () { }
if (oUrl && !(options && options.noRevoke)) { img.onload = function (event) {
loadImage.revokeObjectURL(oUrl) return loadImage.onload(img, event, file, callback, options)
}
if (callback) {
callback(loadImage.scale(img, options))
}
} }
if (loadImage.isInstanceOf('Blob', file) || if (loadImage.isInstanceOf('Blob', file) ||
// Files are also Blob instances, but some browsers // Files are also Blob instances, but some browsers
// (Firefox 3.6) support the File API but not Blobs: // (Firefox 3.6) support the File API but not Blobs:
loadImage.isInstanceOf('File', file)) { loadImage.isInstanceOf('File', file)) {
url = oUrl = loadImage.createObjectURL(file) url = img._objectURL = loadImage.createObjectURL(file)
// Store the file type for resize processing:
img._type = file.type
} else if (typeof file === 'string') { } else if (typeof file === 'string') {
url = file url = file
if (options && options.crossOrigin) { if (options && options.crossOrigin) {
@ -53,10 +47,8 @@
var target = e.target var target = e.target
if (target && target.result) { if (target && target.result) {
img.src = target.result img.src = target.result
} else { } else if (callback) {
if (callback) { callback(e)
callback(e)
}
} }
}) })
} }
@ -66,11 +58,36 @@
(window.URL && URL.revokeObjectURL && URL) || (window.URL && URL.revokeObjectURL && URL) ||
(window.webkitURL && webkitURL) (window.webkitURL && webkitURL)
function revokeHelper (img, options) {
if (img._objectURL && !(options && options.noRevoke)) {
loadImage.revokeObjectURL(img._objectURL)
delete img._objectURL
}
}
loadImage.isInstanceOf = function (type, obj) { loadImage.isInstanceOf = function (type, obj) {
// Cross-frame instanceof check // Cross-frame instanceof check
return Object.prototype.toString.call(obj) === '[object ' + type + ']' return Object.prototype.toString.call(obj) === '[object ' + type + ']'
} }
loadImage.transform = function (img, options, callback, file, data) {
callback(loadImage.scale(img, options, data), data)
}
loadImage.onerror = function (img, event, file, callback, options) {
revokeHelper(img, options)
if (callback) {
callback.call(img, event)
}
}
loadImage.onload = function (img, event, file, callback, options) {
revokeHelper(img, options)
if (callback) {
loadImage.transform(img, options, callback, file, {})
}
}
// Transform image coordinates, allows to override e.g. // Transform image coordinates, allows to override e.g.
// the canvas orientation based on the orientation option, // the canvas orientation based on the orientation option,
// gets canvas, options passed as arguments: // gets canvas, options passed as arguments:
@ -136,8 +153,7 @@
return canvas return canvas
} }
// This method is used to determine if the target image // Determines if the target image should be a canvas element:
// should be a canvas element:
loadImage.hasCanvasOption = function (options) { loadImage.hasCanvasOption = function (options) {
return options.canvas || options.crop || !!options.aspectRatio return options.canvas || options.crop || !!options.aspectRatio
} }
@ -147,7 +163,7 @@
// Returns a canvas object if the browser supports canvas // Returns a canvas object if the browser supports canvas
// and the hasCanvasOption method returns true or a canvas // and the hasCanvasOption method returns true or a canvas
// object is passed as image, else the scaled image: // object is passed as image, else the scaled image:
loadImage.scale = function (img, options) { loadImage.scale = function (img, options, data) {
options = options || {} options = options || {}
var canvas = document.createElement('canvas') var canvas = document.createElement('canvas')
var useCanvas = img.getContext || var useCanvas = img.getContext ||
@ -188,7 +204,7 @@
} }
} }
if (useCanvas) { if (useCanvas) {
options = loadImage.getTransformedOptions(img, options) options = loadImage.getTransformedOptions(img, options, data)
sourceX = options.left || 0 sourceX = options.left || 0
sourceY = options.top || 0 sourceY = options.top || 0
if (options.sourceWidth) { if (options.sourceWidth) {

@ -1,6 +1,6 @@
{ {
"name": "blueimp-load-image", "name": "blueimp-load-image",
"version": "2.6.2", "version": "2.7.0",
"main": "index.js", "main": "index.js",
"title": "JavaScript Load Image", "title": "JavaScript Load Image",
"description": "JavaScript Load Image is a library to load images provided as File or Blob objects or via URL. It returns an optionally scaled and/or cropped HTML img or canvas element. It also provides a method to parse image meta data to extract Exif tags and thumbnails and to restore the complete image header after resizing.", "description": "JavaScript Load Image is a library to load images provided as File or Blob objects or via URL. It returns an optionally scaled and/or cropped HTML img or canvas element. It also provides a method to parse image meta data to extract Exif tags and thumbnails and to restore the complete image header after resizing.",
@ -31,13 +31,16 @@
"url": "git://github.com/blueimp/JavaScript-Load-Image.git" "url": "git://github.com/blueimp/JavaScript-Load-Image.git"
}, },
"devDependencies": { "devDependencies": {
"mocha-phantomjs": "4.0.1", "phantomjs-prebuilt": "2.1.13",
"standard": "6.0.7", "mocha-phantomjs-core": "1.3.1",
"uglify-js": "2.6.1" "standard": "8.3.0",
"uglify-js": "2.7.3"
}, },
"scripts": { "scripts": {
"test": "standard *.js js/*.js test/*.js && mocha-phantomjs test/index.html", "lint": "standard *.js js/*.js test/*.js",
"build": "cd js && uglifyjs load-image.js load-image-orientation.js load-image-meta.js load-image-exif.js load-image-exif-map.js -c -m -o load-image.all.min.js --source-map load-image.all.min.js.map", "unit": "phantomjs node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js test/index.html",
"test": "npm run lint && npm run unit",
"build": "cd js && uglifyjs load-image.js load-image-meta.js load-image-exif.js load-image-exif-map.js load-image-orientation.js -c -m -o load-image.all.min.js --source-map load-image.all.min.js.map",
"preversion": "npm test", "preversion": "npm test",
"version": "npm run build && git add -A js", "version": "npm run build && git add -A js",
"postversion": "git push --tags origin master master:gh-pages && npm publish" "postversion": "git push --tags origin master master:gh-pages && npm publish"

@ -24,17 +24,17 @@
<body> <body>
<div id="mocha"></div> <div id="mocha"></div>
<script src="vendor/mocha.js"></script> <script src="vendor/mocha.js"></script>
<script src="vendor/expect.js"></script> <script src="vendor/chai.js"></script>
<script> <script>
window.initMochaPhantomJS && initMochaPhantomJS(); window.initMochaPhantomJS && initMochaPhantomJS();
mocha.setup('bdd'); mocha.setup('bdd');
</script> </script>
<script src="vendor/canvas-to-blob.js"></script> <script src="vendor/canvas-to-blob.js"></script>
<script src="../js/load-image.js"></script> <script src="../js/load-image.js"></script>
<script src="../js/load-image-orientation.js"></script>
<script src="../js/load-image-meta.js"></script> <script src="../js/load-image-meta.js"></script>
<script src="../js/load-image-exif.js"></script> <script src="../js/load-image-exif.js"></script>
<script src="../js/load-image-exif-map.js"></script> <script src="../js/load-image-exif-map.js"></script>
<script src="../js/load-image-orientation.js"></script>
<script src="test.js"></script> <script src="test.js"></script>
<script> <script>
mocha.checkLeaks(); mocha.checkLeaks();

@ -9,7 +9,7 @@
* http://www.opensource.org/licenses/MIT * http://www.opensource.org/licenses/MIT
*/ */
/*global window, describe, it, Blob */ /* global describe, it, Blob */
;(function (expect, loadImage) { ;(function (expect, loadImage) {
'use strict' 'use strict'
@ -21,7 +21,7 @@
'ovGITCqXzKbzCY1Kp9Sq9YrNarfcrvcLDovH5PKsAAA7' 'ovGITCqXzKbzCY1Kp9Sq9YrNarfcrvcLDovH5PKsAAA7'
var imageUrlGIF = 'data:image/gif;base64,' + b64DataGIF var imageUrlGIF = 'data:image/gif;base64,' + b64DataGIF
var blobGIF = canCreateBlob && window.dataURLtoBlob(imageUrlGIF) var blobGIF = canCreateBlob && window.dataURLtoBlob(imageUrlGIF)
// 1x2px JPEG (color white, with the Exif orientation flag set to 6): // 2x1px JPEG (color white, with the Exif orientation flag set to 6):
var b64DataJPEG = '/9j/4AAQSkZJRgABAQEAYABgAAD/4QAiRXhpZgAASUkqAAgAAA' + var b64DataJPEG = '/9j/4AAQSkZJRgABAQEAYABgAAD/4QAiRXhpZgAASUkqAAgAAA' +
'ABABIBAwABAAAABgASAAAAAAD/2wBDAAEBAQEBAQEBAQEBAQEB' + 'ABABIBAwABAAAABgASAAAAAAD/2wBDAAEBAQEBAQEBAQEBAQEB' +
'AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ' + 'AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ' +
@ -59,43 +59,43 @@
var img = loadImage(blobGIF, function () { var img = loadImage(blobGIF, function () {
return return
}) })
expect(img).to.be.an(Object) expect(img).to.be.an.instanceOf(Object)
expect(img.onload).to.be.a('function') expect(img.onload).to.be.a('function')
expect(img.onerror).to.be.a('function') expect(img.onerror).to.be.a('function')
}) })
it('Load image url', function (done) { it('Load image url', function (done) {
expect(loadImage(imageUrlGIF, function (img) { expect(loadImage(imageUrlGIF, function (img) {
expect(img.width).to.be(80) expect(img.width).to.equal(80)
expect(img.height).to.be(60) expect(img.height).to.equal(60)
done() done()
})).to.be.ok() })).to.be.ok
}) })
it('Load image blob', function (done) { it('Load image blob', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.width).to.be(80) expect(img.width).to.equal(80)
expect(img.height).to.be(60) expect(img.height).to.equal(60)
done() done()
})).to.be.ok() })).to.be.ok
}) })
it('Return image loading error to callback', function (done) { it('Return image loading error to callback', function (done) {
expect(loadImage('404', function (img) { expect(loadImage('404', function (img) {
expect(img).to.be.a(window.Event) expect(img).to.be.an.instanceOf(window.Event)
expect(img.type).to.be('error') expect(img.type).to.equal('error')
done() done()
})).to.be.ok() })).to.be.ok
}) })
it('Keep object URL if noRevoke is true', function (done) { it('Keep object URL if noRevoke is true', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
loadImage(img.src, function (img2) { loadImage(img.src, function (img2) {
expect(img.width).to.be(img2.width) expect(img.width).to.equal(img2.width)
expect(img.height).to.be(img2.height) expect(img.height).to.equal(img2.height)
done() done()
}) })
}, {noRevoke: true})).to.be.ok() }, {noRevoke: true})).to.be.ok
}) })
it('Discard object URL if noRevoke is undefined or false', function (done) { it('Discard object URL if noRevoke is undefined or false', function (done) {
@ -103,12 +103,12 @@
loadImage(img.src, function (img2) { loadImage(img.src, function (img2) {
if (!window.callPhantom) { if (!window.callPhantom) {
// revokeObjectUrl doesn't seem to have an effect in PhantomJS // revokeObjectUrl doesn't seem to have an effect in PhantomJS
expect(img2).to.be.a(window.Event) expect(img2).to.be.an.instanceOf(window.Event)
expect(img2.type).to.be('error') expect(img2.type).to.equal('error')
} }
done() done()
}) })
})).to.be.ok() })).to.be.ok
}) })
}) })
@ -116,146 +116,146 @@
describe('max/min', function () { describe('max/min', function () {
it('Scale to maxWidth', function (done) { it('Scale to maxWidth', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.width).to.be(40) expect(img.width).to.equal(40)
expect(img.height).to.be(30) expect(img.height).to.equal(30)
done() done()
}, {maxWidth: 40})).to.be.ok() }, {maxWidth: 40})).to.be.ok
}) })
it('Scale to maxHeight', function (done) { it('Scale to maxHeight', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.width).to.be(20) expect(img.width).to.equal(20)
expect(img.height).to.be(15) expect(img.height).to.equal(15)
done() done()
}, {maxHeight: 15})).to.be.ok() }, {maxHeight: 15})).to.be.ok
}) })
it('Scale to minWidth', function (done) { it('Scale to minWidth', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.width).to.be(160) expect(img.width).to.equal(160)
expect(img.height).to.be(120) expect(img.height).to.equal(120)
done() done()
}, {minWidth: 160})).to.be.ok() }, {minWidth: 160})).to.be.ok
}) })
it('Scale to minHeight', function (done) { it('Scale to minHeight', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.width).to.be(320) expect(img.width).to.equal(320)
expect(img.height).to.be(240) expect(img.height).to.equal(240)
done() done()
}, {minHeight: 240})).to.be.ok() }, {minHeight: 240})).to.be.ok
}) })
it('Scale to minWidth but respect maxWidth', function (done) { it('Scale to minWidth but respect maxWidth', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.width).to.be(160) expect(img.width).to.equal(160)
expect(img.height).to.be(120) expect(img.height).to.equal(120)
done() done()
}, {minWidth: 240, maxWidth: 160})).to.be.ok() }, {minWidth: 240, maxWidth: 160})).to.be.ok
}) })
it('Scale to minHeight but respect maxHeight', function (done) { it('Scale to minHeight but respect maxHeight', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.width).to.be(160) expect(img.width).to.equal(160)
expect(img.height).to.be(120) expect(img.height).to.equal(120)
done() done()
}, {minHeight: 180, maxHeight: 120})).to.be.ok() }, {minHeight: 180, maxHeight: 120})).to.be.ok
}) })
it('Scale to minWidth but respect maxHeight', function (done) { it('Scale to minWidth but respect maxHeight', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.width).to.be(160) expect(img.width).to.equal(160)
expect(img.height).to.be(120) expect(img.height).to.equal(120)
done() done()
}, {minWidth: 240, maxHeight: 120})).to.be.ok() }, {minWidth: 240, maxHeight: 120})).to.be.ok
}) })
it('Scale to minHeight but respect maxWidth', function (done) { it('Scale to minHeight but respect maxWidth', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.width).to.be(160) expect(img.width).to.equal(160)
expect(img.height).to.be(120) expect(img.height).to.equal(120)
done() done()
}, {minHeight: 180, maxWidth: 160})).to.be.ok() }, {minHeight: 180, maxWidth: 160})).to.be.ok
}) })
it('Scale up with the given pixelRatio', function (done) { it('Scale up with the given pixelRatio', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.width).to.be(320) expect(img.width).to.equal(320)
expect(img.height).to.be(240) expect(img.height).to.equal(240)
expect(img.style.width).to.be('160px') expect(img.style.width).to.equal('160px')
expect(img.style.height).to.be('120px') expect(img.style.height).to.equal('120px')
done() done()
}, {minWidth: 160, canvas: true, pixelRatio: 2})).to.be.ok() }, {minWidth: 160, canvas: true, pixelRatio: 2})).to.be.ok
}) })
it('Scale down with the given pixelRatio', function (done) { it('Scale down with the given pixelRatio', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.width).to.be(80) expect(img.width).to.equal(80)
expect(img.height).to.be(60) expect(img.height).to.equal(60)
expect(img.style.width).to.be('40px') expect(img.style.width).to.equal('40px')
expect(img.style.height).to.be('30px') expect(img.style.height).to.equal('30px')
done() done()
}, {maxWidth: 40, canvas: true, pixelRatio: 2})).to.be.ok() }, {maxWidth: 40, canvas: true, pixelRatio: 2})).to.be.ok
}) })
it('Scale down with the given downsamplingRatio', function (done) { it('Scale down with the given downsamplingRatio', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.width).to.be(20) expect(img.width).to.equal(20)
expect(img.height).to.be(15) expect(img.height).to.equal(15)
done() done()
}, {maxWidth: 20, canvas: true, downsamplingRatio: 0.5})).to.be.ok() }, {maxWidth: 20, canvas: true, downsamplingRatio: 0.5})).to.be.ok
}) })
it('Ignore max settings if image dimensions are smaller', function (done) { it('Ignore max settings if image dimensions are smaller', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.width).to.be(80) expect(img.width).to.equal(80)
expect(img.height).to.be(60) expect(img.height).to.equal(60)
done() done()
}, {maxWidth: 160, maxHeight: 120})).to.be.ok() }, {maxWidth: 160, maxHeight: 120})).to.be.ok
}) })
it('Ignore min settings if image dimensions are larger', function (done) { it('Ignore min settings if image dimensions are larger', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.width).to.be(80) expect(img.width).to.equal(80)
expect(img.height).to.be(60) expect(img.height).to.equal(60)
done() done()
}, {minWidth: 40, minHeight: 30})).to.be.ok() }, {minWidth: 40, minHeight: 30})).to.be.ok
}) })
}) })
describe('contain', function () { describe('contain', function () {
it('Scale up to contain image in max dimensions', function (done) { it('Scale up to contain image in max dimensions', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.width).to.be(160) expect(img.width).to.equal(160)
expect(img.height).to.be(120) expect(img.height).to.equal(120)
done() done()
}, {maxWidth: 160, maxHeight: 160, contain: true})).to.be.ok() }, {maxWidth: 160, maxHeight: 160, contain: true})).to.be.ok
}) })
it('Scale down to contain image in max dimensions', function (done) { it('Scale down to contain image in max dimensions', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.width).to.be(40) expect(img.width).to.equal(40)
expect(img.height).to.be(30) expect(img.height).to.equal(30)
done() done()
}, {maxWidth: 40, maxHeight: 40, contain: true})).to.be.ok() }, {maxWidth: 40, maxHeight: 40, contain: true})).to.be.ok
}) })
}) })
describe('cover', function () { describe('cover', function () {
it('Scale up to cover max dimensions with image dimensions', function (done) { it('Scale up to cover max dimensions with image dimensions', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.width).to.be(160) expect(img.width).to.equal(160)
expect(img.height).to.be(120) expect(img.height).to.equal(120)
done() done()
}, {maxWidth: 120, maxHeight: 120, cover: true})).to.be.ok() }, {maxWidth: 120, maxHeight: 120, cover: true})).to.be.ok
}) })
it('Scale down to cover max dimensions with image dimensions', function (done) { it('Scale down to cover max dimensions with image dimensions', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.width).to.be(40) expect(img.width).to.equal(40)
expect(img.height).to.be(30) expect(img.height).to.equal(30)
done() done()
}, {maxWidth: 30, maxHeight: 30, cover: true})).to.be.ok() }, {maxWidth: 30, maxHeight: 30, cover: true})).to.be.ok
}) })
}) })
}) })
@ -263,208 +263,219 @@
describe('Cropping', function () { describe('Cropping', function () {
it('Crop to same values for maxWidth and maxHeight', function (done) { it('Crop to same values for maxWidth and maxHeight', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.width).to.be(40) expect(img.width).to.equal(40)
expect(img.height).to.be(40) expect(img.height).to.equal(40)
done() done()
}, {maxWidth: 40, maxHeight: 40, crop: true})).to.be.ok() }, {maxWidth: 40, maxHeight: 40, crop: true})).to.be.ok
}) })
it('Crop to different values for maxWidth and maxHeight', function (done) { it('Crop to different values for maxWidth and maxHeight', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.width).to.be(40) expect(img.width).to.equal(40)
expect(img.height).to.be(60) expect(img.height).to.equal(60)
done() done()
}, {maxWidth: 40, maxHeight: 60, crop: true})).to.be.ok() }, {maxWidth: 40, maxHeight: 60, crop: true})).to.be.ok
}) })
it('Crop using the given sourceWidth and sourceHeight dimensions', function (done) { it('Crop using the given sourceWidth and sourceHeight dimensions', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.width).to.be(40) expect(img.width).to.equal(40)
expect(img.height).to.be(40) expect(img.height).to.equal(40)
done() done()
}, {sourceWidth: 40, sourceHeight: 40, crop: true})).to.be.ok() }, {sourceWidth: 40, sourceHeight: 40, crop: true})).to.be.ok
}) })
it('Crop using the given left and top coordinates', function (done) { it('Crop using the given left and top coordinates', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.width).to.be(40) expect(img.width).to.equal(40)
expect(img.height).to.be(20) expect(img.height).to.equal(20)
done() done()
}, {left: 40, top: 40, crop: true})).to.be.ok() }, {left: 40, top: 40, crop: true})).to.be.ok
}) })
it('Crop using the given right and bottom coordinates', function (done) { it('Crop using the given right and bottom coordinates', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.width).to.be(40) expect(img.width).to.equal(40)
expect(img.height).to.be(20) expect(img.height).to.equal(20)
done() done()
}, {right: 40, bottom: 40, crop: true})).to.be.ok() }, {right: 40, bottom: 40, crop: true})).to.be.ok
}) })
it('Crop using the given 2:1 aspectRatio', function (done) { it('Crop using the given 2:1 aspectRatio', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.width).to.be(80) expect(img.width).to.equal(80)
expect(img.height).to.be(40) expect(img.height).to.equal(40)
done() done()
}, {aspectRatio: 2})).to.be.ok() }, {aspectRatio: 2})).to.be.ok
}) })
it('Crop using the given 2:3 aspectRatio', function (done) { it('Crop using the given 2:3 aspectRatio', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.width).to.be(40) expect(img.width).to.equal(40)
expect(img.height).to.be(60) expect(img.height).to.equal(60)
done() done()
}, {aspectRatio: 2 / 3})).to.be.ok() }, {aspectRatio: 2 / 3})).to.be.ok
}) })
it('Crop using maxWidth/maxHeight with the given pixelRatio', function (done) { it('Crop using maxWidth/maxHeight with the given pixelRatio', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.width).to.be(80) expect(img.width).to.equal(80)
expect(img.height).to.be(80) expect(img.height).to.equal(80)
expect(img.style.width).to.be('40px') expect(img.style.width).to.equal('40px')
expect(img.style.height).to.be('40px') expect(img.style.height).to.equal('40px')
done() done()
}, {maxWidth: 40, maxHeight: 40, crop: true, pixelRatio: 2})).to.be.ok() }, {maxWidth: 40, maxHeight: 40, crop: true, pixelRatio: 2})).to.be.ok
}) })
it('Crop using sourceWidth/sourceHeight with the given pixelRatio', function (done) { it('Crop using sourceWidth/sourceHeight with the given pixelRatio', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.width).to.be(80) expect(img.width).to.equal(80)
expect(img.height).to.be(80) expect(img.height).to.equal(80)
expect(img.style.width).to.be('40px') expect(img.style.width).to.equal('40px')
expect(img.style.height).to.be('40px') expect(img.style.height).to.equal('40px')
done() done()
}, {sourceWidth: 40, sourceHeight: 40, crop: true, pixelRatio: 2})).to.be.ok() }, {sourceWidth: 40, sourceHeight: 40, crop: true, pixelRatio: 2})).to.be.ok
}) })
}) })
describe('Orientation', function () { describe('Orientation', function () {
it('Should keep the orientation', function (done) { it('Should keep the orientation', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.width).to.be(80) expect(img.width).to.equal(80)
expect(img.height).to.be(60) expect(img.height).to.equal(60)
done() done()
}, {orientation: 1})).to.be.ok() }, {orientation: 1})).to.be.ok
}) })
it('Should rotate left', function (done) { it('Should rotate left', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.width).to.be(60) expect(img.width).to.equal(60)
expect(img.height).to.be(80) expect(img.height).to.equal(80)
done() done()
}, {orientation: 8})).to.be.ok() }, {orientation: 8})).to.be.ok
}) })
it('Should rotate right', function (done) { it('Should rotate right', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.width).to.be(60) expect(img.width).to.equal(60)
expect(img.height).to.be(80) expect(img.height).to.equal(80)
done() done()
}, {orientation: 6})).to.be.ok() }, {orientation: 6})).to.be.ok
}) })
it('Should adjust constraints to new coordinates', function (done) { it('Should adjust constraints to new coordinates', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.width).to.be(60) expect(img.width).to.equal(60)
expect(img.height).to.be(80) expect(img.height).to.equal(80)
done() done()
}, {orientation: 6, maxWidth: 60, maxHeight: 80})).to.be.ok() }, {orientation: 6, maxWidth: 60, maxHeight: 80})).to.be.ok
}) })
it('Should adjust left and top to new coordinates', function (done) { it('Should adjust left and top to new coordinates', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.width).to.be(30) expect(img.width).to.equal(30)
expect(img.height).to.be(60) expect(img.height).to.equal(60)
done() done()
}, {orientation: 5, left: 30, top: 20})).to.be.ok() }, {orientation: 5, left: 30, top: 20})).to.be.ok
}) })
it('Should adjust right and bottom to new coordinates', function (done) { it('Should adjust right and bottom to new coordinates', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.width).to.be(30) expect(img.width).to.equal(30)
expect(img.height).to.be(60) expect(img.height).to.equal(60)
done() done()
}, {orientation: 5, right: 30, bottom: 20})).to.be.ok() }, {orientation: 5, right: 30, bottom: 20})).to.be.ok
}) })
it('Should adjust left and bottom to new coordinates', function (done) { it('Should adjust left and bottom to new coordinates', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.width).to.be(30) expect(img.width).to.equal(30)
expect(img.height).to.be(60) expect(img.height).to.equal(60)
done() done()
}, {orientation: 7, left: 30, bottom: 20})).to.be.ok() }, {orientation: 7, left: 30, bottom: 20})).to.be.ok
}) })
it('Should adjust right and top to new coordinates', function (done) { it('Should adjust right and top to new coordinates', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.width).to.be(30) expect(img.width).to.equal(30)
expect(img.height).to.be(60) expect(img.height).to.equal(60)
done() done()
}, {orientation: 7, right: 30, top: 20})).to.be.ok() }, {orientation: 7, right: 30, top: 20})).to.be.ok
}) })
it('Should rotate left with the given pixelRatio', function (done) { it('Should rotate left with the given pixelRatio', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.width).to.be(120) expect(img.width).to.equal(120)
expect(img.height).to.be(160) expect(img.height).to.equal(160)
expect(img.style.width).to.be('60px') expect(img.style.width).to.equal('60px')
expect(img.style.height).to.be('80px') expect(img.style.height).to.equal('80px')
done() done()
}, {orientation: 8, pixelRatio: 2})).to.be.ok() }, {orientation: 8, pixelRatio: 2})).to.be.ok
}) })
it('Should rotate right with the given pixelRatio', function (done) { it('Should rotate right with the given pixelRatio', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.width).to.be(120) expect(img.width).to.equal(120)
expect(img.height).to.be(160) expect(img.height).to.equal(160)
expect(img.style.width).to.be('60px') expect(img.style.width).to.equal('60px')
expect(img.style.height).to.be('80px') expect(img.style.height).to.equal('80px')
done() done()
}, {orientation: 6, pixelRatio: 2})).to.be.ok() }, {orientation: 6, pixelRatio: 2})).to.be.ok
}) })
it('Should ignore too small orientation value', function (done) { it('Should ignore too small orientation value', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.width).to.be(80) expect(img.width).to.equal(80)
expect(img.height).to.be(60) expect(img.height).to.equal(60)
done() done()
}, {orientation: -1})).to.be.ok() }, {orientation: -1})).to.be.ok
}) })
it('Should ignore too large orientation value', function (done) { it('Should ignore too large orientation value', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.width).to.be(80) expect(img.width).to.equal(80)
expect(img.height).to.be(60) expect(img.height).to.equal(60)
done() done()
}, {orientation: 9})).to.be.ok() }, {orientation: 9})).to.be.ok
})
it('Should rotate right based on the exif orientation value', function (done) {
expect(loadImage(blobJPEG, function (img, data) {
expect(data).to.be.ok
expect(data.exif).to.be.ok
expect(data.exif.get('Orientation')).to.equal(6)
expect(img.width).to.equal(1)
expect(img.height).to.equal(2)
done()
}, {orientation: true})).to.be.ok
}) })
}) })
describe('Canvas', function () { describe('Canvas', function () {
it('Return img element to callback if canvas is not true', function (done) { it('Return img element to callback if canvas is not true', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.getContext).to.not.be.ok() expect(img.getContext).to.not.be.ok
expect(img.nodeName.toLowerCase()).to.be('img') expect(img.nodeName.toLowerCase()).to.equal('img')
done() done()
})).to.be.ok() })).to.be.ok
}) })
it('Return canvas element to callback if canvas is true', function (done) { it('Return canvas element to callback if canvas is true', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.getContext).to.be.ok() expect(img.getContext).to.be.ok
expect(img.nodeName.toLowerCase()).to.be('canvas') expect(img.nodeName.toLowerCase()).to.equal('canvas')
done() done()
}, {canvas: true})).to.be.ok() }, {canvas: true})).to.be.ok
}) })
it('Return scaled canvas element to callback', function (done) { it('Return scaled canvas element to callback', function (done) {
expect(loadImage(blobGIF, function (img) { expect(loadImage(blobGIF, function (img) {
expect(img.getContext).to.be.ok() expect(img.getContext).to.be.ok
expect(img.nodeName.toLowerCase()).to.be('canvas') expect(img.nodeName.toLowerCase()).to.equal('canvas')
expect(img.width).to.be(40) expect(img.width).to.equal(40)
expect(img.height).to.be(30) expect(img.height).to.equal(30)
done() done()
}, {canvas: true, maxWidth: 40})).to.be.ok() }, {canvas: true, maxWidth: 40})).to.be.ok
}) })
it('Accept a canvas element as parameter for loadImage.scale', function (done) { it('Accept a canvas element as parameter for loadImage.scale', function (done) {
@ -472,39 +483,49 @@
img = loadImage.scale(img, { img = loadImage.scale(img, {
maxWidth: 40 maxWidth: 40
}) })
expect(img.getContext).to.be.ok() expect(img.getContext).to.be.ok
expect(img.nodeName.toLowerCase()).to.be('canvas') expect(img.nodeName.toLowerCase()).to.equal('canvas')
expect(img.width).to.be(40) expect(img.width).to.equal(40)
expect(img.height).to.be(30) expect(img.height).to.equal(30)
done() done()
}, {canvas: true})).to.be.ok() }, {canvas: true})).to.be.ok
}) })
}) })
describe('Metadata', function () { describe('Metadata', function () {
it('Should parse Exif information', function (done) { it('Should parse Exif information', function (done) {
loadImage.parseMetaData(blobJPEG, function (data) { loadImage.parseMetaData(blobJPEG, function (data) {
expect(data.exif).to.be.ok() expect(data.exif).to.be.ok
expect(data.exif.get('Orientation')).to.be(6) expect(data.exif.get('Orientation')).to.equal(6)
done() done()
}) })
}) })
it('Should parse the complete image head', function (done) { it('Should parse the complete image head', function (done) {
loadImage.parseMetaData(blobJPEG, function (data) { loadImage.parseMetaData(blobJPEG, function (data) {
expect(data.imageHead).to.be.ok() expect(data.imageHead).to.be.ok
loadImage.parseMetaData( loadImage.parseMetaData(
createBlob(data.imageHead, 'image/jpeg'), createBlob(data.imageHead, 'image/jpeg'),
function (data) { function (data) {
expect(data.exif).to.be.ok() expect(data.exif).to.be.ok
expect(data.exif.get('Orientation')).to.be(6) expect(data.exif.get('Orientation')).to.equal(6)
done() done()
} }
) )
}) })
}) })
it('Should parse meta data automatically', function (done) {
expect(loadImage(blobJPEG, function (img, data) {
expect(data).to.be.ok
expect(data.imageHead).to.be.ok
expect(data.exif).to.be.ok
expect(data.exif.get('Orientation')).to.equal(6)
done()
}, {meta: true})).to.be.ok
})
}) })
}( }(
this.expect, this.chai.expect,
this.loadImage this.loadImage
)) ))

@ -1,12 +1,12 @@
{ {
"name": "blueimp-tmpl", "name": "blueimp-tmpl",
"homepage": "https://github.com/blueimp/JavaScript-Templates", "homepage": "https://github.com/blueimp/JavaScript-Templates",
"version": "3.4.0", "version": "3.5.0",
"_release": "3.4.0", "_release": "3.5.0",
"_resolution": { "_resolution": {
"type": "version", "type": "version",
"tag": "v3.4.0", "tag": "v3.5.0",
"commit": "dcb7a7b44c733c5df0b6000e777bc6942646607e" "commit": "19dfc68580d036de22f1767ef8fde1a6da75b64b"
}, },
"_source": "https://github.com/blueimp/JavaScript-Templates.git", "_source": "https://github.com/blueimp/JavaScript-Templates.git",
"_target": ">=2.5.4", "_target": ">=2.5.4",

@ -10,8 +10,6 @@
* http://www.opensource.org/licenses/MIT * http://www.opensource.org/licenses/MIT
*/ */
/*global require, __dirname, process, console */
;(function () { ;(function () {
'use strict' 'use strict'
var path = require('path') var path = require('path')

@ -9,7 +9,7 @@
* http://www.opensource.org/licenses/MIT * http://www.opensource.org/licenses/MIT
*/ */
/* global document, tmpl */ /* global tmpl */
;(function () { ;(function () {
'use strict' 'use strict'

@ -9,7 +9,7 @@
* http://www.opensource.org/licenses/MIT * http://www.opensource.org/licenses/MIT
*/ */
/*global define, module */ /* global define */
;(function ($) { ;(function ($) {
'use strict' 'use strict'
@ -20,7 +20,7 @@
} }
} }
tmpl.cache = {} tmpl.cache = {}
tmpl.encReg = /[<>&"'\x00]/g tmpl.encReg = /[<>&"'\x00]/g // eslint-disable-line no-control-regex
tmpl.encMap = { tmpl.encMap = {
'<': '&lt;', '<': '&lt;',
'>': '&gt;', '>': '&gt;',

@ -12,7 +12,7 @@
* http://ejohn.org/blog/javascript-micro-templating/ * http://ejohn.org/blog/javascript-micro-templating/
*/ */
/*global document, define, module */ /* global define */
;(function ($) { ;(function ($) {
'use strict' 'use strict'
@ -55,7 +55,7 @@
return "_s+='" return "_s+='"
} }
} }
tmpl.encReg = /[<>&"'\x00]/g tmpl.encReg = /[<>&"'\x00]/g // eslint-disable-line no-control-regex
tmpl.encMap = { tmpl.encMap = {
'<': '&lt;', '<': '&lt;',
'>': '&gt;', '>': '&gt;',

@ -1,2 +1,2 @@
!function(e){"use strict";var n=function(e,t){var r=/[^\w\-\.:]/.test(e)?new Function(n.arg+",tmpl","var _e=tmpl.encode"+n.helper+",_s='"+e.replace(n.regexp,n.func)+"';return _s;"):n.cache[e]=n.cache[e]||n(n.load(e));return t?r(t,n):function(e){return r(e,n)}};n.cache={},n.load=function(e){return document.getElementById(e).innerHTML},n.regexp=/([\s'\\])(?!(?:[^{]|\{(?!%))*%\})|(?:\{%(=|#)([\s\S]+?)%\})|(\{%)|(%\})/g,n.func=function(e,n,t,r,c,u){return n?{"\n":"\\n","\r":"\\r"," ":"\\t"," ":" "}[n]||"\\"+n:t?"="===t?"'+_e("+r+")+'":"'+("+r+"==null?'':"+r+")+'":c?"';":u?"_s+='":void 0},n.encReg=/[<>&"'\x00]/g,n.encMap={"<":"&lt;",">":"&gt;","&":"&amp;",'"':"&quot;","'":"&#39;"},n.encode=function(e){return(null==e?"":""+e).replace(n.encReg,function(e){return n.encMap[e]||""})},n.arg="o",n.helper=",print=function(s,e){_s+=e?(s==null?'':s):_e(s);},include=function(s,d){_s+=tmpl(s,d);}","function"==typeof define&&define.amd?define(function(){return n}):"object"==typeof module&&module.exports?module.exports=n:e.tmpl=n}(this); !function(e){"use strict";var n=function(e,t){var r=/[^\w\-\.:]/.test(e)?new Function(n.arg+",tmpl","var _e=tmpl.encode"+n.helper+",_s='"+e.replace(n.regexp,n.func)+"';return _s;"):n.cache[e]=n.cache[e]||n(n.load(e));return t?r(t,n):function(e){return r(e,n)}};n.cache={},n.load=function(e){return document.getElementById(e).innerHTML},n.regexp=/([\s'\\])(?!(?:[^{]|\{(?!%))*%\})|(?:\{%(=|#)([\s\S]+?)%\})|(\{%)|(%\})/g,n.func=function(e,n,t,r,c,u){return n?{"\n":"\\n","\r":"\\r","\t":"\\t"," ":" "}[n]||"\\"+n:t?"="===t?"'+_e("+r+")+'":"'+("+r+"==null?'':"+r+")+'":c?"';":u?"_s+='":void 0},n.encReg=/[<>&"'\x00]/g,n.encMap={"<":"&lt;",">":"&gt;","&":"&amp;",'"':"&quot;","'":"&#39;"},n.encode=function(e){return(null==e?"":""+e).replace(n.encReg,function(e){return n.encMap[e]||""})},n.arg="o",n.helper=",print=function(s,e){_s+=e?(s==null?'':s):_e(s);},include=function(s,d){_s+=tmpl(s,d);}","function"==typeof define&&define.amd?define(function(){return n}):"object"==typeof module&&module.exports?module.exports=n:e.tmpl=n}(this);
//# sourceMappingURL=tmpl.min.js.map //# sourceMappingURL=tmpl.min.js.map

@ -1 +1 @@
{"version":3,"sources":["tmpl.js"],"names":["$","tmpl","str","data","f","test","Function","arg","helper","replace","regexp","func","cache","load","id","document","getElementById","innerHTML","s","p1","p2","p3","p4","p5","\n","\r","\t"," ","encReg","encMap","<",">","&","\"","'","encode","c","define","amd","module","exports","this"],"mappings":"CAgBE,SAAUA,GACV,YACA,IAAIC,GAAO,SAAUC,EAAKC,GACxB,GAAIC,GAAK,aAAaC,KAAKH,GAEvB,GAAII,UACJL,EAAKM,IAAM,QACX,qBAAuBN,EAAKO,OAAS,QACnCN,EAAIO,QAAQR,EAAKS,OAAQT,EAAKU,MAAQ,gBAJxCV,EAAKW,MAAMV,GAAOD,EAAKW,MAAMV,IAAQD,EAAKA,EAAKY,KAAKX,GAMxD,OAAOC,GAAOC,EAAED,EAAMF,GAAQ,SAAUE,GACtC,MAAOC,GAAED,EAAMF,IAGnBA,GAAKW,SACLX,EAAKY,KAAO,SAAUC,GACpB,MAAOC,UAASC,eAAeF,GAAIG,WAErChB,EAAKS,OAAS,2EACdT,EAAKU,KAAO,SAAUO,EAAGC,EAAIC,EAAIC,EAAIC,EAAIC,GACvC,MAAIJ,IAEAK,KAAM,MACNC,KAAM,MACNC,IAAM,MACNC,IAAK,KACLR,IAAO,KAAOA,EAEdC,EACS,MAAPA,EACK,QAAUC,EAAK,MAEjB,MAAQA,EAAK,aAAeA,EAAK,MAEtCC,EACK,KAELC,EACK,QADT,QAIFtB,EAAK2B,OAAS,eACd3B,EAAK4B,QACHC,IAAK,OACLC,IAAK,OACLC,IAAK,QACLC,IAAK,SACLC,IAAK,SAEPjC,EAAKkC,OAAS,SAAUjB,GACtB,OAAa,MAALA,EAAY,GAAK,GAAKA,GAAGT,QAC/BR,EAAK2B,OACL,SAAUQ,GACR,MAAOnC,GAAK4B,OAAOO,IAAM,MAI/BnC,EAAKM,IAAM,IACXN,EAAKO,OAAS,0FAEQ,kBAAX6B,SAAyBA,OAAOC,IACzCD,OAAO,WACL,MAAOpC,KAEkB,gBAAXsC,SAAuBA,OAAOC,QAC9CD,OAAOC,QAAUvC,EAEjBD,EAAEC,KAAOA,GAEXwC","file":"tmpl.min.js"} {"version":3,"sources":["tmpl.js"],"names":["$","tmpl","str","data","f","test","Function","arg","helper","replace","regexp","func","cache","load","id","document","getElementById","innerHTML","s","p1","p2","p3","p4","p5","\n","\r","\t"," ","encReg","encMap","<",">","&","\"","'","encode","c","define","amd","module","exports","this"],"mappings":"CAgBE,SAAUA,GACV,YACA,IAAIC,GAAO,SAAUC,EAAKC,GACxB,GAAIC,GAAK,aAAaC,KAAKH,GAEvB,GAAII,UACJL,EAAKM,IAAM,QACX,qBAAuBN,EAAKO,OAAS,QACnCN,EAAIO,QAAQR,EAAKS,OAAQT,EAAKU,MAAQ,gBAJxCV,EAAKW,MAAMV,GAAOD,EAAKW,MAAMV,IAAQD,EAAKA,EAAKY,KAAKX,GAMxD,OAAOC,GAAOC,EAAED,EAAMF,GAAQ,SAAUE,GACtC,MAAOC,GAAED,EAAMF,IAGnBA,GAAKW,SACLX,EAAKY,KAAO,SAAUC,GACpB,MAAOC,UAASC,eAAeF,GAAIG,WAErChB,EAAKS,OAAS,2EACdT,EAAKU,KAAO,SAAUO,EAAGC,EAAIC,EAAIC,EAAIC,EAAIC,GACvC,MAAIJ,IAEAK,KAAM,MACNC,KAAM,MACNC,KAAM,MACNC,IAAK,KACLR,IAAO,KAAOA,EAEdC,EACS,MAAPA,EACK,QAAUC,EAAK,MAEjB,MAAQA,EAAK,aAAeA,EAAK,MAEtCC,EACK,KAELC,EACK,QADT,QAIFtB,EAAK2B,OAAS,eACd3B,EAAK4B,QACHC,IAAK,OACLC,IAAK,OACLC,IAAK,QACLC,IAAK,SACLC,IAAK,SAEPjC,EAAKkC,OAAS,SAAUjB,GACtB,OAAa,MAALA,EAAY,GAAK,GAAKA,GAAGT,QAC/BR,EAAK2B,OACL,SAAUQ,GACR,MAAOnC,GAAK4B,OAAOO,IAAM,MAI/BnC,EAAKM,IAAM,IACXN,EAAKO,OAAS,0FAEQ,kBAAX6B,SAAyBA,OAAOC,IACzCD,OAAO,WACL,MAAOpC,KAEkB,gBAAXsC,SAAuBA,OAAOC,QAC9CD,OAAOC,QAAUvC,EAEjBD,EAAEC,KAAOA,GAEXwC","file":"tmpl.min.js"}

@ -1,6 +1,6 @@
{ {
"name": "blueimp-tmpl", "name": "blueimp-tmpl",
"version": "3.4.0", "version": "3.5.0",
"title": "JavaScript Templates", "title": "JavaScript Templates",
"description": "1KB lightweight, fast & powerful JavaScript templating engine with zero dependencies. Compatible with server-side environments like Node.js, module loaders like RequireJS, Browserify or webpack and all web browsers.", "description": "1KB lightweight, fast & powerful JavaScript templating engine with zero dependencies. Compatible with server-side environments like Node.js, module loaders like RequireJS, Browserify or webpack and all web browsers.",
"keywords": [ "keywords": [
@ -19,13 +19,15 @@
}, },
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"expect.js": "0.3.1", "chai": "3.5.0",
"mocha": "2.3.4", "mocha": "3.1.0",
"standard": "6.0.7", "standard": "8.3.0",
"uglify-js": "2.6.1" "uglify-js": "2.7.3"
}, },
"scripts": { "scripts": {
"test": "standard js/*.js test/*.js && mocha", "lint": "standard js/*.js test/*.js",
"unit": "mocha",
"test": "npm run lint && npm run unit",
"build": "cd js && uglifyjs tmpl.js -c -m -o tmpl.min.js --source-map tmpl.min.js.map", "build": "cd js && uglifyjs tmpl.js -c -m -o tmpl.min.js --source-map tmpl.min.js.map",
"preversion": "npm test", "preversion": "npm test",
"version": "npm run build && git add -A js", "version": "npm run build && git add -A js",

@ -24,7 +24,7 @@
<body> <body>
<div id="mocha"></div> <div id="mocha"></div>
<script src="vendor/mocha.js"></script> <script src="vendor/mocha.js"></script>
<script src="vendor/expect.js"></script> <script src="vendor/chai.js"></script>
<script> <script>
mocha.setup('bdd'); mocha.setup('bdd');
</script> </script>

@ -9,7 +9,7 @@
* http://www.opensource.org/licenses/MIT * http://www.opensource.org/licenses/MIT
*/ */
/*global beforeEach, afterEach, describe, it, require */ /* global beforeEach, afterEach, describe, it */
;(function (context, expect, tmpl) { ;(function (context, expect, tmpl) {
'use strict' 'use strict'
@ -53,7 +53,7 @@
it('String template', function () { it('String template', function () {
expect( expect(
tmpl('{%=o.value%}', data) tmpl('{%=o.value%}', data)
).to.be( ).to.equal(
'value' 'value'
) )
}) })
@ -61,7 +61,7 @@
it('Load template by id', function () { it('Load template by id', function () {
expect( expect(
tmpl('template', data) tmpl('template', data)
).to.be( ).to.equal(
'value' 'value'
) )
}) })
@ -69,7 +69,7 @@
it('Retun function when called without data parameter', function () { it('Retun function when called without data parameter', function () {
expect( expect(
tmpl('{%=o.value%}')(data) tmpl('{%=o.value%}')(data)
).to.be( ).to.equal(
'value' 'value'
) )
}) })
@ -86,7 +86,7 @@
it('Escape HTML special characters with {%=o.prop%}', function () { it('Escape HTML special characters with {%=o.prop%}', function () {
expect( expect(
tmpl('{%=o.special%}', data) tmpl('{%=o.special%}', data)
).to.be( ).to.equal(
'&lt;&gt;&amp;&quot;&#39;' '&lt;&gt;&amp;&quot;&#39;'
) )
}) })
@ -94,7 +94,7 @@
it('Allow HTML special characters with {%#o.prop%}', function () { it('Allow HTML special characters with {%#o.prop%}', function () {
expect( expect(
tmpl('{%#o.special%}', data) tmpl('{%#o.special%}', data)
).to.be( ).to.equal(
'<>&"\'\x00' '<>&"\'\x00'
) )
}) })
@ -102,7 +102,7 @@
it('Function call', function () { it('Function call', function () {
expect( expect(
tmpl('{%=o.func()%}', data) tmpl('{%=o.func()%}', data)
).to.be( ).to.equal(
'value' 'value'
) )
}) })
@ -110,7 +110,7 @@
it('Dot notation', function () { it('Dot notation', function () {
expect( expect(
tmpl('{%=o.deep.value%}', data) tmpl('{%=o.deep.value%}', data)
).to.be( ).to.equal(
'value' 'value'
) )
}) })
@ -118,7 +118,7 @@
it('Handle single quotes', function () { it('Handle single quotes', function () {
expect( expect(
tmpl('\'single quotes\'{%=": \'"%}', data) tmpl('\'single quotes\'{%=": \'"%}', data)
).to.be( ).to.equal(
"'single quotes': &#39;" "'single quotes': &#39;"
) )
}) })
@ -126,7 +126,7 @@
it('Handle double quotes', function () { it('Handle double quotes', function () {
expect( expect(
tmpl('"double quotes"{%=": \\""%}', data) tmpl('"double quotes"{%=": \\""%}', data)
).to.be( ).to.equal(
'"double quotes": &quot;' '"double quotes": &quot;'
) )
}) })
@ -134,7 +134,7 @@
it('Handle backslashes', function () { it('Handle backslashes', function () {
expect( expect(
tmpl('\\backslashes\\{%=": \\\\"%}', data) tmpl('\\backslashes\\{%=": \\\\"%}', data)
).to.be( ).to.equal(
'\\backslashes\\: \\' '\\backslashes\\: \\'
) )
}) })
@ -148,7 +148,7 @@
'{%=o.zeroValue%}', '{%=o.zeroValue%}',
data data
) )
).to.be( ).to.equal(
'false0' 'false0'
) )
}) })
@ -162,7 +162,7 @@
'{%#o.zeroValue%}', '{%#o.zeroValue%}',
data data
) )
).to.be( ).to.equal(
'false0' 'false0'
) )
}) })
@ -173,7 +173,7 @@
'\n\r\t{%=o.value%} \n\r\t{%=o.value%} ', '\n\r\t{%=o.value%} \n\r\t{%=o.value%} ',
data data
) )
).to.be( ).to.equal(
'\n\r\tvalue \n\r\tvalue ' '\n\r\tvalue \n\r\tvalue '
) )
}) })
@ -183,7 +183,7 @@
it('Escape HTML special characters with print(data)', function () { it('Escape HTML special characters with print(data)', function () {
expect( expect(
tmpl('{% print(o.special); %}', data) tmpl('{% print(o.special); %}', data)
).to.be( ).to.equal(
'&lt;&gt;&amp;&quot;&#39;' '&lt;&gt;&amp;&quot;&#39;'
) )
}) })
@ -191,7 +191,7 @@
it('Allow HTML special characters with print(data, true)', function () { it('Allow HTML special characters with print(data, true)', function () {
expect( expect(
tmpl('{% print(o.special, true); %}', data) tmpl('{% print(o.special, true); %}', data)
).to.be( ).to.equal(
'<>&"\'\x00' '<>&"\'\x00'
) )
}) })
@ -205,7 +205,7 @@
'{% print(o.zeroValue); %}', '{% print(o.zeroValue); %}',
data data
) )
).to.be( ).to.equal(
'false0' 'false0'
) )
}) })
@ -219,7 +219,7 @@
'{% print(o.zeroValue, true); %}', '{% print(o.zeroValue, true); %}',
data data
) )
).to.be( ).to.equal(
'false0' 'false0'
) )
}) })
@ -227,7 +227,7 @@
it('Include template', function () { it('Include template', function () {
expect( expect(
tmpl('{% include("template", {value: "value"}); %}', data) tmpl('{% include("template", {value: "value"}); %}', data)
).to.be( ).to.equal(
'value' 'value'
) )
}) })
@ -235,7 +235,7 @@
it('If condition', function () { it('If condition', function () {
expect( expect(
tmpl('{% if (o.value) { %}true{% } else { %}false{% } %}', data) tmpl('{% if (o.value) { %}true{% } else { %}false{% } %}', data)
).to.be( ).to.equal(
'true' 'true'
) )
}) })
@ -246,7 +246,7 @@
'{% if (o.undefinedValue) { %}false{% } else { %}true{% } %}', '{% if (o.undefinedValue) { %}false{% } else { %}true{% } %}',
data data
) )
).to.be( ).to.equal(
'true' 'true'
) )
}) })
@ -258,7 +258,7 @@
'{%=o.list[i]%}{% } %}', '{%=o.list[i]%}{% } %}',
data data
) )
).to.be( ).to.equal(
'12345' '12345'
) )
}) })
@ -270,7 +270,7 @@
'print(o.list[i]);} %}', 'print(o.list[i]);} %}',
data data
) )
).to.be( ).to.equal(
'12345' '12345'
) )
}) })
@ -282,7 +282,7 @@
'include("template", {value: o.list[i]});} %}', 'include("template", {value: o.list[i]});} %}',
data data
).replace(/[\r\n]/g, '') ).replace(/[\r\n]/g, '')
).to.be( ).to.equal(
'12345' '12345'
) )
}) })
@ -293,13 +293,13 @@
'{% if (o.list.length % 5 === 0) { %}5 list items{% } %}', '{% if (o.list.length % 5 === 0) { %}5 list items{% } %}',
data data
).replace(/[\r\n]/g, '') ).replace(/[\r\n]/g, '')
).to.be( ).to.equal(
'5 list items' '5 list items'
) )
}) })
}) })
}( }(
this, this,
this.expect || require('expect.js'), (this.chai || require('chai')).expect,
this.tmpl || require('../js/tmpl') this.tmpl || require('../js/tmpl')
)) ))

@ -25,7 +25,7 @@
"tag": "v1.3.23", "tag": "v1.3.23",
"commit": "f000ab2a40a0e930c2913855b96a4e4d59c8920f" "commit": "f000ab2a40a0e930c2913855b96a4e4d59c8920f"
}, },
"_source": "git://github.com/dangrossman/bootstrap-daterangepicker.git", "_source": "https://github.com/dangrossman/bootstrap-daterangepicker.git",
"_target": "1.3.*", "_target": "1.3.*",
"_originalSource": "bootstrap-daterangepicker" "_originalSource": "bootstrap-daterangepicker"
} }

@ -21,7 +21,7 @@
"_resolution": { "_resolution": {
"type": "version", "type": "version",
"tag": "4.5.9", "tag": "4.5.9",
"commit": "ba2580967f7409784921b4320e297522175e45bb" "commit": "5de42515a5ca7015de75627ad8067f786d7fc425"
}, },
"_source": "https://github.com/AngelFQC/ckeditor-releases.git", "_source": "https://github.com/AngelFQC/ckeditor-releases.git",
"_target": "*", "_target": "*",

@ -57,7 +57,7 @@
"tag": "v1.0.0", "tag": "v1.0.0",
"commit": "c0805bc83c9270a0be4afdfbd02d517de7a4c970" "commit": "c0805bc83c9270a0be4afdfbd02d517de7a4c970"
}, },
"_source": "git://github.com/fengyuanchen/cropper.git", "_source": "https://github.com/fengyuanchen/cropper.git",
"_target": "1.0.*", "_target": "1.0.*",
"_originalSource": "cropper" "_originalSource": "cropper"
} }

@ -30,7 +30,7 @@
"tag": "v4.4.0", "tag": "v4.4.0",
"commit": "f2cc73da12f0e6d828bc2daaa72bff457067bf39" "commit": "f2cc73da12f0e6d828bc2daaa72bff457067bf39"
}, },
"_source": "git://github.com/FortAwesome/Font-Awesome.git", "_source": "https://github.com/FortAwesome/Font-Awesome.git",
"_target": "4.4.*", "_target": "4.4.*",
"_originalSource": "fontawesome" "_originalSource": "fontawesome"
} }

@ -56,7 +56,7 @@
"tag": "v2.3.2", "tag": "v2.3.2",
"commit": "29fb42d6316bd2c293fbcaf699af4427f80abebb" "commit": "29fb42d6316bd2c293fbcaf699af4427f80abebb"
}, },
"_source": "git://github.com/arshaw/fullcalendar.git", "_source": "https://github.com/fullcalendar/fullcalendar.git",
"_target": "2.3.2", "_target": "2.3.2",
"_originalSource": "fullcalendar" "_originalSource": "fullcalendar"
} }

@ -40,7 +40,7 @@
"tag": "v0.5.4", "tag": "v0.5.4",
"commit": "eef318b0892b5ecec2c95a9c2f7f06c420978cbe" "commit": "eef318b0892b5ecec2c95a9c2f7f06c420978cbe"
}, },
"_source": "git://github.com/davidjbradshaw/image-map-resizer.git", "_source": "https://github.com/davidjbradshaw/image-map-resizer.git",
"_target": "0.5.*", "_target": "0.5.*",
"_originalSource": "image-map-resizer" "_originalSource": "image-map-resizer"
} }

@ -17,7 +17,7 @@
"tag": "v1.4.3", "tag": "v1.4.3",
"commit": "5293dacee881e78b25bd4f699161fca81dff5205" "commit": "5293dacee881e78b25bd4f699161fca81dff5205"
}, },
"_source": "git://github.com/rmm5t/jquery-timeago.git", "_source": "https://github.com/rmm5t/jquery-timeago.git",
"_target": "1.4.*", "_target": "1.4.*",
"_originalSource": "jquery-timeago" "_originalSource": "jquery-timeago"
} }

@ -15,7 +15,7 @@
"tag": "1.11.4", "tag": "1.11.4",
"commit": "c34f8dbf3ba57b3784b93f26119f436c0e8288e1" "commit": "c34f8dbf3ba57b3784b93f26119f436c0e8288e1"
}, },
"_source": "git://github.com/components/jqueryui.git", "_source": "https://github.com/components/jqueryui.git",
"_target": "1.11.*", "_target": "1.11.*",
"_originalSource": "jquery-ui" "_originalSource": "jquery-ui"
} }

@ -21,7 +21,7 @@
"tag": "0.2.10", "tag": "0.2.10",
"commit": "058c143d6623f8d39cd45becc1205b9aee325246" "commit": "058c143d6623f8d39cd45becc1205b9aee325246"
}, },
"_source": "git://github.com/gromo/jquery.scrollbar.git", "_source": "https://github.com/gromo/jquery.scrollbar.git",
"_target": "0.2.*", "_target": "0.2.*",
"_originalSource": "jquery.scrollbar" "_originalSource": "jquery.scrollbar"
} }

@ -17,7 +17,7 @@
"tag": "v1.5.5", "tag": "v1.5.5",
"commit": "8498e17dc6c4b5aa21f3a2bbe8c20f3a461c3211" "commit": "8498e17dc6c4b5aa21f3a2bbe8c20f3a461c3211"
}, },
"_source": "git://github.com/trentrichardson/jQuery-Timepicker-Addon.git", "_source": "https://github.com/trentrichardson/jQuery-Timepicker-Addon.git",
"_target": "1.5.*", "_target": "1.5.*",
"_originalSource": "jqueryui-timepicker-addon" "_originalSource": "jqueryui-timepicker-addon"
} }

@ -8,7 +8,7 @@
"tag": "v2.8.3", "tag": "v2.8.3",
"commit": "d6bb30c0f12ebb3ddd01e90b0bf435e1c34e6f11" "commit": "d6bb30c0f12ebb3ddd01e90b0bf435e1c34e6f11"
}, },
"_source": "git://github.com/Modernizr/Modernizr.git", "_source": "https://github.com/Modernizr/Modernizr.git",
"_target": "2.8.*", "_target": "2.8.*",
"_originalSource": "modernizr" "_originalSource": "modernizr"
} }

@ -24,7 +24,7 @@
"tag": "2.9.0", "tag": "2.9.0",
"commit": "8b35bc74c0e88c1a8c58ccb90117a9edc9f6a479" "commit": "8b35bc74c0e88c1a8c58ccb90117a9edc9f6a479"
}, },
"_source": "git://github.com/moment/moment.git", "_source": "https://github.com/moment/moment.git",
"_target": "~2.9.0", "_target": "~2.9.0",
"_originalSource": "moment" "_originalSource": "moment"
} }

@ -8,7 +8,7 @@
"tag": "v1.15.4", "tag": "v1.15.4",
"commit": "6f84fbcd42bd6ab1af8134ef0c495e8a6c3175f7" "commit": "6f84fbcd42bd6ab1af8134ef0c495e8a6c3175f7"
}, },
"_source": "git://github.com/HenrikJoreteg/SimpleWebRTC.git", "_source": "https://github.com/HenrikJoreteg/SimpleWebRTC.git",
"_target": "1.15.*", "_target": "1.15.*",
"_originalSource": "simpleWebRTC" "_originalSource": "simpleWebRTC"
} }
Loading…
Cancel
Save