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 StripTagBody(tags, next) {
if (typeof next !== "function") {
next = function () {};
}
var isRemoveAllTag = !Array.isArray(tags);
function isRemoveTag(tag) {
if (isRemoveAllTag) return true;
return _.indexOf(tags, tag) !== -1;
}
var removeList = [];
var posStart = false;
return {
... | remove tag body
specify a `tags` list, if the tag is not in the `tags` list then process by the specify function (optional)
@param {array} tags
@param {function} next | StripTagBody | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function isRemoveTag(tag) {
if (isRemoveAllTag) return true;
return _.indexOf(tags, tag) !== -1;
} | remove tag body
specify a `tags` list, if the tag is not in the `tags` list then process by the specify function (optional)
@param {array} tags
@param {function} next | isRemoveTag | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function stripCommentTag(html) {
var retHtml = "";
var lastPos = 0;
while (lastPos < html.length) {
var i = html.indexOf("<!--", lastPos);
if (i === -1) {
retHtml += html.slice(lastPos);
break;
}
retHtml += html.slice(lastPos, i);
var j = html.indexOf("-->", i);
if (j === -1) {... | remove html comments
@param {String} html
@return {String} | stripCommentTag | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function stripBlankChar(html) {
var chars = html.split("");
chars = chars.filter(function (char) {
var c = char.charCodeAt(0);
if (c === 127) return false;
if (c <= 31) {
if (c === 10 || c === 13) return true;
return false;
}
return true;
});
return chars.join("");
} | remove invisible characters
@param {String} html
@return {String} | stripBlankChar | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function filterXSS(html, options) {
var xss = new FilterXSS(options);
return xss.process(html);
} | filter xss function
@param {String} html
@param {Object} options { whiteList, onTag, onTagAttr, onIgnoreTag, onIgnoreTagAttr, safeAttrValue, escapeHtml }
@return {String} | filterXSS | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function isWorkerEnv() {
return (
typeof self !== "undefined" &&
typeof DedicatedWorkerGlobalScope !== "undefined" &&
self instanceof DedicatedWorkerGlobalScope
);
} | filter xss function
@param {String} html
@param {Object} options { whiteList, onTag, onTagAttr, onIgnoreTag, onIgnoreTagAttr, safeAttrValue, escapeHtml }
@return {String} | isWorkerEnv | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function getTagName(html) {
var i = _.spaceIndex(html);
var tagName;
if (i === -1) {
tagName = html.slice(1, -1);
} else {
tagName = html.slice(1, i + 1);
}
tagName = _.trim(tagName).toLowerCase();
if (tagName.slice(0, 1) === "/") tagName = tagName.slice(1);
if (tagName.slice(-1) === "/") tagNam... | get tag name
@param {String} html e.g. '<a hef="#">'
@return {String} | getTagName | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function parseTag(html, onTag, escapeHtml) {
"use strict";
var rethtml = "";
var lastPos = 0;
var tagStart = false;
var quoteStart = false;
var currentPos = 0;
var len = html.length;
var currentTagName = "";
var currentHtml = "";
chariterator: for (currentPos = 0; currentPos < len; currentPos++) {... | parse input html and returns processed html
@param {String} html
@param {Function} onTag e.g. function (sourcePosition, position, tag, html, isClosing)
@param {Function} escapeHtml
@return {String} | parseTag | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function addAttr(name, value) {
name = _.trim(name);
name = name.replace(REGEXP_ILLEGAL_ATTR_NAME, "").toLowerCase();
if (name.length < 1) return;
var ret = onAttr(name, value || "");
if (ret) retAttrs.push(ret);
} | parse input attributes and returns processed attributes
@param {String} html e.g. `href="#" target="_blank"`
@param {Function} onAttr e.g. `function (name, value)`
@return {String} | addAttr | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function findNextEqual(str, i) {
for (; i < str.length; i++) {
var c = str[i];
if (c === " ") continue;
if (c === "=") return i;
return -1;
}
} | parse input attributes and returns processed attributes
@param {String} html e.g. `href="#" target="_blank"`
@param {Function} onAttr e.g. `function (name, value)`
@return {String} | findNextEqual | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function findNextQuotationMark(str, i) {
for (; i < str.length; i++) {
var c = str[i];
if (c === " ") continue;
if (c === "'" || c === '"') return i;
return -1;
}
} | parse input attributes and returns processed attributes
@param {String} html e.g. `href="#" target="_blank"`
@param {Function} onAttr e.g. `function (name, value)`
@return {String} | findNextQuotationMark | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function findBeforeEqual(str, i) {
for (; i > 0; i--) {
var c = str[i];
if (c === " ") continue;
if (c === "=") return i;
return -1;
}
} | parse input attributes and returns processed attributes
@param {String} html e.g. `href="#" target="_blank"`
@param {Function} onAttr e.g. `function (name, value)`
@return {String} | findBeforeEqual | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function isQuoteWrapString(text) {
if (
(text[0] === '"' && text[text.length - 1] === '"') ||
(text[0] === "'" && text[text.length - 1] === "'")
) {
return true;
} else {
return false;
}
} | parse input attributes and returns processed attributes
@param {String} html e.g. `href="#" target="_blank"`
@param {Function} onAttr e.g. `function (name, value)`
@return {String} | isQuoteWrapString | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function stripQuoteWrap(text) {
if (isQuoteWrapString(text)) {
return text.substr(1, text.length - 2);
} else {
return text;
}
} | parse input attributes and returns processed attributes
@param {String} html e.g. `href="#" target="_blank"`
@param {Function} onAttr e.g. `function (name, value)`
@return {String} | stripQuoteWrap | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function isNull(obj) {
return obj === undefined || obj === null;
} | returns `true` if the input value is `undefined` or `null`
@param {Object} obj
@return {Boolean} | isNull | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function getAttrs(html) {
var i = _.spaceIndex(html);
if (i === -1) {
return {
html: "",
closing: html[html.length - 2] === "/",
};
}
html = _.trim(html.slice(i + 1, -1));
var isClosing = html[html.length - 1] === "/";
if (isClosing) html = _.trim(html.slice(0, -1));
return {
html:... | get attributes for a tag
@param {String} html
@return {Object}
- {String} html
- {Boolean} closing | getAttrs | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function shallowCopyObject(obj) {
var ret = {};
for (var i in obj) {
ret[i] = obj[i];
}
return ret;
} | shallow copy
@param {Object} obj
@return {Object} | shallowCopyObject | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function keysToLowerCase(obj) {
var ret = {};
for (var i in obj) {
if (Array.isArray(obj[i])) {
ret[i.toLowerCase()] = obj[i].map(function (item) {
return item.toLowerCase();
});
} else {
ret[i.toLowerCase()] = obj[i];
}
}
return ret;
} | shallow copy
@param {Object} obj
@return {Object} | keysToLowerCase | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.js | MIT |
function FilterXSS(options) {
options = shallowCopyObject(options || {});
if (options.stripIgnoreTag) {
if (options.onIgnoreTag) {
console.error(
'Notes: cannot use these two options "stripIgnoreTag" and "onIgnoreTag" at the same time'
);
}
options.onIgnoreTag = DEFAULT.onIgnoreTagS... | FilterXSS class
@param {Object} options
whiteList (or allowList), onTag, onTagAttr, onIgnoreTag,
onIgnoreTagAttr, safeAttrValue, escapeHtml
stripIgnoreTagBody, allowCommentTag, stripBlankChar
css{whiteList, onAttr, onIgnoreAttr} `css=false` means don't use `cssfilter` | FilterXSS | javascript | TavernAI/TavernAI | public/scripts/xss.js | https://github.com/TavernAI/TavernAI/blob/master/public/scripts/xss.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 | demo/src/main/webapp/js/FileAPI.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/FileAPI.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/FileAPI.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/FileAPI.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/FileAPI.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/FileAPI.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/FileAPI.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/FileAPI.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/FileAPI.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/FileAPI.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/ng-file-upload-all.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/ng-file-upload-all.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/ng-file-upload-all.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/ng-file-upload-all.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/ng-file-upload-all.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/ng-file-upload-all.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/ng-file-upload-all.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/ng-file-upload-all.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/ng-file-upload-all.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/ng-file-upload-all.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/ng-file-upload-all.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/ng-file-upload-all.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/ng-file-upload-all.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/ng-file-upload-all.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/ng-file-upload-all.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/ng-file-upload-all.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/ng-file-upload-all.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/ng-file-upload-all.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/ng-file-upload-all.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/ng-file-upload-all.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/ng-file-upload-all.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/ng-file-upload-all.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/ng-file-upload-all.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/ng-file-upload-all.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/ng-file-upload-all.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/ng-file-upload-all.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/ng-file-upload-all.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/ng-file-upload-all.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/ng-file-upload-all.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/ng-file-upload-all.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/ng-file-upload-all.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/ng-file-upload-all.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/ng-file-upload-all.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/ng-file-upload-all.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/ng-file-upload-all.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | demo/src/main/webapp/js/ng-file-upload-all.js | https://github.com/danialfarid/ng-file-upload/blob/master/demo/src/main/webapp/js/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 | 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 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 | 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 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 | 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 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 | 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 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 | 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 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 | 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 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 | 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 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 | 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 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 | 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 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 | 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 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 | 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 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 | 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 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 | 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 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 | 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 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 | 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 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 | 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 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 | 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 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 | 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 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 | 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 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 | 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 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 | 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 |
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 | 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 |
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 | 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 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 | 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 |
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 | 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 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 | 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 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 | 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 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 | 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 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 | 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 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 | 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 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 | 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 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 | 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 |
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 | 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 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 | 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 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 | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.