Skip to content
This repository was archived by the owner on Jun 21, 2024. It is now read-only.

Commit 4e74d8c

Browse files
committed
Merge branch 'release/v2.1-final'
2 parents e964970 + 6dc7a93 commit 4e74d8c

File tree

10 files changed

+795
-1968
lines changed

10 files changed

+795
-1968
lines changed

README.md

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,15 @@ Actually, all functions listed behind, are jQuery compatible. Then, all mQuery c
178178

179179
// http://api.jquery.com/append/
180180
.append(...elem: mQuery | NodeList | HTMLElement): this
181+
182+
// http://api.jquery.com/width/
183+
.width(value?: string | number): this | number
184+
185+
// http://api.jquery.com/height/
186+
.height(value?: string | number): this | number
187+
188+
// http://api.jquery.com/load/
189+
.load(url: string, data?: Object | string, complete?: Function): this | number
181190
```
182191

183192
### AJAX
@@ -200,6 +209,15 @@ Actually, all functions listed behind, are jQuery compatible. Then, all mQuery c
200209
m$.Deferred(beforeStart?: Function): Deferred
201210
```
202211

212+
### Shorthand Methods
213+
```typescript
214+
// To use shorthand event methods, declare it using:
215+
m$.shorthands(events: string[])
216+
217+
// Example:
218+
m$.shorthands(['click', 'mouseenter', 'focus'])
219+
```
220+
203221
### Utils
204222
```typescript
205223
// http://api.jquery.com/jQuery.isArrayLike/
@@ -249,14 +267,15 @@ Actually, all functions listed behind, are jQuery compatible. Then, all mQuery c
249267
m$.cookie(key: string, value?: any, options: {timeout: seconds, path: string}): any
250268
```
251269

252-
### On Working...
253-
- [width([size])](http://api.jquery.com/width/)
254-
- [height([size])](http://api.jquery.com/height/)
255-
256270
## Author
257271

258272
- Created and maintained by [Emerson C. Romaneli](https://github.com/ECRomaneli) (@ECRomaneli).
259273

260274
## License
261275

262-
[MIT License](https://github.com/ECRomaneli/mQuery/blob/master/LICENSE.md)
276+
mQuery:
277+
[MIT License](https://github.com/ECRomaneli/mQuery/blob/master/LICENSE.md)
278+
279+
jQuery:
280+
[License Page](https://jquery.org/license/)
281+

dist/module/mquery.d.ts

Lines changed: 55 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export declare function m$(selector?: mQuery | NodeList | Node | Node[] | string
1414
export declare const mQuery: typeof m$;
1515
export declare namespace m$ {
1616
type Class = mQuery;
17-
type Deferred = m$.Promise.Deferred;
17+
type Deferred = Promise.Deferred;
1818
type ForEachIterator<T> = (keyOrIndex: any, value: T) => boolean | void;
1919
type EachIterator = ForEachIterator<HTMLElement>;
2020
type ArrayLikeObject = PlainObject | ArrayLike<any>;
@@ -23,8 +23,8 @@ export declare namespace m$ {
2323
length?: number;
2424
};
2525
type AJAXSuccess = (data?: any, textStatus?: string, XHR?: XMLHttpRequest) => void;
26-
type AJAXDetails = (XHR?: XMLHttpRequest, settingsOrStatus?: PlainObject | string, errorThrown?: string) => void;
27-
type AJAXSettings = {
26+
type AJAXDetails = (XHR?: XMLHttpRequest, optionsOrStatus?: PlainObject | string, errorThrown?: string) => void;
27+
type AJAXOptions = {
2828
method?: string;
2929
beforeSend?: AJAXDetails;
3030
complete?: AJAXDetails;
@@ -63,6 +63,7 @@ export declare namespace m$ {
6363
*/
6464
class mQuery implements ArrayLike<HTMLElement> {
6565
[index: number]: HTMLElement;
66+
[key: string]: any;
6667
prevObject?: mQuery;
6768
length: number;
6869
/**
@@ -86,7 +87,7 @@ export declare namespace m$ {
8687
* Specify a function to execute when the DOM is fully loaded.
8788
* @param handler A function to execute after the DOM is ready.
8889
*/
89-
ready(handler: EventListener): this;
90+
ready(handler: Function): this;
9091
/**
9192
* Iterate over a mQuery object, executing a function for each matched element.
9293
* @param handler A function to execute for each matched element.
@@ -382,8 +383,41 @@ export declare namespace m$ {
382383
* @param index A zero-based integer indicating which element to retrieve.
383384
*/
384385
get(index?: number): HTMLElement[] | HTMLElement;
385-
width(value?: any): mQuery | number;
386-
height(value?: any): mQuery | number;
386+
/**
387+
* Get the current computed width for the first element in the set of matched elements.
388+
*/
389+
width(): number;
390+
/**
391+
* Set the CSS width of each element in the set of matched elements.
392+
* @param valueFn A function returning the width to set. Receives the index and the old width. "this" refers to the current element in the set.
393+
*/
394+
width(valueFn: (index?: number, width?: number) => string | number): mQuery;
395+
/**
396+
* Set the CSS width of each element in the set of matched elements.
397+
* @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string).
398+
*/
399+
width(value: string | number): mQuery;
400+
/**
401+
* Get the current computed height for the first element in the set of matched elements.
402+
*/
403+
height(): number;
404+
/**
405+
* Set the CSS height of every matched element.
406+
* @param valueFn A function returning the height to set. Receives the index and the old height. "this" refers to the current element in the set.
407+
*/
408+
height(valueFn: (index?: number, width?: number) => string | number): mQuery;
409+
/**
410+
* Set the CSS height of every matched element.
411+
* @param value An integer representing the number of pixels, or an integer with an optional unit of measure appended (as a string).
412+
*/
413+
height(value: string | number): mQuery;
414+
/**
415+
* Load data from the server and place the returned HTML into the matched element.
416+
* @param url A string containing the URL to which the request is sent.
417+
* @param data A plain object or string that is sent to the server with the request.
418+
* @param complete A callback function that is executed when the request completes.
419+
*/
420+
load(url: any, data?: AJAXSuccess | any, complete?: AJAXSuccess): this;
387421
/**
388422
* Merge the contents of an object onto the mQuery prototype to provide new mQuery instance methods.
389423
* @param obj An object to merge onto the jQuery prototype.
@@ -494,20 +528,25 @@ export declare namespace m$ {
494528
timeout?: number;
495529
path?: string;
496530
}): void;
531+
/**
532+
* Set default values for future Ajax requests. Its use is not recommended.
533+
* @param options A set of key/value pairs that configure the default Ajax request. All options are optional.
534+
*/
535+
function ajaxSetup(options: AJAXOptions): PlainObject;
497536
/**
498537
* Perform an asynchronous HTTP (Ajax) request.
499538
* @param url A string containing the URL to which the request is sent.
500539
*/
501540
function ajax(url: string): Deferred;
502541
/**
503-
* @param settings AJAX options.
542+
* @param options AJAX options.
504543
*/
505-
function ajax(settings: AJAXSettings): Deferred;
544+
function ajax(options: AJAXOptions): Deferred;
506545
/**
507546
* @param url A string containing the URL to which the request is sent.
508-
* @param settings AJAX options.
547+
* @param options AJAX options.
509548
*/
510-
function ajax(url: string, settings: AJAXSettings): Deferred;
549+
function ajax(url: string, options: AJAXOptions): Deferred;
511550
/**
512551
* Load data from the server using a HTTP GET request.
513552
* @param url A string containing the URL to which the request is sent.
@@ -523,9 +562,9 @@ export declare namespace m$ {
523562
function get(url: string, data: any, success: AJAXSuccess): Deferred;
524563
/**
525564
* Load data from the server using a HTTP GET request.
526-
* @param settings A set of key/value pairs that configure the Ajax request.
565+
* @param options A set of key/value pairs that configure the Ajax request.
527566
*/
528-
function get(settings: AJAXSettings): Deferred;
567+
function get(options: AJAXOptions): Deferred;
529568
/**
530569
* Load data from the server using a HTTP POST request.
531570
* @param url A string containing the URL to which the request is sent.
@@ -541,9 +580,9 @@ export declare namespace m$ {
541580
function post(url: string, data: any, success: AJAXSuccess): Deferred;
542581
/**
543582
* Load data from the server using a HTTP POST request.
544-
* @param settings A set of key/value pairs that configure the Ajax request.
583+
* @param options A set of key/value pairs that configure the Ajax request.
545584
*/
546-
function post(settings: AJAXSettings): Deferred;
585+
function post(options: AJAXOptions): Deferred;
547586
function param(obj: ArrayLikeObject, tradicional?: boolean): string;
548587
/**
549588
* Set event shorthand methods.
@@ -555,7 +594,7 @@ export declare namespace m$ {
555594
* @param beforeStart A function that is called just before the constructor returns.
556595
*/
557596
function Deferred(beforeStart?: Function): Deferred;
558-
const ready: (handler: EventListener) => mQuery;
597+
const ready: (handler: Function) => mQuery;
559598
}
560599
export declare namespace m$.Promise {
561600
enum State {
@@ -580,6 +619,6 @@ export declare namespace m$.Promise {
580619
done(callback: (...args: any[]) => void): Deferred;
581620
fail(callback: (...args: any[]) => void): Deferred;
582621
then(successFilter: (...args: any[]) => any, errorFilter?: (...args: any[]) => any): Deferred;
583-
allways(callback: (...args: any[]) => void): Deferred;
622+
always(callback: (...args: any[]) => void): Deferred;
584623
}
585624
}

0 commit comments

Comments
 (0)