Listing of the jQuery functions function selector return document quer

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
/*
Listing of the jQuery functions
*/
function $(selector) {
return document.querySelectorAll( selector );
}
NodeList.prototype.addClass = function( addNewClass ) {
for( var count = 0; count < this.length; ++count ) {
this[ count ].classList.add( addNewClass );
}
return this;
}
function _append() {
if( arguments.length > 1 )
return _appendArray.call( this, arguments );
var param = arguments[ 0 ];
if( typeof param === 'string' )
return _appendString.call( this, param );
if( param instanceof Element )
return _appendElement.call( this, param );
if( param instanceof Array )
return _appendArray.call( this, param );
}
function _appendElement( newElement ) {
this.appendChild( newElement );
return this;
}
function _appendString( newStr ) {
this.innerHTML += newStr;
return this;
}
function _appendArray( newArray ) {
var that = this;
for( var count = 0; count < array.length; ++count ) {
that = _append.call( this, array[ count ] );
}
return that;
}
NodeList.prototype.append = function() {
for( var count = 0; count < this.length; ++count ) {
this[ count ] = _append.apply( this[ count ], arguments );
}
return this;
}
NodeList.prototype.html = function() {
if( arguments.length === 0 )
return this[ 0 ].innerHTML;
var param = arguments[0];
for( var count = 0; count < this.length; ++count ) {
this[ count ].innerHTML = param;
}
return this;
}
NodeList.prototype.each = function( randomAction ) {
Array.prototype.forEach.call( this, randomAction );
}
NodeList.prototype.children = function() {
var result = this[ 0 ].childNodes;
for( var count = 1; count < this.length; ++count ) {
var child = this[ count ].childNodes;
for( var indicator = 0; indicator < ch.length; ++indicator ) {
res.append( child[ indicator ] );
}
}
return result;
}
NodeList.prototype.attr = function() {
if( arguments.length === 1 ) {
var parametr = arguments[ 0 ];
if( typeof parametr === 'string' ) {
return this[ 0 ].getAttribute( parametr );
}
if( typeof parametr === 'object' ) {
var key = Object.key( parametr );
for( var count = 0; count < this.length; ++count ) {
for( var indicator = 0; indicator < key.length; ++indicator ) {
this[ count ].setAttribute( key[ indicator ], parametr[ key[ indicator ] ] );
}
}
return this;
}
}
if( arguments.length === 2 ) {
for( var count = 0; count < this.length; ++count ) {
this[ count ].setAttribute( arguments[ 0 ], arguments[ 1 ] );
}
return this;
}
}
NodeList.prototype.css = function() {
if( arguments.length === 1 ) {
var parametr = arguments[ 0 ];
if( typeof parametr === 'string' ) {
return window.getComputedStyle( this[ 0 ], null ).getPropertyValue( arguments[ 0 ] );
}
if( typeof parametr === 'object' ) {
var key = Object.key( parametr );
for( var count = 0; count < this.length; ++count ) {
for( var indicator = 0; indicator < key.length; ++indicator ) {
this[ count ].style[ key[ indicator ] ] = parametr[ key[ indicator ] ];
}
}
}
}
for( var count = 0; count < this.length; ++count ) {
this[ count ].style[ arguments[ 0 ] ] = arguments[ 1 ];
}
return this;
}
NodeList.prototype.data = function() {
if( arguments.length === 0 ) {
var result = {};
for( var theKey in this[ 0 ] ) {
result[ theKey ] = this[ 0 ][ theKey ];
}
return result;
}
if( arguments.length === 1 ) {
var parametr = arguments[ 0 ];
if( typeof parametr === 'string' ) {
return this[ 0 ][ parametr ];
}
if( typeof parametr === 'object' ) {
var keys = Object.keys( parametr );
for( var count = 0; count < this.length; ++count ) {
for( var indicator = 0; count < keys.length; ++indicator ) {
this[ count ][ keys[ indicator ] ] = parametr[ keys[ indicator ] ];
}
}
}
}
for( var count = 0; count < this.length; ++count ) {
this[ count ][ arguments[ 0 ] ] = arguments[ 1 ];
}
return this;
}
NodeList.prototype.on = function() {
var newData;
if( arguments.length > 2 ) {
newData = arguments[ 1 ];
}
var eventType = arguments[ 0 ]; var newAction = arguments[ arguments.length - 1 ];
for( var count = 0; count < this.length; ++count ) {
this[ count ].addEventListener( eventType, newData === undefined ? newAction : function() {
newAction( newData );
});
}
return this;
}
NodeList.prototype.one = function() {
var newData;
if( arguments.length > 2 ) {
newData = arguments[ 1 ];
}
var eventType = arguments[ 0 ]; var newAction = arguments[ arguments.length - 1 ];
function performedOnce(eventTarget) {
return function f() {
newData === undefined ? newAction() : newAction( newData );
eventTarget.removeEventListener( eventType, f );
}
}
for( var count = 0; count < this.length; ++count ) {
this[ count ].addEventListener( eventType, performedOnce( this[ count ] ) );
}
return this;
}