diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 1416d60..0000000 --- a/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: node_js -node_js: - - "0.10" - - "0.11" \ No newline at end of file diff --git a/PROCESS.md b/PROCESS.md deleted file mode 100644 index a39d84b..0000000 --- a/PROCESS.md +++ /dev/null @@ -1,42 +0,0 @@ -* ✘ Always keep context of target: it’s desirable behaviour. Event source, delegate and holder are accessible as event object properties. - * No. In that case you can’t set context in any way - flexibility hurdle. - -* Kinds of targets: - * `Element` - * `Object` - * `undefined` - infer target from the selector passed - -* Kinds of callback modifiers: - * `Function` - no modifier - * `undefined` - use target method instead - * `:name` - event modifiers - -* Ways to keep context: - * handler-wrapper - 1. Create curried handler-wrapper (event modifiers, redirects, target method) ← fn, target. - 2. Store handler-wrapper keyed by fn + target← - - * `.bind` - 1. Store modified handler to modifiedCbCache = `fn: modifiedFn` - 2. Store bound modified handler to targetCbCache = `target: {modifiedFn: moundModifiedFn}`; - - nested weak map - -* Do not use redirects: - * They seriously complicate handlers handling - * It’s not a js way to declare things/callbacks - * ✔ They’re easily implemented as function(e){a(e); b(e); c(e);} - -* Do not use self-referenced props: - * It seriously complicates parsing - * It is unable to be compressed - * ✔ It should beimplemented in 'before/after/changed' state. - -* It should not have .once implementation - use Emmy's `one` instead. It’s weird to pass pseudos or any other params to .once. - * .once('click:pass()') ? Use .on('click:once:pass') - -* Avoid CSV's - you can always pass list or object with separate items. - * 'click:a, click:b' → ['click:a', 'click:b'] - * 'a, b': {...} → 'a: {...}, b: {...}' - -* :not(.a) is different scenario than :on(:not(.a)). - * First ignores calls from `.a` element, second catches calls on from any element not `.a`, inc. from `.a` and in-between. \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index f173b65..0000000 --- a/README.md +++ /dev/null @@ -1,131 +0,0 @@ -

- Enot - - - - -

- -Enot is [Emitter](https://github.com/dfcreative/emmy) with humanized **e**vents **not**ation. It is like [xtags events](http://www.x-tags.org/docs#pseudos) standalone with additional [pseudos](#pseudos). - - - - -# Install - -To use in browser use browserify or [build](enot.js). - -`$ npm install enot` - -```js -var Emitter = require('enot'); -``` - -# Use - -Use Enot as simple emitter with optionally extended event notation: - -```js -Emitter.on('document click:pass(rightmouse)', callback); -Emitter.emit('document click'); -``` - -Enot can be used with any [Emmy](https://github.com/dfcreative/emmy#use)/[component-emitter](https://github.com/component/emitter) use-case. - - -# Examples - -* `click` - call on click -* `click:later(100)` - call 100ms after click -* `click:throttle(200)` - fire not more often than 200ms -* `click:one` - fire once -* `window message` - call on window gets message -* `document unload` - call on user is going to leave -* `.bad-link click` - elements matching selector click -* `:root click:delegate(.bad-link)` - the same as above but in a delegate way -* `.element click, document keypress:pass(enter)` - bind two callbacks - - - - - - - -# Event Notation - -Basic event notation syntax is: - -```js -[] [<:pseudo1><:pseudo2>]... -``` - -| Parameter | Description | -|----|----| -| `target` | Regular CSS-selector (possibly extended with relative pseudos, see [query-relative](http://github.io/dfcreative/query-relative)), `document`/`window` keyword or target property accessible via `@` prefix, e.g. `@firstChild`. | -| `event` | Event name | -| `:pseudo` | Event modifier, see [list of pseudos](#pseudos). | - - - - -# Pseudos - -Use the following pseudos for events as `click:`. - -Pseudo | Alias | Description ----|---|--- -`:once` | `:one` | fire callback once. -`:on(selector)` | `:delegate(selector)` | listen for bubbled event on elements mathing selector. -`:not(selector)` | | the opposite to `delegate`—ignore bubbled event on elements matching selector. -`:pass(codes/keynames)` | `:keypass(codes/keynames)` | filter event by `code`. Useful for keyboard/mouse events. Full list of codes can be found in [key-name](https://github.com/dfcreative/key-name). Use as `:keypass(enter, 25, 26)`. -`:later(100)` | | invoke callback 100 ms after. -`:throttle(20)` | | invoke callbak not more than once per 20 ms. - -Modifiers can be combined, e.g. `click:once:on(.inner-tag):not(.ignore):pass(rightmouse):later(50)`. - - - -# API - -API consists of common Emitter methods: `on`, `off`, `emit`, and every inherited from Emmy. Methods are chainable, so you can compose lists of calls: `Enot.on(target, 'click', cb).emit(target, 'click').off(target, 'click');`. - - -### `Enot.on(target(s)?, event(s)?, listener)` - -| Parameter | Description | -|----|----| -| `target` | Any object, including _HTMLElement_, _Array_ etc. If omitted — global event will be registered. Can be list of targets (_NodeList_ or _Array_). | -| `event` | Event declaration, in simple case — event name. | -| `callback` | Any _function_ to invoke | -| `events` | Object with event declarations as keys and callbacks as values. | - -```js -//simple event -Enot.on(document.querySelectorAll('.buy-button'), 'click', function(){...}); - -//events object -Enot.on(myPlugin, { - 'window resize, document myPlugin:update': 'update', - 'update': function(){...}, - 'submit, click:on(.submit-button), keypress:pass(enter)': function(){...} -}); -``` - - -### `Enot.off(target(s), event(s)?, listener?)` - -| Parameter | Description | -|----|----| -| `target` | Any object, including _HTMLElement_, _Array_ etc. If omitted — global event will be unbound. Can be list of targets (_NodeList_ or _Array_). | -| `event` | Event name. If omitted - all events for the target will be unbound. | -| `callback` | Any _function_ or _string_ previously bound. If omitted - all events for the target will be unbound. | - - -### `Enot.emit(target, event, data?, bubbles?)` - -Fire event on the target. Optionally pass `data` and `bubbles` params. `data` will be accessible as `event.detail` in callback. - - - - -[![NPM](https://nodei.co/npm/enot.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/enot/) diff --git a/UNLICENSE b/UNLICENSE deleted file mode 100644 index 00d2e13..0000000 --- a/UNLICENSE +++ /dev/null @@ -1,24 +0,0 @@ -This is free and unencumbered software released into the public domain. - -Anyone is free to copy, modify, publish, use, compile, sell, or -distribute this software, either in source code form or as a compiled -binary, for any purpose, commercial or non-commercial, and by any -means. - -In jurisdictions that recognize copyright laws, the author or authors -of this software dedicate any and all copyright interest in the -software to the public domain. We make this dedication for the benefit -of the public at large and to the detriment of our heirs and -successors. We intend this dedication to be an overt act of -relinquishment in perpetuity of all present and future rights to this -software under copyright law. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -For more information, please refer to \ No newline at end of file diff --git a/build/externs.js b/build/externs.js deleted file mode 100644 index 57aed7a..0000000 --- a/build/externs.js +++ /dev/null @@ -1,2269 +0,0 @@ -/** Some emitter externs */ - - -/** - * @param {(string|jQuerySelector|Element|jQuery|function(number))} arg1 - * @return {!jQuery} - */ -var on, once, emit, off, delegate, later, keypass, throttle, not; - -var listeners = function(){}; -var hasListeners = function(){}; - - - - - - - -/** - * @fileoverview Externs for jQuery 1.8.2 - * - * Note that some functions use different return types depending on the number - * of parameters passed in. In these cases, you may need to annotate the type - * of the result in your code, so the JSCompiler understands which type you're - * expecting. For example: - * var elt = /** @type {Element} * / (foo.get(0)); - * - * @see http://api.jquery.com/ - * @externs - */ - -/** - * @typedef {(Window|Document|Element|Array.|string|jQuery| - * NodeList)} - */ -var jQuerySelector; - -/** @typedef {function(...)|Array.} */ -var jQueryCallback; - -/** - * @constructor - * @param {(jQuerySelector|Element|Object|Array.|jQuery|string| - * function())=} arg1 - * @param {(Element|jQuery|Document| - * Object.)=} arg2 - * @return {!jQuery} - */ -function jQuery(arg1, arg2) {} - -/** - * @constructor - * @extends {jQuery} - * @param {(jQuerySelector|Element|Object|Array.|jQuery|string| - * function())=} arg1 - * @param {(Element|jQuery|Document| - * Object.)=} arg2 - * @return {!jQuery} - */ -function $(arg1, arg2) {} - -/** - * @param {(jQuerySelector|Array.|string|jQuery)} arg1 - * @param {Element=} context - * @return {!jQuery} - * @nosideeffects - */ -jQuery.prototype.add = function(arg1, context) {}; - -/** - * @param {(jQuerySelector|Array.|string|jQuery)} arg1 - * @return {!jQuery} - * @nosideeffects - */ -jQuery.prototype.addBack = function(arg1) {}; - -/** - * @param {(string|function(number,String))} arg1 - * @return {!jQuery} - */ -jQuery.prototype.addClass = function(arg1) {}; - -/** - * @param {(string|Element|jQuery|function(this:Element,number))} arg1 - * @param {...(string|Element|jQuery)} var_args - * @return {!jQuery} - */ -jQuery.prototype.after = function(arg1, var_args) {}; - -/** - * @param {(string|Object.)} arg1 - * @param {Object.=} settings - * @return {jQuery.jqXHR} - */ -jQuery.ajax = function(arg1, settings) {}; - -/** - * @param {(string|Object.)} arg1 - * @param {Object.=} settings - * @return {jQuery.jqXHR} - */ -$.ajax = function(arg1, settings) {}; - -/** - * @param {function(!jQuery.event,XMLHttpRequest,Object.)} handler - * @return {!jQuery} - */ -jQuery.prototype.ajaxComplete = function(handler) {}; - -/** - * @param {function(!jQuery.event,jQuery.jqXHR,Object.,*)} handler - * @return {!jQuery} - */ -jQuery.prototype.ajaxError = function(handler) {}; - -/** - * @param {(string| - * function(Object.,Object.,jQuery.jqXHR))} dataTypes - * @param {function(Object.,Object.,jQuery.jqXHR)=} handler - */ -jQuery.ajaxPrefilter = function(dataTypes, handler) {}; - -/** - * @param {(string| - * function(Object.,Object.,jQuery.jqXHR))} dataTypes - * @param {function(Object.,Object.,jQuery.jqXHR)=} handler - */ -$.ajaxPrefilter = function(dataTypes, handler) {}; - -/** - * @param {function(!jQuery.event,jQuery.jqXHR,Object.)} handler - * @return {!jQuery} - */ -jQuery.prototype.ajaxSend = function(handler) {}; - -/** @const */ -jQuery.ajaxSettings = {}; - -/** @const */ -$.ajaxSettings = {}; - -/** @type {Object.} */ -jQuery.ajaxSettings.accepts = {}; - -/** @type {Object.} */ -$.ajaxSettings.accepts = {}; - -/** @type {boolean} */ -jQuery.ajaxSettings.async; - -/** @type {boolean} */ -$.ajaxSettings.async; - -/** @type {Object.} */ -jQuery.ajaxSettings.contents = {}; - -/** @type {Object.} */ -$.ajaxSettings.contents = {}; - -/** @type {string} */ -jQuery.ajaxSettings.contentType; - -/** @type {string} */ -$.ajaxSettings.contentType; - -/** @type {Object.} */ -jQuery.ajaxSettings.converters = {}; - -/** @type {Object.} */ -$.ajaxSettings.converters = {}; - -/** @type {Object.} */ -jQuery.ajaxSettings.flatOptions = {}; - -/** @type {Object.} */ -$.ajaxSettings.flatOptions = {}; - -/** @type {boolean} */ -jQuery.ajaxSettings.global; - -/** @type {boolean} */ -$.ajaxSettings.global; - -/** @type {boolean} */ -jQuery.ajaxSettings.isLocal; - -/** @type {boolean} */ -$.ajaxSettings.isLocal; - -/** @type {boolean} */ -jQuery.ajaxSettings.processData; - -/** @type {boolean} */ -$.ajaxSettings.processData; - -/** @type {Object.} */ -jQuery.ajaxSettings.responseFields = {}; - -/** @type {Object.} */ -$.ajaxSettings.responseFields = {}; - -/** @type {boolean} */ -jQuery.ajaxSettings.traditional; - -/** @type {boolean} */ -$.ajaxSettings.traditional; - -/** @type {string} */ -jQuery.ajaxSettings.type; - -/** @type {string} */ -$.ajaxSettings.type; - -/** @type {string} */ -jQuery.ajaxSettings.url; - -/** @type {string} */ -$.ajaxSettings.url; - -/** @return {XMLHttpRequest|ActiveXObject} */ -jQuery.ajaxSettings.xhr = function() {}; - -/** @return {XMLHttpRequest|ActiveXObject} */ -$.ajaxSettings.xhr = function() {}; - -/** @param {Object.} options */ -jQuery.ajaxSetup = function(options) {}; - -/** @param {Object.} options */ -$.ajaxSetup = function(options) {}; - -/** - * @param {function()} handler - * @return {!jQuery} - */ -jQuery.prototype.ajaxStart = function(handler) {}; - -/** - * @param {function()} handler - * @return {!jQuery} - */ -jQuery.prototype.ajaxStop = function(handler) {}; - -/** - * @param {function(!jQuery.event,XMLHttpRequest,Object.)} handler - * @return {!jQuery} - */ -jQuery.prototype.ajaxSuccess = function(handler) {}; - -/** - * @return {!jQuery} - * @nosideeffects - */ -jQuery.prototype.andSelf = function() {}; - -/** - * @param {Object.} properties - * @param {(string|number|function()|Object.)=} arg2 - * @param {(string|function())=} easing - * @param {function()=} complete - * @return {!jQuery} - */ -jQuery.prototype.animate = function(properties, arg2, easing, complete) {}; - -/** - * @param {(string|Element|jQuery|function(this:Element,number,string))} arg1 - * @param {...(string|Element|jQuery)} var_args - * @return {!jQuery} - */ -jQuery.prototype.append = function(arg1, var_args) {}; - -/** - * @param {(jQuerySelector|Element|jQuery)} target - * @return {!jQuery} - */ -jQuery.prototype.appendTo = function(target) {}; - -/** - * @param {(string|Object.)} arg1 - * @param {(string|number|boolean|function(number,string))=} arg2 - * @return {(string|!jQuery)} - */ -jQuery.prototype.attr = function(arg1, arg2) {}; - -/** - * @param {(string|Element|jQuery|function(this:Element,number))} arg1 - * @param {...(string|Element|jQuery)} var_args - * @return {!jQuery} - */ -jQuery.prototype.before = function(arg1, var_args) {}; - -/** - * @param {(string|Object.)} arg1 - * @param {(Object.|function(!jQuery.event=)|boolean)=} eventData - * @param {(function(!jQuery.event=)|boolean)=} arg3 - * @return {!jQuery} - */ -jQuery.prototype.bind = function(arg1, eventData, arg3) {}; - -/** - * @param {(function(!jQuery.event=)|Object.)=} arg1 - * @param {function(!jQuery.event=)=} handler - * @return {!jQuery} - */ -jQuery.prototype.blur = function(arg1, handler) {}; - -/** @type {boolean} */ -jQuery.boxModel; - -/** @type {boolean} */ -$.boxModel; - -/** @type {Object.} */ -jQuery.browser; - -/** @type {Object.} */ -$.browser; - -/** - * @type {boolean} - * @const - */ -jQuery.browser.mozilla; - -/** - * @type {boolean} - * @const - */ -$.browser.mozilla; - -/** - * @type {boolean} - * @const - */ -jQuery.browser.msie; - -/** - * @type {boolean} - * @const - */ -$.browser.msie; - -/** - * @type {boolean} - * @const - */ -jQuery.browser.opera; - -/** - * @type {boolean} - * @const - */ -$.browser.opera; - -/** - * @deprecated - * @type {boolean} - * @const - */ -jQuery.browser.safari; - -/** - * @deprecated - * @type {boolean} - * @const - */ -$.browser.safari; - -/** @type {string} */ -jQuery.browser.version; - -/** @type {string} */ -$.browser.version; - -/** - * @type {boolean} - * @const - */ -jQuery.browser.webkit; - -/** - * @type {boolean} - * @const - */ -$.browser.webkit; - -/** - * @constructor - * @private - */ -jQuery.callbacks = function () {}; - -/** - * @param {string=} flags - * @return {jQuery.callbacks} - */ -jQuery.Callbacks = function (flags) {}; - -/** @param {function()} callbacks */ -jQuery.callbacks.prototype.add = function(callbacks) {}; - -/** @return {undefined} */ -jQuery.callbacks.prototype.disable = function() {}; - -/** @return {undefined} */ -jQuery.callbacks.prototype.empty = function() {}; - -/** @param {...*} var_args */ -jQuery.callbacks.prototype.fire = function(var_args) {}; - -/** @return {boolean} */ -jQuery.callbacks.prototype.fired = function() {}; - -/** @param {...*} var_args */ -jQuery.callbacks.prototype.fireWith = function(var_args) {}; - -/** - * @param {function()} callback - * @return {boolean} - * @nosideeffects - */ -jQuery.callbacks.prototype.has = function(callback) {}; - -/** @return {undefined} */ -jQuery.callbacks.prototype.lock = function() {}; - -/** @return {boolean} */ -jQuery.callbacks.prototype.locked = function() {}; - -/** @param {function()} callbacks */ -jQuery.callbacks.prototype.remove = function(callbacks) {}; - -/** - * @param {(function(!jQuery.event=)|Object.)=} arg1 - * @param {function(!jQuery.event=)=} handler - * @return {!jQuery} - */ -jQuery.prototype.change = function(arg1, handler) {}; - -/** - * @param {jQuerySelector=} selector - * @return {!jQuery} - * @nosideeffects - */ -jQuery.prototype.children = function(selector) {}; - -/** - * @param {string=} queueName - * @return {!jQuery} - */ -jQuery.prototype.clearQueue = function(queueName) {}; - -/** - * @param {(function(!jQuery.event=)|Object.)=} arg1 - * @param {function(!jQuery.event=)=} handler - * @return {!jQuery} - */ -jQuery.prototype.click = function(arg1, handler) {}; - -/** - * @param {boolean=} withDataAndEvents - * @param {boolean=} deepWithDataAndEvents - * @return {!jQuery} - * @suppress {checkTypes} see issue 583 - */ -jQuery.prototype.clone = function(withDataAndEvents, deepWithDataAndEvents) {}; - -/** - * @param {(jQuerySelector|jQuery|Element|string|Array.)} arg1 - * @param {Element=} context - * @return {!jQuery} - * @nosideeffects - */ -jQuery.prototype.closest = function(arg1, context) {}; - -/** - * @param {Element} container - * @param {Element} contained - * @return {boolean} - */ -jQuery.contains = function(container, contained) {}; - -/** - * @param {Element} container - * @param {Element} contained - * @return {boolean} - */ -$.contains = function(container, contained) {}; - -/** - * @return {!jQuery} - * @nosideeffects - */ -jQuery.prototype.contents = function() {}; - -/** @type {Element} */ -jQuery.prototype.context; - -/** - * @param {(string|Object.)} arg1 - * @param {(string|number|function(number,*))=} arg2 - * @return {(string|!jQuery)} - */ -jQuery.prototype.css = function(arg1, arg2) {}; - -/** @type {Object.} */ -jQuery.cssHooks; - -/** @type {Object.} */ -$.cssHooks; - -/** - * @param {Element} elem - * @param {string=} key - * @param {*=} value - * @return {*} - */ -jQuery.data = function(elem, key, value) {}; - -/** - * @param {(string|Object.)=} arg1 - * @param {*=} value - * @return {*} - */ -jQuery.prototype.data = function(arg1, value) {}; - -/** - * @param {Element} elem - * @param {string=} key - * @param {*=} value - * @return {*} - */ -$.data = function(elem, key, value) {}; - -/** - * @param {(function(!jQuery.event=)|Object.)=} arg1 - * @param {function(!jQuery.event=)=} handler - * @return {!jQuery} - */ -jQuery.prototype.dblclick = function(arg1, handler) {}; - -/** - * @constructor - * @implements {jQuery.Promise} - * @param {function()=} opt_fn - * @see http://api.jquery.com/category/deferred-object/ - */ -jQuery.deferred = function(opt_fn) {}; - -/** - * @constructor - * @extends {jQuery.deferred} - * @param {function()=} opt_fn - * @return {jQuery.Deferred} - */ -jQuery.Deferred = function(opt_fn) {}; - -/** - * @constructor - * @extends {jQuery.deferred} - * @param {function()=} opt_fn - * @see http://api.jquery.com/category/deferred-object/ - */ -$.deferred = function(opt_fn) {}; - -/** - * @constructor - * @extends {jQuery.deferred} - * @param {function()=} opt_fn - * @return {jQuery.deferred} - */ -$.Deferred = function(opt_fn) {}; - -/** - * @override - * @param {jQueryCallback} alwaysCallbacks - * @param {jQueryCallback=} alwaysCallbacks2 - * @return {jQuery.deferred} - */ -jQuery.deferred.prototype.always - = function(alwaysCallbacks, alwaysCallbacks2) {}; - -/** - * @override - * @param {jQueryCallback} doneCallbacks - * @param {jQueryCallback=} doneCallbacks2 - * @return {jQuery.deferred} - */ -jQuery.deferred.prototype.done = function(doneCallbacks, doneCallbacks2) {}; - -/** - * @override - * @param {jQueryCallback} failCallbacks - * @param {jQueryCallback=} failCallbacks2 - * @return {jQuery.deferred} - */ -jQuery.deferred.prototype.fail = function(failCallbacks, failCallbacks2) {}; - -/** - * @param {...*} var_args - * @return {jQuery.deferred} - */ -jQuery.deferred.prototype.notify = function(var_args) {}; - -/** - * @param {Object} context - * @param {...*} var_args - * @return {jQuery.deferred} - */ -jQuery.deferred.prototype.notifyWith = function(context, var_args) {}; - -/** - * @override - * @param {function()=} doneFilter - * @param {function()=} failFilter - * @param {function()=} progressFilter - * @return {jQuery.Promise} - */ -jQuery.deferred.prototype.pipe - = function(doneFilter, failFilter, progressFilter) {}; - -/** - * @param {function()} progressCallbacks - * @return {jQuery.deferred} - */ -jQuery.deferred.prototype.progress = function(progressCallbacks) {}; - -/** - * @param {Object=} target - * @return {jQuery.Promise} - */ -jQuery.deferred.prototype.promise = function(target) {}; - -/** - * @param {...*} var_args - * @return {jQuery.deferred} - */ -jQuery.deferred.prototype.reject = function(var_args) {}; - -/** - * @param {Object} context - * @param {Array.<*>=} args - * @return {jQuery.deferred} - */ -jQuery.deferred.prototype.rejectWith = function(context, args) {}; - -/** - * @param {...*} var_args - * @return {jQuery.deferred} - */ -jQuery.deferred.prototype.resolve = function(var_args) {}; - -/** - * @param {Object} context - * @param {Array.<*>=} args - * @return {jQuery.deferred} - */ -jQuery.deferred.prototype.resolveWith = function(context, args) {}; - -/** @return {string} */ -jQuery.deferred.prototype.state = function() {}; - -/** - * @override - * @param {jQueryCallback} doneCallbacks - * @param {jQueryCallback=} failCallbacks - * @param {jQueryCallback=} progressCallbacks - * @return {jQuery.deferred} - */ -jQuery.deferred.prototype.then - = function(doneCallbacks, failCallbacks, progressCallbacks) {}; - -/** - * @param {number} duration - * @param {string=} queueName - * @return {!jQuery} - */ -jQuery.prototype.delay = function(duration, queueName) {}; - -/** - * @param {string} selector - * @param {(string|Object.)} arg2 - * @param {(function(!jQuery.event=)|Object.)=} arg3 - * @param {function(!jQuery.event=)=} handler - * @return {!jQuery} - */ -jQuery.prototype.delegate = function(selector, arg2, arg3, handler) {}; - -/** - * @param {Element} elem - * @param {string=} queueName - */ -jQuery.dequeue = function(elem, queueName) {}; - -/** - * @param {string=} queueName - * @return {!jQuery} - */ -jQuery.prototype.dequeue = function(queueName) {}; - -/** - * @param {Element} elem - * @param {string=} queueName - */ -$.dequeue = function(elem, queueName) {}; - -/** - * @param {jQuerySelector=} selector - * @return {!jQuery} - */ -jQuery.prototype.detach = function(selector) {}; - -/** - * @deprecated - * @param {(string|Object.)=} arg1 - * @param {string=} handler - * @return {!jQuery} - */ -jQuery.prototype.die = function(arg1, handler) {}; - -/** - * @param {Object} collection - * @param {function(number,?)} callback - * @return {Object} - */ -jQuery.each = function(collection, callback) {}; - -/** - * @param {function(number,Element)} fnc - * @return {!jQuery} - */ -jQuery.prototype.each = function(fnc) {}; - -/** - * @param {Object} collection - * @param {function(number,?)} callback - * @return {Object} - */ -$.each = function(collection, callback) {}; - -/** @return {!jQuery} */ -jQuery.prototype.empty = function() {}; - -/** - * @return {!jQuery} - * @nosideeffects - */ -jQuery.prototype.end = function() {}; - -/** - * @param {number} arg1 - * @return {!jQuery} - */ -jQuery.prototype.eq = function(arg1) {}; - -/** @param {string} message */ -jQuery.error = function(message) {}; - -/** - * @deprecated - * @param {(function(!jQuery.event=)|Object.)} arg1 - * @param {function(!jQuery.event=)=} handler - * @return {!jQuery} - */ -jQuery.prototype.error = function(arg1, handler) {}; - -/** @param {string} message */ -$.error = function(message) {}; - -/** - * @constructor - * @param {string} eventType - */ -jQuery.event = function(eventType) {}; - -/** - * @constructor - * @extends {jQuery.event} - * @param {string} eventType - * @param {Object=} properties - * @return {jQuery.Event} - */ -jQuery.Event = function(eventType, properties) {}; - -/** - * @constructor - * @extends {jQuery.event} - * @param {string} eventType - */ -$.event = function(eventType) {}; - -/** - * @constructor - * @extends {jQuery.event} - * @param {string} eventType - * @param {Object=} properties - * @return {$.Event} - */ -$.Event = function(eventType, properties) {}; - -/** @type {Element} */ -jQuery.event.prototype.currentTarget; - -/** @type {Object.} */ -jQuery.event.prototype.data; - -/** @type {Element} */ -jQuery.event.prototype.delegateTarget; - -/** - * @return {boolean} - * @nosideeffects - */ -jQuery.event.prototype.isDefaultPrevented = function() {}; - -/** - * @return {boolean} - * @nosideeffects - */ -jQuery.event.prototype.isImmediatePropagationStopped = function() {}; - -/** - * @return {boolean} - * @nosideeffects - */ -jQuery.event.prototype.isPropagationStopped = function() {}; - -/** @type {string} */ -jQuery.event.prototype.namespace; - -/** @type {Event} */ -jQuery.event.prototype.originalEvent; - -/** @type {number} */ -jQuery.event.prototype.pageX; - -/** @type {number} */ -jQuery.event.prototype.pageY; - -/** @return {undefined} */ -jQuery.event.prototype.preventDefault = function() {}; - -/** @type {Object.} */ -jQuery.event.prototype.props; - -/** @type {Element} */ -jQuery.event.prototype.relatedTarget; - -/** @type {*} */ -jQuery.event.prototype.result; - -/** @return {undefined} */ -jQuery.event.prototype.stopImmediatePropagation = function() {}; - -/** @return {undefined} */ -jQuery.event.prototype.stopPropagation = function() {}; - -/** @type {Element} */ -jQuery.event.prototype.target; - -/** @type {number} */ -jQuery.event.prototype.timeStamp; - -/** @type {string} */ -jQuery.event.prototype.type; - -/** @type {number} */ -jQuery.event.prototype.which; - -/** - * @param {(Object|boolean)} arg1 - * @param {...*} var_args - * @return {Object} - */ -jQuery.extend = function(arg1, var_args) {}; - -/** - * @param {(Object|boolean)} arg1 - * @param {...*} var_args - * @return {Object} - */ -jQuery.prototype.extend = function(arg1, var_args) {}; - -/** - * @param {(Object|boolean)} arg1 - * @param {...*} var_args - * @return {Object} - */ -$.extend = function(arg1, var_args) {}; - -/** - * @param {(string|number|function())=} duration - * @param {(function()|string)=} arg2 - * @param {function()=} callback - * @return {!jQuery} - */ -jQuery.prototype.fadeIn = function(duration, arg2, callback) {}; - -/** - * @param {(string|number|function())=} duration - * @param {(function()|string)=} arg2 - * @param {function()=} callback - * @return {!jQuery} - */ -jQuery.prototype.fadeOut = function(duration, arg2, callback) {}; - -/** - * @param {(string|number)} duration - * @param {number} opacity - * @param {(function()|string)=} arg3 - * @param {function()=} callback - * @return {!jQuery} - */ -jQuery.prototype.fadeTo = function(duration, opacity, arg3, callback) {}; - -/** - * @param {(string|number|function())=} duration - * @param {(string|function())=} easing - * @param {function()=} callback - * @return {!jQuery} - */ -jQuery.prototype.fadeToggle = function(duration, easing, callback) {}; - -/** - * @param {(jQuerySelector|function(number)|Element|jQuery)} arg1 - * @return {!jQuery} - */ -jQuery.prototype.filter = function(arg1) {}; - -/** - * @param {(jQuerySelector|jQuery|Element)} arg1 - * @return {!jQuery} - * @nosideeffects - */ -jQuery.prototype.find = function(arg1) {}; - -/** @return {!jQuery} */ -jQuery.prototype.first = function() {}; - -/** @see http://docs.jquery.com/Plugins/Authoring */ -jQuery.fn; - -/** @see http://docs.jquery.com/Plugins/Authoring */ -$.fn; - -/** - * @param {(function(!jQuery.event=)|Object.)=} arg1 - * @param {function(!jQuery.event=)=} handler - * @return {!jQuery} - */ -jQuery.prototype.focus = function(arg1, handler) {}; - -/** - * @param {(function(!jQuery.event=)|Object.)} arg1 - * @param {function(!jQuery.event=)=} handler - * @return {!jQuery} - */ -jQuery.prototype.focusin = function(arg1, handler) {}; - -/** - * @param {(function(!jQuery.event=)|Object.)} arg1 - * @param {function(!jQuery.event=)=} handler - * @return {!jQuery} - */ -jQuery.prototype.focusout = function(arg1, handler) {}; - -/** @const */ -jQuery.fx = {}; - -/** @const */ -$.fx = {}; - -/** @type {number} */ -jQuery.fx.interval; - -/** @type {number} */ -$.fx.interval; - -/** @type {boolean} */ -jQuery.fx.off; - -/** @type {boolean} */ -$.fx.off; - -/** - * @param {string} url - * @param {(Object.|string| - * function(string,string,jQuery.jqXHR))=} data - * @param {(function(string,string,jQuery.jqXHR)|string)=} success - * @param {string=} dataType - * @return {jQuery.jqXHR} - */ -jQuery.get = function(url, data, success, dataType) {}; - -/** - * @param {number=} index - * @return {(Element|Array.)} - * @nosideeffects - */ -jQuery.prototype.get = function(index) {}; - -/** - * @param {string} url - * @param {(Object.|string| - * function(string,string,jQuery.jqXHR))=} data - * @param {(function(string,string,jQuery.jqXHR)|string)=} success - * @param {string=} dataType - * @return {jQuery.jqXHR} - */ -$.get = function(url, data, success, dataType) {}; - -/** - * @param {string} url - * @param {(Object.| - * function(Object.,string,jQuery.jqXHR))=} data - * @param {function(Object.,string,jQuery.jqXHR)=} success - * @return {jQuery.jqXHR} - * @see http://api.jquery.com/jquery.getjson/#jQuery-getJSON-url-data-success - */ -jQuery.getJSON = function(url, data, success) {}; - -/** - * @param {string} url - * @param {(Object.| - * function(Object.,string,jQuery.jqXHR))=} data - * @param {function(Object.,string,jQuery.jqXHR)=} success - * @return {jQuery.jqXHR} - * @see http://api.jquery.com/jquery.getjson/#jQuery-getJSON-url-data-success - */ -$.getJSON = function(url, data, success) {}; - -/** - * @param {string} url - * @param {function(Node,string,jQuery.jqXHR)=} success - * @return {jQuery.jqXHR} - */ -jQuery.getScript = function(url, success) {}; - -/** - * @param {string} url - * @param {function(Node,string,jQuery.jqXHR)=} success - * @return {jQuery.jqXHR} - */ -$.getScript = function(url, success) {}; - -/** @param {string} code */ -jQuery.globalEval = function(code) {}; - -/** @param {string} code */ -$.globalEval = function(code) {}; - -/** - * @param {Array.<*>} arr - * @param {function(*,number)} fnc - * @param {boolean=} invert - * @return {Array.<*>} - */ -jQuery.grep = function(arr, fnc, invert) {}; - -/** - * @param {Array.<*>} arr - * @param {function(*,number)} fnc - * @param {boolean=} invert - * @return {Array.<*>} - */ -$.grep = function(arr, fnc, invert) {}; - -/** - * @param {(string|Element)} arg1 - * @return {!jQuery} - * @nosideeffects - */ -jQuery.prototype.has = function(arg1) {}; - -/** - * @param {string} className - * @return {boolean} - * @nosideeffects - */ -jQuery.prototype.hasClass = function(className) {}; - -/** - * @param {Element} elem - * @return {boolean} - * @nosideeffects - */ -jQuery.hasData = function(elem) {}; - -/** - * @param {Element} elem - * @return {boolean} - * @nosideeffects - */ -$.hasData = function(elem) {}; - -/** - * @param {(string|number|function(number,number))=} arg1 - * @return {(number|!jQuery)} - */ -jQuery.prototype.height = function(arg1) {}; - -/** - * @param {(string|number|function())=} duration - * @param {(function()|string)=} arg2 - * @param {function()=} callback - * @return {!jQuery} - */ -jQuery.prototype.hide = function(duration, arg2, callback) {}; - -/** @param {boolean} hold */ -jQuery.holdReady = function(hold) {}; - -/** @param {boolean} hold */ -$.holdReady = function(hold) {}; - -/** - * @param {function(!jQuery.event=)} arg1 - * @param {function(!jQuery.event=)=} handlerOut - * @return {!jQuery} - */ -jQuery.prototype.hover = function(arg1, handlerOut) {}; - -/** - * @param {(string|function(number,string))=} arg1 - * @return {(string|!jQuery)} - */ -jQuery.prototype.html = function(arg1) {}; - -/** - * @param {*} value - * @param {Array.<*>} arr - * @param {number=} fromIndex - * @return {number} - * @nosideeffects - */ -jQuery.inArray = function(value, arr, fromIndex) {}; - -/** - * @param {*} value - * @param {Array.<*>} arr - * @param {number=} fromIndex - * @return {number} - * @nosideeffects - */ -$.inArray = function(value, arr, fromIndex) {}; - -/** - * @param {(jQuerySelector|Element|jQuery)=} arg1 - * @return {number} - */ -jQuery.prototype.index = function(arg1) {}; - -/** - * @return {number} - * @nosideeffects - */ -jQuery.prototype.innerHeight = function() {}; - -/** - * @return {number} - * @nosideeffects - */ -jQuery.prototype.innerWidth = function() {}; - -/** - * @param {(jQuerySelector|Element|jQuery)} target - * @return {!jQuery} - */ -jQuery.prototype.insertAfter = function(target) {}; - -/** - * @param {(jQuerySelector|Element|jQuery)} target - * @return {!jQuery} - */ -jQuery.prototype.insertBefore = function(target) {}; - -/** - * @param {(jQuerySelector|function(number)|jQuery|Element)} arg1 - * @return {boolean} - */ -jQuery.prototype.is = function(arg1) {}; - -/** - * @param {*} obj - * @return {boolean} - * @nosideeffects - */ -jQuery.isArray = function(obj) {}; - -/** - * @param {*} obj - * @return {boolean} - * @nosideeffects - */ -$.isArray = function(obj) {}; - -/** - * @param {Object} obj - * @return {boolean} - * @nosideeffects - */ -jQuery.isEmptyObject = function(obj) {}; - -/** - * @param {Object} obj - * @return {boolean} - * @nosideeffects - */ -$.isEmptyObject = function(obj) {}; - -/** - * @param {*} obj - * @return {boolean} - * @nosideeffects - */ -jQuery.isFunction = function(obj) {}; - -/** - * @param {*} obj - * @return {boolean} - * @nosideeffects - */ -$.isFunction = function(obj) {}; - -/** - * @param {*} value - * @return {boolean} - * @nosideeffects - */ -jQuery.isNumeric = function(value) {}; - -/** - * @param {*} value - * @return {boolean} - * @nosideeffects - */ -$.isNumeric = function(value) {}; - -/** - * @param {Object} obj - * @return {boolean} - * @nosideeffects - */ -jQuery.isPlainObject = function(obj) {}; - -/** - * @param {Object} obj - * @return {boolean} - * @nosideeffects - */ -$.isPlainObject = function(obj) {}; - -/** - * @param {*} obj - * @return {boolean} - * @nosideeffects - */ -jQuery.isWindow = function(obj) {}; - -/** - * @param {*} obj - * @return {boolean} - * @nosideeffects - */ -$.isWindow = function(obj) {}; - -/** - * @param {Element} node - * @return {boolean} - * @nosideeffects - */ -jQuery.isXMLDoc = function(node) {}; - -/** - * @param {Element} node - * @return {boolean} - * @nosideeffects - */ -$.isXMLDoc = function(node) {}; - -/** @type {string} */ -jQuery.prototype.jquery; - -/** - * @constructor - * @extends {XMLHttpRequest} - * @implements {jQuery.Promise} - * @private - * @see http://api.jquery.com/jQuery.ajax/#jqXHR - */ -jQuery.jqXHR = function () {}; - -/** - * @override - * @param {jQueryCallback} alwaysCallbacks - * @param {jQueryCallback=} alwaysCallbacks2 - * @return {jQuery.jqXHR} - */ -jQuery.jqXHR.prototype.always = - function(alwaysCallbacks, alwaysCallbacks2) {}; - -/** - * @deprecated - * @param {function()} callback - * @return {jQuery.jqXHR} -*/ -jQuery.jqXHR.prototype.complete = function (callback) {}; - -/** - * @override - * @param {jQueryCallback} doneCallbacks - * @return {jQuery.jqXHR} - */ -jQuery.jqXHR.prototype.done = function(doneCallbacks) {}; - -/** - * @deprecated - * @param {function()} callback - * @return {jQuery.jqXHR} -*/ -jQuery.jqXHR.prototype.error = function (callback) {}; - -/** - * @override - * @param {jQueryCallback} failCallbacks - * @return {jQuery.jqXHR} - */ -jQuery.jqXHR.prototype.fail = function(failCallbacks) {}; - -/** - * @deprecated - * @override - */ -jQuery.jqXHR.prototype.onreadystatechange = function (callback) {}; - -/** - * @override - * @param {function()=} doneFilter - * @param {function()=} failFilter - * @param {function()=} progressFilter - * @return {jQuery.jqXHR} - */ -jQuery.jqXHR.prototype.pipe = - function(doneFilter, failFilter, progressFilter) {}; - -/** - * @deprecated - * @param {function()} callback - * @return {jQuery.jqXHR} -*/ -jQuery.jqXHR.prototype.success = function (callback) {}; - -/** - * @override - * @param {jQueryCallback} doneCallbacks - * @param {jQueryCallback=} failCallbacks - * @param {jQueryCallback=} progressCallbacks - * @return {jQuery.jqXHR} - */ -jQuery.jqXHR.prototype.then = - function(doneCallbacks, failCallbacks, progressCallbacks) {}; - -/** - * @param {(function(!jQuery.event=)|Object.)=} arg1 - * @param {function(!jQuery.event=)=} handler - * @return {!jQuery} - */ -jQuery.prototype.keydown = function(arg1, handler) {}; - -/** - * @param {(function(!jQuery.event=)|Object.)=} arg1 - * @param {function(!jQuery.event=)=} handler - * @return {!jQuery} - */ -jQuery.prototype.keypress = function(arg1, handler) {}; - -/** - * @param {(function(!jQuery.event=)|Object.)=} arg1 - * @param {function(!jQuery.event=)=} handler - * @return {!jQuery} - */ -jQuery.prototype.keyup = function(arg1, handler) {}; - -/** @return {!jQuery} */ -jQuery.prototype.last = function() {}; - -/** @type {number} */ -jQuery.prototype.length; - -/** - * @deprecated - * @param {(string|Object)} arg1 - * @param {(function(!jQuery.event=)|Object)=} arg2 - * @param {function(!jQuery.event=)=} handler - * @return {!jQuery} - */ -jQuery.prototype.live = function(arg1, arg2, handler) {}; - -/** - * @deprecated - * @param {(function(!jQuery.event=)|Object.|string)} arg1 - * @param {(function(!jQuery.event=)|Object.|string)=} arg2 - * @param {function(string,string,XMLHttpRequest)=} complete - * @return {!jQuery} - */ -jQuery.prototype.load = function(arg1, arg2, complete) {}; - -/** - * @param {*} obj - * @return {Array.<*>} - */ -jQuery.makeArray = function(obj) {}; - -/** - * @param {*} obj - * @return {Array.<*>} - */ -$.makeArray = function(obj) {}; - -/** - * @param {(Array.<*>|Object.)} arg1 - * @param {(function(*,number)|function(*,(string|number)))} callback - * @return {Array.<*>} - */ -jQuery.map = function(arg1, callback) {}; - -/** - * @param {function(number,Element)} callback - * @return {!jQuery} - */ -jQuery.prototype.map = function(callback) {}; - -/** - * @param {(Array.<*>|Object.)} arg1 - * @param {(function(*,number)|function(*,(string|number)))} callback - * @return {Array.<*>} - */ -$.map = function(arg1, callback) {}; - -/** - * @param {Array.<*>} first - * @param {Array.<*>} second - * @return {Array.<*>} - */ -jQuery.merge = function(first, second) {}; - -/** - * @param {Array.<*>} first - * @param {Array.<*>} second - * @return {Array.<*>} - */ -$.merge = function(first, second) {}; - -/** - * @param {(function(!jQuery.event=)|Object.)=} arg1 - * @param {function(!jQuery.event=)=} handler - * @return {!jQuery} - */ -jQuery.prototype.mousedown = function(arg1, handler) {}; - -/** - * @param {(function(!jQuery.event=)|Object.)=} arg1 - * @param {function(!jQuery.event=)=} handler - * @return {!jQuery} - */ -jQuery.prototype.mouseenter = function(arg1, handler) {}; - -/** - * @param {(function(!jQuery.event=)|Object.)=} arg1 - * @param {function(!jQuery.event=)=} handler - * @return {!jQuery} - */ -jQuery.prototype.mouseleave = function(arg1, handler) {}; - -/** - * @param {(function(!jQuery.event=)|Object.)=} arg1 - * @param {function(!jQuery.event=)=} handler - * @return {!jQuery} - */ -jQuery.prototype.mousemove = function(arg1, handler) {}; - -/** - * @param {(function(!jQuery.event=)|Object.)=} arg1 - * @param {function(!jQuery.event=)=} handler - * @return {!jQuery} - */ -jQuery.prototype.mouseout = function(arg1, handler) {}; - -/** - * @param {(function(!jQuery.event=)|Object.)=} arg1 - * @param {function(!jQuery.event=)=} handler - * @return {!jQuery} - */ -jQuery.prototype.mouseover = function(arg1, handler) {}; - -/** - * @param {(function(!jQuery.event=)|Object.)=} arg1 - * @param {function(!jQuery.event=)=} handler - * @return {!jQuery} - */ -jQuery.prototype.mouseup = function(arg1, handler) {}; - -/** - * @param {jQuerySelector=} selector - * @return {!jQuery} - * @nosideeffects - */ -jQuery.prototype.next = function(selector) {}; - -/** - * @param {string=} selector - * @return {!jQuery} - * @nosideeffects - */ -jQuery.prototype.nextAll = function(selector) {}; - -/** - * @param {(jQuerySelector|Element)=} arg1 - * @param {jQuerySelector=} filter - * @return {!jQuery} - * @nosideeffects - */ -jQuery.prototype.nextUntil = function(arg1, filter) {}; - -/** - * @param {boolean=} removeAll - * @return {Object} - */ -jQuery.noConflict = function(removeAll) {}; - -/** - * @param {boolean=} removeAll - * @return {Object} - */ -$.noConflict = function(removeAll) {}; - -/** - * @return {function()} - * @nosideeffects - */ -jQuery.noop = function() {}; - -/** - * @return {function()} - * @nosideeffects - */ -$.noop = function() {}; - -/** - * @param {(jQuerySelector|Array.|function(number)|jQuery)} arg1 - * @return {!jQuery} - */ -jQuery.prototype.not = function(arg1) {}; - -/** - * @return {number} - * @nosideeffects - */ -jQuery.now = function() {}; - -/** - * @return {number} - * @nosideeffects - */ -$.now = function() {}; - -/** - * @param {(string|Object.)=} arg1 - * @param {(string|function(!jQuery.event=))=} selector - * @param {function(!jQuery.event=)=} handler - * @return {!jQuery} - */ -jQuery.prototype.off = function(arg1, selector, handler) {}; - -/** - * @param {({left:number,top:number}| - * function(number,{top:number,left:number}))=} arg1 - * @return {({left:number,top:number}|!jQuery)} - */ -jQuery.prototype.offset = function(arg1) {}; - -/** - * @return {!jQuery} - * @nosideeffects - */ -jQuery.prototype.offsetParent = function() {}; - -/** - * @param {(string|Object.)} arg1 - * @param {*=} selector - * @param {*=} data - * @param {function(!jQuery.event=)=} handler - * @return {!jQuery} - */ -jQuery.prototype.on = function(arg1, selector, data, handler) {}; - -/** - * @param {(string|Object.)} arg1 - * @param {*=} arg2 - * @param {*=} arg3 - * @param {function(!jQuery.event=)=} handler - * @return {!jQuery} - */ -jQuery.prototype.one = function(arg1, arg2, arg3, handler) {}; - -/** - * @param {boolean=} includeMargin - * @return {number} - * @nosideeffects - */ -jQuery.prototype.outerHeight = function(includeMargin) {}; - -/** - * @param {boolean=} includeMargin - * @return {number} - * @nosideeffects - */ -jQuery.prototype.outerWidth = function(includeMargin) {}; - -/** - * @param {(Object.|Array.>)} obj - * @param {boolean=} traditional - * @return {string} - */ -jQuery.param = function(obj, traditional) {}; - -/** - * @param {(Object.|Array.>)} obj - * @param {boolean=} traditional - * @return {string} - */ -$.param = function(obj, traditional) {}; - -/** - * @param {jQuerySelector=} selector - * @return {!jQuery} - * @nosideeffects - */ -jQuery.prototype.parent = function(selector) {}; - -/** - * @param {jQuerySelector=} selector - * @return {!jQuery} - * @nosideeffects - */ -jQuery.prototype.parents = function(selector) {}; - -/** - * @param {(jQuerySelector|Element)=} arg1 - * @param {jQuerySelector=} filter - * @return {!jQuery} - * @nosideeffects - */ -jQuery.prototype.parentsUntil = function(arg1, filter) {}; - -/** - * @param {string} json - * @return {Object.} - */ -jQuery.parseJSON = function(json) {}; - -/** - * @param {string} json - * @return {Object.} - */ -$.parseJSON = function(json) {}; - -/** - * @param {string} data - * @return {Document} - */ -jQuery.parseXML = function(data) {}; - -/** - * @param {string} data - * @return {Document} - */ -$.parseXML = function(data) {}; - -/** - * @return {{left:number,top:number}} - * @nosideeffects - */ -jQuery.prototype.position = function() {}; - -/** - * @param {string} url - * @param {(Object.|string| - * function(string,string,jQuery.jqXHR))=} data - * @param {(function(string,string,jQuery.jqXHR)|string)=} success - * @param {string=} dataType - * @return {jQuery.jqXHR} - */ -jQuery.post = function(url, data, success, dataType) {}; - -/** - * @param {string} url - * @param {(Object.|string| - * function(string,string,jQuery.jqXHR))=} data - * @param {(function(string,string,jQuery.jqXHR)|string)=} success - * @param {string=} dataType - * @return {jQuery.jqXHR} - */ -$.post = function(url, data, success, dataType) {}; - -/** - * @param {(string|Element|jQuery|function(this:Element,number,string))} arg1 - * @param {...(string|Element|jQuery)} var_args - * @return {!jQuery} - */ -jQuery.prototype.prepend = function(arg1, var_args) {}; - -/** - * @param {(jQuerySelector|Element|jQuery)} target - * @return {!jQuery} - */ -jQuery.prototype.prependTo = function(target) {}; - -/** - * @param {jQuerySelector=} selector - * @return {!jQuery} - * @nosideeffects - */ -jQuery.prototype.prev = function(selector) {}; - -/** - * @param {jQuerySelector=} selector - * @return {!jQuery} - * @nosideeffects - */ -jQuery.prototype.prevAll = function(selector) {}; - -/** - * @param {(jQuerySelector|Element)=} arg1 - * @param {jQuerySelector=} filter - * @return {!jQuery} - * @nosideeffects - */ -jQuery.prototype.prevUntil = function(arg1, filter) {}; - -/** - * @param {(string|Object)=} type - * @param {Object=} target - * @return {jQuery.Promise} - */ -jQuery.prototype.promise = function(type, target) {}; - -/** - * @interface - * @private - * @see http://api.jquery.com/Types/#Promise - */ -jQuery.Promise = function () {}; - -/** - * @param {jQueryCallback} alwaysCallbacks - * @param {jQueryCallback=} alwaysCallbacks2 - * @return {jQuery.Promise} - */ -jQuery.Promise.prototype.always = - function(alwaysCallbacks, alwaysCallbacks2) {}; - -/** - * @param {jQueryCallback} doneCallbacks - * @return {jQuery.Promise} - */ -jQuery.Promise.prototype.done = function(doneCallbacks) {}; - -/** - * @param {jQueryCallback} failCallbacks - * @return {jQuery.Promise} - */ -jQuery.Promise.prototype.fail = function(failCallbacks) {}; - -/** - * @param {function()=} doneFilter - * @param {function()=} failFilter - * @param {function()=} progressFilter - * @return {jQuery.Promise} - */ -jQuery.Promise.prototype.pipe = - function(doneFilter, failFilter, progressFilter) {}; - -/** - * @param {jQueryCallback} doneCallbacks - * @param {jQueryCallback=} failCallbacks - * @param {jQueryCallback=} progressCallbacks - * @return {jQuery.Promise} - */ -jQuery.Promise.prototype.then = - function(doneCallbacks, failCallbacks, progressCallbacks) {}; - -/** - * @param {(string|Object.)} arg1 - * @param {(string|number|boolean|function(number,String))=} arg2 - * @return {(string|boolean|!jQuery)} - */ -jQuery.prototype.prop = function(arg1, arg2) {}; - -/** - * @param {...*} var_args - * @return {function()} - */ -jQuery.proxy = function(var_args) {}; - -/** - * @param {...*} var_args - * @return {function()} - */ -$.proxy = function(var_args) {}; - -/** - * @param {Array.} elements - * @param {string=} name - * @param {Array.<*>=} args - * @return {!jQuery} - */ -jQuery.prototype.pushStack = function(elements, name, args) {}; - -/** - * @param {(string|Array.|function(function()))=} queueName - * @param {(Array.|function(function()))=} arg2 - * @return {(Array.|!jQuery)} - */ -jQuery.prototype.queue = function(queueName, arg2) {}; - -/** - * @param {Element} elem - * @param {string=} queueName - * @param {(Array.|function())=} arg3 - * @return {(Array.|!jQuery)} - */ -jQuery.queue = function(elem, queueName, arg3) {}; - -/** - * @param {Element} elem - * @param {string=} queueName - * @param {(Array.|function())=} arg3 - * @return {(Array.|!jQuery)} - */ -$.queue = function(elem, queueName, arg3) {}; - -/** - * @param {function()} handler - * @return {!jQuery} - */ -jQuery.prototype.ready = function(handler) {}; - -/** - * @param {string=} selector - * @return {!jQuery} - */ -jQuery.prototype.remove = function(selector) {}; - -/** - * @param {string} attributeName - * @return {!jQuery} - */ -jQuery.prototype.removeAttr = function(attributeName) {}; - -/** - * @param {(string|function(number,string))=} arg1 - * @return {!jQuery} - */ -jQuery.prototype.removeClass = function(arg1) {}; - -/** - * @param {(string|Array.)=} arg1 - * @return {!jQuery} - */ -jQuery.prototype.removeData = function(arg1) {}; - -/** - * @param {Element} elem - * @param {string=} name - * @return {!jQuery} - */ -jQuery.removeData = function(elem, name) {}; - -/** - * @param {Element} elem - * @param {string=} name - * @return {!jQuery} - */ -$.removeData = function(elem, name) {}; - -/** - * @param {string} propertyName - * @return {!jQuery} - */ -jQuery.prototype.removeProp = function(propertyName) {}; - -/** - * @param {jQuerySelector} target - * @return {!jQuery} - */ -jQuery.prototype.replaceAll = function(target) {}; - -/** - * @param {(string|Element|jQuery|function())} arg1 - * @return {!jQuery} - */ -jQuery.prototype.replaceWith = function(arg1) {}; - -/** - * @param {(function(!jQuery.event=)|Object.)=} arg1 - * @param {function(!jQuery.event=)=} handler - * @return {!jQuery} - */ -jQuery.prototype.resize = function(arg1, handler) {}; - -/** - * @param {(function(!jQuery.event=)|Object.)=} arg1 - * @param {function(!jQuery.event=)=} handler - * @return {!jQuery} - */ -jQuery.prototype.scroll = function(arg1, handler) {}; - -/** - * @param {number=} value - * @return {(number|!jQuery)} - */ -jQuery.prototype.scrollLeft = function(value) {}; - -/** - * @param {number=} value - * @return {(number|!jQuery)} - */ -jQuery.prototype.scrollTop = function(value) {}; - -/** - * @param {(function(!jQuery.event=)|Object.)=} arg1 - * @param {function(!jQuery.event=)=} handler - * @return {!jQuery} - */ -jQuery.prototype.select = function(arg1, handler) {}; - -/** - * @return {string} - * @nosideeffects - */ -jQuery.prototype.serialize = function() {}; - -/** - * @return {Array.>} - * @nosideeffects - */ -jQuery.prototype.serializeArray = function() {}; - -/** - * @param {(string|number|function())=} duration - * @param {(function()|string)=} arg2 - * @param {function()=} callback - * @return {!jQuery} - */ -jQuery.prototype.show = function(duration, arg2, callback) {}; - -/** - * @param {jQuerySelector=} selector - * @return {!jQuery} - * @nosideeffects - */ -jQuery.prototype.siblings = function(selector) {}; - -/** - * @deprecated - * @return {number} - * @nosideeffects - */ -jQuery.prototype.size = function() {}; - -/** - * @param {number} start - * @param {number=} end - * @return {!jQuery} - */ -jQuery.prototype.slice = function(start, end) {}; - -/** - * @param {(Object.|string|number)=} optionsOrDuration - * @param {(function()|string)=} completeOrEasing - * @param {function()=} complete - * @return {!jQuery} - */ -jQuery.prototype.slideDown = - function(optionsOrDuration, completeOrEasing, complete) {}; - -/** - * @param {(Object.|string|number)=} optionsOrDuration - * @param {(function()|string)=} completeOrEasing - * @param {function()=} complete - * @return {!jQuery} - */ -jQuery.prototype.slideToggle = - function(optionsOrDuration, completeOrEasing, complete) {}; - -/** - * @param {(Object.|string|number)=} optionsOrDuration - * @param {(function()|string)=} completeOrEasing - * @param {function()=} complete - * @return {!jQuery} - */ -jQuery.prototype.slideUp = - function(optionsOrDuration, completeOrEasing, complete) {}; - -/** - * @param {(boolean|string)=} arg1 - * @param {boolean=} arg2 - * @param {boolean=} jumpToEnd - * @return {!jQuery} - */ -jQuery.prototype.stop = function(arg1, arg2, jumpToEnd) {}; - -/** - * @deprecated - * @return {!jQuery} - * @nosideeffects - */ -jQuery.sub = function() {}; - -/** - * @deprecated - * @return {!jQuery} - * @nosideeffects - */ -$.sub = function() {}; - -/** - * @param {(function(!jQuery.event=)|Object.)=} arg1 - * @param {function(!jQuery.event=)=} handler - * @return {!jQuery} - */ -jQuery.prototype.submit = function(arg1, handler) {}; - -/** @type {Object.} */ -jQuery.support; - -/** @type {Object.} */ -$.support; - -/** @type {boolean} */ -jQuery.support.boxModel; - -/** @type {boolean} */ -$.support.boxModel; - -/** @type {boolean} */ -jQuery.support.changeBubbles; - -/** @type {boolean} */ -$.support.changeBubbles; - -/** @type {boolean} */ -jQuery.support.cssFloat; - -/** @type {boolean} */ -$.support.cssFloat; - -/** @type {boolean} */ -jQuery.support.fixedPosition; - -/** @type {boolean} */ -$.support.fixedPosition; - -/** @type {boolean} */ -jQuery.support.hrefNormalized; - -/** @type {boolean} */ -$.support.hrefNormalized; - -/** @type {boolean} */ -jQuery.support.htmlSerialize; - -/** @type {boolean} */ -$.support.htmlSerialize; - -/** @type {boolean} */ -jQuery.support.leadingWhitespace; - -/** @type {boolean} */ -$.support.leadingWhitespace; - -/** @type {boolean} */ -jQuery.support.noCloneEvent; - -/** @type {boolean} */ -$.support.noCloneEvent; - -/** @type {boolean} */ -jQuery.support.opacity; - -/** @type {boolean} */ -$.support.opacity; - -/** @type {boolean} */ -jQuery.support.scriptEval; - -/** @type {boolean} */ -$.support.scriptEval; - -/** @type {boolean} */ -jQuery.support.style; - -/** @type {boolean} */ -$.support.style; - -/** @type {boolean} */ -jQuery.support.submitBubbles; - -/** @type {boolean} */ -$.support.submitBubbles; - -/** @type {boolean} */ -jQuery.support.tbody; - -/** @type {boolean} */ -$.support.tbody; - -/** - * @param {(string|function(number,string))=} arg1 - * @return {(string|!jQuery)} - */ -jQuery.prototype.text = function(arg1) {}; - -/** - * @return {Array.} - * @nosideeffects - */ -jQuery.prototype.toArray = function() {}; - -/** - * @deprecated - * @param {(function(!jQuery.event=)|string|number|function()|boolean)=} arg1 - * @param {(function(!jQuery.event=)|function()|string)=} arg2 - * @param {(function(!jQuery.event=)|function())=} arg3 - * @return {!jQuery} - */ -jQuery.prototype.toggle = function(arg1, arg2, arg3) {}; - -/** - * @param {(string|boolean|function(number,string,boolean))=} arg1 - * @param {boolean=} flag - * @return {!jQuery} - */ -jQuery.prototype.toggleClass = function(arg1, flag) {}; - -/** - * @param {(string|jQuery.event)} arg1 - * @param {...*} var_args - * @return {!jQuery} - */ -jQuery.prototype.trigger = function(arg1, var_args) {}; - -/** - * @param {string|jQuery.event} eventType - * @param {Array.<*>=} extraParameters - * @return {*} - */ -jQuery.prototype.triggerHandler = function(eventType, extraParameters) {}; - -/** - * @param {string} str - * @return {string} - * @nosideeffects - */ -jQuery.trim = function(str) {}; - -/** - * @param {string} str - * @return {string} - * @nosideeffects - */ -$.trim = function(str) {}; - -/** - * @param {*} obj - * @return {string} - * @nosideeffects - */ -jQuery.type = function(obj) {}; - -/** - * @param {*} obj - * @return {string} - * @nosideeffects - */ -$.type = function(obj) {}; - -/** - * @param {(string|function(!jQuery.event=)|jQuery.event)=} arg1 - * @param {(function(!jQuery.event=)|boolean)=} arg2 - * @return {!jQuery} - */ -jQuery.prototype.unbind = function(arg1, arg2) {}; - -/** - * @param {string=} arg1 - * @param {(string|Object.)=} arg2 - * @param {function(!jQuery.event=)=} handler - * @return {!jQuery} - */ -jQuery.prototype.undelegate = function(arg1, arg2, handler) {}; - -/** - * @param {Array.} arr - * @return {Array.} - */ -jQuery.unique = function(arr) {}; - -/** - * @param {Array.} arr - * @return {Array.} - */ -$.unique = function(arr) {}; - -/** - * @deprecated - * @param {(function(!jQuery.event=)|Object.)} arg1 - * @param {function(!jQuery.event=)=} handler - * @return {!jQuery} - */ -jQuery.prototype.unload = function(arg1, handler) {}; - -/** @return {!jQuery} */ -jQuery.prototype.unwrap = function() {}; - -/** - * @param {(string|Array.|function(number,*))=} arg1 - * @return {(string|number|Array.|!jQuery)} - */ -jQuery.prototype.val = function(arg1) {}; - -/** - * @param {jQuery.deferred} deferred - * @param {...jQuery.deferred} deferreds - * @return {jQuery.Promise} - */ -jQuery.when = function(deferred, deferreds) {}; - -/** - * @param {jQuery.deferred} deferred - * @param {...jQuery.deferred} deferreds - * @return {jQuery.Promise} - */ -$.when = function(deferred, deferreds) {}; - -/** - * @param {(string|number|function(number,number))=} arg1 - * @return {(number|!jQuery)} - */ -jQuery.prototype.width = function(arg1) {}; - -/** - * @param {(string|jQuerySelector|Element|jQuery|function(number))} arg1 - * @return {!jQuery} - */ -jQuery.prototype.wrap = function(arg1) {}; - -/** - * @param {(string|jQuerySelector|Element|jQuery)} wrappingElement - * @return {!jQuery} - */ -jQuery.prototype.wrapAll = function(wrappingElement) {}; - -/** - * @param {(string|function(number))} arg1 - * @return {!jQuery} - */ -jQuery.prototype.wrapInner = function(arg1) {}; \ No newline at end of file diff --git a/enot.js b/enot.js deleted file mode 100644 index 20562f5..0000000 --- a/enot.js +++ /dev/null @@ -1,23 +0,0 @@ -(function(){function fa(a,b){if(a)for(var c=z.parse(a+""),d=c[0].split(/\s*,\s*/),e=0;e"!==b[0])return b;var c=(1E9*Math.random()>>>0)+Oa++;U(a,function(a,b){a.setAttribute("data-__qr",b);return a},c);b='[data-__qr="'+c+'"]'+b}else if(">"===b[0])return":scope "+b;return b}function m(a){if(!a)return a;for(var b in w)a[b]=w[b];return a}function F(a,b){var c=b[0],d=b[1];Pa(d)||W(c)?(c=null,d=b[0],b=C(b,0)):b=C(b,1);if(d)if(b=C(b,1),d&&"object"===typeof d&&d.constructor=== -Object)for(var e in d)fa(e,function(b){F(a,[c,b].concat(d[b]))});else W(d)?fa(d,function(d){var e=G(d),g;g=c;e=e[0];g||(g=[document]);g=e?"window"===e?[window]:"document"===e?[document]:Qa(g,e,!0):Ra(g)?g:[g];for(var e=0,h=g.length;eb?Math.max(0,b+e):b||0;for(void 0!==c&&(e=0>c?c+e:c);e-- >b;)d[e-b]=a[e];return d};var ja=n,Ca=t;p.wrap=function(a,b,c,d){function e(){if(d.apply(a,arguments))return c.apply(a,arguments)}e.fn=c;return e};z={parse:function(a,b){function c(a){return"\\"+d.push(a.slice(1,-1))}if("string"!==typeof a)return[a];var d=[],e;b=b||"()";for(var f=new RegExp(["\\",b[0],"[^\\",b[0],"\\",b[1],"]*\\", -b[1]].join(""));a!=e;)e=a,a=a.replace(f,c);d.unshift(a);return d},stringify:function(a,b,c){function d(a){return c[0]+b[a.slice(1)]+c[1]}var e;if(!a)return"";"string"!==typeof a&&(c=b,b=a,a=b[0]);for(c=c||"()";a!=e;)e=a,a=a.replace(/\\[0-9]+/,d);return a}};Z=function(a){return Y(a)||a&&!y(a)&&!a.nodeType&&("undefined"!=typeof window?a!=window:!0)&&!u(a)&&"number"===typeof a.length};var ba=document,Ta=ba.documentElement;J=function(a,b){if(!k(a))throw Error("Bad argument "+a);if(a===ba)return Ta;if(!b|| -(k(b)?a==b:x(a,b)))return a;for(;(a=a.parentNode)&&a!==ba;)if(!b||(k(b)?a==b:x(a,b)))return a};var ca=document,Ua=ca.documentElement,Da=p;L.wrap=function(a,b,c,d){function e(){var a=arguments,b=this;setTimeout(function(){c.apply(b,a)},d)}u(d)&&(a=d,d=c,c=a);e.fn=c;return e};var ka=n,Ea=h,M=t,ma=n,O=h,Fa=k,Ia=t;aa=function(a,b){if(a){var c=arguments;if(y(b))c=O(arguments,2),b.split(/\s+/).forEach(function(b){b=b.split(".")[0];la.apply(this,[a,b].concat(c))});else return la.apply(this,c)}};var N="undefined"=== -typeof jQuery?void 0:jQuery,Ha="undefined"===typeof document?void 0:document,Ga="undefined"===typeof window?void 0:window,Va={"\u2325":18,alt:18,option:18,backspace:8,capslock:20,caps:20,clear:12,context:93,"\u2318":91,cmd:91,command:91,"\u2303":17,ctrl:17,control:17,del:46,"delete":46,down:40,end:35,"\u2386":13,enter:13,"return":13,esc:27,escape:27,home:36,insert:45,left:37,pagedown:34,"pg-down":34,pageup:33,"pg-up":33,pause:19,right:39,"\u21e7":16,shift:16,space:32,tab:9,up:38,F1:112,F2:113,F3:114, -F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,leftmouse:1,rightmouse:3,middlemouse:2,"*":106,"+":107,plus:107,"-":109,minus:109,";":186,semicolon:186,"=":187,equals:187,",":188,dash:189,".":190,"/":191,"`":192,"~":192,"[":219,"\\":220,"]":221,"'":222},Wa=H,na=p;P.wrap=function(a,b,c,d){if(d)return d=Y(d)?d:y(d)?d.split(/\s*,\s*/):[d],d=d.map(Wa),na.wrap(a,b,c,function(a){for(var b=void 0!==a.which?a.which:a.keyCode,c=d.length;c--;)if(a=d[c],b==a||Va[a]==b)return!0})};var oa=n, -Ka=p,Ja=r;B.wrap=function(a,b,c,d){function e(){d(a,b,e);c.apply(a,arguments)}e.fn=c;return e};var pa=p,Aa="undefined"!==typeof document?J:null;Q.wrap=function(a,b,c,d){if(Aa){if(u(d)){var e=d;d=c;c=e}return pa.wrap(a,b,c,function(b){b=b.target;return I(a,b)?(b=Aa(b,d))&&I(a,b)?!1:!0:!1})}};var qa=p;R.wrap=function(a,b,c,d){function e(){c.apply(a,arguments);r(a,b,e);setTimeout(function(){qa(a,b,e)},d)}if(u(d)){var f=d;d=c;c=f}e.fn=c;return e};var ra=p,Ba="undefined"!==typeof document?J:null;S.wrap= -function(a,b,c,d){if(Ba){if(u(d)){var e=d;d=c;c=e}return ra.wrap(a,b,c,function(b){var c=b.target;if(c!==a&&(c=Ba(c,d))&&a!==c&&I(a,c))return b.delegateTarget=c,!0})}};var Xa=document.documentElement;n={closest:J,parent:function(a,b){if(!k(a))throw Error("Bad argument "+a);if(a===ca)return Ua;for(;(a=a.parentNode)&&a!==ca;)if(!b||(k(b)?a==b:x(a,b)))return a},prev:function(a,b){if(!k(a))throw Error("Bad argument "+a);for(;a=a.previousSibling;)if(1===a.nodeType&&(!b||(k(b)?a===b:x(a,b))))return a}, -next:function(a,b){if(!k(a))throw Error("Bad argument "+a);for(;a=a.nextSibling;)if(1===a.nodeType&&(!b||(k(b)?a===b:x(a,b))))return a},root:function(){return Xa}};var La=h,s=sa.prototype;s.on=D(p);s.once=D(B);s.off=D(r);s.emit=D(aa);s.listeners=function(a){return t(this,a)};s.hasListeners=function(a){return!!t(this,a).length};var T=document,V=n,v=Z,Na=y,Ma=k,E=z,Ya=ya,wa=!0;try{T.querySelector(":scope")}catch(bb){wa=!1}n=function(a,b,c){"string"===typeof a&&(c=b,b=a,a=T);if(!a)return c?[]:null;a= -ta(a,b);return!c&&v(a)?a[0]:Ya(a)};var Oa=Date.now()%1E9,da;for(da in V)n[da]=V[da];var C=h,Pa=u,W=y,Ra=Z,Qa=n,xa=z,w=m.prototype=Object.create(sa.prototype);w.on=function(a,b,c){Za(this,a,b,c);return this};w.once=function(a,b,c){$a(this,a,b,c);return this};w.off=function(a,b){r(this,a,b);X(this,a,b);return this};w.emit=function(){ab.apply(this,[this].concat(C(arguments)));return this};var ea=new WeakMap,Za=m.on=function(){F(function(a,b,c){if(c){var d=G(b);b=d[1].split(":")[0];var d=Sa(a,d[1],c), -e;(e=ea.get(c))||ea.set(c,e={});(e[b]||(e[b]=[])).push(d);p(a,b,d)}},arguments);return m},X=m.off=function(){F(function(a,b,c){b=G(b)[1].split(":")[0];if(c){if(c=ea.get(c))if(c=c[b])for(var d=c.length;d--;)r(a,b,c[d])}else r(a,b,c)},arguments);return m},ab=m.emit=function(){F(function(a,b){W(b)&&(b=G(b)[1].split(":")[0]);aa.apply(a,[a,b].concat(C(arguments,2)))},arguments);return m},$a=m.once=function(){B.apply(this,arguments);return m},l={};l.on=l.delegate=S.wrap;l.not=Q.wrap;l.pass=l.keypass=P.wrap; -l.one=l.once=B.wrap;l.throttle=R.wrap;l.later=L.wrap})(); diff --git a/index.js b/index.js deleted file mode 100644 index e960612..0000000 --- a/index.js +++ /dev/null @@ -1,365 +0,0 @@ -/** - * @module enot - */ - - -var slice = require('sliced'); -var emitter = require('emmy').prototype; -var eachCSV = require('each-csv'); -var isFn = require('mutype/is-fn'); -var isObject = require('mutype/is-object'); -var isString = require('mutype/is-string'); -var isArrayLike = require('mutype/is-array-like'); -var unprefix = require('mustring/unprefix'); -var q = require('queried'); -var paren = require('parenthesis'); - - -var _on = require('emmy/on'), _off= require('emmy/off'), _emit = require('emmy/emit'), _once = require('emmy/once'); - - -//TODO: query multiple targets in on/off/emit - now callback is got improperly - - -/** - * @constructor - * - * Mixins any object passed. - * Implements EventEmitter interface. - * Static methods below are useful as wrappers. - */ -function Enot (target) { - if (!target) return target; - - //mixin any object passed - for (var meth in proto) { - target[meth] = proto[meth]; - } - - return target; -} - - - -/** - * Prototype should be instanceof Emitter - * also fill basic event methods like `listeners` - */ -var proto = Enot.prototype = Object.create(emitter); - - -//prototype methods -proto['on'] = function (a,b,c) { - on(this, a,b,c); - return this; -}; -proto['once'] = function (a,b,c) { - once(this, a,b,c); - return this; -}; - -proto['off'] = function (a,b) { - //call super off (some fns could’ve been bound outside) - _off(this, a,b); - - off(this, a,b); - return this; -}; - -proto['emit'] = function () { - emit.apply(this, [this].concat(slice(arguments))); - return this; -}; - - -/** - * Storage of modified fns for orig fns, per-event - * - * e.g. - * fn: {evt: [cb1, cb2, ...]} - */ -var cbCache = new WeakMap; - - -/** - * Static wrapper API - */ -var on = Enot['on'] = function on () { - invoke(function (target, ref, fn) { - if (!fn) return; - - var parts = getParts(ref); - var evt = parts[1].split(':')[0]; - - //get fn wrapper with pseudos applied - var modFn = getCallback(target, parts[1], fn); - - //save modified fn to the callback cache to unbind - var cbSet, cbList; - if (!(cbSet = cbCache.get(fn))) cbCache.set(fn, cbSet = {}); - cbList = cbSet[evt] || (cbSet[evt] = []); - cbList.push(modFn); - - _on(target, evt, modFn); - }, arguments); - - return Enot; -}; -var off = Enot['off'] = function off () { - invoke(function (target, ref, fn) { - var parts = getParts(ref); - var evt = parts[1].split(':')[0]; - //clean cb reference - if (fn) { - var cbSet = cbCache.get(fn); - if (!cbSet) return; - - var cbList = cbSet[evt]; - - if (!cbList) return; - - for (var i = cbList.length; i--;) { - _off(target, evt, cbList[i]); - - //FIXME: remove reference to avoid leaks - // cbList.splice(i,1); - } - } else { - _off(target, evt, fn); - } - - }, arguments); - - return Enot; -}; -var emit = Enot['emit'] = function emit () { - invoke(function (target, ref) { - if (isString(ref)) { - ref = getParts(ref)[1].split(':')[0]; - } - _emit.apply(target, [target, ref].concat(slice(arguments, 2))); - - }, arguments); - - return Enot; -}; -var once = Enot['once'] = function once () { - _once.apply(this, arguments); - return Enot; -} - - -/** Redirect, parse event notations and call target method */ -function invoke (fn, args) { - var target = args[0], refs = args[1]; - - //if no target specified - use mediator - //refs can be both object/string, so first check an fn - // emit('document click'), emit(document, 'click') - // on(document, {sett}), on('document sett') - if (isFn(refs) || isString(target)) { - target = null; - refs = args[0]; - args = slice(args, 0); - } - else { - args = slice(args, 1); - } - - //ignore absent evtRefs/fn - if (!refs) return; - - - //shorten args, exclude refs - args = slice(args, 1); - - //batch refs - if (isObject(refs)) { - for (var evtRefs in refs) { - eachCSV(evtRefs, function (evtRef) { - invoke(fn, [target, evtRef].concat(refs[evtRef])); - }); - } - - return; - } - - - //string refs - if (isString(refs)) { - eachCSV(refs, function (evtRef) { - //get targets to apply - var parts = getParts(evtRef); - var targets = getTargets(target, parts[0]); - - //iterate over each target - for (var i = 0, l = targets.length; i < l; i++) { - fn.apply(targets[i], [targets[i], evtRef].concat(args)); - } - }); - - return; - } - - //non-string refs - fn.apply(target, [target, refs].concat(args)); -} - - -/** - * Detect event/target parts in event reference. - * Event reference (basic event notation) looks: - * '[target] event' - * Event goes last. - * - * Exact order, in theory, could be detected - * because list of exact tags is known - * as well as dashed-notation for custom elements - * so the order could be guessed - * but it complicates parsing - * and it is illogical (Subject → Verb scheme is natural). - * - * @example - * 'a b' → ['a', 'b'] - * 'document click': ['document', 'click'] - * - * - * @param {string} str Event notation - * - * @return {Array} Result of parsing: ['', ''] - */ -function getParts(str) { - var result = ['','']; - - //get event name - the last token - var eventString = str.match(/[\w\.\:\$\-]+(?:\:[\w\.\:\-\$]+(?:\(.+\))?)*$/)[0]; - - //remainder is a target reference - parse target - result[0] = str.slice(0, -eventString.length).trim(); - - //parse event - result[1] = unprefix(eventString, 'on'); - - return result; -} - - -/** - * Get targets by a query string. - * Ensures result is array. - * - * @param {Element|Object} target A target(s) to relate - * @param {string} str Target reference - * - * @return {Array} Resulting targets found - */ -function getTargets (target, str) { - // console.log('parseTarget `' + str + '`', target) - - //no target means global target (mediator) - if (!target) target = [document]; - - //no string means self evt - if (!str) { - return isArrayLike(target) ? target : [target]; - } - - //some reserved words - if(str === 'window') return [window]; - else if(str === 'document') return [document]; - - //query relative selector - else { - return q.all(str, target); - } -} - - -/** - * Get callback for the event string - * basically wrap passed event - * - * @example - * 'click:once:on(.element)' - apply `once` wrapper, `on` wrapper - * - * @param {function} fn An initial function to wrap - * @param {string} str A string containing event part - * - * @return {function} Constructed callback for the event string - */ -function getCallback (target, evtStr, fn) { - if (!fn) return; - - var targetFn = fn; - - //escape all parentheses - var parens = paren.parse(evtStr); - - //get pseudos list & evt - var pseudoList = parens[0].split(':'); - var evt = pseudoList.shift(); - - //wrap each modifier - pseudoList - //:once should go last - .sort(function (a, b) { - if (a === 'once' || a === 'one') return -1; - if (b === 'once' || b === 'one') return 1; - return 0; - }) - .forEach(function (pseudo) { - //get pseudo name/ref parts from parenthesis token - var parts = pseudo.split('\\'); - - var pseudoName = parts[0]; - var pseudoParams = paren.stringify(parens[parts[1]], parens); - - //for :once method pass special `off` as param - if (!pseudoParams) pseudoParams = function (target, evt, cb) { - off(target, evt, cb); - off(target, evt, fn); - }; - - if (pseudos[pseudoName]) { - targetFn = pseudos[pseudoName](target, evt, targetFn, pseudoParams); - } - }); - - return targetFn; -} - - - -/** - * Dics of pseudos. - * Includes all xtags ones: delegate, pass. - * - * @module enot/pseudos - */ - -var pseudos = {}; - -pseudos['on'] = -pseudos['delegate'] = -require('emmy/delegate').wrap; - -pseudos['not'] = -require('emmy/not').wrap; - -pseudos['pass'] = -pseudos['keypass'] = -require('emmy/keypass').wrap; - -pseudos['one'] = -pseudos['once'] = -require('emmy/once').wrap; - -pseudos['throttle'] = -require('emmy/throttle').wrap; - -pseudos['later'] = -require('emmy/later').wrap; - - - -module.exports = Enot; \ No newline at end of file diff --git a/logo.png b/logo.png new file mode 100644 index 0000000..39f7a9e Binary files /dev/null and b/logo.png differ diff --git a/logo.psd b/logo.psd new file mode 100644 index 0000000..4de3c12 Binary files /dev/null and b/logo.psd differ diff --git a/package.json b/package.json deleted file mode 100644 index fc62d07..0000000 --- a/package.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "name": "enot", - "version": "2.0.8", - "description": "Event NOTation system", - "main": "index.js", - "files": [ - "index.js", - "enot.js" - ], - "scripts": { - "build-min": "npm run build && npm run min && npm run clean && cat enot.js | gzip-size | pretty-bytes", - "build": "uncommon ./index -w \";(function(){window['Emitter']=Enot;%output%;})();\" > enot.dev.js", - "min": "ccjs enot.dev.js --language_in=ECMASCRIPT5 --compilation_level=ADVANCED --process_jquery_primitives --externs=build/externs.js > enot.js", - "clean": "rm enot.dev.js", - "test": "mochify", - "watch": "watchify -r ./index.js:.. -r chai -d -o ./test/bundle.js" - }, - "dependencies": { - "each-csv": "*", - "emmy": "^5.3.3", - "key-name": ">=1.0.1", - "matches-selector": ">=1.x", - "mustring": "^1.0.0", - "mutype": "*", - "parenthesis": ">=1.1.0", - "queried": "^1.4.4", - "sliced": "0.0.5" - }, - "repository": { - "type": "git", - "url": "git@github.com:dfcreative/enot.git" - }, - "keywords": [ - "events", - "event", - "emitter", - "component", - "notation" - ], - "author": { - "name": "Deema Yvanow", - "email": "dfcreative@gmail.com", - "url": "http://github.com/dfcreative" - }, - "license": "unlicensed", - "bugs": { - "url": "https://github.com/dfcreative/enot/issues" - }, - "homepage": "https://github.com/dfcreative/enot", - "devDependencies": { - "browserify": "5.x", - "chai": "~1.9.1", - "closurecompiler": "~1.x", - "icicle": "~0.x", - "jquery": "~2.x", - "mocha": "~1.x", - "mocha-phantomjs": "~3.5.0", - "mochify": "^2.13.0", - "phantomjs": "~1.9.7-15", - "polymer-weakmap": "^2.0.0", - "require-stub": "*", - "testling": "~1.x" - }, - "testling": { - "files": "test/index.js", - "scripts": "node_modules/polymer-weakmap/weakmap.js", - "harness": "mocha", - "browsers": [ - "ie/6..latest", - "chrome/22..latest", - "firefox/16..latest", - "safari/latest", - "opera/11.0..latest", - "iphone/6", - "ipad/6", - "android-browser/latest" - ] - } -} diff --git a/test/compliance.js b/test/compliance.js deleted file mode 100644 index e5d062c..0000000 --- a/test/compliance.js +++ /dev/null @@ -1,212 +0,0 @@ -/** - * component/emitter compliance tests - * - * https://github.com/component/emitter/blob/master/test/emitter.js - */ - - -var WeakMap = typeof WeakMap !== 'undefined' ? WeakMap : require('polymer-weakmap'); - -var doc = typeof document === 'undefined' ? undefined : document; -var win = typeof window === 'undefined' ? undefined : window; - -var Emitter = doc && typeof Emitter !== 'undefined' ? Emitter : require('..'); -var should = typeof chai !== 'undefined' ? chai.should() : require('chai').should(); - - -function Custom() { - Emitter.call(this); -} - -// Custom.prototype.__proto__ = Emitter.prototype; -Custom.prototype = Object.create(Emitter.prototype); - -describe('Custom', function(){ - describe('with Emitter.call(this)', function(){ - it('should work', function(done){ - var emitter = new Custom; - emitter.on('foo', function(){done()}); - emitter.emit('foo'); - }) - }) -}) - -describe('Emitter', function(){ - describe('.on(event, fn)', function(){ - it('should add listeners', function(){ - var emitter = new Emitter; - var calls = []; - - emitter.on('foo', function(val){ - calls.push('one', val); - }); - - emitter.on('foo', function(val){ - calls.push('two', val); - }); - - emitter.emit('foo', 1); - emitter.emit('bar', 1); - emitter.emit('foo', 2); - - calls.should.eql([ 'one', 1, 'two', 1, 'one', 2, 'two', 2 ]); - }) - }) - - describe('.once(event, fn)', function(){ - it('should add a single-shot listener', function(){ - var emitter = new Emitter; - var calls = []; - - emitter.once('foo', function(val){ - calls.push('one', val); - }); - - emitter.emit('foo', 1); - emitter.emit('foo', 2); - emitter.emit('foo', 3); - emitter.emit('bar', 1); - - calls.should.eql([ 'one', 1 ]); - }) - }) - - describe('.off(event, fn)', function(){ - it('should remove a listener', function(){ - var emitter = new Emitter; - var calls = []; - - function one() { calls.push('one'); } - function two() { calls.push('two'); } - - emitter.on('foo', one); - emitter.on('foo', two); - emitter.off('foo', two); - - emitter.emit('foo'); - - calls.should.eql([ 'one' ]); - }) - - it('should work with .once()', function(){ - var emitter = new Emitter; - var calls = []; - - function one() { calls.push('one'); } - - // console.log('---once1') - emitter.once('foo', one); - // console.log('---once2') - emitter.once('fee', one); - // console.log('---off') - emitter.off('foo', one); - - emitter.emit('foo'); - - calls.should.eql([]); - }) - - it('should work when called from an event', function(){ - var emitter = new Emitter - , called - function b () { - called = true; - } - emitter.on('tobi', function () { - emitter.off('tobi', b); - }); - emitter.on('tobi', b); - emitter.emit('tobi'); - called.should.be.true; - called = false; - emitter.emit('tobi'); - called.should.be.false; - }); - }) - - describe('.off(event)', function(){ - it('should remove all listeners for an event', function(){ - var emitter = new Emitter; - var calls = []; - - function one() { calls.push('one'); } - function two() { calls.push('two'); } - - emitter.on('foo', one); - emitter.on('foo', two); - emitter.off('foo'); - - emitter.emit('foo'); - emitter.emit('foo'); - - calls.should.eql([]); - }) - }) - - describe('.off()', function(){ - it('should remove all listeners', function(){ - var emitter = new Emitter; - var calls = []; - - function one() { calls.push('one'); } - function two() { calls.push('two'); } - - emitter.on('foo', one); - emitter.on('bar', two); - - emitter.emit('foo'); - emitter.emit('bar'); - - emitter.off(); - - emitter.emit('foo'); - emitter.emit('bar'); - - calls.should.eql(['one', 'two']); - }) - }) - - describe('.listeners(event)', function(){ - describe('when handlers are present', function(){ - it('should return an array of callbacks', function(){ - var emitter = new Emitter; - function foo(){} - emitter.on('foo', foo); - emitter.listeners('foo').should.eql([foo]); - }) - }) - - describe('when no handlers are present', function(){ - it('should return an empty array', function(){ - var emitter = new Emitter; - emitter.listeners('foo').should.eql([]); - }) - }) - }) - - describe('.hasListeners(event)', function(){ - describe('when handlers are present', function(){ - it('should return true', function(){ - var emitter = new Emitter; - emitter.on('foo', function(){}); - emitter.hasListeners('foo').should.be.true; - }) - }) - - describe('when no handlers are present', function(){ - it('should return false', function(){ - var emitter = new Emitter; - emitter.hasListeners('foo').should.be.false; - }) - }) - }) -}) - -describe('Emitter(obj)', function(){ - it('should mixin', function(done){ - var proto = {}; - Emitter(proto); - proto.on('something', done); - proto.emit('something'); - }) -}) \ No newline at end of file diff --git a/test/index.html b/test/index.html deleted file mode 100644 index 768b0ce..0000000 --- a/test/index.html +++ /dev/null @@ -1,40 +0,0 @@ - - -Enot tests - - - -
- - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/test/index.js b/test/index.js deleted file mode 100644 index 76b8f5f..0000000 --- a/test/index.js +++ /dev/null @@ -1,981 +0,0 @@ -var WeakMap = typeof WeakMap !== 'undefined' ? WeakMap : require('polymer-weakmap/weakmap'); -var Enot = typeof Emitter !== 'undefined' ? Emitter : require('..'); -var assert = typeof chai !== 'undefined' ? chai.assert : require('chai').assert; - - -//create testing tree -var c = document.createElement('div'); -c.className = 'container'; -var p = document.createElement('div'); -p.className = 'parent'; -var t = document.createElement('div'); -t.className = 'target'; -var f = document.createElement('div'); -f.className = 'first'; -var s = document.createElement('div'); -s.className = 'second'; -var l = document.createElement('div'); -l.className = 'last'; -var i = document.createElement('div'); -i.className = 'inner'; - - -document.body.appendChild(c); -c.appendChild(p); -p.appendChild(f); -p.appendChild(s); -p.appendChild(t); -p.appendChild(l); -t.appendChild(i); - - -describe('Static API', function(){ - it("Basic on/emit/off", function(){ - var i = 0; - var cb = function(e){ - assert.equal(e.detail, 123); - // console.log('off') - Enot.off(document, "hello", cb); - i++; - }; - Enot.on(document, "hello", cb); - - // console.log('---emits') - Enot.emit(document, "hello", 123) - .emit(document, "hello", 123); - - assert.equal(i,1); - }); - - - it('List of targets', function(){ - var targets = [f,s,l]; - var i = 0; - - function fn(){ - i++; - } - - // console.log('---on') - Enot.on(targets, 'x', fn) - // console.log('---emit') - Enot.emit(targets, 'x'); - - assert.equal(i, 3); - - // console.log('---off') - Enot.off(targets, 'x', fn) - .emit(targets, 'x'); - - assert.equal(i, 3); - }); - - - it('Batch references', function(){ - var i = 0; - - var a = { - a: function(){i++}, - b: function(){i--} - }; - - Enot.on(a, a); - - Enot.emit(a, 'a'); - - assert.equal(i, 1); - - Enot.emit(a, 'b'); - - assert.equal(i, 0); - - Enot.off(a, a); - - Enot.emit(a, 'a'); - - assert.equal(i, 0); - }); - - - it("Pass details", function(){ - var i = 0; - var fn = function(e){ - e.detail === 123 && i++; - }; - Enot.on(document, "hello", fn); - Enot.emit(document, "hello", 123); - assert.equal(i, 1) - - Enot.off(document, "hello", fn); - Enot.emit(document, "hello", 123); - assert.equal(i, 1); - }); -}); - - - -describe('Emitter class', function(){ - it('inherit Enot', function(){ - var A = function(){}; - A.prototype = Object.create(Enot.prototype); - var a = new A; - - var i = 0; - a.on('a:once', function(){i++}); - a.emit('a'); - a.emit('a'); - assert.equal(i, 1); - }); -}); - - - -describe("Pseudos", function(){ - it("`:once` pseudo", function(){ - var i = 0, j = 0; - Enot.on(document, "hello:once", function(e){ - e.detail === 123 && i++; - }); - Enot.on(document, "hello:once", function(e){ - e.detail === 123 && i++; - }); - // console.log('--emit') - Enot.emit(document, "hello", 123); - assert.equal(i, 2); - - // console.log('--emit2') - Enot.emit(document, "hello", 123); - assert.equal(i, 2); - - // console.log('--emit3') - Enot.emit(document, "hello", 123); - assert.equal(i, 2); - }); - - - it("unbind :once callbacks", function(){ - var a = document.createElement('div'); - var log = []; - var fn = function(){log.push(1)}; - - Enot.on(a, 'a:once', fn); - Enot.off(a, 'a', fn); - Enot.emit(a, 'a'); - Enot.emit(a, 'a'); - - assert.deepEqual(log, []); - - log = []; - Enot.on(a, 'b:once', fn); - Enot.off(a, 'b:once', fn); - Enot.emit(a, 'b'); - Enot.emit(a, 'b'); - - assert.deepEqual(log, []); - }); - - - it(":delegate", function(){ - if (window.mochaPhantomJS) return; - - var i = 0, j = 0; - var el = document.createElement("div"); - document.body.appendChild(el); - - var inc = function(){ - i++; - }; - - // console.log('---bind body') - Enot.on(document.body, "document hello:delegate(p, div, .some)", inc); - - var sideLink = document.createElement("span"); - document.body.appendChild(sideLink); - - // console.log('---bind sidelink') - Enot.on(sideLink, "hello", function(){ - j++; - }); - - // console.log('---emit body hello') - Enot.emit(document.body, "hello"); - assert.equal(i, 0); - - Enot.emit(el, "hello", null, true); - assert.equal(i, 1); - - // console.log('---emit sidelink hello') - // Enot.emit(sideLink, "hello", null, true); - // assert.equal(i, 1); - // assert.equal(j, 1); - - // Enot.off(document.body, "document hello:delegate(div)", inc); - }); - - - it("click:pass pseudo", function(){ - var i = 0; - var el = document.createElement("div"); - document.body.appendChild(el); - - Enot.on(el, "click:pass(rightMouse, leftMouse)", function(e){ - // console.log("filtered click") - i++ - }) - Enot.on(el, "click", function(){ - // console.log("simple click") - }) - - var evt = createMouseEvt("click", 1) - // console.log("----fire 1") - Enot.emit(el, evt); - - assert.equal(i, 0); - - var evt = createMouseEvt("click", 2); - // console.log("----fire 2") - Enot.emit(el, evt); - - assert.equal(i, 1); - }); - - it("keypress:pass pseudo", function(){ - if (/phantomjs/i.test(navigator.userAgent)) return; - - var k = 0, a = 0, ka=0; - var el = document.createElement("div"); - - Enot.on(el, "keydown", function(e){ - // console.log("all", e) - a++ - }) - Enot.on(el, "keydown:pass(83, Enter)", function(e){ - // console.log("→ filtered 1") - k++ - }) - Enot.on(el, "keydown:pass(65, enter, 68)", function(e){ - // console.log("→ filtered 2") - ka++ - }) - - var evt = createKeyEvt("keydown", 65) - - Enot.emit(el, evt); - assert.equal(a, 1) - assert.equal(k, 0) - assert.equal(ka, 1) - - // s - var evt = createKeyEvt("keydown", 83) - Enot.emit(el, evt); - assert.equal(a, 2) - assert.equal(k, 1) - assert.equal(ka, 1) - - // s2 - var evt = createKeyEvt("keydown", 83); - Enot.emit(el, evt); - assert.equal(a, 3) - assert.equal(k, 2) - assert.equal(ka, 1) - - //enter - var evt = createKeyEvt("keydown", 13); - Enot.emit(el, evt); - assert.equal(a, 4); - assert.equal(k, 3); - assert.equal(ka, 2); - }); - - it("combine modifiers", function(){ - if (/phantomjs/i.test(navigator.userAgent)) return; - - var i = 0; - - var el = document.createElement("div"); - el.className = "item"; - - var el2 = document.createElement("div"); - - document.body.appendChild(el); - document.body.appendChild(el2); - - Enot.on(document.body, "hello:delegate(.item):once", function(e){ - e.detail === 123 && i++ - }); - - // console.log('---emit body') - Enot.emit(document, "hello", 123, true); - assert.equal(i, 0); - // console.log('---emit el') - Enot.emit(el, "hello", 123, true); - assert.equal(i, 1); - // console.log('---emit el2') - Enot.emit(el2, "hello", 123, true); - assert.equal(i, 1); - // console.log('---emit el') - Enot.emit(el, "hello", 123, true); - assert.equal(i, 1); - // console.log('---emit el2') - Enot.emit(el, "hello", 123, true); - assert.equal(i, 1); - - // once again - var i = 0; - Enot.on(document.body, "keydown:delegate(.item, .post):pass(escape)", function(e){ - // console.log("keypress shit", e) - i++ - }) - - Enot.emit(document.body, createKeyEvt("keypress", 27), 123, true) - assert.equal(i, 0) - // console.log('-----emit', el) - Enot.emit(el, createKeyEvt("keydown", 27), 123, true) - assert.equal(i, 1) - Enot.emit(el2, "hello", createKeyEvt("keydown", 27), 123, true) - assert.equal(i, 1) - Enot.emit(el, "hello", createKeyEvt("keydown", 29), 123, true) - assert.equal(i, 1) - Enot.emit(el, createKeyEvt("keydown", 27), 123, true) - assert.equal(i, 2) - }); - - it(":not(selector)", function(){ - var i = 0, j = 0; - - var a = document.createElement('div'); - a.className = 'a'; - - document.body.appendChild(a); - - var b = document.createElement('div'); - b.className = 'b'; - a.appendChild(b); - var c = document.createElement('div'); - c.className = 'c'; - b.appendChild(c); - var d = document.createElement('span'); - d.className = 'd'; - c.appendChild(d); - - // console.log('--------on :root click'); - Enot.on(':root click:not(.a)', function(){ - i++ - }); - // console.log('--------on .b click'); - Enot.on('.b click:not(.c)', function(){ - // console.log('.b callback') - j++ - }) - - // console.log('--------emit body click'); - Enot.emit('body click', null, true); - assert.equal(i, 1); - - // console.log('--------emit a click'); - Enot.emit(a, 'click', null, true); - // console.log('--------emit b click'); - Enot.emit(b, 'click', null, true); - // console.log('--------emit c click'); - Enot.emit(c, 'click', null, true); - // console.log('--------emit d click'); - Enot.emit(d, 'click', null, true); - assert.equal(i, 1); - assert.equal(j, 1); - }); - - it(":not on elements which are no more in DOM", function(){ - var a = document.createElement('div'); - a.className = 'a'; - a.innerHTML = '' - document.body.appendChild(a); - - var i = 0; - - - Enot.on(a, 'click', function(){ - // console.log('---a click', this) - this.innerHTML = '' - }) - - //look how element caused the event has been removed from DOM in the first callback, but doc is still triggered by it - Enot.on('document click:not(.a)', function(e){ - // console.log('---document click', this, a.innerHTML) - i++ - }); - // console.log('----emit click', a.firstChild) - Enot.emit(a.firstChild, 'click', true, true); - - assert.equal(i, 0); - }) - - it(":later, :later(), :later(N)", function(done){ - var a = document.createElement('div'); - var i = 0; - - Enot.on(a, 'dsd:later(100)', function(){ - i++; - }); - Enot.emit(a, 'dsd'); - assert.equal(i, 0); - - setTimeout(function(){ - assert.equal(i, 1); - done(); - }, 110); - }); -}); - - -//TODO: structurize these tests -//TODO: separate functionality tests and corner-cases -describe("Regression", function(){ - it("treat unknown modifiers as a part of event", function(){ - var i = 0; - Enot.on(document,"hello:world", function(){ - i++ - }) - Enot.emit(document, "hello:world") - assert.equal(i, 1); - }); - - it("don't shit the bed with window binding", function(){ - Enot.on(document.body, 'window resize', function(){}) - }); - - it("fire on discrete delegate target", function(){ - if (window.mochaPhantomJS) return; - - var log = []; - - Enot.on(document, "document hello:delegate(.target)", function(){ - log.push("hello") - }) - - var el = document.createElement("div"); - var outerEl = document.createElement("div"); - outerEl.className = "target"; - outerEl.appendChild(el); - document.body.appendChild(outerEl) - - dispatchEvt(el, "hello", null, true); - - assert.deepEqual(log, ["hello"]) - }); - - it("should fire events on different targets", function(){ - var i = 0; - var a = document.createElement('div'); - var b = document.createElement('div'); - var fn = function(){i++} - // console.log('bind a') - Enot.on(a, 'a', fn); - // console.log('bind b') - Enot.on(b, 'a', fn); - // console.log('emit a') - Enot.emit(a, 'a') - // console.log('emit b') - Enot.emit(b, 'a') - - assert.equal(i,2) - }); - - it("empty target", function(){ - Enot.on({}, '.xy a', function(){}) - Enot.off({}, '.xy a', function(){}) - }); - - it("fire recognizes evtRef events", function(){ - var i = 0; - Enot.on(document, 'x', function(){i++}); - Enot.emit({}, 'document x'); - - assert.equal(i, 1); - }); - - it("listed declarations", function(){ - var i = 0, - target = { - a: {}, - b: document.body - } - - Enot.on(target, 'x, y, z', function(){ - i++; - }); - Enot.on(document, 'f,z', function(){ - i++ - }) - - Enot.emit(target, 'x,y'); - assert.equal(i, 2); - - Enot.emit(document.body, 'z,document f', null, true); - assert.equal(i,4); - }); - - it('mod delegate case', function(){ - if (window.mochaPhantomJS) return; - - var i = 0; - Enot.on(null, 'body evt:delegate(.a)', function(){ - i++ - }); - - var el = document.createElement("div"); - el.className = "a"; - document.body.appendChild(el); - - dispatchEvt(el, "evt", true, true); - assert.equal(i, 1); - }); - - it(':throttle mod case', function(done){ - var i = 0; - var a = document.createElement('div'); - // console.time('x') - // var initT = +new Date; - - //should be called 10 times less often than dispatched event - Enot.on(a, "x:throttle(50)", function(){ - i++ - // console.log(new Date - initT); - assert.equal(this, a); - }) - - document.body.appendChild(a); - - var interval = setInterval(function(){ - dispatchEvt(a, "x") - },5) - - setTimeout(function(){ - //should be instantly called - assert.equal(i, 1); - }, 11); - - setTimeout(function(){ - clearInterval(interval); - // console.timeEnd('x'); - - assert.closeTo(i, 5, 1); - done(); - }, 240) - }); - - // - it("key modifiers"); - - // - it("sequence of keypresses"); - - // - it("normalized touch"); - - //normalized crossbrowser animend - it("animend"); - - // - it("any event"); - - it("absent target", function(){ - var i = 0; - // console.log('---on doc') - var inc = function(){ - i++ - }; - Enot.on("document click", inc); - // console.log('---emit') - Enot.emit("document click"); - Enot.emit(document, "click"); - - assert.equal(i, 2); - - Enot.emit("document click"); - assert.equal(i, 3); - - // console.log('---off doc') - Enot.off(document, "click", inc); - Enot.emit("document click"); - Enot.emit(document, "click"); - assert.equal(i, 3); - }); - - it(":delegate() currentTarget & target", function(){ - if (window.mochaPhantomJS) return; - - var a = document.createElement('div'); - a.className = 'd'; - var b = document.createElement('div'); - a.appendChild(b); - document.body.appendChild(a); - - var cTarget; - Enot.on('document click:delegate(.d)', function(e){ - cTarget = e.delegateTarget; - }); - Enot.emit(b, 'click', null, true); - assert.equal(cTarget, a); - }); - - it(".items event - bind all selected items, not the only one", function(){ - var a1 = document.createElement('div') - a1.className = 'aer'; - var a2 = a1.cloneNode(true); - - document.body.appendChild(a1); - document.body.appendChild(a2); - - var i = 0; - var inc = function(){ - i++ - } - Enot.on('.aer click', inc); - Enot.emit(document.querySelectorAll('.aer'), 'click'); - assert.equal(i, 2); - - Enot.emit('.aer click'); - assert.equal(i, 4); - - // console.log('--------- off .aer click') - Enot.off('.aer click', inc); - Enot.emit('.aer click'); - assert.equal(i, 4); - - //NodeList tests - // var nativeNodeList = NodeList; - // window.NodeList = null; - // Enot.emit(document.querySelectorAll('.aer'), 'click'); - // assert.equal(i, 4); - // window.NodeList = nativeNodeList; - }); - - it("ignore empty callback", function(){ - var i = 0; - - var target = { - a: function(){ - i++ - } - } - - Enot.on(target, 'a'); - Enot.emit(target, 'a'); - assert.equal(i, 0); - - Enot.off(target, 'a'); - Enot.emit(target, 'a'); - - - Enot.emit({}, 'b'); - - assert.equal(i, 0); - }); - - it("target order notation agnostic"); - - it("no target means viewport === any event of this type", function(){ - var i = 0; - Enot.on('a', function(){ - i++ - }); - - Enot.emit('a'); - assert.equal(i, 1); - - Enot.off('a'); - Enot.emit('a'); - assert.equal(i, 1); - }); - - it("multiple off", function(){ - var i = 0; - var a = { - x: function(){i++} - } - - Enot.on(a, 'x', a.x); - Enot.on(a, 'y', function(){a.x()}); - Enot.emit(a, 'x'); - Enot.emit(a, 'y'); - - assert.equal(i, 2); - - Enot.off(a, 'x'); - Enot.off(a, 'y'); - Enot.emit(a, 'x'); - Enot.emit(a, 'y'); - assert.equal(i, 2); - }); - - //FIXME: unfortunately, component-emitter is intrusive - it.skip('keep target objects untouched (jQuery intrusion)', function(){ - var a = {}; - Enot.on(a, 'x', function(){}); - - assert.deepEqual(a, {}) - }); - - it('delegate within target', function(){ - var log = []; - - var a = document.createElement('div'); - a.innerHTML = '
'; - document.body.appendChild(a); - var b = a.firstChild.cloneNode(); - document.body.appendChild(b); - - Enot.on(a, 'click:delegate(.xxx)', function(){ - log.push(1) - }); - Enot.on('click:delegate(.xxx)', function(){ - log.push(2) - }) - Enot.on(a, '.xxx click', function(){ - log.push(3) - }) - Enot.emit('.xxx click', true, true); - assert.sameMembers(log, [1,2,3]); - - Enot.off(a, 'click'); - Enot.off(a, '.xxx click'); - Enot.off('.xxx click'); - - Enot.emit('.xxx click', true, true); - assert.sameMembers(log, [1,2,3]); - }) - - - it("multiple :once callbacks", function(){ - var a = {}, log = []; - - Enot.on(a, 'init:once', function(){ - log.push(1) - }) - Enot.on(a, 'init:once', function(){ - log.push(2) - }) - Enot.on(a, 'init:once', function(){ - log.push(3) - }) - - Enot.emit(a, 'init'); - assert.deepEqual(log, [1,2,3]) - - Enot.emit(a, 'init'); - assert.deepEqual(log, [1,2,3]) - }) - - it("query elements out of target", function(){ - var log = []; - - var a = document.createElement('div'); - - var b = a.cloneNode(); - b.className = 'item'; - - document.body.appendChild(a); - document.body.appendChild(b); - - Enot.on(':root .item click', function(){ - log.push(1) - }) - Enot.on(a, '.item click', function(){ - log.push(2); - }) - - - Enot.emit(b, 'click'); - Enot.emit(a, 'click'); - - assert.deepEqual(log, [1]); - }) - - it("bind dotted notations", function(){ - var a = { - inc: function(){ - i++ - } - }; - var i = 0; - Enot.on(a, "a.b", a.inc) - Enot.emit(a, "a.b"); - - assert.equal(i, 1); - - // console.log('---off') - Enot.off(a, "a.b"); - Enot.emit(a, "a.b"); - assert.equal(i, 1); - }); - - it("list only queryResults, not the any object with length", function(){ - var i = 0; - - var a = document.createElement('iframe'); - // a.src = 'http://kudago.com'; - a.style.display = 'none'; - document.body.appendChild(a); - - Enot.on({}, 'window x', function(){ - i++ - }) - - Enot.emit('window x'); - Enot.emit('window x'); - - assert.equal(i, 2); - }); - - it.skip("emit event instances passed", function(){ - //faced this case in MOD with Enot.emit(a,b, event) in redirector - //faced this case in draggy when I needed emit(Draggy.element, 'mouseenter', outerMouseEvent); - var target = {}; - var i = 0; - - Enot.on(target, 'x', function(e){ - i++ - assert.equal(e.detail, 123) - }) - - var e = new CustomEvent('x', {'detail': 123}); - Enot.emit(target, e); - - assert.equal(i, 1); - }) - - it('jQuery event separator (.)') - - it('one method', function(){ - var i = 0; - Enot.once(document, "hello", function(e){ - e.detail === 123 && i++ - }) - Enot.once(document, "hello", function(e){ - e.detail === 123 && i++ - }) - Enot.emit(document, "hello", 123) - assert.equal(i, 2) - - Enot.emit(document, "hello", 123) - assert.equal(i, 2) - - Enot.emit(document, "hello", 123) - assert.equal(i, 2) - }) - - - it.skip('test lists in .once', function(){ - Enot.once('a, b', function(){ - - }) - }) - - it('a function shared between targets', function(){ - var a = {}; - var b = {}; - var i = 0, j = 0; - - var fn = function(){ - this === a && i++; - this === b && j++; - } - - Enot.on(a, 'x', fn); - Enot.on(b, 'x', fn); - - Enot.emit(a, 'x'); - Enot.emit(b, 'x'); - - assert.equal(i, 1); - assert.equal(j, 1); - }) - - it.skip('delegate method', function(){ - Enot.delegate('.some x', fn); - Enot.off('.some x', fn); - }); -}); - - - - - - - - - - - - - - - - - - - - - - - -//helpers -function dispatchEvt(el, eventName, data, bubbles){ - var event; - if (el instanceof HTMLElement || el === window || el === document) { - if (!(eventName instanceof Event)) { - event = document.createEvent("CustomEvent"); - event.initCustomEvent(eventName, bubbles, null, data) - } else { - event = eventName; - } - // var event = new CustomEvent(eventName, { detail: data, bubbles: bubbles }) - el.dispatchEvent(event); - } else { - if (el.fire) el.fire(eventName); - else if (el.trigger) el.trigger(eventName); - else if (el.emit) el.emit(eventName); - } -} - -function createKeyEvt(name, code){ - var evt = document.createEvent("KeyboardEvent"); - try{ - Object.defineProperty(evt, 'keyCode', { - get : function() { - return this.keyCodeVal; - } - }); - Object.defineProperty(evt, 'which', { - get : function() { - return this.keyCodeVal; - } - }); - } catch (e) { - } - - evt.keyCode = this.keyCodeVal; - evt.which = this.keyCodeVal; - - if (evt.initKeyboardEvent) { - evt.initKeyboardEvent("keydown", true, true, document.defaultView, false, false, false, false, code, code); - } else { - evt.initKeyEvent("keydown", true, true, document.defaultView, false, false, false, false, code, code); - } - - evt.keyCodeVal = code; - - return evt; -} - -function createMouseEvt(name, btn){ - var evt = document.createEvent("MouseEvent") - evt.initMouseEvent( - name, true,true,window, - 1, 0,0,0,0, - false,false,false,false, - btn, null - ) - evt.which = btn; - return evt -} diff --git a/test/util.js b/test/util.js deleted file mode 100644 index bb93e99..0000000 --- a/test/util.js +++ /dev/null @@ -1,23 +0,0 @@ -//testing helpers stuff - - -function listen(el, evt, fn){ - //bind target fn - if (typeof $ !== "undefined"){ - //delegate to jquery - $(el).on(evt, fn); - } else { - //listen element - el.addEventListener(evt, fn) - } -} -function stopListen(el, evt, fn){ - //bind target fn - if (typeof $ !== "undefined"){ - //delegate to jquery - $(el).off(evt, fn); - } else { - //listen element - el.removeEventListener(evt, fn) - } -} \ No newline at end of file diff --git a/test/weakmap.js b/test/weakmap.js deleted file mode 100644 index 8d2155a..0000000 --- a/test/weakmap.js +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2012 The Polymer Authors. All rights reserved. - * Use of this source code is governed by a BSD-style - * license that can be found in the LICENSE file. - */ - -if (typeof WeakMap === 'undefined') { - (function() { - var defineProperty = Object.defineProperty; - var counter = Date.now() % 1e9; - - var WeakMap = function() { - this.name = '__st' + (Math.random() * 1e9 >>> 0) + (counter++ + '__'); - }; - - WeakMap.prototype = { - set: function(key, value) { - var entry = key[this.name]; - if (entry && entry[0] === key) - entry[1] = value; - else - defineProperty(key, this.name, {value: [key, value], writable: true}); - }, - get: function(key) { - var entry; - return (entry = key[this.name]) && entry[0] === key ? - entry[1] : undefined; - }, - delete: function(key) { - var entry = key[this.name]; - if (!entry) return false; - var hasValue = entry[0] === key; - entry[0] = entry[1] = undefined; - return hasValue; - }, - has: function(key) { - var entry = key[this.name]; - if (!entry) return false; - return entry[0] === key; - } - }; - - window.WeakMap = WeakMap; - })(); -}