@tarojs/extend 4.1.3-alpha.1 → 4.1.3-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1665 @@
1
+ /*
2
+ zepto-1.0rc1.d.ts may be freely distributed under the MIT license.
3
+
4
+ Copyright (c) 2013 Josh Baldwin https://github.com/jbaldwin/zepto.d.ts
5
+
6
+ Permission is hereby granted, free of charge, to any person
7
+ obtaining a copy of this software and associated documentation
8
+ files (the "Software"), to deal in the Software without
9
+ restriction, including without limitation the rights to use,
10
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the
12
+ Software is furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be
15
+ included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24
+ OTHER DEALINGS IN THE SOFTWARE.
25
+ */
26
+
27
+ interface ZeptoStatic {
28
+ /**
29
+ * Core
30
+ */
31
+
32
+ /**
33
+ * Create a Zepto collection object by performing a CSS selector, wrapping DOM nodes, or creating elements from an HTML string.
34
+ * @param selector
35
+ * @param context
36
+ * @return
37
+ */
38
+ (selector: string, context?: any): ZeptoCollection;
39
+
40
+ /**
41
+ * @see ZeptoStatic();
42
+ * @param collection
43
+ */
44
+ (collection: ZeptoCollection): ZeptoCollection;
45
+
46
+ /**
47
+ * @see ZeptoStatic();
48
+ * @param element
49
+ */
50
+ (element: HTMLElement): ZeptoCollection;
51
+
52
+ /**
53
+ * @see ZeptoStatic();
54
+ * @param htmlString
55
+ */
56
+ (htmlString: string): ZeptoCollection;
57
+
58
+ /**
59
+ * @see ZeptoStatic();
60
+ * @param attributes
61
+ */
62
+ (htmlString: string, attributes: any): ZeptoCollection;
63
+
64
+ /**
65
+ * @see ZeptoStatic();
66
+ * @param object
67
+ */
68
+ (object: any): ZeptoCollection; // window and document tests break without this
69
+
70
+ /**
71
+ * Turn a dasherized string into “camel case”. Doesn’t affect already camel-cased strings.
72
+ * @param str
73
+ * @return
74
+ */
75
+ camelCase(str: string): string;
76
+
77
+ /**
78
+ * Check if the parent node contains the given DOM node. Returns false if both are the same node.
79
+ * @param parent
80
+ * @param node
81
+ * @return
82
+ */
83
+ contains(parent: HTMLElement, node: HTMLElement): boolean;
84
+
85
+ /**
86
+ * Iterate over array elements or object key-value pairs. Returning false from the iterator function stops the iteration.
87
+ * @param collection
88
+ * @param fn
89
+ */
90
+ each(collection: any[], fn: (index: number, item: any) => boolean): void;
91
+
92
+ /**
93
+ * @see ZeptoStatic.each
94
+ */
95
+ each(collection: any, fn: (key: string, value: any) => boolean): void;
96
+
97
+ /**
98
+ * Extend target object with properties from each of the source objects, overriding the properties on target.
99
+ * By default, copying is shallow. An optional true for the first argument triggers deep (recursive) copying.
100
+ * @param target
101
+ * @param sources
102
+ * @return
103
+ */
104
+ extend(target: any, ...sources: any[]): any;
105
+
106
+ /**
107
+ * @see ZeptoStatic.extend
108
+ * @param deep
109
+ */
110
+ extend(deep: boolean, target: any, ...sources: any[]): any;
111
+
112
+ /**
113
+ * 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.
114
+ */
115
+ fn: any;
116
+
117
+ /**
118
+ * Get a new array containing only the items for which the callback function returned true.
119
+ * @param items
120
+ * @param fn
121
+ * @return
122
+ */
123
+ grep(items: any[], fn: (item: any) => boolean): any[];
124
+
125
+ /**
126
+ * Get the position of element inside an array, or -1 if not found.
127
+ * @param element
128
+ * @param array
129
+ * @param fromIndex
130
+ * @return
131
+ */
132
+ inArray(element: any, array: any[], fromIndex?: number): number;
133
+
134
+ /**
135
+ * True if the object is an array.
136
+ * @param object
137
+ * @return
138
+ */
139
+ isArray(object: any): boolean;
140
+
141
+ /**
142
+ * True if the object is a function.
143
+ * @param object
144
+ * @return
145
+ */
146
+ isFunction(object: any): boolean;
147
+
148
+ /**
149
+ * True if the object is a “plain” JavaScript object, which is only true for object literals and objects created with new Object.
150
+ * @param object
151
+ * @return
152
+ */
153
+ isPlainObject(object: any): boolean;
154
+
155
+ /**
156
+ * 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.
157
+ * @param object
158
+ * @return
159
+ */
160
+ isWindow(object: any): boolean;
161
+
162
+ /**
163
+ * Iterate through elements of collection and return all results of running the iterator function, with null and undefined values filtered out.
164
+ * @param collection
165
+ * @param fn
166
+ * @return
167
+ */
168
+ map(collection: any[], fn: (item: any, index: number) => any): any[];
169
+
170
+ /**
171
+ * Alias for the native JSON.parse method.
172
+ * @param str
173
+ * @return
174
+ */
175
+ parseJSON(str: string): any;
176
+
177
+ /**
178
+ * Remove whitespace from beginning and end of a string; just like String.prototype.trim().
179
+ * @param str
180
+ * @return
181
+ */
182
+ trim(str: string): string;
183
+
184
+ /**
185
+ * Get string type of an object. Possible types are: null undefined boolean number string function array date regexp object error.
186
+ * For other objects it will simply report “object”. To find out if an object is a plain JavaScript object, use isPlainObject.
187
+ * @param object
188
+ * @return
189
+ */
190
+ type(object: any): string;
191
+
192
+ /**
193
+ * Event
194
+ */
195
+
196
+ /**
197
+ * 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.
198
+ * An event initialized with this function can be triggered with trigger.
199
+ * @param type
200
+ * @param properties
201
+ * @return
202
+ */
203
+ Event(type: string, properties: any): Event;
204
+
205
+ /**
206
+ * 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.
207
+ */
208
+ proxy(fn: Function, context: any): Function;
209
+
210
+ /**
211
+ * Ajax
212
+ */
213
+
214
+ /**
215
+ * Perform an Ajax request. It can be to a local resource, or cross-domain via HTTP access control support in browsers or JSONP.
216
+ * Options:
217
+ * type (default: “GET”): HTTP request method (“GET”, “POST”, or other)
218
+ * url (default: current URL): URL to which the request is made
219
+ * 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
220
+ * processData (default: true): whether to automatically serialize data for non-GET requests to string
221
+ * 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.
222
+ * dataType (default: none): response type to expect from the server (“json”, “jsonp”, “xml”, “html”, or “text”)
223
+ * timeout (default: 0): request timeout in milliseconds, 0 for no timeout
224
+ * headers: object of additional HTTP headers for the Ajax request
225
+ * async (default: true): set to false to issue a synchronous (blocking) request
226
+ * global (default: true): trigger global Ajax events on this request
227
+ * context (default: window): context to execute callbacks in
228
+ * traditional (default: false): activate traditional (shallow) serialization of data parameters with $.param
229
+ * If the URL contains =? or dataType is “jsonp”, the request is performed by injecting a <script> tag instead of using XMLHttpRequest (see JSONP). This has the limitation of contentType, dataType, headers, and async not being supported.
230
+ * @param options
231
+ * @return
232
+ */
233
+ ajax(options: ZeptoAjaxSettings): XMLHttpRequest;
234
+
235
+ /**
236
+ * Perform a JSONP request to fetch data from another domain.
237
+ * This method has no advantages over $.ajax and should not be used.
238
+ * @param options Ajax settings to use with JSONP call.
239
+ * @deprecated use $.ajax instead.
240
+ */
241
+ ajaxJSONP(options: ZeptoAjaxSettings): XMLHttpRequest;
242
+
243
+ /**
244
+ * Object containing the default settings for Ajax requests. Most settings are described in $.ajax. The ones that are useful when set globally are:
245
+ * @example
246
+ * timeout (default: 0): set to a non-zero value to specify a default timeout for Ajax requests in milliseconds
247
+ * global (default: true): set to false to prevent firing Ajax events
248
+ * xhr (default: XMLHttpRequest factory): set to a function that returns instances of XMLHttpRequest (or a compatible object)
249
+ * accepts: MIME types to request from the server for specific dataType values:
250
+ * script: “text/javascript, application/javascript”
251
+ * json: “application/json”
252
+ * xml: “application/xml, text/xml”
253
+ * html: “text/html”
254
+ * text: “text/plain”
255
+ */
256
+ ajaxSettings: ZeptoAjaxSettings;
257
+
258
+ /**
259
+ * Perform an Ajax GET request. This is a shortcut for the $.ajax method.
260
+ * @param url URL to send the HTTP GET request to.
261
+ * @param fn Callback function when the HTTP GET request is completed.
262
+ * @return The XMLHttpRequest object.
263
+ */
264
+ get(url: string, fn: (data: any, status: string, xhr: XMLHttpRequest) => void): XMLHttpRequest;
265
+
266
+ /**
267
+ * @see ZeptoStatic.get
268
+ * @param data See ZeptoAjaxSettings.data
269
+ */
270
+ get(url: string, data: any, fn: (data: any, status: string, xhr: XMLHttpRequest) => void): XMLHttpRequest;
271
+
272
+ /**
273
+ * Get JSON data via Ajax GET request. This is a shortcut for the $.ajax method.
274
+ * @param url URL to send the HTTP GET request to.
275
+ * @param fn Callback function when the HTTP GET request is completed.
276
+ * @return The XMLHttpRequest object.
277
+ */
278
+ getJSON(url: string, fn: (data: any, status: string, xhr: XMLHttpRequest) => void): XMLHttpRequest;
279
+
280
+ /**
281
+ * @see ZeptoStatic.getJSON
282
+ * @param data See ZeptoAjaxSettings.data
283
+ */
284
+ getJSON(url: string, data: any, fn: (data: any, status: string, xhr: XMLHttpRequest) => void): XMLHttpRequest;
285
+
286
+ /**
287
+ * Serialize an object to a URL-encoded string representation for use in Ajax request query strings and post data. If shallow is set, nested objects are not serialized and nested array values won’t use square brackets on their keys.
288
+ * Also accepts an array in serializeArray format, where each item has “name” and “value” properties.
289
+ * @param object Serialize this object to URL-encoded string representation.
290
+ * @param shallow Only serialize the first level of `object`.
291
+ * @return Seralized URL-encoded string representation of `object`.
292
+ */
293
+ param(object: any, shallow?: boolean): string;
294
+
295
+ /**
296
+ * Perform an Ajax POST request. This is a shortcut for the $.ajax method.
297
+ * @param url URL to send the HTTP POST request to.
298
+ * @param fn Callback function when the HTTP POST request is completed.
299
+ * @return The XMLHttpRequest object.
300
+ */
301
+ post(url: string, fn: (data: any, status: string, xhr: XMLHttpRequest) => void, dataType?: string): XMLHttpRequest;
302
+
303
+ /**
304
+ * @see ZeptoStatic.post
305
+ * @param data See ZeptoAjaxSettings.data
306
+ */
307
+ post(
308
+ url: string,
309
+ data: any,
310
+ fn: (data: any, status: string, xhr: XMLHttpRequest) => void,
311
+ dataType?: string,
312
+ ): XMLHttpRequest;
313
+
314
+ /**
315
+ * Effects
316
+ */
317
+
318
+ /**
319
+ * Global settings for animations.
320
+ */
321
+ fx: ZeptoEffects;
322
+
323
+ /**
324
+ * Detect
325
+ */
326
+
327
+ /**
328
+ * The following boolean flags are set to true if they apply, if not they're either set to 'false' or 'undefined'. We recommend accessing them with `!!` prefixed to coerce to a boolean.
329
+ */
330
+ os: {
331
+ /**
332
+ * OS version.
333
+ */
334
+ version: string;
335
+
336
+ /**
337
+ * General device type
338
+ */
339
+ phone: boolean;
340
+ tablet: boolean;
341
+
342
+ /**
343
+ * Specific OS
344
+ */
345
+ ios: boolean;
346
+ android: boolean;
347
+ webos: boolean;
348
+ blackberry: boolean;
349
+ bb10: boolean;
350
+ rimtabletos: boolean;
351
+
352
+ /**
353
+ * Specific device type
354
+ */
355
+ iphone: boolean;
356
+ ipad: boolean;
357
+ touchpad: boolean;
358
+ kindle: boolean;
359
+ };
360
+
361
+ /**
362
+ * The following boolean flags are set to true if they apply, if not they're either set to 'false' or 'undefined'. We recommend accessing them with `!!` prefixed to coerce to a boolean.
363
+ */
364
+ browser: {
365
+ /**
366
+ * Browser version.
367
+ */
368
+ version: string;
369
+
370
+ /**
371
+ * Specific browser
372
+ */
373
+ chrome: boolean;
374
+ firefox: boolean;
375
+ silk: boolean;
376
+ playbook: boolean;
377
+ };
378
+ }
379
+
380
+ interface ZeptoEffects {
381
+ /**
382
+ * (default false in browsers that support CSS transitions): set to true to disable all animate() transitions.
383
+ */
384
+ off: boolean;
385
+
386
+ /**
387
+ * An object with duration settings for animations.
388
+ * Change existing values or add new properties to affect animations that use a string for setting duration.
389
+ */
390
+ speeds: ZeptoEffectsSpeeds;
391
+ }
392
+
393
+ interface ZeptoEffectsSpeeds {
394
+ /**
395
+ * Default = 400ms.
396
+ */
397
+ _default: number;
398
+
399
+ /**
400
+ * Default = 200ms.
401
+ */
402
+ fast: number;
403
+
404
+ /**
405
+ * Default = 600ms.
406
+ */
407
+ slow: number;
408
+ }
409
+
410
+ interface ZeptoCollection {
411
+ /**
412
+ * Core
413
+ */
414
+
415
+ /**
416
+ * Modify the current collection by adding the results of performing the CSS selector on the whole document, or, if context is given, just inside context elements.
417
+ * @param selector
418
+ * @param context
419
+ * @return Self object.
420
+ */
421
+ add(selector: string, context?: any): ZeptoCollection;
422
+
423
+ /**
424
+ * Add class name to each of the elements in the collection. Multiple class names can be given in a space-separated string.
425
+ * @param name
426
+ * @return Self object.
427
+ */
428
+ addClass(name: string): ZeptoCollection;
429
+
430
+ /**
431
+ * Add content to the DOM after each elements in the collection. The content can be an HTML string, a DOM node or an array of nodes.
432
+ * @param content
433
+ * @return Self object.
434
+ */
435
+ after(content: string): ZeptoCollection;
436
+
437
+ /*
438
+ * @see ZeptoCollection.after
439
+ */
440
+ after(content: HTMLElement): ZeptoCollection;
441
+
442
+ /**
443
+ * @see ZeptoCollection.after
444
+ */
445
+ after(content: HTMLElement[]): ZeptoCollection;
446
+
447
+ /**
448
+ * @see ZeptoCollection.after
449
+ */
450
+ after(content: ZeptoCollection): ZeptoCollection;
451
+
452
+ /**
453
+ * Append content to the DOM inside each individual element in the collection. The content can be an HTML string, a DOM node or an array of nodes.
454
+ * @param content
455
+ * @return Self object.
456
+ */
457
+ append(content: string): ZeptoCollection;
458
+
459
+ /**
460
+ * @see ZeptoCollection.append
461
+ */
462
+ append(content: HTMLElement): ZeptoCollection;
463
+
464
+ /**
465
+ * @see ZeptoCollection.append
466
+ */
467
+ append(content: HTMLElement[]): ZeptoCollection;
468
+
469
+ /**
470
+ * @see ZeptoCollection.append
471
+ */
472
+ append(content: ZeptoCollection): ZeptoCollection;
473
+
474
+ /**
475
+ * Append elements from the current collection to the target element. This is like append, but with reversed operands.
476
+ * @param target
477
+ * @return Self object.
478
+ */
479
+ appendTo(target: string): ZeptoCollection;
480
+
481
+ /**
482
+ * @see ZeptoCollection.appendTo
483
+ */
484
+ appendTo(target: HTMLElement): ZeptoCollection;
485
+
486
+ /**
487
+ * @see ZeptoCollection.appendTo
488
+ */
489
+ appendTo(target: HTMLElement[]): ZeptoCollection;
490
+
491
+ /**
492
+ * @see ZeptoCollection.appendTo
493
+ */
494
+ appendTo(target: ZeptoCollection): ZeptoCollection;
495
+
496
+ /**
497
+ * Read or set DOM attributes. When no value is given, reads specified attribute from the first element in the collection. When value is given, sets the attribute to that value on each element in the collection. When value is null, the attribute is removed (like with removeAttr). Multiple attributes can be set by passing an object with name-value pairs.
498
+ * To read DOM properties such as checked or selected, use prop.
499
+ * @param name
500
+ * @return
501
+ */
502
+ attr(name: string): string;
503
+
504
+ /**
505
+ * @see ZeptoCollection.attr
506
+ * @param value
507
+ */
508
+ attr(name: string, value: any): ZeptoCollection;
509
+
510
+ /**
511
+ * @see ZeptoCollection.attr
512
+ * @param fn
513
+ * @param oldValue
514
+ */
515
+ attr(name: string, fn: (index: number, oldValue: any) => void): ZeptoCollection;
516
+
517
+ /**
518
+ * @see ZeptoCollection.attr
519
+ * @param object
520
+ */
521
+ attr(object: any): ZeptoCollection;
522
+
523
+ /**
524
+ * Add content to the DOM before each element in the collection. The content can be an HTML string, a DOM node or an array of nodes.
525
+ * @param content
526
+ * @return Self object.
527
+ */
528
+ before(content: string): ZeptoCollection;
529
+
530
+ /**
531
+ * @see ZeptoCollection.before
532
+ */
533
+ before(content: HTMLElement): ZeptoCollection;
534
+
535
+ /**
536
+ * @see ZeptoCollection.before
537
+ */
538
+ before(content: HTMLElement[]): ZeptoCollection;
539
+
540
+ /**
541
+ * @see ZeptoCollection.before
542
+ */
543
+ before(content: ZeptoCollection): ZeptoCollection;
544
+
545
+ /**
546
+ * Get immediate children of each element in the current collection. If selector is given, filter the results to only include ones matching the CSS selector.
547
+ * @param selector
548
+ * @return Children elements.
549
+ */
550
+ children(selector?: string): ZeptoCollection;
551
+
552
+ /**
553
+ * Duplicate all elements in the collection via deep clone.
554
+ * (!) This method doesn't have an option for copying data and event handlers over to the new elements, as it has in jQuery.
555
+ * @return Clone of the self object.
556
+ */
557
+ clone(): ZeptoCollection;
558
+
559
+ /**
560
+ * Traverse upwards from the current element to find the first element that matches the selector. If context node is given, consider only elements that are its descendants. This method is similar to parents(selector), but it only returns the first ancestor matched.
561
+ * If a Zepto collection or element is given, the resulting element will have to match one of the given elements instead of a selector.
562
+ * @param selector
563
+ * @param context
564
+ * @return Closest element from the selector and context.
565
+ */
566
+ closest(selector: string, context?: any): ZeptoCollection;
567
+
568
+ /**
569
+ * Modify the collection by adding elements to it. If any of the arguments is an array, its elements are merged into the current collection.
570
+ * (!) This is a Zepto-provided method that is not part of the jQuery API.
571
+ * @param nodes
572
+ * @return Self object.
573
+ */
574
+ concat(...nodes: any[]): ZeptoCollection;
575
+
576
+ /**
577
+ * Get the children of each element in the collection, including text and comment nodes.
578
+ * @return Children including text and comment nodes.
579
+ */
580
+ contents(): ZeptoCollection;
581
+
582
+ /**
583
+ * Read or set CSS properties on DOM elements. When no value is given, returns the CSS property from the first element in the collection. When a value is given, sets the property to that value on each element of the collection. Multiple properties can be set by passing an object to the method.
584
+ * When a value for a property is blank (empty string, null, or undefined), that property is removed. When a unitless number value is given, “px” is appended to it for properties that require units.
585
+ * @param property
586
+ * @return
587
+ */
588
+ css(property: string): any;
589
+
590
+ /**
591
+ * @see ZeptoCollection.css
592
+ * @param value
593
+ */
594
+ css(property: string, value: any): ZeptoCollection;
595
+
596
+ /**
597
+ * @see ZeptoCollection.css
598
+ * @param properties
599
+ */
600
+ css(properties: any): ZeptoCollection;
601
+
602
+ /**
603
+ * Read or write data-* DOM attributes. Behaves like attr, but prepends data- to the attribute name.
604
+ * When reading attribute values, the following conversions apply:
605
+ * “true”, “false”, and “null” are converted to corresponding types;
606
+ * number values are converted to actual numeric types;
607
+ * JSON values are parsed, if it’s valid JSON;
608
+ * everything else is returned as string.
609
+ * (!) Zepto's basic implementation of `data()` only stores strings. To store arbitrary objects, include the optional "data" module in your custom build of Zepto.
610
+ * @param name
611
+ * @return
612
+ */
613
+ data(name: string): any;
614
+
615
+ /**
616
+ * @see ZeptoCollection.data
617
+ * @param value
618
+ */
619
+ data(name: string, value: any): ZeptoCollection;
620
+
621
+ /**
622
+ * Iterate through every element of the collection. Inside the iterator function, this keyword refers to the current item (also passed as the second argument to the function). If the iterator function returns false, iteration stops.
623
+ * @param fn
624
+ * @param item
625
+ * @return Self object.
626
+ */
627
+ each(fn: (index: number, item: any) => boolean): ZeptoCollection;
628
+
629
+ /**
630
+ * Clear DOM contents of each element in the collection.
631
+ * @return Self object.
632
+ */
633
+ empty(): ZeptoCollection;
634
+
635
+ /**
636
+ * Get the item at position specified by index from the current collection.
637
+ * @param index
638
+ * @return Item specified by index in this collection.
639
+ */
640
+ eq(index: number): ZeptoCollection;
641
+
642
+ /**
643
+ * Filter the collection to contain only items that match the CSS selector. If a function is given, return only elements for which the function returns a truthy value. Inside the function, the this keyword refers to the current element.
644
+ * For the opposite, see not.
645
+ * @param selector
646
+ * @return Filtered collection.
647
+ */
648
+ filter(selector: string): ZeptoCollection;
649
+
650
+ /**
651
+ * @see ZeptoCollection.filter
652
+ * @param fn
653
+ */
654
+ filter(fn: (index: number) => boolean): ZeptoCollection;
655
+
656
+ /**
657
+ * Find elements that match CSS selector executed in scope of nodes in the current collection.
658
+ * If a Zepto collection or element is given, filter those elements down to only ones that are descendants of element in the current collection.
659
+ * @param selector
660
+ * @return Found items.
661
+ */
662
+ find(selector: string): ZeptoCollection;
663
+
664
+ /**
665
+ * @see ZeptoCollection.find
666
+ * @param collection
667
+ */
668
+ find(collection: ZeptoCollection): ZeptoCollection;
669
+
670
+ /**
671
+ * @see ZeptoCollection.find
672
+ * @param element
673
+ */
674
+ find(element: Element): ZeptoCollection;
675
+
676
+ /**
677
+ * Get the first element of the current collection.
678
+ * @return First element in the current collection.
679
+ */
680
+ first(): ZeptoCollection;
681
+
682
+ /**
683
+ * Iterate through every element of the collection. Similar to each, but the arguments for the iterator functions are different, and returning false from the iterator won’t stop the iteration.
684
+ * (!) This is a Zepto-provided method that is not part of the jQuery API.
685
+ * @param fn
686
+ * @return
687
+ */
688
+ forEach(fn: (item: any, index: number, array: any[]) => void): ZeptoCollection;
689
+
690
+ /**
691
+ * Get all elements or a single element from the current collection. When no index is given, returns all elements in an ordinary array. When index is specified, return only the element at that position. This is different than eq in the way that the returned node is not wrapped in a Zepto collection.
692
+ * @return
693
+ */
694
+ get(): HTMLElement[];
695
+
696
+ /**
697
+ * @see ZeptoCollection.get
698
+ * @param index
699
+ */
700
+ get(index: number): HTMLElement;
701
+
702
+ /**
703
+ * Filter the current collection to include only elements that have any number of descendants that match a selector, or that contain a specific DOM node.
704
+ * @param selector
705
+ * @return
706
+ */
707
+ has(selector: string): ZeptoCollection;
708
+
709
+ /**
710
+ * @see ZeptoCollection.has
711
+ * @param node
712
+ */
713
+ has(node: HTMLElement): ZeptoCollection;
714
+
715
+ /**
716
+ * Check if any elements in the collection have the specified class.
717
+ * @param name
718
+ * @return
719
+ */
720
+ hasClass(name: string): boolean;
721
+
722
+ /**
723
+ * Get the height of the first element in the collection; or set the height of all elements in the collection.
724
+ * @return
725
+ */
726
+ height(): number;
727
+
728
+ /**
729
+ * @see ZeptoCollection.height
730
+ * @param value
731
+ */
732
+ height(value: number): ZeptoCollection;
733
+
734
+ /**
735
+ * @see ZeptoCollection.height
736
+ * @param fn
737
+ */
738
+ height(fn: (index: number, oldHeight: number) => void): ZeptoCollection;
739
+
740
+ /**
741
+ * Hide elements in this collection by setting their display CSS property to none.
742
+ * @return
743
+ */
744
+ hide(): ZeptoCollection;
745
+
746
+ /**
747
+ * Get or set HTML contents of elements in the collection. When no content given, returns innerHTML of the first element. When content is given, use it to replace contents of each element. Content can be any of the types described in append.
748
+ * @return
749
+ */
750
+ html(): string;
751
+
752
+ /**
753
+ * @see ZeptoCollection.html
754
+ * @param content
755
+ */
756
+ html(content: string): ZeptoCollection;
757
+
758
+ /**
759
+ * @see ZeptoCollection.html
760
+ * @param content
761
+ */
762
+ html(content: HTMLElement): ZeptoCollection;
763
+
764
+ /**
765
+ * @see ZeptoCollection.html
766
+ * @param content
767
+ */
768
+ html(content: HTMLElement[]): ZeptoCollection;
769
+
770
+ /**
771
+ * @see ZeptoCollection.html
772
+ * @param fn
773
+ */
774
+ html(fn: (index: number, oldHtml: string) => void): ZeptoCollection;
775
+
776
+ /**
777
+ * Get the position of an element. When no element is given, returns position of the current element among its siblings. When an element is given, returns its position in the current collection. Returns -1 if not found.
778
+ * @param element
779
+ * @return
780
+ */
781
+ index(element?: string): number;
782
+
783
+ /**
784
+ * @see ZeptoCollection.index
785
+ * @param element
786
+ */
787
+ index(element?: HTMLElement): number;
788
+
789
+ /**
790
+ * @see ZeptoCollection.index
791
+ * @param element
792
+ */
793
+ index(element?: any): number; // not sure so leaving in for now
794
+
795
+ /**
796
+ * Get the position of an element in the current collection. If fromIndex number is given, search only from that position onwards. Returns the 0-based position when found and -1 if not found. Use of index is recommended over this method.
797
+ * (!) This is a Zepto-provided method that is not part of the jQuery API.
798
+ * @see ZeptoCollection.index
799
+ * @param element
800
+ * @param fromIndex
801
+ * @return
802
+ */
803
+ indexOf(element: string, fromIndex?: number): number;
804
+
805
+ /**
806
+ * @see ZeptoCollection.indexOf
807
+ * @param element
808
+ */
809
+ indexOf(element: HTMLElement, fromIndex?: number): number;
810
+
811
+ /**
812
+ * @see ZeptoCollection.indexOf
813
+ * @param element
814
+ */
815
+ indexOf(element: any, fromIndex?: number): number; // not sure so leaving in for now
816
+
817
+ /**
818
+ * Insert elements from the current collection after the target element in the DOM. This is like after, but with reversed operands.
819
+ * @param target
820
+ * @return
821
+ */
822
+ insertAfter(target: string): ZeptoCollection;
823
+
824
+ /**
825
+ * @see ZeptoCollection.insertAfter
826
+ * @param target
827
+ */
828
+ insertAfter(target: HTMLElement): ZeptoCollection;
829
+
830
+ /**
831
+ * Insert elements from the current collection before each of the target elements in the DOM. This is like before, but with reversed operands.
832
+ * @param target
833
+ * @return
834
+ */
835
+ insertBefore(target: string): ZeptoCollection;
836
+
837
+ /**
838
+ * @see ZeptoCollection.insertBefore
839
+ * @param target
840
+ */
841
+ insertBefore(target: HTMLElement): ZeptoCollection;
842
+
843
+ /**
844
+ * Check if the first element of the current collection matches the CSS selector. For basic support of jQuery’s non-standard pseudo-selectors such as :visible, include the optional “selector” module.
845
+ * (!) jQuery CSS extensions are not supported. The optional "selector" module only provides limited support for few of the most used ones.
846
+ * @param selector
847
+ * @return
848
+ */
849
+ is(selector?: string): boolean;
850
+
851
+ /**
852
+ * Get the last element of the current collection.
853
+ * @return
854
+ */
855
+ last(): ZeptoCollection;
856
+
857
+ /**
858
+ * Iterate through all elements and collect the return values of the iterator function. Inside the iterator function, this keyword refers to the current item (also passed as the second argument to the function).
859
+ * Returns a collection of results of iterator function, with null and undefined values filtered out.
860
+ * @param fn
861
+ * @return
862
+ */
863
+ map(fn: (index: number, item: any) => any): ZeptoCollection;
864
+
865
+ /**
866
+ * Get the next sibling—optinally filtered by selector—of each element in the collection.
867
+ * @param selector
868
+ * @return
869
+ */
870
+ next(selector?: string): ZeptoCollection;
871
+
872
+ /**
873
+ * Filter the current collection to get a new collection of elements that don’t match the CSS selector. If another collection is given instead of selector, return only elements not present in it. If a function is given, return only elements for which the function returns a falsy value. Inside the function, the this keyword refers to the current element.
874
+ * For the opposite, see filter.
875
+ * @param selector
876
+ * @return
877
+ */
878
+ not(selector: string): ZeptoCollection;
879
+
880
+ /**
881
+ * @see ZeptoCollection.not
882
+ * @param collection
883
+ */
884
+ not(collection: ZeptoCollection): ZeptoCollection;
885
+
886
+ /**
887
+ * @see ZeptoCollection.not
888
+ * @param fn
889
+ */
890
+ not(fn: (index: number) => boolean): ZeptoCollection;
891
+
892
+ /**
893
+ * Get position of the element in the document. Returns an object with properties: top, left, width and height.
894
+ * When given an object with properties left and top, use those values to position each element in the collection relative to the document.
895
+ * @return
896
+ */
897
+ offset(): ZeptoCoordinates;
898
+
899
+ /**
900
+ * @see ZeptoCollection.offset
901
+ * @param coordinates
902
+ */
903
+ offset(coordinates: ZeptoCoordinates): ZeptoCollection;
904
+
905
+ /**
906
+ * @see ZeptoCollection.offset
907
+ * @param fn
908
+ */
909
+ offset(fn: (index: number, oldOffset: number) => void): ZeptoCollection;
910
+
911
+ /**
912
+ * Find the first ancestor element that is positioned, meaning its CSS position value is “relative”, “absolute” or “fixed”.
913
+ * @return
914
+ */
915
+ offsetParent(): ZeptoCollection;
916
+
917
+ /**
918
+ * Get immediate parents of each element in the collection. If CSS selector is given, filter results to include only ones matching the selector.
919
+ * @param selector
920
+ * @return
921
+ */
922
+ parent(selector?: string): ZeptoCollection;
923
+
924
+ /**
925
+ * Get all ancestors of each element in the collection. If CSS selector is given, filter results to include only ones matching the selector.
926
+ * To get only immediate parents, use parent. To only get the first ancestor that matches the selector, use closest.
927
+ * @param selector
928
+ * @return
929
+ */
930
+ parents(selector?: string): ZeptoCollection;
931
+
932
+ /**
933
+ * Get values from a named property of each element in the collection, with null and undefined values filtered out.
934
+ * (!) This is a Zepto-provided method that is not part of the jQuery API.
935
+ * @param property
936
+ * @return
937
+ */
938
+ pluck(property: string): string[];
939
+
940
+ /**
941
+ * Get the position of the first element in the collection, relative to the offsetParent. This information is useful when absolutely positioning an element to appear aligned with another.
942
+ * Returns an object with properties: top, left.
943
+ * @return
944
+ */
945
+ position(): ZeptoPosition;
946
+
947
+ /**
948
+ * Prepend content to the DOM inside each element in the collection. The content can be an HTML string, a DOM node or an array of nodes.
949
+ * @param content
950
+ * @return
951
+ */
952
+ prepend(content: string): ZeptoCollection;
953
+
954
+ /**
955
+ * @see ZeptoCollection.prepend
956
+ * @param content
957
+ */
958
+ prepend(content: HTMLElement): ZeptoCollection;
959
+
960
+ /**
961
+ * @see ZeptoCollection.prepend
962
+ * @param content
963
+ */
964
+ prepend(content: HTMLElement[]): ZeptoCollection;
965
+
966
+ /**
967
+ * @see ZeptoCollection.prepend
968
+ * @param content
969
+ */
970
+ prepend(content: ZeptoCollection): ZeptoCollection;
971
+
972
+ /**
973
+ * Prepend elements of the current collection inside each of the target elements. This is like prepend, only with reversed operands.
974
+ * @param content
975
+ * @return
976
+ */
977
+ prependTo(content: string): ZeptoCollection;
978
+
979
+ /**
980
+ * @see ZeptoCollection.prependTo
981
+ * @param content
982
+ */
983
+ prependTo(content: HTMLElement): ZeptoCollection;
984
+
985
+ /**
986
+ * @see ZeptoCollection.prependTo
987
+ * @param content
988
+ */
989
+ prependTo(content: HTMLElement[]): ZeptoCollection;
990
+
991
+ /**
992
+ * @see ZeptoCollection.prependTo
993
+ * @param content
994
+ */
995
+ prependTo(content: ZeptoCollection): ZeptoCollection;
996
+
997
+ /**
998
+ * Get the previous sibling—optionally filtered by selector—of each element in the collection.
999
+ * @param selector
1000
+ * @return
1001
+ */
1002
+ prev(selector?: string): ZeptoCollection;
1003
+
1004
+ /**
1005
+ * Read or set properties of DOM elements. This should be preferred over attr in case of reading values of properties that change with user interaction over time, such as checked and selected.
1006
+ * @param prop
1007
+ * @return
1008
+ */
1009
+ prop(name: string): any;
1010
+
1011
+ /**
1012
+ * @see ZeptoCollection.Prop
1013
+ * @param value
1014
+ */
1015
+ prop(name: string, value: any): ZeptoCollection;
1016
+
1017
+ /**
1018
+ * @see ZeptoCollection.Prop
1019
+ * @param fn
1020
+ */
1021
+ prop(name: string, fn: (index: number, oldValue: any) => void): ZeptoCollection;
1022
+
1023
+ /**
1024
+ * Add elements to the end of the current collection.
1025
+ * (!) This is a Zepto-provided method that is not part of the jQuery API.
1026
+ * @param elements
1027
+ * @return
1028
+ */
1029
+ push(...elements: any[]): ZeptoCollection;
1030
+
1031
+ /**
1032
+ * Attach an event handler for the “DOMContentLoaded” event that fires when the DOM on the page is ready. It’s recommended to use the $() function instead of this method.
1033
+ * @param fn
1034
+ * @return
1035
+ */
1036
+ ready(fn: ($: ZeptoStatic) => void): ZeptoCollection;
1037
+
1038
+ /**
1039
+ * Identical to Array.reduce that iterates over current collection.
1040
+ * (!) This is a Zepto-provided method that is not part of the jQuery API.
1041
+ * @param fn
1042
+ * @return
1043
+ */
1044
+ reduce(fn: (memo: any, item: any, index: number, array: any[], initial: any) => any): any;
1045
+
1046
+ /**
1047
+ * Remove elements in the current collection from their parent nodes, effectively detaching them from the DOM.
1048
+ * @return
1049
+ */
1050
+ remove(): ZeptoCollection;
1051
+
1052
+ /**
1053
+ * Remove the specified attribute from all elements in the collection.
1054
+ * @param name
1055
+ * @return
1056
+ */
1057
+ removeAttr(name: string): ZeptoCollection;
1058
+
1059
+ /**
1060
+ * Remove the specified class name from all elements in the collection. When the class name isn’t given, remove all class names. Multiple class names can be given in a space-separated string.
1061
+ * @param name
1062
+ * @return
1063
+ */
1064
+ removeClass(name?: string): ZeptoCollection;
1065
+
1066
+ /**
1067
+ * @see ZeptoCollection.removeClass
1068
+ * @param fn
1069
+ */
1070
+ removeClass(fn: (index: number, oldClassName: string) => void): ZeptoCollection;
1071
+
1072
+ /**
1073
+ * Replace each element in the collection—both its contents and the element itself—with the new content. Content can be of any type described in before.
1074
+ * @param content
1075
+ * @return
1076
+ */
1077
+ replaceWith(content: string): ZeptoCollection;
1078
+
1079
+ /**
1080
+ * @see ZeptoCollection.replacewith
1081
+ * @param content
1082
+ */
1083
+ replaceWith(content: HTMLElement): ZeptoCollection;
1084
+
1085
+ /**
1086
+ * @see ZeptoCollection.replacewith
1087
+ * @param content
1088
+ */
1089
+ replaceWith(content: HTMLElement[]): ZeptoCollection;
1090
+
1091
+ /**
1092
+ * Gets the value of how many pixels were scrolled so far on window or scrollable element on the page.
1093
+ * @return
1094
+ */
1095
+ scrollTop(): number;
1096
+
1097
+ /**
1098
+ * Restore the default value for the “display” property of each element in the array, effectively showing them if they were hidden with hide.
1099
+ * @return
1100
+ */
1101
+ show(): ZeptoCollection;
1102
+
1103
+ /**
1104
+ * Get all sibling nodes of each element in the collection. If CSS selector is specified, filter the results to contain only elements that match the selector.
1105
+ * @param selector
1106
+ * @return
1107
+ */
1108
+ siblings(selector?: string): ZeptoCollection;
1109
+
1110
+ /**
1111
+ * Get the number of elements in this collection.
1112
+ * @return
1113
+ */
1114
+ size(): number;
1115
+
1116
+ /**
1117
+ * Get the number of elements in this collection.
1118
+ */
1119
+ length: number;
1120
+
1121
+ /**
1122
+ * Extract the subset of this array, starting at start index. If end is specified, extract up to but not including end index.
1123
+ * @param start
1124
+ * @param end
1125
+ * @return
1126
+ */
1127
+ slice(start?: number, end?: number): ZeptoCollection[];
1128
+
1129
+ /**
1130
+ * Get or set the text content of elements in the collection. When no content is given, returns the text content of the first element in the collection. When content is given, uses it to replace the text contents of each element in the collection. This is similar to html, with the exception it can’t be used for getting or setting HTML.
1131
+ * @return
1132
+ */
1133
+ text(): string;
1134
+
1135
+ /**
1136
+ * @see ZeptoCollection.text
1137
+ * @param content
1138
+ * @return
1139
+ */
1140
+ text(content: string): ZeptoCollection;
1141
+
1142
+ /**
1143
+ * Toggle between showing and hiding each of the elements, based on whether the first element is visible or not. If setting is present, this method behaves like show if setting is truthy or hide otherwise.
1144
+ * @param setting
1145
+ * @return
1146
+ */
1147
+ toggle(setting?: boolean): ZeptoCollection;
1148
+
1149
+ /**
1150
+ * Toggle given class names (space-separated) in each element in the collection. The class name is removed if present on an element; otherwise it’s added. If setting is present, this method behaves like addClass if setting is truthy or removeClass otherwise.
1151
+ * @param names
1152
+ * @param setting
1153
+ * @return
1154
+ */
1155
+ toggleClass(names: string, setting?: boolean): ZeptoCollection;
1156
+
1157
+ /**
1158
+ * @see ZeptoCollection.toggleClass
1159
+ * @param fn
1160
+ */
1161
+ toggleClass(fn: (index: number, oldClassNames: string) => void, setting?: boolean): ZeptoCollection;
1162
+
1163
+ /**
1164
+ * Remove immediate parent nodes of each element in the collection and put their children in their place. Basically, this method removes one level of ancestry while keeping current elements in the DOM.
1165
+ * @return
1166
+ */
1167
+ unwrap(): ZeptoCollection;
1168
+
1169
+ /**
1170
+ * Get or set the value of form controls. When no value is given, return the value of the first element. For <select multiple>, an array of values is returend. When a value is given, set all elements to this value.
1171
+ * @return
1172
+ */
1173
+ val(): string;
1174
+
1175
+ /**
1176
+ * @see ZeptoCollection.val
1177
+ * @param value
1178
+ * @return
1179
+ */
1180
+ val(value: any): ZeptoCollection;
1181
+
1182
+ /**
1183
+ * @see ZeptoCollection.val
1184
+ * @param fn
1185
+ */
1186
+ val(fn: (index: number, oldValue: any) => void): ZeptoCollection;
1187
+
1188
+ /**
1189
+ * Get the width of the first element in the collection; or set the width of all elements in the collection.
1190
+ * @return
1191
+ */
1192
+ width(): number;
1193
+
1194
+ /**
1195
+ * @see ZeptoCollection.width
1196
+ * @param value
1197
+ * @return
1198
+ */
1199
+ width(value: number): ZeptoCollection;
1200
+
1201
+ /**
1202
+ * @see ZeptoCollection.width
1203
+ * @param fn
1204
+ */
1205
+ width(fn: (index: number, oldWidth: number) => void): ZeptoCollection;
1206
+
1207
+ /**
1208
+ * Wrap each element of the collection separately in a DOM structure. Structure can be a single element or several nested elements, and can be passed in as a HTML string or DOM node, or as a function that is called for each element and returns one of the first two types.
1209
+ * Keep in mind that wrapping works best when operating on nodes that are part of the DOM. When calling wrap() on a new element and then inserting the result in the document, the element will lose the wrapping.
1210
+ * @param structure
1211
+ * @return
1212
+ */
1213
+ wrap(structure: string): ZeptoCollection;
1214
+
1215
+ /**
1216
+ * @see ZeptoCollection.wrap
1217
+ * @param structure
1218
+ */
1219
+ wrap(structure: HTMLElement): ZeptoCollection;
1220
+
1221
+ /**
1222
+ * @see ZeptoCollection.wrap
1223
+ * @param fn
1224
+ */
1225
+ wrap(fn: (index: number) => string): ZeptoCollection;
1226
+
1227
+ /**
1228
+ * Wrap all elements in a single structure. Structure can be a single element or several nested elements, and can be passed in as a HTML string or DOM node.
1229
+ * @param structure
1230
+ * @return
1231
+ */
1232
+ wrapAll(structure: string): ZeptoCollection;
1233
+
1234
+ /**
1235
+ * @see ZeptoCollection.wrapAll
1236
+ * @param structure
1237
+ */
1238
+ wrapAll(structure: HTMLElement): ZeptoCollection;
1239
+
1240
+ /**
1241
+ * Wrap the contents of each element separately in a structure. Structure can be a single element or several nested elements, and can be passed in as a HTML string or DOM node, or as a function that is called for each element and returns one of the first two types.
1242
+ * @param structure
1243
+ * @return
1244
+ */
1245
+ wrapInner(structure: string): ZeptoCollection;
1246
+
1247
+ /**
1248
+ * @see ZeptoCollection.wrapInner
1249
+ * @param structure
1250
+ */
1251
+ wrapInner(structure: HTMLElement): ZeptoCollection;
1252
+
1253
+ /**
1254
+ * @see ZeptoCollection.wrapInner
1255
+ * @param fn
1256
+ */
1257
+ wrapInner(fn: (index: number) => string): ZeptoCollection;
1258
+
1259
+ /**
1260
+ * Event
1261
+ */
1262
+
1263
+ /**
1264
+ * Attach an event handler to elements.
1265
+ * @deprecated use ZeptoCollection.on instead.
1266
+ * @param type
1267
+ * @param fn
1268
+ * @return
1269
+ */
1270
+ bind(type: string, fn: ZeptoEventHandler): ZeptoCollection;
1271
+
1272
+ /**
1273
+ * Attach an event handler that is only triggered when the event originated from a node that matches a selector.
1274
+ * @deprecated use ZeptoCollection.on instead.
1275
+ * @param selector
1276
+ * @param type
1277
+ * @param fn
1278
+ * @return
1279
+ */
1280
+ delegate(selector: string, type: string, fn: ZeptoEventHandler): ZeptoCollection;
1281
+
1282
+ /**
1283
+ * Detach event handler added by live.
1284
+ * @deprecated use ZeptoCollection.off instead.
1285
+ * @param type
1286
+ * @param fn
1287
+ * @return
1288
+ */
1289
+ die(type: string, fn: ZeptoEventHandler): ZeptoCollection;
1290
+
1291
+ /**
1292
+ * @see ZeptoCollection.die
1293
+ * @deprecated use ZeptoCollection.off instead.
1294
+ * @param types
1295
+ */
1296
+ die(types: any): ZeptoCollection;
1297
+
1298
+ /**
1299
+ * Like delegate where the selector is taken from the current collection.
1300
+ * @deprecated use ZeptoCollection.on instead.
1301
+ * @param type
1302
+ * @param fn
1303
+ * @return
1304
+ */
1305
+ live(type: string, fn: ZeptoEventHandler): ZeptoCollection;
1306
+
1307
+ /**
1308
+ * Detach event handlers added with on. To detach a specific event handler, the same function must be passed that was used for on(). Otherwise, just calling this method with an event type with detach all handlers of that type. When called without arguments, it detaches all event handlers registered on current elements.
1309
+ * @param type
1310
+ * @param selector
1311
+ * @param fn
1312
+ * @return
1313
+ */
1314
+ off(type: string, selector: string, fn: ZeptoEventHandler): ZeptoCollection;
1315
+
1316
+ /**
1317
+ * @see ZeptoCollection.off
1318
+ */
1319
+ off(type: string, fn: ZeptoEventHandler): ZeptoCollection;
1320
+
1321
+ /**
1322
+ * @see ZeptoCollection.off
1323
+ */
1324
+ off(type: string, selector?: string): ZeptoCollection;
1325
+
1326
+ /**
1327
+ * @see ZeptoCollection.off
1328
+ */
1329
+ off(): ZeptoCollection;
1330
+
1331
+ /**
1332
+ * @see ZeptoCollection.off
1333
+ * @param events
1334
+ */
1335
+ off(events: ZeptoEventHandlers, selector?: string): ZeptoCollection;
1336
+
1337
+ /**
1338
+ * Add event handlers to the elements in collection. Multiple event types can be passed in a space-separated string, or as an object where event types are keys and handlers are values. If a CSS selector is given, the handler function will only be called when an event originates from an element that matches the selector.
1339
+ * Event handlers are executed in the context of the element to which the handler is attached, or the matching element in case a selector is provided. When an event handler returns false, preventDefault() is called for the current event, preventing the default browser action such as following links.
1340
+ * @param type
1341
+ * @param selector
1342
+ * @param fn
1343
+ * @return
1344
+ */
1345
+ on(type: string, selector: string, fn: ZeptoEventHandler): ZeptoCollection;
1346
+
1347
+ /**
1348
+ * @see ZeptoCollection.on
1349
+ */
1350
+ on(type: string, fn: ZeptoEventHandler): ZeptoCollection;
1351
+ // todo: v0.9 will introduce string literals
1352
+ // on(type: 'ajaxStart', fn: ZeptoAjaxStartEvent): ZeptoCollection;
1353
+ // on(type: 'ajaxBeforeSend', fn: ZeptoAjaxBeforeSendEvent): ZeptoCollection;
1354
+ // on(type: 'ajaxSend', fn: ZeptoAjaxSendEvent): ZeptoCollection;
1355
+ // on(type: 'ajaxSuccess', fn: ZeptoAjaxSuccessEvent): ZeptoCollection;
1356
+ // on(type: 'ajaxError', fn: ZeptoAjaxErrorEvent): ZeptoCollection;
1357
+ // on(type: 'ajaxComplete', fn: ZeptoAjaxCompleteEvent): ZeptoCollection;
1358
+ // on(type: 'ajaxStop', fn: ZeptoAjaxStopEvent): ZeptoCollection;
1359
+
1360
+ /**
1361
+ * @see ZeptoCollection.on
1362
+ * @param events
1363
+ */
1364
+ on(events: ZeptoEventHandlers, selector?: string): ZeptoCollection;
1365
+
1366
+ /**
1367
+ * Adds an event handler that removes itself the first time it runs, ensuring that the handler only fires once.
1368
+ * @param type
1369
+ * @param fn
1370
+ * @return
1371
+ */
1372
+ one(type: string, fn: ZeptoEventHandler): ZeptoCollection;
1373
+
1374
+ /**
1375
+ * @see ZeptoCollection.one
1376
+ * @param events
1377
+ */
1378
+ one(events: ZeptoEventHandlers): ZeptoCollection;
1379
+
1380
+ /**
1381
+ * Trigger the specified event on elements of the collection. Event can either be a string type, or a full event object obtained with $.Event. If a data array is given, it is passed as additional arguments to event handlers.
1382
+ * (!) Zepto only supports triggering events on DOM elements.
1383
+ * @param event
1384
+ * @param data
1385
+ * @return
1386
+ */
1387
+ trigger(event: string, data?: any[]): ZeptoCollection;
1388
+
1389
+ /**
1390
+ * Like trigger, but triggers only event handlers on current elements and doesn’t bubble.
1391
+ * @param event
1392
+ * @param data
1393
+ * @return
1394
+ */
1395
+ triggerHandler(event: string, data?: any[]): ZeptoCollection;
1396
+
1397
+ /**
1398
+ * Detach event handler added with bind.
1399
+ * @deprecated use ZeptoCollection.off instead.
1400
+ * @param type
1401
+ * @param fn
1402
+ * @return
1403
+ */
1404
+ unbind(type: string, fn: ZeptoEventHandler): ZeptoCollection;
1405
+
1406
+ /**
1407
+ * Detach event handler added with delegate.
1408
+ * @deprecated use ZeptoCollection.off instead.
1409
+ * @param selector
1410
+ * @param type
1411
+ * @param fn
1412
+ * @return
1413
+ */
1414
+ undelegate(selector: string, type: string, fn: ZeptoEventHandler): ZeptoCollection;
1415
+
1416
+ focusin(): ZeptoCollection;
1417
+ focusin(fn: ZeptoEventHandler): ZeptoCollection;
1418
+
1419
+ focusout(): ZeptoCollection;
1420
+ focusout(fn: ZeptoEventHandler): ZeptoCollection;
1421
+
1422
+ load(): ZeptoCollection;
1423
+ load(fn: ZeptoEventHandler): ZeptoCollection;
1424
+
1425
+ resize(): ZeptoCollection;
1426
+ resize(fn: ZeptoEventHandler): ZeptoCollection;
1427
+
1428
+ scroll(): ZeptoCollection;
1429
+ scroll(fn: ZeptoEventHandler): ZeptoCollection;
1430
+
1431
+ unload(): ZeptoCollection;
1432
+ unload(fn: ZeptoEventHandler): ZeptoCollection;
1433
+
1434
+ click(): ZeptoCollection;
1435
+ click(fn: ZeptoEventHandler): ZeptoCollection;
1436
+
1437
+ dblclick(): ZeptoCollection;
1438
+ dblclick(fn: ZeptoEventHandler): ZeptoCollection;
1439
+
1440
+ mousedown(): ZeptoCollection;
1441
+ mousedown(fn: ZeptoEventHandler): ZeptoCollection;
1442
+
1443
+ mouseup(): ZeptoCollection;
1444
+ mouseup(fn: ZeptoEventHandler): ZeptoCollection;
1445
+
1446
+ mousemove(): ZeptoCollection;
1447
+ mousemove(fn: ZeptoEventHandler): ZeptoCollection;
1448
+
1449
+ mouseover(): ZeptoCollection;
1450
+ mouseover(fn: ZeptoEventHandler): ZeptoCollection;
1451
+
1452
+ mouseout(): ZeptoCollection;
1453
+ mouseout(fn: ZeptoEventHandler): ZeptoCollection;
1454
+
1455
+ mouseenter(): ZeptoCollection;
1456
+ mouseenter(fn: ZeptoEventHandler): ZeptoCollection;
1457
+
1458
+ mouseleave(): ZeptoCollection;
1459
+ mouseleave(fn: ZeptoEventHandler): ZeptoCollection;
1460
+
1461
+ change(): ZeptoCollection;
1462
+ change(fn: ZeptoEventHandler): ZeptoCollection;
1463
+
1464
+ select(): ZeptoCollection;
1465
+ select(fn: ZeptoEventHandler): ZeptoCollection;
1466
+
1467
+ keydown(): ZeptoCollection;
1468
+ keydown(fn: ZeptoEventHandler): ZeptoCollection;
1469
+
1470
+ keypress(): ZeptoCollection;
1471
+ keypress(fn: ZeptoEventHandler): ZeptoCollection;
1472
+
1473
+ keyup(): ZeptoCollection;
1474
+ keyup(fn: ZeptoEventHandler): ZeptoCollection;
1475
+
1476
+ error(): ZeptoCollection;
1477
+ error(fn: ZeptoEventHandler): ZeptoCollection;
1478
+
1479
+ focus(): ZeptoCollection;
1480
+ focus(fn: ZeptoEventHandler): ZeptoCollection;
1481
+
1482
+ blur(): ZeptoCollection;
1483
+ blur(fn: ZeptoEventHandler): ZeptoCollection;
1484
+
1485
+ /**
1486
+ * Ajax
1487
+ */
1488
+
1489
+ /**
1490
+ * Set the html contents of the current collection to the result of a GET Ajax call to the given URL. Optionally, a CSS selector can be specified in the URL, like so, to use only the HTML content matching the selector for updating the collection:
1491
+ * $('#some_element').load('/foo.html #bar')
1492
+ * If no CSS selector is given, the complete response text is used instead.
1493
+ * Note that any JavaScript blocks found are only executed in case no selector is given.
1494
+ * @param url URL to send the HTTP GET request to.
1495
+ * @param fn Callback function when the HTTP GET request is completed.
1496
+ * @return Self object.
1497
+ * @example
1498
+ * $('#some_element').load('/foo.html #bar')
1499
+ */
1500
+ load(url: string, fn?: (data: any, status: string, xhr: XMLHttpRequest) => void): ZeptoCollection;
1501
+
1502
+ /**
1503
+ * Form
1504
+ */
1505
+
1506
+ /**
1507
+ * Serialize form values to an URL-encoded string for use in Ajax post requests.
1508
+ * @return Seralized form values in URL-encoded string.
1509
+ */
1510
+ serialize(): string;
1511
+
1512
+ /**
1513
+ * Serialize form into an array of objects with name and value properties. Disabled form controls, buttons, and unchecked radio buttons/checkboxes are skipped. The result doesn’t include data from file inputs.
1514
+ * @return Array with name value pairs from the Form.
1515
+ */
1516
+ serializeArray(): any[];
1517
+
1518
+ /**
1519
+ * Trigger or attach a handler for the submit event. When no function given, trigger the “submit” event on the current form and have it perform its submit action unless preventDefault() was called for the event.
1520
+ * When a function is given, this simply attaches it as a handler for the “submit” event on current elements.
1521
+ * @return Self object.
1522
+ */
1523
+ submit(): ZeptoCollection;
1524
+
1525
+ /**
1526
+ * @see ZeptoCollection.submit
1527
+ * @param fn Handler for the 'submit' event on current elements.
1528
+ * @return Self object.
1529
+ */
1530
+ submit(fn: (e: any) => void): ZeptoCollection;
1531
+
1532
+ /**
1533
+ * Effects
1534
+ */
1535
+
1536
+ /**
1537
+ * Smoothly transition CSS properties of elements in the current collection.
1538
+ * @param properties object that holds CSS values to animate to; or CSS keyframe animation name.
1539
+ * Zepto also supports the following CSS transform porperties:
1540
+ * translate(X|Y|Z|3d)
1541
+ * rotate(X|Y|Z|3d)
1542
+ * scale(X|Y|Z)
1543
+ * matrix(3d)
1544
+ * perspective
1545
+ * skew(X|Y)
1546
+ * @param duration (default 400): duration in milliseconds, or a string:
1547
+ * fast (200 ms)
1548
+ * slow (600 ms)
1549
+ * any custom property of $.fx.speeds
1550
+ * @param easing (default linear): specifies the type of animation easing to use, one of:
1551
+ * ease
1552
+ * linear
1553
+ * ease-in
1554
+ * ease-out
1555
+ * ease-in-out
1556
+ * cubic-bezier(x1, y1, x2, y2)
1557
+ * @param complete Callback function when the animation has completed.
1558
+ * @return Self object.
1559
+ * @note If the duration is 0 or $.fx.off is true (default in a browser that doesn’t support CSS transitions), animations will not be executed; instead the target values will take effect instantly. Similarly, when the target CSS properties match the current state of the element, there will be no animation and the complete function won’t be called.
1560
+ * If the first argument is a string instead of object, it is taken as a CSS keyframe animation name.
1561
+ * @note Zepto exclusively uses CSS transitions for effects and animation. jQuery easings are not supported. jQuery's syntax for relative changes ("=+10px") is not supported. See the spec for a list of animatable properties (http://www.w3.org/TR/css3-transitions/#animatable-properties-). Browser support may vary, so be sure to test in all browsers you want to support.
1562
+ */
1563
+ animate(properties: any, duration?: number, easing?: string, complete?: () => void): ZeptoCollection;
1564
+
1565
+ /**
1566
+ * @see ZeptoCollection.animate
1567
+ * @param options Animation options.
1568
+ */
1569
+ animate(properties: any, options: ZeptoAnimateSettings): ZeptoCollection;
1570
+ }
1571
+
1572
+ interface ZeptoAjaxSettings {
1573
+ type?: string | undefined;
1574
+ url?: string | undefined;
1575
+ data?: any;
1576
+ processData?: boolean | undefined;
1577
+ contentType?: string | undefined;
1578
+ mimeType?: string | undefined;
1579
+ dataType?: string | undefined;
1580
+ jsonp?: string | undefined;
1581
+ jsonpCallback?: any; // string or Function
1582
+ timeout?: number | undefined;
1583
+ headers?: { [key: string]: string } | undefined;
1584
+ async?: boolean | undefined;
1585
+ global?: boolean | undefined;
1586
+ context?: any;
1587
+ traditional?: boolean | undefined;
1588
+ cache?: boolean | undefined;
1589
+ xhrFields?: { [key: string]: any } | undefined;
1590
+ username?: string | undefined;
1591
+ password?: string | undefined;
1592
+ beforeSend?: ((xhr: XMLHttpRequest, settings: ZeptoAjaxSettings) => boolean) | undefined;
1593
+ success?: ((data: any, status: string, xhr: XMLHttpRequest) => void) | undefined;
1594
+ error?: ((xhr: XMLHttpRequest, errorType: string, error: Error) => void) | undefined;
1595
+ complete?: ((xhr: XMLHttpRequest, status: string) => void) | undefined;
1596
+ }
1597
+
1598
+ // Fired if no other ajax requests are currently active
1599
+ // event name: ajaxStart
1600
+ interface ZeptoAjaxStartEvent {
1601
+ (): void;
1602
+ }
1603
+
1604
+ // Before sending the request, can be cancelled
1605
+ // event name: ajaxBeforeSend
1606
+ interface ZeptoAjaxBeforeSendEvent {
1607
+ (xhr: XMLHttpRequest, options: ZeptoAjaxSettings): void;
1608
+ }
1609
+
1610
+ // Like ajaxBeforeSend, but not cancellable
1611
+ // event name: ajaxSend
1612
+ interface ZeptoAjaxSendEvent {
1613
+ (xhr: XMLHttpRequest, options: ZeptoAjaxSettings): void;
1614
+ }
1615
+
1616
+ // When the response is success
1617
+ // event name: ajaxSuccess
1618
+ interface ZeptoAjaxSuccessEvent {
1619
+ (xhr: XMLHttpRequest, options: ZeptoAjaxSettings, data: any): void;
1620
+ }
1621
+
1622
+ // When there was an error
1623
+ // event name: ajaxError
1624
+ interface ZeptoAjaxErrorEvent {
1625
+ (xhr: XMLHttpRequest, options: ZeptoAjaxSettings, error: Error): void;
1626
+ }
1627
+
1628
+ // After request has completed, regardless of error or success
1629
+ // event name: ajaxComplete
1630
+ interface ZeptoAjaxCompleteEvent {
1631
+ (xhr: XMLHttpRequest, options: ZeptoAjaxSettings): void;
1632
+ }
1633
+
1634
+ // Fired if this was the last active Ajax request.
1635
+ // event name: ajaxStop
1636
+ interface ZeptoAjaxStopEvent {
1637
+ (): void;
1638
+ }
1639
+
1640
+ interface ZeptoAnimateSettings {
1641
+ duration?: number | undefined;
1642
+ easing?: string | undefined;
1643
+ complete?: (() => void) | undefined;
1644
+ }
1645
+
1646
+ interface ZeptoPosition {
1647
+ top: number;
1648
+ left: number;
1649
+ }
1650
+
1651
+ interface ZeptoCoordinates extends ZeptoPosition {
1652
+ width: number;
1653
+ height: number;
1654
+ }
1655
+
1656
+ interface ZeptoEventHandlers {
1657
+ [key: string]: ZeptoEventHandler;
1658
+ }
1659
+ interface ZeptoEventHandler {
1660
+ (e: Event, ...args: any[]): any;
1661
+ }
1662
+ declare var Zepto: (fn: ($: ZeptoStatic) => void) => void;
1663
+ declare var $: ZeptoStatic;
1664
+
1665
+ export { $ }