mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-31 04:59:21 +03:00
Added "Custom Theme Configuration" (background)
This commit is contained in:
parent
0587d66d45
commit
ef81865ef2
45 changed files with 1151 additions and 73654 deletions
26
vendors/queue/LICENSE
vendored
Normal file
26
vendors/queue/LICENSE
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
Copyright (c) 2012, Michael Bostock
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* The name Michael Bostock may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL MICHAEL BOSTOCK BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
83
vendors/queue/README.md
vendored
Normal file
83
vendors/queue/README.md
vendored
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
# queue.js
|
||||
|
||||
**Queue.js** is yet another asynchronous helper library for JavaScript. Think of it as a minimalist version of [Async.js](https://github.com/caolan/async) that allows fine-tuning over parallelism. Or, think of it as a version of [TameJs](https://github.com/maxtaco/tamejs/) that does not use code generation.
|
||||
|
||||
For example, if you wanted to stat two files in parallel:
|
||||
|
||||
```js
|
||||
queue()
|
||||
.defer(fs.stat, __dirname + "/../Makefile")
|
||||
.defer(fs.stat, __dirname + "/../package.json")
|
||||
.await(function(error, file1, file2) { console.log(file1, file2); });
|
||||
```
|
||||
|
||||
Or, if you wanted to run a bazillion asynchronous tasks (here represented as an array of closures) serially:
|
||||
|
||||
```js
|
||||
var q = queue(1);
|
||||
tasks.forEach(function(t) { q.defer(t); });
|
||||
q.awaitAll(function(error, results) { console.log("all done!"); });
|
||||
```
|
||||
|
||||
Queue.js can be run inside Node.js or in a browser.
|
||||
|
||||
## Installation
|
||||
|
||||
In a browser, you can use the official hosted copy on [d3js.org](http://d3js.org):
|
||||
|
||||
```html
|
||||
<script src="http://d3js.org/queue.v1.min.js"></script>
|
||||
```
|
||||
|
||||
Queue.js supports the asynchronous module definition (AMD) API. For example, if you use [RequireJS](http://requirejs.org/), you may load as follows:
|
||||
|
||||
```js
|
||||
require.config({paths: {queue: "http://d3js.org/queue.v1.min"}});
|
||||
|
||||
require(["queue"], function(queue) {
|
||||
console.log(queue.version);
|
||||
});
|
||||
```
|
||||
|
||||
In Node, use [NPM](http://npmjs.org) to install:
|
||||
|
||||
```bash
|
||||
npm install queue-async
|
||||
```
|
||||
|
||||
And then `require("queue-async")`. (The package name is [queue-async](https://npmjs.org/package/queue-async) because the name “queue” was already taken.)
|
||||
|
||||
## API Reference
|
||||
|
||||
### queue([parallelism])
|
||||
|
||||
Constructs a new queue with the specified *parallelism*. If *parallelism* is not specified, the queue has infinite parallelism. Otherwise, *parallelism* is a positive integer. For example, if *parallelism* is 1, then all tasks will be run in series. If *parallelism* is 3, then at most three tasks will be allowed to proceed concurrently; this is useful, for example, when loading resources in a web browser.
|
||||
|
||||
### queue.defer(task[, arguments…])
|
||||
|
||||
Adds the specified asynchronous *task* function to the queue, with any optional *arguments*. The *task* will be called with the specified optional arguments and an additional callback argument; the callback must then be invoked by the task when it has finished. The task must invoke the callback with two arguments: the error, if any, and the result of the task. For example:
|
||||
|
||||
```js
|
||||
function simpleTask(callback) {
|
||||
setTimeout(function() {
|
||||
callback(null, {answer: 42});
|
||||
}, 250);
|
||||
}
|
||||
```
|
||||
|
||||
If an error occurs, any tasks that were scheduled *but not yet started* will not run. For a serial queue (of *parallelism* 1), this means that a task will only run if all previous tasks succeed. For a queue with higher parallelism, only the first error that occurs is reported to the await callback, and tasks that were started before the error occurred will continue to run; note, however, that their results will not be reported to the await callback.
|
||||
|
||||
Tasks can only be deferred before the *await* callback is set. If a task is deferred after the await callback is set, the behavior of the queue is undefined.
|
||||
|
||||
### queue.await(callback)
|
||||
### queue.awaitAll(callback)
|
||||
|
||||
Sets the *callback* to be invoked when all deferred tasks have finished.
|
||||
|
||||
The first argument to the *callback* is the first error that occurred, or null if no error occurred. If an error occurred, there are no additional arguments to the callback. Otherwise, the *await* callback is passed each result as an additional separate argument, while the *awaitAll* callback is passed a single array of results as the second argument.
|
||||
|
||||
If all tasks complete before the *await* or *awaitAll* callback is set, the callback will be invoked immediately. This method should only be called once, after any tasks have been deferred. If the await callback is set multiple times, or set before a task is deferred, the behavior of the queue is undefined.
|
||||
|
||||
## Callbacks
|
||||
|
||||
The callbacks follow the Node.js convention where the first argument is an optional error object and the second argument is the result of the task. Queue.js does not support asynchronous functions that return multiple results; however, you can homogenize such functions by wrapping them and converting multiple results into a single object or array.
|
||||
80
vendors/queue/queue.js
vendored
Normal file
80
vendors/queue/queue.js
vendored
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
(function() {
|
||||
var slice = [].slice;
|
||||
|
||||
function queue(parallelism) {
|
||||
var q,
|
||||
tasks = [],
|
||||
started = 0, // number of tasks that have been started (and perhaps finished)
|
||||
active = 0, // number of tasks currently being executed (started but not finished)
|
||||
remaining = 0, // number of tasks not yet finished
|
||||
popping, // inside a synchronous task callback?
|
||||
error = null,
|
||||
await = noop,
|
||||
all;
|
||||
|
||||
if (!parallelism) parallelism = Infinity;
|
||||
|
||||
function pop() {
|
||||
while (popping = started < tasks.length && active < parallelism) {
|
||||
var i = started++,
|
||||
t = tasks[i],
|
||||
a = slice.call(t, 1);
|
||||
a.push(callback(i));
|
||||
++active;
|
||||
t[0].apply(null, a);
|
||||
}
|
||||
}
|
||||
|
||||
function callback(i) {
|
||||
return function(e, r) {
|
||||
--active;
|
||||
if (error != null) return;
|
||||
if (e != null) {
|
||||
error = e; // ignore new tasks and squelch active callbacks
|
||||
started = remaining = NaN; // stop queued tasks from starting
|
||||
notify();
|
||||
} else {
|
||||
tasks[i] = r;
|
||||
if (--remaining) popping || pop();
|
||||
else notify();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function notify() {
|
||||
if (error != null) await(error);
|
||||
else if (all) await(error, tasks);
|
||||
else await.apply(null, [error].concat(tasks));
|
||||
}
|
||||
|
||||
return q = {
|
||||
defer: function() {
|
||||
if (!error) {
|
||||
tasks.push(arguments);
|
||||
++remaining;
|
||||
pop();
|
||||
}
|
||||
return q;
|
||||
},
|
||||
await: function(f) {
|
||||
await = f;
|
||||
all = false;
|
||||
if (!remaining) notify();
|
||||
return q;
|
||||
},
|
||||
awaitAll: function(f) {
|
||||
await = f;
|
||||
all = true;
|
||||
if (!remaining) notify();
|
||||
return q;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function noop() {}
|
||||
|
||||
queue.version = "1.0.7";
|
||||
if (typeof define === "function" && define.amd) define(function() { return queue; });
|
||||
else if (typeof module === "object" && module.exports) module.exports = queue;
|
||||
else this.queue = queue;
|
||||
})();
|
||||
1
vendors/queue/queue.min.js
vendored
Normal file
1
vendors/queue/queue.min.js
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
!function(){function n(n){function e(){for(;i=a<c.length&&n>p;){var u=a++,e=c[u],o=t.call(e,1);o.push(l(u)),++p,e[0].apply(null,o)}}function l(n){return function(u,t){--p,null==s&&(null!=u?(s=u,a=d=0/0,o()):(c[n]=t,--d?i||e():o()))}}function o(){null!=s?m(s):f?m(s,c):m.apply(null,[s].concat(c))}var r,i,f,c=[],a=0,p=0,d=0,s=null,m=u;return n||(n=1/0),r={defer:function(){return s||(c.push(arguments),++d,e()),r},await:function(n){return m=n,f=!1,d||o(),r},awaitAll:function(n){return m=n,f=!0,d||o(),r}}}function u(){}var t=[].slice;n.version="1.0.7","function"==typeof define&&define.amd?define(function(){return n}):"object"==typeof module&&module.exports?module.exports=n:this.queue=n}();
|
||||
Loading…
Add table
Add a link
Reference in a new issue