File tree Expand file tree Collapse file tree 2 files changed +95
-0
lines changed Expand file tree Collapse file tree 2 files changed +95
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Type definitions for eq.js
2
+ // Project: https://github.com/Snugug/eq.js
3
+ // Definitions by: Stephen Lautier <https://github.com/stephenlautier>
4
+ // Definitions: https://github.com/borisyankov/DefinitelyTyped
5
+
6
+ declare var eqjs : eq . EqjsStatic ;
7
+
8
+ // Support AMD require
9
+ declare module 'eqjs' {
10
+ export = eqjs ;
11
+ }
12
+
13
+ declare module eq {
14
+ type AvailableElementType = HTMLElement | HTMLElement [ ] | NodeList | JQuery ;
15
+
16
+ interface EqjsStatic {
17
+
18
+ /**
19
+ * List of all nodes.
20
+ */
21
+ nodes : EqjsNodesTable ;
22
+
23
+ /**
24
+ * Number of nodes in eqjs.nodes.
25
+ */
26
+ nodesLength : number ;
27
+
28
+ /**
29
+ * Runs through all nodes and finds their widths and points
30
+ * @param nodes
31
+ * @param callback function to use as a callback once query and nodeWrites have finished
32
+ */
33
+ query ( nodes : AvailableElementType , callback ?: Function ) : void ;
34
+
35
+ /**
36
+ * Refreshes the list of nodes for eqjs to work with
37
+ */
38
+ refreshNodes ( ) : void ;
39
+
40
+ /**
41
+ * Sorts a simple object (key: value) by value and returns a sorted object.
42
+ * @param obj e.g. "small: 380, medium: 490, large: 600"
43
+ * @returns { }
44
+ */
45
+ sortObj ( obj : string ) : EqjsKeyValuePair [ ] ;
46
+
47
+ /**
48
+ * Runs through all nodes and writes their eq status.
49
+ * @param nodes An array or NodeList of nodes to query
50
+ * @returns { }
51
+ */
52
+ nodeWrites ( nodes ?: AvailableElementType ) : void ;
53
+ }
54
+
55
+ interface EqjsKeyValuePair {
56
+ key : string ;
57
+ value : number ;
58
+ }
59
+
60
+ interface EqjsNodesTable {
61
+ [ index : number ] : HTMLElement ;
62
+ }
63
+
64
+ }
65
+
66
+ // Support jQuery selectors.
67
+ interface JQuery { }
Original file line number Diff line number Diff line change
1
+ /// <reference path="eqjs.d.ts" />
2
+ /// <reference path="../jquery/jquery.d.ts" />
3
+
4
+ var nodes = document . getElementsByClassName ( ".test-container" ) ;
5
+ var node = document . getElementById ( "#test-container" ) ;
6
+ var $nodes = $ ( ".selector" ) ;
7
+
8
+ eqjs . query ( node ) ;
9
+ eqjs . query ( node , ( ) => { } ) ;
10
+ eqjs . query ( nodes ) ;
11
+ eqjs . query ( $nodes ) ;
12
+
13
+ var nodesCount : number = eqjs . nodesLength ;
14
+
15
+ eqjs . refreshNodes ( ) ;
16
+
17
+ eqjs . nodeWrites ( ) ;
18
+ eqjs . nodeWrites ( node ) ;
19
+ eqjs . nodeWrites ( nodes ) ;
20
+ eqjs . nodeWrites ( $nodes ) ;
21
+
22
+ var sortMap = eqjs . sortObj ( "small: 380, medium: 490, large: 600" ) ;
23
+ var sortFirstKey = sortMap [ 0 ] . key ;
24
+ var sortFirstValue = sortMap [ 0 ] . value ;
25
+
26
+ var nodesMap = eqjs . nodes ;
27
+
28
+ var ele : HTMLElement = nodesMap [ 1 ] ;
You can’t perform that action at this time.
0 commit comments