mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-04 06:57:03 +03:00
Use jQuery.slim
Underscore.js _.uniq(_.compact( to native Array.filter((value, index, self) => !!value && self.indexOf(value) == index) Underscore.js _.compact to native Array.filter(value => !!value) Underscore.js _.uniq to native Array.filter((value, index, self) => self.indexOf(value) == index) Underscore.js _.values to native Object.values Underscore.js _.flatten to native Array.flat Underscore.js _.union to native Array.concat + unique filter Underscore.js _.reduce to native Array.reduce Underscore.js _.escape replaced with advanced htmlspecialchars() Underscore.js _.memoize replaced Now Underscore.js is a slim custom version (only _.debounce, _.defer & _.throttle)
This commit is contained in:
parent
996a71ad8a
commit
dca0ff02ed
27 changed files with 515 additions and 353 deletions
6
vendors/underscore/underscore-min.custom.js
vendored
Normal file
6
vendors/underscore/underscore-min.custom.js
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
// Underscore.js 1.9.2
|
||||
// https://underscorejs.org
|
||||
// (c) 2009-2018 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
||||
// Underscore may be freely distributed under the MIT license.
|
||||
|
||||
(()=>{var e=function(t){return t instanceof e?t:this instanceof e?void 0:new e(t)};"undefined"==typeof exports||exports.nodeType?("object"==typeof self&&self.self===self&&self||"object"==typeof global&&global.global===global&&global||this||{})._=e:("undefined"!=typeof module&&!module.nodeType&&module.exports&&(exports=module.exports=e),exports._=e);e.VERSION="1.9.2";var t=function(e,t,n,o,l){if(!(o instanceof t))return e.apply(n,l);var r,u="object"!=typeof(r=e.prototype)?{}:Object.create(r),i=e.apply(u,l);return"object"==typeof i?i:u};e.defer=(()=>{var e=(e,t,...n)=>setTimeout(()=>e.apply(null,n),t),n=function(...o){for(var l=0,r=[o[l++],1];l<o.length;)r.push(o[l++]);return t(e,n,this,this,r)};return n})(),e.throttle=function(e,t,n){var o,l,r,u,i=0;n||(n={});var a=function(){i=!1===n.leading?0:Date.now(),o=null,u=e.apply(l,r),o||(l=r=null)},f=function(){var f=Date.now();i||!1!==n.leading||(i=f);var p=t-(f-i);return l=this,r=arguments,p<=0||p>t?(o&&(clearTimeout(o),o=null),i=f,u=e.apply(l,r),o||(l=r=null)):o||!1===n.trailing||(o=setTimeout(a,p)),u};return f.cancel=function(){clearTimeout(o),i=0,o=l=r=null},f},e.debounce=function(e,t,n){var o,l,r=function(t,n){o=null,n&&(l=e.apply(t,n))},u=function(...u){if(o&&clearTimeout(o),n){var i=!o;o=setTimeout(r,t),i&&(l=e.apply(this,u))}else{var a=this;o=setTimeout(()=>r.apply(null,[a,u]),t)}return l};return u.cancel=function(){clearTimeout(o),o=null},u},"function"==typeof define&&define.amd&&define("underscore",[],function(){return e})})();
|
||||
169
vendors/underscore/underscore.custom.js
vendored
Normal file
169
vendors/underscore/underscore.custom.js
vendored
Normal file
|
|
@ -0,0 +1,169 @@
|
|||
// Underscore.js 1.9.2
|
||||
// https://underscorejs.org
|
||||
// (c) 2009-2018 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
||||
// Underscore may be freely distributed under the MIT license.
|
||||
/*
|
||||
_.debounce
|
||||
_.defer
|
||||
_.throttle
|
||||
*/
|
||||
|
||||
(() => {
|
||||
|
||||
// Baseline setup
|
||||
// --------------
|
||||
|
||||
// Create a safe reference to the Underscore object for use below.
|
||||
var _ = function(obj) {
|
||||
if (obj instanceof _) return obj;
|
||||
if (!(this instanceof _)) return new _(obj);
|
||||
};
|
||||
|
||||
// Export the Underscore object for **Node.js**, with
|
||||
// backwards-compatibility for their old module API. If we're in
|
||||
// the browser, add `_` as a global object.
|
||||
// (`nodeType` is checked to ensure that `module`
|
||||
// and `exports` are not HTML elements.)
|
||||
if (typeof exports != 'undefined' && !exports.nodeType) {
|
||||
if (typeof module != 'undefined' && !module.nodeType && module.exports) {
|
||||
exports = module.exports = _;
|
||||
}
|
||||
exports._ = _;
|
||||
} else {
|
||||
// Establish the root object, `window` (`self`) in the browser, `global`
|
||||
// on the server, or `this` in some virtual machines. We use `self`
|
||||
// instead of `window` for `WebWorker` support.
|
||||
var root = typeof self == 'object' && self.self === self && self ||
|
||||
typeof global == 'object' && global.global === global && global ||
|
||||
this ||
|
||||
{};
|
||||
root._ = _;
|
||||
}
|
||||
|
||||
// Current version.
|
||||
_.VERSION = '1.9.2';
|
||||
|
||||
// An internal function for creating a new object that inherits from another.
|
||||
var baseCreate = function(prototype) {
|
||||
if (typeof prototype !== 'object') return {};
|
||||
return Object.create(prototype);
|
||||
};
|
||||
|
||||
// Function (ahem) Functions
|
||||
// ------------------
|
||||
|
||||
// Determines whether to execute a function as a constructor
|
||||
// or a normal function with the provided arguments.
|
||||
var executeBound = function(sourceFunc, boundFunc, context, callingContext, args) {
|
||||
if (!(callingContext instanceof boundFunc)) return sourceFunc.apply(context, args);
|
||||
var self = baseCreate(sourceFunc.prototype);
|
||||
var result = sourceFunc.apply(self, args);
|
||||
return (typeof result === 'object') ? result : self;
|
||||
};
|
||||
|
||||
// Defers a function, scheduling it to run after the current call stack has
|
||||
// cleared.
|
||||
_.defer = (() => {
|
||||
var func = (func, wait, ...args) => setTimeout(() => func.apply(null, args), wait);
|
||||
var bound = function(...params) {
|
||||
var position = 0;
|
||||
var args = [params[position++], 1];
|
||||
while (position < params.length) args.push(params[position++]);
|
||||
return executeBound(func, bound, this, this, args);
|
||||
};
|
||||
return bound;
|
||||
})();
|
||||
|
||||
// Returns a function, that, when invoked, will only be triggered at most once
|
||||
// during a given window of time. Normally, the throttled function will run
|
||||
// as much as it can, without ever going more than once per `wait` duration;
|
||||
// but if you'd like to disable the execution on the leading edge, pass
|
||||
// `{leading: false}`. To disable execution on the trailing edge, ditto.
|
||||
_.throttle = function(func, wait, options) {
|
||||
var timeout, context, args, result;
|
||||
var previous = 0;
|
||||
if (!options) options = {};
|
||||
|
||||
var later = function() {
|
||||
previous = options.leading === false ? 0 : Date.now();
|
||||
timeout = null;
|
||||
result = func.apply(context, args);
|
||||
if (!timeout) context = args = null;
|
||||
};
|
||||
|
||||
var throttled = function() {
|
||||
var now = Date.now();
|
||||
if (!previous && options.leading === false) previous = now;
|
||||
var remaining = wait - (now - previous);
|
||||
context = this;
|
||||
args = arguments;
|
||||
if (remaining <= 0 || remaining > wait) {
|
||||
if (timeout) {
|
||||
clearTimeout(timeout);
|
||||
timeout = null;
|
||||
}
|
||||
previous = now;
|
||||
result = func.apply(context, args);
|
||||
if (!timeout) context = args = null;
|
||||
} else if (!timeout && options.trailing !== false) {
|
||||
timeout = setTimeout(later, remaining);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
throttled.cancel = function() {
|
||||
clearTimeout(timeout);
|
||||
previous = 0;
|
||||
timeout = context = args = null;
|
||||
};
|
||||
|
||||
return throttled;
|
||||
};
|
||||
|
||||
// Returns a function, that, as long as it continues to be invoked, will not
|
||||
// be triggered. The function will be called after it stops being called for
|
||||
// N milliseconds. If `immediate` is passed, trigger the function on the
|
||||
// leading edge, instead of the trailing.
|
||||
_.debounce = function(func, wait, immediate) {
|
||||
var timeout, result;
|
||||
|
||||
var later = function(context, args) {
|
||||
timeout = null;
|
||||
if (args) result = func.apply(context, args);
|
||||
};
|
||||
|
||||
var debounced = function(...args) {
|
||||
if (timeout) clearTimeout(timeout);
|
||||
if (immediate) {
|
||||
var callNow = !timeout;
|
||||
timeout = setTimeout(later, wait);
|
||||
if (callNow) result = func.apply(this, args);
|
||||
} else {
|
||||
var obj = this;
|
||||
timeout = setTimeout(() => later.apply(null, [obj, args]), wait);
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
debounced.cancel = function() {
|
||||
clearTimeout(timeout);
|
||||
timeout = null;
|
||||
};
|
||||
|
||||
return debounced;
|
||||
};
|
||||
|
||||
// AMD registration happens at the end for compatibility with AMD loaders
|
||||
// that may not enforce next-turn semantics on modules. Even though general
|
||||
// practice for AMD registration is to be anonymous, underscore registers
|
||||
// as a named module because, like jQuery, it is a base library that is
|
||||
// popular enough to be bundled in a third party lib, but not be part of
|
||||
// an AMD load request. Those cases could generate an error when an
|
||||
// anonymous define() is called outside of a loader request.
|
||||
if (typeof define == 'function' && define.amd) {
|
||||
define('underscore', [], function() {
|
||||
return _;
|
||||
});
|
||||
}
|
||||
})();
|
||||
Loading…
Add table
Add a link
Reference in a new issue