-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
1198 lines (826 loc) · 43.8 KB
/
index.html
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta property="og:title" content="Rye">
<meta property="og:image" content="http://ryejs.com/images/rye-share.png">
<meta property="og:description" content="Rye is a lightweight (6k only!) JS library for DOM manipulation and events for the modern web. Touch events/gestures, event emitter, isolated DOM events and more!">
<title>Rye</title>
<link rel="stylesheet" href="styles/main.css?h=6ecdf9478098f894387acaf37cab85e1">
<link rel="icon" type="image/png" href="/images/favicon.png">
<link rel="shortcut icon" href="/favicon.ico">
<script>
var _gaq = [
['_setAccount', 'UA-37660534-1']
, ['_trackPageview']
]
;(function(){
var ga = document.createElement('script')
, s = document.getElementsByTagName('script')[0]
ga.type = 'text/javascript'
ga.async = true
ga.src = 'http://www.google-analytics.com/ga.js'
s.parentNode.insertBefore(ga, s)
})()
</script>
</head>
<body>
<header class="header">
<h1 class="logo">Rye</h1>
<ol class="download" role="group" aria-label="Download options">
<li>
<input type="radio" id="download-production" name="purpose" checked aria-hidden="true">
<label for="download-production" aria-hidden="true">Production <span>(6.3KB, Minified + GZip)</span></label>
<a href="dist/rye-0.1.3.min.js" class="button" role="button">Download Rye 0.1.3 <span class="vhidden">for production</span></a>
</li>
<li>
<input type="radio" id="download-development" name="purpose" aria-hidden="true">
<label for="download-development" aria-hidden="true">Development <span>(44.4KB, Uncompressed)</span></label>
<a href="dist/rye-0.1.3.js" class="button" role="button">Download Rye 0.1.3 <span class="vhidden">for development</span></a>
</li>
</ol>
</header>
<div class="navigation">
<div class="content">
<a href="/" class="home" rel="home">rye.js <span>(0.1.3)</span></a>
<nav>
<ul>
<li><a href="#rye">Rye</a>
<ul><li><a href="#rye-constructor">Constructor</a></li>
<li><a href="#rye-ryedefine">Rye.define</a></li>
<li><a href="#rye-ryerequire">Rye.require</a></li></ul></li>
<li><a href="#data">Data</a>
<ul><li><a href="#data-data">data</a></li>
<li><a href="#data-@set" class="module" >@set</a></li>
<li><a href="#data-@get" class="module" >@get</a></li></ul></li>
<li><a href="#traversal">Traversal</a>
<ul><li><a href="#traversal-find">find</a></li>
<li><a href="#traversal-index">index</a></li>
<li><a href="#traversal-add">add</a></li>
<li><a href="#traversal-plucknode">pluckNode</a></li>
<li><a href="#traversal-next">next</a></li>
<li><a href="#traversal-prev">prev</a></li>
<li><a href="#traversal-siblings">siblings</a></li>
<li><a href="#traversal-parent">parent</a></li>
<li><a href="#traversal-parents">parents</a></li>
<li><a href="#traversal-closest">closest</a></li>
<li><a href="#traversal-children">children</a></li></ul></li>
<li><a href="#filter">Filter</a>
<ul><li><a href="#filter-filter">filter</a></li>
<li><a href="#filter-filternot">filter not</a></li>
<li><a href="#filter-contains">contains</a></li>
<li><a href="#filter-is">is</a></li>
<li><a href="#filter-first">first</a></li>
<li><a href="#filter-last">last</a></li></ul></li>
<li><a href="#query">Query</a>
<ul><li><a href="#query-@matches" class="module" >@matches</a></li>
<li><a href="#query-@qsa" class="module" >@qsa</a></li>
<li><a href="#query-@getclosestnode" class="module" >@getClosestNode</a></li></ul></li>
<li><a href="#collection">Collection</a>
<ul><li><a href="#collection-get">get</a></li>
<li><a href="#collection-eq">eq</a></li>
<li><a href="#collection-foreach">forEach</a></li>
<li><a href="#collection-reduce">reduce</a></li>
<li><a href="#collection-reduceright">reduceRight</a></li>
<li><a href="#collection-indexof">indexOf</a></li>
<li><a href="#collection-map">map</a></li>
<li><a href="#collection-sort">sort</a></li>
<li><a href="#collection-each">each</a></li>
<li><a href="#collection-iterate">iterate</a></li>
<li><a href="#collection-push">push</a></li>
<li><a href="#collection-slice">slice</a></li>
<li><a href="#collection-concat">concat</a></li>
<li><a href="#collection-pluck">pluck</a></li>
<li><a href="#collection-put">put</a></li></ul></li>
<li><a href="#manipulation">Manipulation</a>
<ul><li><a href="#manipulation-text">text</a></li>
<li><a href="#manipulation-html">html</a></li>
<li><a href="#manipulation-empty">empty</a></li>
<li><a href="#manipulation-append">append</a></li>
<li><a href="#manipulation-prepend">prepend</a></li>
<li><a href="#manipulation-after">after</a></li>
<li><a href="#manipulation-before">before</a></li>
<li><a href="#manipulation-clone">clone</a></li>
<li><a href="#manipulation-remove">remove</a></li>
<li><a href="#manipulation-val">val</a></li>
<li><a href="#manipulation-attr">attr</a></li>
<li><a href="#manipulation-removeattr">removeAttr</a></li>
<li><a href="#manipulation-prop">prop</a></li>
<li><a href="#manipulation-ryecreate">Rye.create</a></li>
<li><a href="#manipulation-@getvalue" class="module" >@getValue</a></li>
<li><a href="#manipulation-@getattribute" class="module" >@getAttribute</a></li></ul></li>
<li><a href="#style">Style</a>
<ul><li><a href="#style-show">show</a></li>
<li><a href="#style-hide">hide</a></li>
<li><a href="#style-css">css</a></li>
<li><a href="#style-hasclass">hasClass</a></li>
<li><a href="#style-addclass">addClass</a></li>
<li><a href="#style-removeclass">removeClass</a></li>
<li><a href="#style-toggleclass">toggleClass</a></li>
<li><a href="#style-@getcss" class="module" >@getCSS</a></li>
<li><a href="#style-@setcss" class="module" >@setCSS</a></li>
<li><a href="#style-@hasclass" class="module" >@hasClass</a></li>
<li><a href="#style-@addclass" class="module" >@addClass</a></li>
<li><a href="#style-@removeclass" class="module" >@removeClass</a></li></ul></li>
<li><a href="#eventemitter">Event Emitter</a>
<ul><li><a href="#eventemitter-addlisteneron">addListener (on)</a></li>
<li><a href="#eventemitter-once">once</a></li>
<li><a href="#eventemitter-removelistener">removeListener</a></li>
<li><a href="#eventemitter-trigger">trigger</a></li>
<li><a href="#eventemitter-proxy">proxy</a></li></ul></li>
<li><a href="#domeventemitter">DOM Event Emitter</a>
<ul><li><a href="#domeventemitter-addlisteneron">addListener (on)</a></li>
<li><a href="#domeventemitter-onceone">once (one)</a></li>
<li><a href="#domeventemitter-removelisteneroff">removeListener (off)</a></li>
<li><a href="#domeventemitter-destroy">destroy</a></li>
<li><a href="#domeventemitter-trigger">trigger</a></li>
<li><a href="#domeventemitter-emit">emit</a></li>
<li><a href="#domeventemitter-proxy">proxy</a></li></ul></li>
<li><a href="#events">Events</a>
<ul><li><a href="#events-addlistener">addListener</a></li>
<li><a href="#events-once">once</a></li>
<li><a href="#events-removelistener">removeListener</a></li>
<li><a href="#events-trigger">trigger</a></li>
<li><a href="#events-@getemitter" class="module" >@getEmitter</a></li>
<li><a href="#events-@createevent" class="module" >@createEvent</a></li>
<li><a href="#events-@addlistener" class="module" >@addListener</a></li>
<li><a href="#events-@once" class="module" >@once</a></li>
<li><a href="#events-@removelistener" class="module" >@removeListener</a></li>
<li><a href="#events-@trigger" class="module" >@trigger</a></li>
<li><a href="#events-ryesubscribe">Rye.subscribe</a></li>
<li><a href="#events-ryeunsubscribe">Rye.unsubscribe</a></li>
<li><a href="#events-ryepublish">Rye.publish</a></li></ul></li>
<li><a href="#touchevents">Touch Events</a></li>
<li><a href="#request">Request</a>
<ul><li><a href="#request-ryerequest">Rye.request()</a></li>
<li><a href="#request-ryeget">Rye.get()</a></li>
<li><a href="#request-ryepost">Rye.post()</a></li>
<li><a href="#request-serialize">serialize</a></li>
<li><a href="#request-@request" class="module" >@request</a></li>
<li><a href="#request-@serialize" class="module" >@serialize</a></li>
<li><a href="#request-@appendquery" class="module" >@appendQuery</a></li>
<li><a href="#request-@defaults" class="module" >@defaults</a></li>
<li><a href="#request-@get" class="module" >@get</a></li>
<li><a href="#request-@post" class="module" >@post</a></li></ul></li>
<li><a href="#util">Util</a>
<ul><li><a href="#util-@extend" class="module" >@extend</a></li>
<li><a href="#util-@inherits" class="module" >@inherits</a></li>
<li><a href="#util-@iselement" class="module" >@isElement</a></li>
<li><a href="#util-@isnodelist" class="module" >@isNodeList</a></li>
<li><a href="#util-@unique" class="module" >@unique</a></li>
<li><a href="#util-@pluck" class="module" >@pluck</a></li>
<li><a href="#util-@put" class="module" >@put</a></li>
<li><a href="#util-@prefix" class="module" >@prefix</a></li>
<li><a href="#util-@applier" class="module" >@applier</a></li>
<li><a href="#util-@curry" class="module" >@curry</a></li>
<li><a href="#util-@getuid" class="module" >@getUid</a></li>
<li><a href="#util-@type" class="module" >@type</a></li>
<li><a href="#util-@is" class="module" >@is</a></li></ul></li>
</ul>
</nav>
</div>
</div>
<div role="main">
<section class="manifesto">
<p><strong>Rye</strong> is a lightweight javascript library for DOM manipulation and events with support for <strong>all modern browsers</strong>, including IE9+. It has support for <strong>touch events</strong>/gestures, an <strong>event emitter</strong>, <strong>isolated DOM events</strong> and more.</p>
<div class="buttons" aria-hidden="true">
<iframe src="http://ghbtns.com/github-btn.html?user=ryejs&repo=rye&type=watch&count=true&size=small" allowtransparency="true" frameborder="0" scrolling="0" width="95" height="20"></iframe>
<iframe src="http://ghbtns.com/github-btn.html?user=ryejs&repo=rye&type=fork&count=true&size=small" allowtransparency="true" frameborder="0" scrolling="0" width="95" height="20"></iframe>
</div>
<h1 id="introduction">Introduction</h1>
<p>Rye is a browser library written from the ground-up with modern browsers in mind. It is an attempt to bring together the best practices in javascript, borrowing from both browser and node.js code patterns. </p>
<p>It also tries to be as minimal as possible, using standard browser APIs and ES5 methods whenever possible. Reading the <a href="https://github.com/ryejs/rye/tree/master/lib">source code</a> is encouraged.</p>
<p>Rye is built as a collection of modules. You can use it whole, or just import specific modules you need. The API should be familiar to everyone who has worked with jQuery or Zepto, but not totally compatible; inconsistencies like <code>.map/.each</code> argument order and behavior have been fixed, and follow the native <code>map/forEach</code> methods.</p>
<p>One important thing to note is that Rye doesn't try to subclass <code>Array</code> in any way. A <code>Rye</code> instance is just a standard object, with the current elements selection stored in the <code>.elements</code> array. All standard ES5 array methods are available and operate on the elements collection; while still providing traversing methods you might know from other libraries like <code>.next</code>, <code>.prev</code>, <code>.children</code>, etc.</p>
<h2 id="browsercompatibility">Browser compatibility</h2>
<table>
<thead>
<tr>
<th style="text-align:left;"> Desktop Browser </th>
<th style="text-align:left;"> Version </th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left;"> Chrome </td>
<td style="text-align:left;"> 6+ </td>
</tr>
<tr>
<td style="text-align:left;"> Safari </td>
<td style="text-align:left;"> 5+ </td>
</tr>
<tr>
<td style="text-align:left;"> Firefox </td>
<td style="text-align:left;"> 6+ </td>
</tr>
<tr>
<td style="text-align:left;"> IE </td>
<td style="text-align:left;"> 9+ </td>
</tr>
<tr>
<td style="text-align:left;"> Opera </td>
<td style="text-align:left;"> 11.5+ </td>
</tr>
</tbody>
</table>
<table>
<thead>
<tr>
<th style="text-align:left;"> Mobile Browser </th>
<th style="text-align:left;"> Version </th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left;"> iOS Safari </td>
<td style="text-align:left;"> 4.1+ (6.0.1) </td>
</tr>
<tr>
<td style="text-align:left;"> Chrome (Android) </td>
<td style="text-align:left;"> 18+ (18) </td>
</tr>
<tr>
<td style="text-align:left;"> Android Browser </td>
<td style="text-align:left;"> 4.0+ </td>
</tr>
<tr>
<td style="text-align:left;"> Firefox (Android) </td>
<td style="text-align:left;"> 15+ (18) </td>
</tr>
<tr>
<td style="text-align:left;"> Blackberry </td>
<td style="text-align:left;"> 10+ </td>
</tr>
<tr>
<td style="text-align:left;"> Opera Mobile </td>
<td style="text-align:left;"> 11.1+ (12.1) </td>
</tr>
</tbody>
</table>
<h2 id="thingsryewontdo">Things Rye won't do</h2>
<ul>
<li>event aliases like <code>delegate</code>, <code>live</code>, <code>click</code>, <code>focus</code></li>
<li>cancel bubbling and prevent default by returning <code>false</code></li>
<li>effects and animation - use CSS transitions</li>
<li>export a global <code>$</code> variable</li>
<li>event namespacing (use your own <a href="#domeventemitter"><code>DOMEventEmitter</code></a> instead)</li>
<li>chain-aware methods like <code>end()</code></li>
</ul>
</section>
<div class="main">
<section class="section-rye"><h1 id="rye">Rye</h1>
<h2 id="rye-constructor">Constructor</h2>
<pre><code>Rye(selector[, context]) <span>⤳ rye collection</span>
Rye(element) <span>⤳ rye collection</span>
Rye(elements) <span>⤳ rye collection</span>
</code></pre>
<p>Creates a Rye collection object.</p>
<h2 id="rye-ryedefine">Rye.define</h2>
<pre><code>Rye.define(name, fn)
</code></pre>
<p>Stores the function named by a string.</p>
<h2 id="rye-ryerequire">Rye.require</h2>
<pre><code>Rye.require(name) <span>⤳ function</span>
</code></pre>
<p>Requires the function stored. All code in Rye is allocated as modules.</p></section>
<section class="section-data"><h1 id="data">Data</h1>
<p>Store arbitrary data associated with the matched elements.</p>
<h2 id="data-data">data</h2>
<pre><code>.data(key[, value]) <span>⤳ self</span>
.data({property: value, ...}) <span>⤳ self</span>
</code></pre>
<p>Get or set data attached to each element in the <code>.elements</code> array.</p>
<h2 id="data-@set">@set</h2>
<pre><code>data.set(element, key, value)
</code></pre>
<p>Stores <code>value</code> in <code>key</code> for <code>element</code>.</p>
<h2 id="data-@get">@get</h2>
<pre><code>data.get(element, key) <span>⤳ mixed</span>
</code></pre>
<p>Returns the value in <code>key</code> for <code>element</code>.</p></section>
<section class="section-query"><h1 id="traversal">Traversal</h1>
<h2 id="traversal-find">find</h2>
<pre><code>.find(selector) <span>⤳ rye collection</span>
</code></pre>
<p>Returns a new Rye collection containing the descendants of the current <code>collection.elements</code>, filtered by <code>selector</code>. Uses <code>.querySelectorAll</code> when available.</p>
<h2 id="traversal-index">index</h2>
<pre><code>.index(selector) <span>⤳ number</span>
</code></pre>
<p>Returns the index at which an element matching <code>selector</code> can be found. If no argument given, returns the index of the first element in the collection relative to it's siblings.</p>
<h2 id="traversal-add">add</h2>
<pre><code>.add(elements) <span>⤳ rye collection</span>
.add(Rye) <span>⤳ rye collection</span>
.add(selector[, context]) <span>⤳ rye collection</span>
</code></pre>
<p>Add elements to <code>collection.elements</code> and return a new collection. Unlike <code>push</code> it doesn't modify the objects <code>.elements</code> array.</p>
<h2 id="traversal-plucknode">pluckNode</h2>
<pre><code>.pluckNode(property) <span>⤳ rye collection</span>
</code></pre>
<p>Uses DOM APIs to create a new set of elements. <code>property</code> should be a method of <code>HTMLElement</code>, ex. <code>parentNode</code> or <code>childNodes</code>. Filters nodes using <a href="#util-@iselement"><code>util.isElement</code></a>.</p>
<p>Used internally by <code>next()</code> and <code>prev()</code>.</p>
<h2 id="traversal-next">next</h2>
<pre><code>.next() <span>⤳ rye collection</span>
</code></pre>
<p>Get the immediately following sibling of each element in collection.</p>
<h2 id="traversal-prev">prev</h2>
<pre><code>.prev() <span>⤳ rye collection</span>
</code></pre>
<p>Get the immediately preceding sibling of each element in collection.</p>
<h2 id="traversal-siblings">siblings</h2>
<pre><code>.siblings() <span>⤳ rye collection</span>
</code></pre>
<p>Get all the siblings of each element in collection. Returns a unique set.</p>
<h2 id="traversal-parent">parent</h2>
<pre><code>.parent([selector]) <span>⤳ rye collection</span>
</code></pre>
<p>Get the parent of each element in collection, optionally filtered by <code>selector</code>.</p>
<h2 id="traversal-parents">parents</h2>
<pre><code>.parents([selector]) <span>⤳ rye collection</span>
</code></pre>
<p>Get the ancestors of each element in collection, optionally filtered by <code>selector</code>.</p>
<h2 id="traversal-closest">closest</h2>
<pre><code>.closest(selector) <span>⤳ rye collection</span>
</code></pre>
<p>For each element in collection, get the first element that matches <code>selector</code> by testing the element itself then traversing up through its ancestors.</p>
<h2 id="traversal-children">children</h2>
<pre><code>.children([selector]) <span>⤳ rye collection</span>
</code></pre>
<p>Get the children of each element in collection, optionally filtered by <code>selector</code>.</p>
<h1 id="filter">Filter</h1>
<h2 id="filter-filter">filter</h2>
<pre><code>.filter(selector[, inverse]) <span>⤳ rye collection</span>
.filter(element[, inverse]) <span>⤳ rye collection</span>
.filter(Rye[, inverse]) <span>⤳ rye collection</span>
.filter(fn[, inverse]) <span>⤳ rye collection</span>
</code></pre>
<p>Returns a new collection keeping elements that match <code>selector</code>, <code>element</code>, <code>Rye</code> or for which <code>fn</code> returns <code>true</code>, as in <code>Array.prototype.filter</code>.</p>
<p>Provide a truthy value to <code>inverse</code> to reverse the result set.</p>
<h2 id="filter-filternot">filter not</h2>
<pre><code>.filter('!' + selector) <span>⤳ rye collection</span>
</code></pre>
<p>Aliast to <code>.filter(selector, inverse=true)</code>. Example: `collection.filter('!.someclass').</p>
<h2 id="filter-contains">contains</h2>
<pre><code>.contains(selector) <span>⤳ rye collection</span>
</code></pre>
<p>Returns a new collection containg elements where at least one descendant matches <code>seletor</code>.</p>
<h2 id="filter-is">is</h2>
<pre><code>.is(selector) <span>⤳ boolean</span>
.is(element[, inverse]) <span>⤳ boolean</span>
.is(Rye[, inverse]) <span>⤳ boolean</span>
.is(fn[, inverse]) <span>⤳ boolean</span>
</code></pre>
<p>Check if the current collection matches <code>selector</code>, <code>element</code>, or the provided function.</p>
<h2 id="filter-first">first</h2>
<pre><code>.first() <span>⤳ rye collection</span>
</code></pre>
<p>Get the first element in the collection.</p>
<h2 id="filter-last">last</h2>
<pre><code>.last() <span>⤳ rye collection</span>
</code></pre>
<p>Get the last element in the collection.</p>
<h1 id="query">Query</h1>
<p>Stand-alone usage: <code>var query = Rye.require('Query')</code></p>
<p>Query utilities implemented using <code>querySelectorAll</code> and <code>matchesSelector</code> APIs.</p>
<h2 id="query-@matches">@matches</h2>
<pre><code>query.matches(element, selector) <span>⤳ boolean</span>
query.matches(element, element) <span>⤳ boolean</span>
query.matches(element, Rye) <span>⤳ boolean</span>
</code></pre>
<p>Check that element matches <code>selector</code>, <code>element</code> or another collection. Uses native <code>matchesSelector</code> when available.</p>
<h2 id="query-@qsa">@qsa</h2>
<pre><code>query.qsa(element, selector) <span>⤳ array</span>
</code></pre>
<p>Perform a CSS selector query using <code>element</code> as root. Uses <code>querySelectorAll</code>, returns a standard <code>Array</code>.</p>
<h2 id="query-@getclosestnode">@getClosestNode</h2>
<pre><code>query.getClosestNode(element, method[, selector]) <span>⤳ element</span>
</code></pre>
<p>Traversing helper. Recursively call <code>method</code> on <code>element</code> until <code>element</code> matches <code>selector</code>. Returns HTML nodes only.</p></section>
<section class="section-collection"><h1 id="collection">Collection</h1>
<h2 id="collection-get">get</h2>
<pre><code>.get(index) <span>⤳ element<br></span>
.get() <span>⤳ array</span>
</code></pre>
<p>Return the element at <code>collection.elements[index]</code>. If no argument given, return a copy of the <code>.elements</code> array.</p>
<h2 id="collection-eq">eq</h2>
<pre><code>.eq(index) <span>⤳ rye collection<br></span>
.eq() <span>⤳ empty rye collection</span>
</code></pre>
<p>Same as <code>.get()</code>, but returns the element as a Rye collection. If no argument given, return an empty collection.</p>
<h2 id="collection-foreach">forEach</h2>
<pre><code>.forEach(callback[, thisArg]) <span>⤳ array</span>
</code></pre>
<p>Call <code>Array.prototype.forEach</code> on <code>collection.elements</code>. Callback receives <code>(value, index, array)</code>.</p>
<h2 id="collection-reduce">reduce</h2>
<pre><code>.reduce(callback[, initialValue]) <span>⤳ array</span>
</code></pre>
<p>Call <code>Array.prototype.reduce</code> on <code>collection.elements</code>. Callback receives <code>(previousValue, currentValue, index, array)</code>.</p>
<h2 id="collection-reduceright">reduceRight</h2>
<pre><code>.reduceRight(callback[, initialValue]) <span>⤳ array</span>
</code></pre>
<p>Same as <a href="#collection-reduce"><code>.reduce</code></a> but operates from right-to-left. Callback receives <code>(previousValue, currentValue, index, array)</code>.</p>
<h2 id="collection-indexof">indexOf</h2>
<pre><code>.indexOf(element[, fromIndex]) <span>⤳ array</span>
</code></pre>
<p>Call <code>Array.prototype.indexOf</code> on <code>collection.elements</code>. Returns the first index
at which the element is found, or -1 if it is not present.</p>
<h2 id="collection-map">map</h2>
<pre><code>.map(callback[, thisArg]) <span>⤳ rye collection</span>
</code></pre>
<p>Calls <code>Array.prototype.map</code> on <code>collection.elements</code>. Returns a new array with the result of calling <code>callback</code> on each element of the array. Callback receives <code>(value, index, array)</code>.</p>
<h2 id="collection-sort">sort</h2>
<pre><code>.sort([fn]) <span>⤳ rye collection</span>
</code></pre>
<p>Calls <code>Array.prototype.sort</code> on <code>collection.elements</code>, with <code>fn</code> as comparison function.</p>
<h2 id="collection-each">each</h2>
<pre><code>.each(callback) <span>⤳ self</span>
</code></pre>
<p>Alias for <a href="#collection-foreach"><code>.forEach</code></a>.</p>
<h2 id="collection-iterate">iterate</h2>
<pre><code>.iterate(fn, context) <span>⤳ function</span>
</code></pre>
<p>Returns a function that will call <code>fn</code> with <code>context</code> for every element in <code>collection.elements</code>. The function receives the current element plus the arguments given on invocation.</p>
<h2 id="collection-push">push</h2>
<pre><code>.push(element) <span>⤳ index</span>
</code></pre>
<p>Add an element to <code>collection.elements</code>. Returns the new element index.</p>
<h2 id="collection-slice">slice</h2>
<pre><code>.slice(start, end) <span>⤳ rye collection</span>
</code></pre>
<p>Calls <code>Array.prototype.slice</code> on <code>collection.elements</code>.</p>
<h2 id="collection-concat">concat</h2>
<pre><code>.concat(elements, ...) <span>⤳ rye collection</span>
</code></pre>
<p>Concatenates an array to <code>collection.elements</code>. Accepts instances of Rye.</p>
<h2 id="collection-pluck">pluck</h2>
<pre><code>.pluck(property) <span>⤳ array</span>
</code></pre>
<p>Plucks the value of <code>property</code> for each element in <code>collection.elements</code>. Alias for <a href="#util-@pluck"><code>util.pluck</code></a>.</p>
<h2 id="collection-put">put</h2>
<pre><code>.put(property, value) <span>⤳ array</span>
</code></pre>
<p>Sets <code>property</code> to <code>value</code> for each element in <code>collection.elements</code>. Alias for <a href="#util-@put"><code>util.put</code></a>.</p></section>
<section class="section-manipulation"><h1 id="manipulation">Manipulation</h1>
<h2 id="manipulation-text">text</h2>
<pre><code>.text(text) <span>⤳ self</span>
.text() <span>⤳ text</span>
</code></pre>
<p>Set or get <code>textContent</code>. If no argument given, returns the first element's value.</p>
<h2 id="manipulation-html">html</h2>
<pre><code>.html(html) <span>⤳ self</span>
.html() <span>⤳ html</span>
</code></pre>
<p>Set or get <code>innerHTML</code>. If no argument given, returns the first element's value.</p>
<h2 id="manipulation-empty">empty</h2>
<pre><code>.empty() <span>⤳ self</span>
</code></pre>
<p>Sets <code>innerHTML</code> to an empty string <code>''</code> for all elements.</p>
<h2 id="manipulation-append">append</h2>
<pre><code>.append(html) <span>⤳ self</span>
.append(element) <span>⤳ self</span>
</code></pre>
<p>Append <code>html</code> or <code>element</code> to each element in the collection. If the argument is an HTML element, it is cloned before each operation.</p>
<h2 id="manipulation-prepend">prepend</h2>
<pre><code>.prepend(html) <span>⤳ self</span>
.prepend(element) <span>⤳ self</span>
</code></pre>
<p>Prepend 'html' or 'element' to each element in the collection.</p>
<h2 id="manipulation-after">after</h2>
<pre><code>.after(html) <span>⤳ self</span>
.after(element) <span>⤳ self</span>
</code></pre>
<p>Insert <code>html</code> or <code>element</code> <em>after</em> each element in the collection.</p>
<h2 id="manipulation-before">before</h2>
<pre><code>.before(html) <span>⤳ self</span>
.before(element) <span>⤳ self</span>
</code></pre>
<p>Insert <code>html</code> or <code>element</code> <em>before</em> each element in the collection.</p>
<h2 id="manipulation-clone">clone</h2>
<pre><code>.clone(deep) <span>⤳ rye collection</span>
</code></pre>
<p>Clone elements with <a href="https://developer.mozilla.org/en-US/docs/DOM/Node.cloneNode"><code>cloneNode(deep)</code></a>. <code>deep</code> defaults to true (copy all child nodes). </p>
<h2 id="manipulation-remove">remove</h2>
<pre><code>.remove() <span>⤳ rye collection</span>
</code></pre>
<p>Remove elements that are in the collection. </p>
<h2 id="manipulation-val">val</h2>
<pre><code>.val() <span>⤳ string</span>
.val(value) <span>⤳ self</span>
</code></pre>
<p>Get or set the <code>value</code> property for all elements. If no argument given, returns value for the first element only. For a <code><select multiple></code> an array of values is returned.</p>
<h2 id="manipulation-attr">attr</h2>
<pre><code>.attr(name) <span>⤳ string</span>
.attr(name, value) <span>⤳ self</span>
.attr({name: value, ...}) <span>⤳ self</span>
</code></pre>
<p>When no <code>value</code> is given, reads specified attribute from the first element in the collection using <code>getAttribute</code>. </p>
<p>When <code>value</code> or an object with <code>key:value</code> pairs is given, set the attribute to <code>value</code> on each element in the collection using <code>setAttribute</code>.</p>
<h2 id="manipulation-removeattr">removeAttr</h2>
<pre><code>.removeAttr(name) <span>⤳ self</span>
</code></pre>
<p>Remove <code>name</code> attribute on each element in the collection using <code>removeAttribute</code>.</p>
<h2 id="manipulation-prop">prop</h2>
<pre><code>.prop(name) <span>⤳ string</span>
.prop(name, value) <span>⤳ self</span>
.prop({name: value, ...}) <span>⤳ self</span>
</code></pre>
<p>Get or set the <em>property</em> <code>name</code> for each element. Implemented as an alias to <a href="#util-@pluck"><code>util.pluck</code></a> and <a href="#util-@put"><code>util.put</code></a>.</p>
<h2 id="manipulation-ryecreate">Rye.create</h2>
<pre><code>Rye.create(html) <span>⤳ rye collection</span>
</code></pre>
<p>Turn a string containing HTML into a DOM element tree.</p>
<h2 id="manipulation-@getvalue">@getValue</h2>
<pre><code>manipulation.getValue(element) <span>⤳ string</span>
</code></pre>
<p>Get the <code>value</code> property of <code>element</code>. Returns an array of values in case <code>element</code> is a <code><select multiple></code>.</p>
<h2 id="manipulation-@getattribute">@getAttribute</h2>
<pre><code>manipulation.getAttribute(element, name) <span>⤳ string</span>
</code></pre>
<p>Get the value of <code>name</code> for a given <code>element</code>. Falls back to <code>getValue</code> for getting the <code>value</code> attribute.</p></section>
<section class="section-style"><h1 id="style">Style</h1>
<h2 id="style-show">show</h2>
<pre><code>.show() <span>⤳ self</span>
</code></pre>
<p>Set <code>display: block</code> on each element; if the element has been hidden with <code>.hide()</code> before the <code>display</code> value is preserved.</p>
<h2 id="style-hide">hide</h2>
<pre><code>.hide() <span>⤳ self</span>
</code></pre>
<p>Set <code>display: none</code> on each element. Saves the <code>display</code> value for subsequent calls.</p>
<h2 id="style-css">css</h2>
<pre><code>.css(prop) <span>⤳ string</span>
.css(prop, value) <span>⤳ self</span>
</code></pre>
<p>Get or set <code>style</code> properties.</p>
<h2 id="style-hasclass">hasClass</h2>
<pre><code>.hasClass(className) <span>⤳ boolean</span>
</code></pre>
<p>Check that the elements' class list contains <code>className</code>.</p>
<h2 id="style-addclass">addClass</h2>
<pre><code>.addClass(className) <span>⤳ self</span>
</code></pre>
<p>Add <code>className</code> to the elements' class list.</p>
<h2 id="style-removeclass">removeClass</h2>
<pre><code>.removeClass(className) <span>⤳ self</span>
</code></pre>
<p>Remove <code>className</code> from the elements' class list.</p>
<h2 id="style-toggleclass">toggleClass</h2>
<pre><code>.toggleClass(className, switch) <span>⤳ self</span>
</code></pre>
<p>If <code>switch</code> is a truthy value, <em>add</em> <code>className</code> to the elements' class list, if it's falsy <em>remove</em> <code>className</code>.</p>
<h2 id="style-@getcss">@getCSS</h2>
<pre><code>style.getCSS(element, property) <span>⤳ string</span>
</code></pre>
<p>Return the value of <code>property</code> in <code>element.style</code>.</p>
<h2 id="style-@setcss">@setCSS</h2>
<pre><code>style.setCSS(element, property, value) <span>⤳ element</span>
</code></pre>
<p>Set <code>property</code> to <code>value</code> on <code>element.style</code>.</p>
<h2 id="style-@hasclass">@hasClass</h2>
<pre><code>style.hasClass(element, className) <span>⤳ boolean</span>
</code></pre>
<p>Returns <code>true</code> if <code>className</code> is contained in <code>element</code>'s class list, <code>false</code> otherwise.</p>
<h2 id="style-@addclass">@addClass</h2>
<pre><code>style.addClass(element, className) <span>⤳ element</span>
</code></pre>
<p>Add <code>className</code> to <code>element</code>'s class list.</p>
<h2 id="style-@removeclass">@removeClass</h2>
<pre><code>style.removeClass(element, className) <span>⤳ element</span>
</code></pre>
<p>Remove <code>className</code> from <code>element</code>'s class list.</p></section>
<section class="section-event-emitter"><h1 id="eventemitter">Event Emitter</h1>
<p>Stand-alone event emitter implementation. Rye itself is an instance of <code>EventEmitter</code>, see <a href="#events-ryepublish"><code>Rye.publish</code></a> / <a href="#events-ryesubscribe"><code>Rye.subscribe</code></a>.</p>
<h2 id="eventemitter-addlisteneron">addListener (on)</h2>
<pre><code>emitter.addListener(event, handler) <span>⤳ self</span>
emitter.on(event, handler) <span>⤳ self</span>
</code></pre>
<h2 id="eventemitter-once">once</h2>
<pre><code>emitter.once(event, handler) <span>⤳ self</span>
</code></pre>
<h2 id="eventemitter-removelistener">removeListener</h2>
<pre><code>emitter.removeListener(event[, handler]) <span>⤳ self</span>
</code></pre>
<h2 id="eventemitter-trigger">trigger</h2>
<pre><code>emitter.trigger(event[, data]) <span>⤳ self</span>
</code></pre>
<h2 id="eventemitter-proxy">proxy</h2>
<pre><code>emitter.proxy(event) <span>⤳ function</span>
</code></pre></section>
<section class="section-dom-event-emitter"><h1 id="domeventemitter">DOM Event Emitter</h1>
<p>Inherits from <code>EventEmitter</code> while handling DOM events. The root <code>element</code> will receive all delegate event handlers. It's used internally to handle event binding.</p>
<p><a href="/samples#custom-dom-event-emitter" class="button">Using a custom DOMEventEmitter</a></p>
<h2 id="domeventemitter-addlisteneron">addListener (on)</h2>
<pre><code>emitter.addListener(event, fn) <span>⤳ self</span>
emitter.on(element, event, fn) <span>⤳ self</span>
</code></pre>
<h2 id="domeventemitter-onceone">once (one)</h2>
<pre><code>emitter.once(event, fn) <span>⤳ self</span>
emitter.one(event, fn) <span>⤳ self</span>
</code></pre>
<h2 id="domeventemitter-removelisteneroff">removeListener (off)</h2>
<pre><code>emitter.removeListener(event[, fn]) <span>⤳ self</span>
emitter.off(event[, fn]) <span>⤳ self</span>
</code></pre>
<h2 id="domeventemitter-destroy">destroy</h2>
<pre><code>emitter.destroy() <span>⤳ self</span>
</code></pre>
<h2 id="domeventemitter-trigger">trigger</h2>
<pre><code>emitter.trigger(event[, data]) <span>⤳ self</span>
</code></pre>
<h2 id="domeventemitter-emit">emit</h2>
<pre><code>emitter.trigger(event[, data]) <span>⤳ self</span>
</code></pre>
<h2 id="domeventemitter-proxy">proxy</h2>
<pre><code>emitter.proxy(event) <span>⤳ function</span>
</code></pre></section>
<section class="section-events"><h1 id="events">Events</h1>
<h2 id="events-addlistener">addListener</h2>
<pre><code>.addListener(name, handler) <span>⤳ self</span>
.on(name, handler) <span>⤳ self</span>
</code></pre>
<h2 id="events-once">once</h2>
<pre><code>.once(name, handler) <span>⤳ self</span>
</code></pre>
<h2 id="events-removelistener">removeListener</h2>
<pre><code>.removeListener(name[, handler]) <span>⤳ self</span>
</code></pre>
<h2 id="events-trigger">trigger</h2>
<pre><code>.trigger(name[, data]) <span>⤳ self</span>
</code></pre>
<h2 id="events-@getemitter">@getEmitter</h2>
<pre><code>events.getEmitter(element) <span>⤳ DOMEventEMitter</span>
</code></pre>
<h2 id="events-@createevent">@createEvent</h2>
<pre><code>events.createEvent(type[, properties]) <span>⤳ Event</span>
events.createEvent(obj[, properties]) <span>⤳ Event</span>
</code></pre>
<h2 id="events-@addlistener">@addListener</h2>
<pre><code>events.addListener(element, name, handler) <span>⤳ self</span>
events.on(element, name, handler) <span>⤳ self</span>
</code></pre>
<h2 id="events-@once">@once</h2>
<pre><code>events.once(element, name, handler) <span>⤳ self</span>
</code></pre>
<h2 id="events-@removelistener">@removeListener</h2>
<pre><code>events.removeListener(element, name[, handler]) <span>⤳ self</span>
</code></pre>
<h2 id="events-@trigger">@trigger</h2>
<pre><code>events.trigger(element, name[, data]) <span>⤳ self</span>
</code></pre>
<h2 id="events-ryesubscribe">Rye.subscribe</h2>
<pre><code>Rye.subscribe(event, handler) <span>⤳ self</span>
</code></pre>
<p>Listen for <code>event</code> on the global event bus.</p>
<h2 id="events-ryeunsubscribe">Rye.unsubscribe</h2>
<pre><code>Rye.unsubscribe(event[, handler]) <span>⤳ self</span>
</code></pre>
<p>Stop listening for <code>event</code> on the global event bus.</p>
<h2 id="events-ryepublish">Rye.publish</h2>
<pre><code>Rye.publish(event[, args...]) <span>⤳ self</span>
</code></pre>
<p>Emit <code>event</code> on the global event bus. Extra arguments will be forwarded to event handlers.</p></section>
<section class="section-touch-events"><h1 id="touchevents">Touch Events</h1>
<ul>
<li><code>tap</code></li>
<li><code>doubletap</code></li>
<li><code>swipe</code></li>
<li><code>swipeleft</code></li>
<li><code>swiperight</code></li>
<li><code>swipeup</code></li>
<li><code>swipedown</code></li>
<li><code>longtap</code></li>
<li><code>singletap</code></li>
</ul>
<p><a href="/samples#touch-events" class="button">touch events sample</a></p></section>
<section class="section-request"><h1 id="request">Request</h1>
<h2 id="request-ryerequest">Rye.request()</h2>
<pre><code>Rye.request(url, callback) <span>⤳ XMLHttpRequest</span>
Rye.request(settings, callback) <span>⤳ XMLHttpRequest</span>
Rye.request(settings) <span>⤳ XMLHttpRequest</span>
</code></pre>