// Type definitions for Zepto 1.0-rc.1
// Project: http://zeptojs.com/
// Definitions by: Josh Baldwin
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/*
zepto-1.0rc1.d.ts may be freely distributed under the MIT license.
Copyright (c) 2013 Josh Baldwin https://github.com/jbaldwin/zepto.d.ts
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
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 OR COPYRIGHT
HOLDERS 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.
*/
interface ZeptoStatic {
/**
* Core
**/
/**
* Create a Zepto collection object by performing a CSS selector, wrapping DOM nodes, or creating elements from an HTML string.
* @param selector
* @param context
* @return
**/
(selector: string, context?: any): ZeptoCollection;
/**
* @see ZeptoStatic();
* @param collection
**/
(collection: ZeptoCollection): ZeptoCollection;
/**
* @see ZeptoStatic();
* @param element
**/
(element: HTMLElement): ZeptoCollection;
/**
* @see ZeptoStatic();
* @param htmlString
**/
(htmlString: string): ZeptoCollection;
/**
* @see ZeptoStatic();
* @param attributes
**/
(htmlString: string, attributes: any): ZeptoCollection;
/**
* @see ZeptoStatic();
* @param object
**/
(object: any): ZeptoCollection; // window and document tests break without this
/**
* Turn a dasherized string into “camel case”. Doesn’t affect already camel-cased strings.
* @param str
* @return
**/
camelCase(str: string): string;
/**
* Check if the parent node contains the given DOM node. Returns false if both are the same node.
* @param parent
* @param node
* @return
**/
contains(parent: HTMLElement, node: HTMLElement): boolean;
/**
* Iterate over array elements or object key-value pairs. Returning false from the iterator function stops the iteration.
* @param collection
* @param fn
**/
each(collection: any[], fn: (index: number, item: any) => boolean): void;
/**
* @see ZeptoStatic.each
**/
each(collection: any, fn: (key: string, value: any) => boolean): void;
/**
* Extend target object with properties from each of the source objects, overriding the properties on target.
* By default, copying is shallow. An optional true for the first argument triggers deep (recursive) copying.
* @param target
* @param sources
* @return
**/
extend(target: any, ...sources: any[]): any;
/**
* @see ZeptoStatic.extend
* @param deep
**/
extend(deep: boolean, target: any, ...sources: any[]): any;
/**
* Zepto.fn is an object that holds all of the methods that are available on Zepto collections, such as addClass(), attr(), and other. Adding a function to this object makes that method available on every Zepto collection.
**/
fn: any;
/**
* Get a new array containing only the items for which the callback function returned true.
* @param items
* @param fn
* @return
**/
grep(items: any[], fn: (item: any) => boolean): any[];
/**
* Get the position of element inside an array, or -1 if not found.
* @param element
* @param array
* @param fromIndex
* @return
**/
inArray(element: any, array: any[], fromIndex?: number): number;
/**
* True if the object is an array.
* @param object
* @return
**/
isArray(object: any): boolean;
/**
* True if the object is a function.
* @param object
* @return
**/
isFunction(object: any): boolean;
/**
* True if the object is a “plain” JavaScript object, which is only true for object literals and objects created with new Object.
* @param object
* @return
**/
isPlainObject(object: any): boolean;
/**
* True if the object is a window object. This is useful for iframes where each one has its own window, and where these objects fail the regular obj === window check.
* @param object
* @return
**/
isWindow(object: any): boolean;
/**
* Iterate through elements of collection and return all results of running the iterator function, with null and undefined values filtered out.
* @param collection
* @param fn
* @return
**/
map(collection: any[], fn: (item: any, index: number) => any): any[];
/**
* Alias for the native JSON.parse method.
* @param str
* @retrun
**/
parseJSON(str: string): any;
/**
* Remove whitespace from beginning and end of a string; just like String.prototype.trim().
* @param str
* @return
**/
trim(str: string): string;
/**
* Get string type of an object. Possible types are: null undefined boolean number string function array date regexp object error.
* For other objects it will simply report “object”. To find out if an object is a plain JavaScript object, use isPlainObject.
* @param object
* @return
**/
type(object: any): string;
/**
* Event
**/
/**
* Create and initialize a DOM event of the specified type. If a properties object is given, use it to extend the new event object. The event is configured to bubble by default; this can be turned off by setting the bubbles property to false.
* An event initialized with this function can be triggered with trigger.
* @param type
* @param properties
* @return
**/
Event(type: string, properties: any): Event;
/**
* Get a function that ensures that the value of this in the original function refers to the context object. In the second form, the original function is read from the specific property of the context object.
**/
proxy(fn: Function, context: any): Function;
/**
* Ajax
**/
/**
* Perform an Ajax request. It can be to a local resource, or cross-domain via HTTP access control support in browsers or JSONP.
* Options:
* type (default: “GET”): HTTP request method (“GET”, “POST”, or other)
* url (default: current URL): URL to which the request is made
* data (default: none): data for the request; for GET requests it is appended to query string of the URL. Non-string objects will get serialized with $.param
* processData (default: true): whether to automatically serialize data for non-GET requests to string
* contentType (default: “application/x-www-form-urlencoded”): the Content-Type of the data being posted to the server (this can also be set via headers). Pass false to skip setting the default value.
* dataType (default: none): response type to expect from the server (“json”, “jsonp”, “xml”, “html”, or “text”)
* timeout (default: 0): request timeout in milliseconds, 0 for no timeout
* headers: object of additional HTTP headers for the Ajax request
* async (default: true): set to false to issue a synchronous (blocking) request
* global (default: true): trigger global Ajax events on this request
* context (default: window): context to execute callbacks in
* traditional (default: false): activate traditional (shallow) serialization of data parameters with $.param
* If the URL contains =? or dataType is “jsonp”, the request is performed by injecting a