code
stringlengths
24
2.07M
docstring
stringlengths
25
85.3k
func_name
stringlengths
1
92
language
stringclasses
1 value
repo
stringlengths
5
64
path
stringlengths
4
172
url
stringlengths
44
218
license
stringclasses
7 values
function arrayBufferToBase64(buffer) { var binary = ''; var bytes = new Uint8Array(buffer); var len = bytes.byteLength; for (var i = 0; i < len; i++) { binary += String.fromCharCode(bytes[i]); } return window.btoa(binary); }
Conserve aspect ratio of the original region. Useful when shrinking/enlarging images to fit into a certain area. Source: http://stackoverflow.com/a/14731922 @param {Number} srcWidth Source area width @param {Number} srcHeight Source area height @param {Number} maxWidth Nestable area maximum available width @param {Nu...
arrayBufferToBase64
javascript
danialfarid/ng-file-upload
demo/src/main/webapp/js/ng-file-upload.js
https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/ng-file-upload.js
MIT
function addEvent(element, event, handler) { if (element.addEventListener) { element.addEventListener(event, handler, false); } else if (element.attachEvent) { element.attachEvent("on" + event, handler); } }
EXIF service is based on the exif-js library (https://github.com/jseidelin/exif-js)
addEvent
javascript
danialfarid/ng-file-upload
demo/src/main/webapp/js/ng-img-crop.js
https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/ng-img-crop.js
MIT
function imageHasData(img) { return !!(img.exifdata); }
EXIF service is based on the exif-js library (https://github.com/jseidelin/exif-js)
imageHasData
javascript
danialfarid/ng-file-upload
demo/src/main/webapp/js/ng-img-crop.js
https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/ng-img-crop.js
MIT
function base64ToArrayBuffer(base64, contentType) { contentType = contentType || base64.match(/^data\:([^\;]+)\;base64,/mi)[1] || ''; // e.g. 'data:image/jpeg;base64,...' => 'image/jpeg' base64 = base64.replace(/^data\:([^\;]+)\;base64,/gmi, ''); var binary = atob(base64); var len = binary.lengt...
EXIF service is based on the exif-js library (https://github.com/jseidelin/exif-js)
base64ToArrayBuffer
javascript
danialfarid/ng-file-upload
demo/src/main/webapp/js/ng-img-crop.js
https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/ng-img-crop.js
MIT
function objectURLToBlob(url, callback) { var http = new XMLHttpRequest(); http.open("GET", url, true); http.responseType = "blob"; http.onload = function(e) { if (this.status == 200 || this.status === 0) { callback(this.response); } }; http.send(); ...
EXIF service is based on the exif-js library (https://github.com/jseidelin/exif-js)
objectURLToBlob
javascript
danialfarid/ng-file-upload
demo/src/main/webapp/js/ng-img-crop.js
https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/ng-img-crop.js
MIT
function getImageData(img, callback) { function handleBinaryFile(binFile) { var data = findEXIFinJPEG(binFile); var iptcdata = findIPTCinJPEG(binFile); img.exifdata = data || {}; img.iptcdata = iptcdata || {}; if (callback) { callback.call(img); ...
EXIF service is based on the exif-js library (https://github.com/jseidelin/exif-js)
getImageData
javascript
danialfarid/ng-file-upload
demo/src/main/webapp/js/ng-img-crop.js
https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/ng-img-crop.js
MIT
function handleBinaryFile(binFile) { var data = findEXIFinJPEG(binFile); var iptcdata = findIPTCinJPEG(binFile); img.exifdata = data || {}; img.iptcdata = iptcdata || {}; if (callback) { callback.call(img); } }
EXIF service is based on the exif-js library (https://github.com/jseidelin/exif-js)
handleBinaryFile
javascript
danialfarid/ng-file-upload
demo/src/main/webapp/js/ng-img-crop.js
https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/ng-img-crop.js
MIT
function findEXIFinJPEG(file) { var dataView = new DataView(file); if (debug) console.log("Got file of length " + file.byteLength); if ((dataView.getUint8(0) != 0xFF) || (dataView.getUint8(1) != 0xD8)) { if (debug) console.log("Not a valid JPEG"); return false; // not a valid jpeg...
EXIF service is based on the exif-js library (https://github.com/jseidelin/exif-js)
findEXIFinJPEG
javascript
danialfarid/ng-file-upload
demo/src/main/webapp/js/ng-img-crop.js
https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/ng-img-crop.js
MIT
function findIPTCinJPEG(file) { var dataView = new DataView(file); if (debug) console.log("Got file of length " + file.byteLength); if ((dataView.getUint8(0) != 0xFF) || (dataView.getUint8(1) != 0xD8)) { if (debug) console.log("Not a valid JPEG"); return false; // not a valid jpeg...
EXIF service is based on the exif-js library (https://github.com/jseidelin/exif-js)
findIPTCinJPEG
javascript
danialfarid/ng-file-upload
demo/src/main/webapp/js/ng-img-crop.js
https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/ng-img-crop.js
MIT
isFieldSegmentStart = function(dataView, offset){ return ( dataView.getUint8(offset) === 0x38 && dataView.getUint8(offset+1) === 0x42 && dataView.getUint8(offset+2) === 0x49 && dataView.getUint8(offset+3) === 0x4D && dataView.getUint8(offse...
EXIF service is based on the exif-js library (https://github.com/jseidelin/exif-js)
isFieldSegmentStart
javascript
danialfarid/ng-file-upload
demo/src/main/webapp/js/ng-img-crop.js
https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/ng-img-crop.js
MIT
function readIPTCData(file, startOffset, sectionLength){ var dataView = new DataView(file); var data = {}; var fieldValue, fieldName, dataSize, segmentType, segmentSize; var segmentStartPos = startOffset; while(segmentStartPos < startOffset+sectionLength) { if(dataView.getUint8(s...
EXIF service is based on the exif-js library (https://github.com/jseidelin/exif-js)
readIPTCData
javascript
danialfarid/ng-file-upload
demo/src/main/webapp/js/ng-img-crop.js
https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/ng-img-crop.js
MIT
function readTags(file, tiffStart, dirStart, strings, bigEnd) { var entries = file.getUint16(dirStart, !bigEnd), tags = {}, entryOffset, tag, i; for (i=0;i<entries;i++) { entryOffset = dirStart + i*12 + 2; tag = strings[file.getUint16(entryOffset, !bigEnd)]...
EXIF service is based on the exif-js library (https://github.com/jseidelin/exif-js)
readTags
javascript
danialfarid/ng-file-upload
demo/src/main/webapp/js/ng-img-crop.js
https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/ng-img-crop.js
MIT
function readTagValue(file, entryOffset, tiffStart, dirStart, bigEnd) { var type = file.getUint16(entryOffset+2, !bigEnd), numValues = file.getUint32(entryOffset+4, !bigEnd), valueOffset = file.getUint32(entryOffset+8, !bigEnd) + tiffStart, offset, vals, val, n, n...
EXIF service is based on the exif-js library (https://github.com/jseidelin/exif-js)
readTagValue
javascript
danialfarid/ng-file-upload
demo/src/main/webapp/js/ng-img-crop.js
https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/ng-img-crop.js
MIT
function getStringFromDB(buffer, start, length) { var outstr = ""; for (var n = start; n < start+length; n++) { outstr += String.fromCharCode(buffer.getUint8(n)); } return outstr; }
EXIF service is based on the exif-js library (https://github.com/jseidelin/exif-js)
getStringFromDB
javascript
danialfarid/ng-file-upload
demo/src/main/webapp/js/ng-img-crop.js
https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/ng-img-crop.js
MIT
function readEXIFData(file, start) { if (getStringFromDB(file, start, 4) != "Exif") { if (debug) console.log("Not valid EXIF data! " + getStringFromDB(file, start, 4)); return false; } var bigEnd, tags, tag, exifData, gpsData, tiffOffset = start + 6; ...
EXIF service is based on the exif-js library (https://github.com/jseidelin/exif-js)
readEXIFData
javascript
danialfarid/ng-file-upload
demo/src/main/webapp/js/ng-img-crop.js
https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/ng-img-crop.js
MIT
getElementOffset=function(elem) { var box = elem.getBoundingClientRect(); var body = document.body; var docElem = document.documentElement; var scrollTop = window.pageYOffset || docElem.scrollTop || body.scrollTop; var scrollLeft = window.pageXOffset || docElem.scrollLeft || body.scrollL...
EXIF service is based on the exif-js library (https://github.com/jseidelin/exif-js)
getElementOffset
javascript
danialfarid/ng-file-upload
demo/src/main/webapp/js/ng-img-crop.js
https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/ng-img-crop.js
MIT
function drawScene() { // clear canvas ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height); if(image!==null) { // draw source image ctx.drawImage(image, 0, 0, ctx.canvas.width, ctx.canvas.height); ctx.save(); // and make it darker ctx.fillStyle = 'rgba(0...
EXIF service is based on the exif-js library (https://github.com/jseidelin/exif-js)
drawScene
javascript
danialfarid/ng-file-upload
demo/src/main/webapp/js/ng-img-crop.js
https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/ng-img-crop.js
MIT
resetCropHost=function() { if(image!==null) { theArea.setImage(image); var imageDims=[image.width, image.height], imageRatio=image.width/image.height, canvasDims=imageDims; if(canvasDims[0]>maxCanvasDims[0]) { canvasDims[0]=maxCanvasDims[0]; can...
EXIF service is based on the exif-js library (https://github.com/jseidelin/exif-js)
resetCropHost
javascript
danialfarid/ng-file-upload
demo/src/main/webapp/js/ng-img-crop.js
https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/ng-img-crop.js
MIT
getChangedTouches=function(event){ if(angular.isDefined(event.changedTouches)){ return event.changedTouches; }else{ return event.originalEvent.changedTouches; } }
Returns event.changedTouches directly if event is a TouchEvent. If event is a jQuery event, return changedTouches of event.originalEvent
getChangedTouches
javascript
danialfarid/ng-file-upload
demo/src/main/webapp/js/ng-img-crop.js
https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/ng-img-crop.js
MIT
onMouseMove=function(e) { if(image!==null) { var offset=getElementOffset(ctx.canvas), pageX, pageY; if(e.type === 'touchmove') { pageX=getChangedTouches(e)[0].pageX; pageY=getChangedTouches(e)[0].pageY; } else { pageX=e.pageX; pageY=e.pag...
Returns event.changedTouches directly if event is a TouchEvent. If event is a jQuery event, return changedTouches of event.originalEvent
onMouseMove
javascript
danialfarid/ng-file-upload
demo/src/main/webapp/js/ng-img-crop.js
https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/ng-img-crop.js
MIT
onMouseDown=function(e) { e.preventDefault(); e.stopPropagation(); if(image!==null) { var offset=getElementOffset(ctx.canvas), pageX, pageY; if(e.type === 'touchstart') { pageX=getChangedTouches(e)[0].pageX; pageY=getChangedTouches(e)[0].pageY; }...
Returns event.changedTouches directly if event is a TouchEvent. If event is a jQuery event, return changedTouches of event.originalEvent
onMouseDown
javascript
danialfarid/ng-file-upload
demo/src/main/webapp/js/ng-img-crop.js
https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/ng-img-crop.js
MIT
onMouseUp=function(e) { if(image!==null) { var offset=getElementOffset(ctx.canvas), pageX, pageY; if(e.type === 'touchend') { pageX=getChangedTouches(e)[0].pageX; pageY=getChangedTouches(e)[0].pageY; } else { pageX=e.pageX; pageY=e.pageY;...
Returns event.changedTouches directly if event is a TouchEvent. If event is a jQuery event, return changedTouches of event.originalEvent
onMouseUp
javascript
danialfarid/ng-file-upload
demo/src/main/webapp/js/ng-img-crop.js
https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/ng-img-crop.js
MIT
updateResultImage=function(scope) { var resultImage=cropHost.getResultImageDataURI(); if(storedResultImage!==resultImage) { storedResultImage=resultImage; if(angular.isDefined(scope.resultImage)) { scope.resultImage=resultImage; } scope.onChange({$data...
Returns event.changedTouches directly if event is a TouchEvent. If event is a jQuery event, return changedTouches of event.originalEvent
updateResultImage
javascript
danialfarid/ng-file-upload
demo/src/main/webapp/js/ng-img-crop.js
https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/ng-img-crop.js
MIT
fnSafeApply=function(fn) { return function(){ $timeout(function(){ scope.$apply(function(scope){ fn(scope); }); }); }; }
Returns event.changedTouches directly if event is a TouchEvent. If event is a jQuery event, return changedTouches of event.originalEvent
fnSafeApply
javascript
danialfarid/ng-file-upload
demo/src/main/webapp/js/ng-img-crop.js
https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/ng-img-crop.js
MIT
_extend = function (dst){ var args = arguments, i = 1, _ext = function (val, key){ dst[key] = val; }; for( ; i < args.length; i++ ){ _each(args[i], _ext); } return dst; }
Merge the contents of two or more objects together into the first object
_extend
javascript
danialfarid/ng-file-upload
dist/FileAPI.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/FileAPI.js
MIT
function Image(file){ if( file instanceof Image ){ var img = new Image(file.file); api.extend(img.matrix, file.matrix); return img; } else if( !(this instanceof Image) ){ return new Image(file); } this.file = file; this.size = file.size || 100; this.matrix = { sx: 0, sy: 0, sw: ...
Remove drag'n'drop @param {HTMLElement} el @param {Function} onHover @param {Function} onDrop
Image
javascript
danialfarid/ng-file-upload
dist/FileAPI.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/FileAPI.js
MIT
fn = function (){ var x = over.x|0 , y = over.y|0 , w = over.w || img.width , h = over.h || img.height , rel = over.rel ; // center | right | left x = (rel == 1 || rel == 4 || rel == 7) ? (dw - w + x)/2 : (rel == 2 || rel == 5 || rel == 8 ? dw - (w + x) : x); ...
Remove drag'n'drop @param {HTMLElement} el @param {Function} onHover @param {Function} onDrop
fn
javascript
danialfarid/ng-file-upload
dist/FileAPI.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/FileAPI.js
MIT
function _transform(err, img){ // img -- info object var images = {} , queue = api.queue(function (err){ fn(err, images); }) ; if( !err ){ api.each(transform, function (params, name){ if( !queue.isFail() ){ var ImgTrans = new Image(img.nodeType ? img : file), isFn = typeof...
Remove drag'n'drop @param {HTMLElement} el @param {Function} onHover @param {Function} onDrop
_transform
javascript
danialfarid/ng-file-upload
dist/FileAPI.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/FileAPI.js
MIT
_complete = function (err){ _this._active = !err; clearTimeout(_failId); clearTimeout(_successId); // api.event.off(video, 'loadedmetadata', _complete); callback && callback(err, _this); }
Start camera streaming @param {Function} callback
_complete
javascript
danialfarid/ng-file-upload
dist/FileAPI.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/FileAPI.js
MIT
doneFn = function (err){ if( err ){ callback(err); } else { // Get camera var cam = Camera.get(el); if( options.start ){ cam.start(callback); } else { callback(null, cam); } } }
Publish camera element into container @static @param {HTMLElement} el @param {Object} options @param {Function} [callback]
doneFn
javascript
danialfarid/ng-file-upload
dist/FileAPI.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/FileAPI.js
MIT
function _px(val){ return val >= 0 ? val + 'px' : val; }
Add "px" postfix, if value is a number @private @param {*} val @return {String}
_px
javascript
danialfarid/ng-file-upload
dist/FileAPI.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/FileAPI.js
MIT
function _detectVideoSignal(video){ var canvas = document.createElement('canvas'), ctx, res = false; try { ctx = canvas.getContext('2d'); ctx.drawImage(video, 0, 0, 1, 1); res = ctx.getImageData(0, 0, 1, 1).data[4] != 255; } catch( e ){} return res; }
@private @param {HTMLVideoElement} video @return {Boolean}
_detectVideoSignal
javascript
danialfarid/ng-file-upload
dist/FileAPI.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/FileAPI.js
MIT
function _wrap(fn) { var id = fn.wid = api.uid(); api.Flash._fn[id] = fn; return 'FileAPI.Flash._fn.' + id; }
FileAPI fallback to Flash @flash-developer "Vladimir Demidov" <v.demidov@corp.mail.ru>
_wrap
javascript
danialfarid/ng-file-upload
dist/FileAPI.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/FileAPI.js
MIT
function _unwrap(fn) { try { api.Flash._fn[fn.wid] = null; delete api.Flash._fn[fn.wid]; } catch (e) { } }
FileAPI fallback to Flash @flash-developer "Vladimir Demidov" <v.demidov@corp.mail.ru>
_unwrap
javascript
danialfarid/ng-file-upload
dist/FileAPI.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/FileAPI.js
MIT
function sendHttp(config) { config.method = config.method || 'POST'; config.headers = config.headers || {}; var deferred = config._deferred = config._deferred || $q.defer(); var promise = deferred.promise; function notifyProgress(e) { if (deferred.notify) { deferred.notify(e); ...
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
sendHttp
javascript
danialfarid/ng-file-upload
dist/ng-file-upload-all.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload-all.js
MIT
function notifyProgress(e) { if (deferred.notify) { deferred.notify(e); } if (promise.progressFunc) { $timeout(function () { promise.progressFunc(e); }); } }
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
notifyProgress
javascript
danialfarid/ng-file-upload
dist/ng-file-upload-all.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload-all.js
MIT
function getNotifyEvent(n) { if (config._start != null && resumeSupported) { return { loaded: n.loaded + config._start, total: (config._file && config._file.size) || n.total, type: n.type, config: config, lengthComputable: true, target: n.target }; } e...
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
getNotifyEvent
javascript
danialfarid/ng-file-upload
dist/ng-file-upload-all.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload-all.js
MIT
function uploadWithAngular() { $http(config).then(function (r) { if (resumeSupported && config._chunkSize && !config._finished && config._file) { var fileSize = config._file && config._file.size || 0; notifyProgress({ loaded: Math.min(config._end, fileSize), ...
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
uploadWithAngular
javascript
danialfarid/ng-file-upload
dist/ng-file-upload-all.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload-all.js
MIT
function copy(obj) { var clone = {}; for (var key in obj) { if (obj.hasOwnProperty(key)) { clone[key] = obj[key]; } } return clone; }
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
copy
javascript
danialfarid/ng-file-upload
dist/ng-file-upload-all.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload-all.js
MIT
function toResumeFile(file, formData) { if (file._ngfBlob) return file; config._file = config._file || file; if (config._start != null && resumeSupported) { if (config._end && config._end >= file.size) { config._finished = true; config._end = file.size; } va...
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
toResumeFile
javascript
danialfarid/ng-file-upload
dist/ng-file-upload-all.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload-all.js
MIT
function addFieldToFormData(formData, val, key) { if (val !== undefined) { if (angular.isDate(val)) { val = val.toISOString(); } if (angular.isString(val)) { formData.append(key, val); } else if (upload.isFile(val)) { var file = toResumeFile(val, formD...
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
addFieldToFormData
javascript
danialfarid/ng-file-upload
dist/ng-file-upload-all.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload-all.js
MIT
function digestConfig() { config._chunkSize = upload.translateScalars(config.resumeChunkSize); config._chunkSize = config._chunkSize ? parseInt(config._chunkSize.toString()) : null; config.headers = config.headers || {}; config.headers['Content-Type'] = undefined; config.transformRequest ...
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
digestConfig
javascript
danialfarid/ng-file-upload
dist/ng-file-upload-all.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload-all.js
MIT
function applyExifRotations(files, attr, scope) { var promises = [upload.emptyPromise()]; angular.forEach(files, function (f, i) { if (f.type.indexOf('image/jpeg') === 0 && upload.attrGetter('ngfFixOrientation', attr, scope, {$file: f})) { promises.push(upload.happyPromise(upload.applyExifRotation...
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
applyExifRotations
javascript
danialfarid/ng-file-upload
dist/ng-file-upload-all.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload-all.js
MIT
function resizeFile(files, attr, scope, ngModel) { var resizeVal = upload.attrGetter('ngfResize', attr, scope); if (!resizeVal || !upload.isResizeSupported() || !files.length) return upload.emptyPromise(); if (resizeVal instanceof Function) { var defer = $q.defer(); return resizeVal(files).then(...
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
resizeFile
javascript
danialfarid/ng-file-upload
dist/ng-file-upload-all.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload-all.js
MIT
function resizeWithParams(params, files, attr, scope, ngModel) { var promises = [upload.emptyPromise()]; function handleFile(f, i) { if (f.type.indexOf('image') === 0) { if (params.pattern && !upload.validatePattern(f, params.pattern)) return; params.resizeIf = function (width, height) { ...
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
resizeWithParams
javascript
danialfarid/ng-file-upload
dist/ng-file-upload-all.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload-all.js
MIT
function handleFile(f, i) { if (f.type.indexOf('image') === 0) { if (params.pattern && !upload.validatePattern(f, params.pattern)) return; params.resizeIf = function (width, height) { return upload.attrGetter('ngfResizeIf', attr, scope, {$width: width, $height: height, $file:...
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
handleFile
javascript
danialfarid/ng-file-upload
dist/ng-file-upload-all.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload-all.js
MIT
function update(files, invalidFiles, newFiles, dupFiles, isSingleModel) { attr.$$ngfPrevValidFiles = files; attr.$$ngfPrevInvalidFiles = invalidFiles; var file = files && files.length ? files[0] : null; var invalidFile = invalidFiles && invalidFiles.length ? invalidFiles[0] : null; if (ng...
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
update
javascript
danialfarid/ng-file-upload
dist/ng-file-upload-all.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload-all.js
MIT
function removeDuplicates() { function equals(f1, f2) { return f1.name === f2.name && (f1.$ngfOrigSize || f1.size) === (f2.$ngfOrigSize || f2.size) && f1.type === f2.type; } function isInPrevFiles(f) { var j; for (j = 0; j < prevValidFiles.length; j++) { if...
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
removeDuplicates
javascript
danialfarid/ng-file-upload
dist/ng-file-upload-all.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload-all.js
MIT
function equals(f1, f2) { return f1.name === f2.name && (f1.$ngfOrigSize || f1.size) === (f2.$ngfOrigSize || f2.size) && f1.type === f2.type; }
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
equals
javascript
danialfarid/ng-file-upload
dist/ng-file-upload-all.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload-all.js
MIT
function isInPrevFiles(f) { var j; for (j = 0; j < prevValidFiles.length; j++) { if (equals(f, prevValidFiles[j])) { return true; } } for (j = 0; j < prevInvalidFiles.length; j++) { if (equals(f, prevInvalidFiles[j])) { return true; ...
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
isInPrevFiles
javascript
danialfarid/ng-file-upload
dist/ng-file-upload-all.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload-all.js
MIT
function toArray(v) { return angular.isArray(v) ? v : [v]; }
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
toArray
javascript
danialfarid/ng-file-upload
dist/ng-file-upload-all.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload-all.js
MIT
function resizeAndUpdate() { function updateModel() { $timeout(function () { update(keep ? prevValidFiles.concat(valids) : valids, keep ? prevInvalidFiles.concat(invalids) : invalids, files, dupFiles, isSingleModel); }, options && options.debounce ? options.deboun...
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
resizeAndUpdate
javascript
danialfarid/ng-file-upload
dist/ng-file-upload-all.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload-all.js
MIT
function updateModel() { $timeout(function () { update(keep ? prevValidFiles.concat(valids) : valids, keep ? prevInvalidFiles.concat(invalids) : invalids, files, dupFiles, isSingleModel); }, options && options.debounce ? options.debounce.change || options.debounce : 0);...
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
updateModel
javascript
danialfarid/ng-file-upload
dist/ng-file-upload-all.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload-all.js
MIT
function isDelayedClickSupported(ua) { // fix for android native browser < 4.4 and safari windows var m = ua.match(/Android[^\d]*(\d+)\.(\d+)/); if (m && m.length > 2) { var v = Upload.defaults.androidFixMinorVersion || 4; return parseInt(m[1]) < 4 || (parseInt(m[1]) === v && parseInt(m[2]) < v)...
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
isDelayedClickSupported
javascript
danialfarid/ng-file-upload
dist/ng-file-upload-all.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload-all.js
MIT
function linkFileSelect(scope, elem, attr, ngModel, $parse, $timeout, $compile, upload) { /** @namespace attr.ngfSelect */ /** @namespace attr.ngfChange */ /** @namespace attr.ngModel */ /** @namespace attr.ngfModelOptions */ /** @namespace attr.ngfMultiple */ /** @namespace attr.ngfCapture */ ...
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
linkFileSelect
javascript
danialfarid/ng-file-upload
dist/ng-file-upload-all.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload-all.js
MIT
calculateAspectRatioFit = function (srcWidth, srcHeight, maxWidth, maxHeight, centerCrop) { var ratio = centerCrop ? Math.max(maxWidth / srcWidth, maxHeight / srcHeight) : Math.min(maxWidth / srcWidth, maxHeight / srcHeight); return { width: srcWidth * ratio, height: srcHeight * ratio, marginX...
Conserve aspect ratio of the original region. Useful when shrinking/enlarging images to fit into a certain area. Source: http://stackoverflow.com/a/14731922 @param {Number} srcWidth Source area width @param {Number} srcHeight Source area height @param {Number} maxWidth Nestable area maximum available width @param {Nu...
calculateAspectRatioFit
javascript
danialfarid/ng-file-upload
dist/ng-file-upload-all.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload-all.js
MIT
resize = function (imagen, width, height, quality, type, ratio, centerCrop, resizeIf) { var deferred = $q.defer(); var canvasElement = document.createElement('canvas'); var imageElement = document.createElement('img'); imageElement.setAttribute('style', 'visibility:hidden;position:fixed;z-index:-100000'...
Conserve aspect ratio of the original region. Useful when shrinking/enlarging images to fit into a certain area. Source: http://stackoverflow.com/a/14731922 @param {Number} srcWidth Source area width @param {Number} srcHeight Source area height @param {Number} maxWidth Nestable area maximum available width @param {Nu...
resize
javascript
danialfarid/ng-file-upload
dist/ng-file-upload-all.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload-all.js
MIT
function linkDrop(scope, elem, attr, ngModel, $parse, $timeout, $window, upload, $http, $q) { var available = dropAvailable(); var attrGetter = function (name, scope, params) { return upload.attrGetter(name, attr, scope, params); }; if (attrGetter('dropAvailable')) { $timeout(function () {...
Conserve aspect ratio of the original region. Useful when shrinking/enlarging images to fit into a certain area. Source: http://stackoverflow.com/a/14731922 @param {Number} srcWidth Source area width @param {Number} srcHeight Source area height @param {Number} maxWidth Nestable area maximum available width @param {Nu...
linkDrop
javascript
danialfarid/ng-file-upload
dist/ng-file-upload-all.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload-all.js
MIT
attrGetter = function (name, scope, params) { return upload.attrGetter(name, attr, scope, params); }
Conserve aspect ratio of the original region. Useful when shrinking/enlarging images to fit into a certain area. Source: http://stackoverflow.com/a/14731922 @param {Number} srcWidth Source area width @param {Number} srcHeight Source area height @param {Number} maxWidth Nestable area maximum available width @param {Nu...
attrGetter
javascript
danialfarid/ng-file-upload
dist/ng-file-upload-all.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload-all.js
MIT
function isDisabled() { return elem.attr('disabled') || attrGetter('ngfDropDisabled', scope); }
Conserve aspect ratio of the original region. Useful when shrinking/enlarging images to fit into a certain area. Source: http://stackoverflow.com/a/14731922 @param {Number} srcWidth Source area width @param {Number} srcHeight Source area height @param {Number} maxWidth Nestable area maximum available width @param {Nu...
isDisabled
javascript
danialfarid/ng-file-upload
dist/ng-file-upload-all.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload-all.js
MIT
function extractFilesAndUpdateModel(source, evt, updateOnType) { if (!source) return; // html needs to be calculated on the same process otherwise the data will be wiped // after promise resolve or setTimeout. var html; try { html = source && source.getData && source.getData('text/...
Conserve aspect ratio of the original region. Useful when shrinking/enlarging images to fit into a certain area. Source: http://stackoverflow.com/a/14731922 @param {Number} srcWidth Source area width @param {Number} srcHeight Source area height @param {Number} maxWidth Nestable area maximum available width @param {Nu...
extractFilesAndUpdateModel
javascript
danialfarid/ng-file-upload
dist/ng-file-upload-all.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload-all.js
MIT
function updateModel(files, evt) { upload.updateModel(ngModel, attr, scope, attrGetter('ngfChange') || attrGetter('ngfDrop'), files, evt); }
Conserve aspect ratio of the original region. Useful when shrinking/enlarging images to fit into a certain area. Source: http://stackoverflow.com/a/14731922 @param {Number} srcWidth Source area width @param {Number} srcHeight Source area height @param {Number} maxWidth Nestable area maximum available width @param {Nu...
updateModel
javascript
danialfarid/ng-file-upload
dist/ng-file-upload-all.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload-all.js
MIT
function extractFilesFromHtml(updateOn, html) { if (!upload.shouldUpdateOn(updateOn, attr, scope) || typeof html !== 'string') return upload.rejectPromise([]); var urls = []; html.replace(/<(img src|img [^>]* src) *=\"([^\"]*)\"/gi, function (m, n, src) { urls.push(src); }); var pr...
Conserve aspect ratio of the original region. Useful when shrinking/enlarging images to fit into a certain area. Source: http://stackoverflow.com/a/14731922 @param {Number} srcWidth Source area width @param {Number} srcHeight Source area height @param {Number} maxWidth Nestable area maximum available width @param {Nu...
extractFilesFromHtml
javascript
danialfarid/ng-file-upload
dist/ng-file-upload-all.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload-all.js
MIT
function calculateDragOverClass(scope, attr, evt, callback) { var obj = attrGetter('ngfDragOverClass', scope, {$event: evt}), dClass = 'dragover'; if (angular.isString(obj)) { dClass = obj; } else if (obj) { if (obj.delay) dragOverDelay = obj.delay; if (obj.accept || obj.reject...
Conserve aspect ratio of the original region. Useful when shrinking/enlarging images to fit into a certain area. Source: http://stackoverflow.com/a/14731922 @param {Number} srcWidth Source area width @param {Number} srcHeight Source area height @param {Number} maxWidth Nestable area maximum available width @param {Nu...
calculateDragOverClass
javascript
danialfarid/ng-file-upload
dist/ng-file-upload-all.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload-all.js
MIT
function extractFiles(items, fileList, allowDir, multiple) { var maxFiles = upload.getValidationAttr(attr, scope, 'maxFiles'); if (maxFiles == null) { maxFiles = Number.MAX_VALUE; } var maxTotalSize = upload.getValidationAttr(attr, scope, 'maxTotalSize'); if (maxTotalSize == null) ...
Conserve aspect ratio of the original region. Useful when shrinking/enlarging images to fit into a certain area. Source: http://stackoverflow.com/a/14731922 @param {Number} srcWidth Source area width @param {Number} srcHeight Source area height @param {Number} maxWidth Nestable area maximum available width @param {Nu...
extractFiles
javascript
danialfarid/ng-file-upload
dist/ng-file-upload-all.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload-all.js
MIT
function traverseFileTree(entry, path) { var defer = $q.defer(); if (entry != null) { if (entry.isDirectory) { var promises = [upload.emptyPromise()]; if (includeDir) { var file = {type: 'directory'}; file.name = file.path = (path || '') + en...
Conserve aspect ratio of the original region. Useful when shrinking/enlarging images to fit into a certain area. Source: http://stackoverflow.com/a/14731922 @param {Number} srcWidth Source area width @param {Number} srcHeight Source area height @param {Number} maxWidth Nestable area maximum available width @param {Nu...
traverseFileTree
javascript
danialfarid/ng-file-upload
dist/ng-file-upload-all.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload-all.js
MIT
readEntries = function () { dirReader.readEntries(function (results) { try { if (!results.length) { angular.forEach(entries.slice(0), function (e) { if (files.length <= maxFiles && totalSize <= maxTotalSize) { ...
Conserve aspect ratio of the original region. Useful when shrinking/enlarging images to fit into a certain area. Source: http://stackoverflow.com/a/14731922 @param {Number} srcWidth Source area width @param {Number} srcHeight Source area height @param {Number} maxWidth Nestable area maximum available width @param {Nu...
readEntries
javascript
danialfarid/ng-file-upload
dist/ng-file-upload-all.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload-all.js
MIT
function dropAvailable() { var div = document.createElement('div'); return ('draggable' in div) && ('ondrop' in div) && !/Edge\/12./i.test(navigator.userAgent); }
Conserve aspect ratio of the original region. Useful when shrinking/enlarging images to fit into a certain area. Source: http://stackoverflow.com/a/14731922 @param {Number} srcWidth Source area width @param {Number} srcHeight Source area height @param {Number} maxWidth Nestable area maximum available width @param {Nu...
dropAvailable
javascript
danialfarid/ng-file-upload
dist/ng-file-upload-all.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload-all.js
MIT
function applyTransform(ctx, orientation, width, height) { switch (orientation) { case 2: return ctx.transform(-1, 0, 0, 1, width, 0); case 3: return ctx.transform(-1, 0, 0, -1, width, height); case 4: return ctx.transform(1, 0, 0, -1, 0, height); case 5: retu...
Conserve aspect ratio of the original region. Useful when shrinking/enlarging images to fit into a certain area. Source: http://stackoverflow.com/a/14731922 @param {Number} srcWidth Source area width @param {Number} srcHeight Source area height @param {Number} maxWidth Nestable area maximum available width @param {Nu...
applyTransform
javascript
danialfarid/ng-file-upload
dist/ng-file-upload-all.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload-all.js
MIT
function arrayBufferToBase64(buffer) { var binary = ''; var bytes = new Uint8Array(buffer); var len = bytes.byteLength; for (var i = 0; i < len; i++) { binary += String.fromCharCode(bytes[i]); } return window.btoa(binary); }
Conserve aspect ratio of the original region. Useful when shrinking/enlarging images to fit into a certain area. Source: http://stackoverflow.com/a/14731922 @param {Number} srcWidth Source area width @param {Number} srcHeight Source area height @param {Number} maxWidth Nestable area maximum available width @param {Nu...
arrayBufferToBase64
javascript
danialfarid/ng-file-upload
dist/ng-file-upload-all.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload-all.js
MIT
function sendHttp(config) { config.method = config.method || 'POST'; config.headers = config.headers || {}; var deferred = config._deferred = config._deferred || $q.defer(); var promise = deferred.promise; function notifyProgress(e) { if (deferred.notify) { deferred.notify(e); ...
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
sendHttp
javascript
danialfarid/ng-file-upload
dist/ng-file-upload.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload.js
MIT
function notifyProgress(e) { if (deferred.notify) { deferred.notify(e); } if (promise.progressFunc) { $timeout(function () { promise.progressFunc(e); }); } }
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
notifyProgress
javascript
danialfarid/ng-file-upload
dist/ng-file-upload.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload.js
MIT
function getNotifyEvent(n) { if (config._start != null && resumeSupported) { return { loaded: n.loaded + config._start, total: (config._file && config._file.size) || n.total, type: n.type, config: config, lengthComputable: true, target: n.target }; } e...
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
getNotifyEvent
javascript
danialfarid/ng-file-upload
dist/ng-file-upload.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload.js
MIT
function uploadWithAngular() { $http(config).then(function (r) { if (resumeSupported && config._chunkSize && !config._finished && config._file) { var fileSize = config._file && config._file.size || 0; notifyProgress({ loaded: Math.min(config._end, fileSize), ...
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
uploadWithAngular
javascript
danialfarid/ng-file-upload
dist/ng-file-upload.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload.js
MIT
function copy(obj) { var clone = {}; for (var key in obj) { if (obj.hasOwnProperty(key)) { clone[key] = obj[key]; } } return clone; }
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
copy
javascript
danialfarid/ng-file-upload
dist/ng-file-upload.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload.js
MIT
function toResumeFile(file, formData) { if (file._ngfBlob) return file; config._file = config._file || file; if (config._start != null && resumeSupported) { if (config._end && config._end >= file.size) { config._finished = true; config._end = file.size; } va...
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
toResumeFile
javascript
danialfarid/ng-file-upload
dist/ng-file-upload.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload.js
MIT
function addFieldToFormData(formData, val, key) { if (val !== undefined) { if (angular.isDate(val)) { val = val.toISOString(); } if (angular.isString(val)) { formData.append(key, val); } else if (upload.isFile(val)) { var file = toResumeFile(val, formD...
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
addFieldToFormData
javascript
danialfarid/ng-file-upload
dist/ng-file-upload.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload.js
MIT
function digestConfig() { config._chunkSize = upload.translateScalars(config.resumeChunkSize); config._chunkSize = config._chunkSize ? parseInt(config._chunkSize.toString()) : null; config.headers = config.headers || {}; config.headers['Content-Type'] = undefined; config.transformRequest ...
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
digestConfig
javascript
danialfarid/ng-file-upload
dist/ng-file-upload.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload.js
MIT
function applyExifRotations(files, attr, scope) { var promises = [upload.emptyPromise()]; angular.forEach(files, function (f, i) { if (f.type.indexOf('image/jpeg') === 0 && upload.attrGetter('ngfFixOrientation', attr, scope, {$file: f})) { promises.push(upload.happyPromise(upload.applyExifRotation...
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
applyExifRotations
javascript
danialfarid/ng-file-upload
dist/ng-file-upload.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload.js
MIT
function resizeFile(files, attr, scope, ngModel) { var resizeVal = upload.attrGetter('ngfResize', attr, scope); if (!resizeVal || !upload.isResizeSupported() || !files.length) return upload.emptyPromise(); if (resizeVal instanceof Function) { var defer = $q.defer(); return resizeVal(files).then(...
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
resizeFile
javascript
danialfarid/ng-file-upload
dist/ng-file-upload.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload.js
MIT
function resizeWithParams(params, files, attr, scope, ngModel) { var promises = [upload.emptyPromise()]; function handleFile(f, i) { if (f.type.indexOf('image') === 0) { if (params.pattern && !upload.validatePattern(f, params.pattern)) return; params.resizeIf = function (width, height) { ...
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
resizeWithParams
javascript
danialfarid/ng-file-upload
dist/ng-file-upload.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload.js
MIT
function handleFile(f, i) { if (f.type.indexOf('image') === 0) { if (params.pattern && !upload.validatePattern(f, params.pattern)) return; params.resizeIf = function (width, height) { return upload.attrGetter('ngfResizeIf', attr, scope, {$width: width, $height: height, $file:...
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
handleFile
javascript
danialfarid/ng-file-upload
dist/ng-file-upload.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload.js
MIT
function update(files, invalidFiles, newFiles, dupFiles, isSingleModel) { attr.$$ngfPrevValidFiles = files; attr.$$ngfPrevInvalidFiles = invalidFiles; var file = files && files.length ? files[0] : null; var invalidFile = invalidFiles && invalidFiles.length ? invalidFiles[0] : null; if (ng...
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
update
javascript
danialfarid/ng-file-upload
dist/ng-file-upload.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload.js
MIT
function removeDuplicates() { function equals(f1, f2) { return f1.name === f2.name && (f1.$ngfOrigSize || f1.size) === (f2.$ngfOrigSize || f2.size) && f1.type === f2.type; } function isInPrevFiles(f) { var j; for (j = 0; j < prevValidFiles.length; j++) { if...
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
removeDuplicates
javascript
danialfarid/ng-file-upload
dist/ng-file-upload.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload.js
MIT
function equals(f1, f2) { return f1.name === f2.name && (f1.$ngfOrigSize || f1.size) === (f2.$ngfOrigSize || f2.size) && f1.type === f2.type; }
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
equals
javascript
danialfarid/ng-file-upload
dist/ng-file-upload.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload.js
MIT
function isInPrevFiles(f) { var j; for (j = 0; j < prevValidFiles.length; j++) { if (equals(f, prevValidFiles[j])) { return true; } } for (j = 0; j < prevInvalidFiles.length; j++) { if (equals(f, prevInvalidFiles[j])) { return true; ...
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
isInPrevFiles
javascript
danialfarid/ng-file-upload
dist/ng-file-upload.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload.js
MIT
function toArray(v) { return angular.isArray(v) ? v : [v]; }
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
toArray
javascript
danialfarid/ng-file-upload
dist/ng-file-upload.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload.js
MIT
function resizeAndUpdate() { function updateModel() { $timeout(function () { update(keep ? prevValidFiles.concat(valids) : valids, keep ? prevInvalidFiles.concat(invalids) : invalids, files, dupFiles, isSingleModel); }, options && options.debounce ? options.deboun...
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
resizeAndUpdate
javascript
danialfarid/ng-file-upload
dist/ng-file-upload.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload.js
MIT
function updateModel() { $timeout(function () { update(keep ? prevValidFiles.concat(valids) : valids, keep ? prevInvalidFiles.concat(invalids) : invalids, files, dupFiles, isSingleModel); }, options && options.debounce ? options.debounce.change || options.debounce : 0);...
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
updateModel
javascript
danialfarid/ng-file-upload
dist/ng-file-upload.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload.js
MIT
function isDelayedClickSupported(ua) { // fix for android native browser < 4.4 and safari windows var m = ua.match(/Android[^\d]*(\d+)\.(\d+)/); if (m && m.length > 2) { var v = Upload.defaults.androidFixMinorVersion || 4; return parseInt(m[1]) < 4 || (parseInt(m[1]) === v && parseInt(m[2]) < v)...
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
isDelayedClickSupported
javascript
danialfarid/ng-file-upload
dist/ng-file-upload.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload.js
MIT
function linkFileSelect(scope, elem, attr, ngModel, $parse, $timeout, $compile, upload) { /** @namespace attr.ngfSelect */ /** @namespace attr.ngfChange */ /** @namespace attr.ngModel */ /** @namespace attr.ngfModelOptions */ /** @namespace attr.ngfMultiple */ /** @namespace attr.ngfCapture */ ...
! AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort, progress, resize, thumbnail, preview, validation and CORS @author Danial <danial.farid@gmail.com> @version 12.2.13
linkFileSelect
javascript
danialfarid/ng-file-upload
dist/ng-file-upload.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload.js
MIT
calculateAspectRatioFit = function (srcWidth, srcHeight, maxWidth, maxHeight, centerCrop) { var ratio = centerCrop ? Math.max(maxWidth / srcWidth, maxHeight / srcHeight) : Math.min(maxWidth / srcWidth, maxHeight / srcHeight); return { width: srcWidth * ratio, height: srcHeight * ratio, marginX...
Conserve aspect ratio of the original region. Useful when shrinking/enlarging images to fit into a certain area. Source: http://stackoverflow.com/a/14731922 @param {Number} srcWidth Source area width @param {Number} srcHeight Source area height @param {Number} maxWidth Nestable area maximum available width @param {Nu...
calculateAspectRatioFit
javascript
danialfarid/ng-file-upload
dist/ng-file-upload.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload.js
MIT
resize = function (imagen, width, height, quality, type, ratio, centerCrop, resizeIf) { var deferred = $q.defer(); var canvasElement = document.createElement('canvas'); var imageElement = document.createElement('img'); imageElement.setAttribute('style', 'visibility:hidden;position:fixed;z-index:-100000'...
Conserve aspect ratio of the original region. Useful when shrinking/enlarging images to fit into a certain area. Source: http://stackoverflow.com/a/14731922 @param {Number} srcWidth Source area width @param {Number} srcHeight Source area height @param {Number} maxWidth Nestable area maximum available width @param {Nu...
resize
javascript
danialfarid/ng-file-upload
dist/ng-file-upload.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload.js
MIT
function linkDrop(scope, elem, attr, ngModel, $parse, $timeout, $window, upload, $http, $q) { var available = dropAvailable(); var attrGetter = function (name, scope, params) { return upload.attrGetter(name, attr, scope, params); }; if (attrGetter('dropAvailable')) { $timeout(function () {...
Conserve aspect ratio of the original region. Useful when shrinking/enlarging images to fit into a certain area. Source: http://stackoverflow.com/a/14731922 @param {Number} srcWidth Source area width @param {Number} srcHeight Source area height @param {Number} maxWidth Nestable area maximum available width @param {Nu...
linkDrop
javascript
danialfarid/ng-file-upload
dist/ng-file-upload.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload.js
MIT
attrGetter = function (name, scope, params) { return upload.attrGetter(name, attr, scope, params); }
Conserve aspect ratio of the original region. Useful when shrinking/enlarging images to fit into a certain area. Source: http://stackoverflow.com/a/14731922 @param {Number} srcWidth Source area width @param {Number} srcHeight Source area height @param {Number} maxWidth Nestable area maximum available width @param {Nu...
attrGetter
javascript
danialfarid/ng-file-upload
dist/ng-file-upload.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload.js
MIT
function isDisabled() { return elem.attr('disabled') || attrGetter('ngfDropDisabled', scope); }
Conserve aspect ratio of the original region. Useful when shrinking/enlarging images to fit into a certain area. Source: http://stackoverflow.com/a/14731922 @param {Number} srcWidth Source area width @param {Number} srcHeight Source area height @param {Number} maxWidth Nestable area maximum available width @param {Nu...
isDisabled
javascript
danialfarid/ng-file-upload
dist/ng-file-upload.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload.js
MIT
function extractFilesAndUpdateModel(source, evt, updateOnType) { if (!source) return; // html needs to be calculated on the same process otherwise the data will be wiped // after promise resolve or setTimeout. var html; try { html = source && source.getData && source.getData('text/...
Conserve aspect ratio of the original region. Useful when shrinking/enlarging images to fit into a certain area. Source: http://stackoverflow.com/a/14731922 @param {Number} srcWidth Source area width @param {Number} srcHeight Source area height @param {Number} maxWidth Nestable area maximum available width @param {Nu...
extractFilesAndUpdateModel
javascript
danialfarid/ng-file-upload
dist/ng-file-upload.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload.js
MIT
function updateModel(files, evt) { upload.updateModel(ngModel, attr, scope, attrGetter('ngfChange') || attrGetter('ngfDrop'), files, evt); }
Conserve aspect ratio of the original region. Useful when shrinking/enlarging images to fit into a certain area. Source: http://stackoverflow.com/a/14731922 @param {Number} srcWidth Source area width @param {Number} srcHeight Source area height @param {Number} maxWidth Nestable area maximum available width @param {Nu...
updateModel
javascript
danialfarid/ng-file-upload
dist/ng-file-upload.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload.js
MIT
function extractFilesFromHtml(updateOn, html) { if (!upload.shouldUpdateOn(updateOn, attr, scope) || typeof html !== 'string') return upload.rejectPromise([]); var urls = []; html.replace(/<(img src|img [^>]* src) *=\"([^\"]*)\"/gi, function (m, n, src) { urls.push(src); }); var pr...
Conserve aspect ratio of the original region. Useful when shrinking/enlarging images to fit into a certain area. Source: http://stackoverflow.com/a/14731922 @param {Number} srcWidth Source area width @param {Number} srcHeight Source area height @param {Number} maxWidth Nestable area maximum available width @param {Nu...
extractFilesFromHtml
javascript
danialfarid/ng-file-upload
dist/ng-file-upload.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload.js
MIT
function calculateDragOverClass(scope, attr, evt, callback) { var obj = attrGetter('ngfDragOverClass', scope, {$event: evt}), dClass = 'dragover'; if (angular.isString(obj)) { dClass = obj; } else if (obj) { if (obj.delay) dragOverDelay = obj.delay; if (obj.accept || obj.reject...
Conserve aspect ratio of the original region. Useful when shrinking/enlarging images to fit into a certain area. Source: http://stackoverflow.com/a/14731922 @param {Number} srcWidth Source area width @param {Number} srcHeight Source area height @param {Number} maxWidth Nestable area maximum available width @param {Nu...
calculateDragOverClass
javascript
danialfarid/ng-file-upload
dist/ng-file-upload.js
https://github.com/danialfarid/ng-file-upload/blob/master/dist/ng-file-upload.js
MIT