File size: 41,321 Bytes
a01128b |
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 |
<!DOCTYPE html>
<html slick-uniqueid="3">
<head>
<style>
@font-face {
font-family: 'Roboto';
font-style: italic;
font-weight: 300;
src: url(https://fonts.gstatic.com/s/roboto/v30/KFOjCnqEu92Fr1Mu51TjASc6CsE.ttf) format('truetype');
}
@font-face {
font-family: 'Roboto';
font-style: italic;
font-weight: 400;
src: url(https://fonts.gstatic.com/s/roboto/v30/KFOkCnqEu92Fr1Mu51xIIzc.ttf) format('truetype');
}
@font-face {
font-family: 'Roboto';
font-style: italic;
font-weight: 700;
src: url(https://fonts.gstatic.com/s/roboto/v30/KFOjCnqEu92Fr1Mu51TzBic6CsE.ttf) format('truetype');
}
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 300;
src: url(https://fonts.gstatic.com/s/roboto/v30/KFOlCnqEu92Fr1MmSU5fBBc9.ttf) format('truetype');
}
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 400;
src: url(https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Mu4mxP.ttf) format('truetype');
}
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 700;
src: url(https://fonts.gstatic.com/s/roboto/v30/KFOlCnqEu92Fr1MmWUlfBBc9.ttf) format('truetype');
}
@font-face {
font-family: 'Source Code Pro';
font-style: normal;
font-weight: 200;
src: url(https://fonts.gstatic.com/s/sourcecodepro/v23/HI_diYsKILxRpg3hIP6sJ7fM7PqPMcMnZFqUwX28DEyQtMlrSQ.ttf) format('truetype');
}
@font-face {
font-family: 'Source Code Pro';
font-style: normal;
font-weight: 300;
src: url(https://fonts.gstatic.com/s/sourcecodepro/v23/HI_diYsKILxRpg3hIP6sJ7fM7PqPMcMnZFqUwX28DJKQtMlrSQ.ttf) format('truetype');
}
@font-face {
font-family: 'Source Code Pro';
font-style: normal;
font-weight: 400;
src: url(https://fonts.gstatic.com/s/sourcecodepro/v23/HI_diYsKILxRpg3hIP6sJ7fM7PqPMcMnZFqUwX28DMyQtMlrSQ.ttf) format('truetype');
}
@font-face {
font-family: 'Source Code Pro';
font-style: normal;
font-weight: 500;
src: url(https://fonts.gstatic.com/s/sourcecodepro/v23/HI_diYsKILxRpg3hIP6sJ7fM7PqPMcMnZFqUwX28DP6QtMlrSQ.ttf) format('truetype');
}
@font-face {
font-family: 'Source Code Pro';
font-style: normal;
font-weight: 600;
src: url(https://fonts.gstatic.com/s/sourcecodepro/v23/HI_diYsKILxRpg3hIP6sJ7fM7PqPMcMnZFqUwX28DBKXtMlrSQ.ttf) format('truetype');
}
@font-face {
font-family: 'Source Code Pro';
font-style: normal;
font-weight: 700;
src: url(https://fonts.gstatic.com/s/sourcecodepro/v23/HI_diYsKILxRpg3hIP6sJ7fM7PqPMcMnZFqUwX28DCuXtMlrSQ.ttf) format('truetype');
}
blockquote,body,dd,div,dl,dt,fieldset,figure,form,h1,h2,h3,h4,h5,h6,legend,li,menu,ol,p,pre,ul{border:0;margin:0;padding:0}
article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{border:0;display:block;margin:0;padding:0}
ol,ul{list-style:none}
button,input,select,textarea{appearance:none;border:0;box-sizing:border-box;font-size:100%;line-height:normal;margin:0;padding:0;text-transform:none;vertical-align:baseline}
button,html input[type="button"],input[type="reset"],input[type="submit"]{appearance:button;cursor:pointer;padding:.2em .3em;}
button:hover,html input[type="button"]:hover,input[type="reset"]:hover,input[type="submit"]:hover{background:#777571;color:#f4f1ed}
button :-moz-focus-inner,input :-moz-focus-inner{border:0;padding:0}
button[disabled],html input[disabled]{cursor:default}
input[type="checkbox"],input[type="radio"]{box-sizing:border-box;padding:0}
input[type="checkbox"]{width:.7em;height:.7em;margin:.15em;border-radius:3px;}
input[type="checkbox"]:checked{background:#777571}
input[type="search"]{appearance:textfield;box-sizing:border-box;cursor:default}
input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{appearance:none}
legend{white-space:normal}
textarea{overflow:auto;resize:vertical;vertical-align:top}
html{font-size:100%;text-size-adjust:100%;vertical-align:baseline}
sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}
sub{bottom:-.25em}
sup{top:-.5em}
pre{white-space:pre;white-space:pre-wrap;word-wrap:break-word}
q,blockquote{quotes:none;}
q:before,blockquote:before,q:after,blockquote:after{content:"";content:none}
table{border-collapse:collapse;border-spacing:0}
img{border:0;max-width:100%;height:auto;vertical-align:middle}
hr{border:0;border-top:solid 1px #dedfdf;display:block;height:0;margin:0;padding:0}
@font-face{font-family:"Entypo";src:url("/fonts/entypo.eot");src:url("/fonts/entypo.eot?#iefix") format("embedded-opentype"),url("/fonts/entypo.woff") format("woff"),url("/fonts/entypo.ttf") format("truetype"),url("/fonts/entypo.svg#entypo") format("svg");font-weight:normal;font-style:normal}
@font-face{font-family:"Entypo Social";src:url("/fonts/entypo-social.eot");src:url("/fonts/entypo-social.eot?#iefix") format("embedded-opentype"),url("/fonts/entypo-social.woff") format("woff"),url("/fonts/entypo-social.ttf") format("truetype"),url("/fonts/entypo-social.svg#entypo-social") format("svg");font-weight:normal;font-style:normal}
body{background:#fff;font-size:1em}
.clearfix{zoom:1}
.clearfix:before,.clearfix:after{content:"";display:table}
.clearfix:after{clear:both}
.hidden{display:none !important;visibility:hidden}
.visually-hidden{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}
::-moz-selection{background:#777571;color:#fff;text-shadow:none}
::selection{background:#777571;color:#fff;text-shadow:none}
a,.grey-link.grey-link-override a{color:#777571;display:inline-block;text-decoration:none;}
a:hover,.grey-link.grey-link-override a:hover{color:#777571}
a:active,.grey-link.grey-link-override a:active,a:focus,.grey-link.grey-link-override a:focus{background:rgba(119,117,113,0.5);-webkit-border-radius:3px;border-radius:3px;color:#fff !important;outline:none}
body,button,html,input,select,textarea{color:#575551;font-family:"Roboto","Helvetica","Arial",sans-serif;font-weight:300}
h1,h2,h3,h4,h5,h6{font-weight:200}
b,strong{font-weight:400}
pre{background:#f1f1f1;-webkit-border-radius:5px;border-radius:5px;display:block;font-family:"Source Code Pro","Lucida Console","Monaco","Courier New",monospace;font-size:.85em;font-weight:400;padding:1em}
code{background:#dedfdf;-webkit-border-radius:3px;border-radius:3px;display:inline;font-family:"Source Code Pro","Lucida Console","Monaco","Courier New",monospace;font-size:.75em;font-weight:600;padding:.25em .5em;vertical-align:baseline}
pre code{background:transparent;-webkit-border-radius:0;border-radius:0;font-size:1em;font-weight:400;padding:0}
p,code,pre{color:#373531}
input,textarea,select{-webkit-appearance:none;-moz-appearance:none;appearance:none;border:solid #e5e3df 1px;-webkit-border-radius:3px;border-radius:3px;color:#777571;cursor:pointer;font-weight:400;padding:.3em .5em;}
input:focus,textarea:focus,select:focus{outline:none;border:solid #e5e3df 1px}
label{cursor:pointer}
select:after{content:"stocazzo"}
input[type="checkbox"]{height:1em;position:relative;width:1em}
#builderOptions table input[type="checkbox"]:checked,#builderOptions table input[type="checkbox"].dependency{background:#f4f1ed}
#builderOptions table input[type="checkbox"].activeChoice:checked{background:#7d8aa5}
input[type="submit"]{background:#f4f1ed;-webkit-border-radius:5px;border-radius:5px;color:#777571 !important;display:block;font-size:1.1em;font-weight:300}
input[type="submit"]:hover{color:#fff !important}
.button{background:#e5e8ed;-webkit-border-radius:5px;border-radius:5px;color:#7d8aa5;display:block;font-size:1.1em;position:relative;}
.button span{display:block;padding:.5em .6em;line-height:1;}
.button span span{padding:0;}
.button span span.icon{font-size:200%;position:absolute;top:.8em;right:.2em;line-height:0;color:#7d8aa5}
.button span.version{display:block;font-size:.8em;margin-top:.2em}
.button.highlighted{background:#7d8aa5;color:#fff;}
.button.highlighted .icon,.button.highlighted pre{color:#fff}
.lighter{color:#acaaa7}
a:active .lighter,a:focus .lighter{color:#fff}
.darker{color:#777571}
a:active .darker,a:focus .darker{color:#fff}
.summary{font-size:1.3em;width:70%}
.description{font-size:1.2em}
.npm{background:#777571;color:#fff;margin:1em 0}
.command{border:none;background:#b1b9c9;color:#fff;-webkit-border-radius:5px;border-radius:5px;display:block;font-weight:400;margin:.5em 0;padding:.15em .5em .25em}
.wrapper{margin:0 auto;max-width:64em;padding:0 4%}
.arrow:after{content:'\e804';font-family:"Entypo"}
.icon{color:#9c9ea0;font-size:220%;line-height:0;position:relative;vertical-align:baseline}
a:active .icon,a:focus .icon{color:#fff}
.previous:after{content:'\e803';font-family:"Entypo"}
.next:after{content:'\e804';font-family:"Entypo"}
.download:after{content:'\e802';font-family:"Entypo"}
.github:after{content:'\e803';font-family:"Entypo Social"}
.twitter:after{content:'\e802';font-family:"Entypo Social"}
.facebook:after{content:'\e800';font-family:"Entypo Social"}
.googleplus:after{content:'\e801';font-family:"Entypo Social"}
.about{background:#e5e8ed;padding-top:0;padding-bottom:1em;}
.about .introduction p{font-size:1.3em;margin:1em 0}
.about .license{background:#fff;border:solid #e5e3df 1px;-webkit-border-radius:5px;border-radius:5px;color:#b1b9c9;margin:1.5em 0 0;padding:1em;}
.about .license h2{margin-bottom:.5em}
.about .license a{color:#6d798f;text-decoration:none}
.updates{padding-top:1em;padding-bottom:1em;}
.updates div.box{background:#e5e8ed;-webkit-border-radius:5px;border-radius:5px;padding:1em}
.updates h3{font-weight:400;margin-bottom:1em;}
.updates h3 span{margin-right:.5em}
.updates p{padding-bottom:.5em}
.updates a{font-weight:400;color:#7d8aa5}
.updates a:hover{text-decoration:underline}
.main .color{color:#7d8aa5}
.main h2{color:#7d8aa5}
.main a{color:#7d8aa5}
.main .selected{background-color:#7d8aa5;border-color:#7d8aa5}
.main .blog{margin-bottom:2em;}
.main .blog a{position:relative;padding:0 .2em}
.main .blog a:focus,.main .blog a:active{background-color:#777571 !important}
.main .blog hr{margin-top:2em;margin-bottom:2em}
.main .blog h2{font-size:2em;padding-bottom:.5em}
.main .blog h3{font-size:2em;padding:.5em .3em 0 .3em;margin-left:-.2em}
.main .blog h4{font-weight:400}
.main .blog ul{padding-left:2em;}
.main .blog ul li{list-style-type:disc;padding:.1em 0}
.main .blog small{border:1px solid #acaaa7;-webkit-border-radius:5px;border-radius:5px;display:block;font-size:.8em;font-weight:400;margin:.5em 0 2em;padding:.5em 1em;}
.main .blog small a{background:#f4f1ed;color:#777571;-webkit-border-radius:3px;border-radius:3px;display:inline;padding:0 .5em}
.main .blog small .comments{float:right}
.main .blog .post p{font-size:1.1em;line-height:1.3em;margin:1em 0}
.main .blog .post p a,.main .blog ul a{font-weight:400;text-decoration:none;color:#7d8aa5}
.main .blog .pagination a{background:#f4f1ed;-webkit-border-radius:5px;border-radius:5px;padding:1em;width:46%;color:#7d8aa5;font-weight:400}
.main .blog .pagination a .icon{font-size:200%;top:.3em;color:#7d8aa5}
.main .blog .pagination .older{float:left;text-align:right}
.main .blog .pagination .newer{float:right;text-align:left}
.main .blog .pagination .icon.previous{float:left;margin-right:.5em}
.main .blog .pagination .icon.next{float:right;margin-left:.5em}
.overview .summary,.overview .description{margin-bottom:1.5em}
.overview .license{font-size:.8em;margin:1em 0 3em}
.overview .use li{float:left;}
.overview .use li a{margin:0 0 0 .35em}
.overview .use li:first-child a{margin:0 .35em 0 0}
.overview .use .button{height:3em}
.features a{display:block;position:relative}
.books img{width:10em}
.books .about{background-color:#fff;padding-top:0;}
.books .about a{font-weight:400}
.books .cover{float:right;width:25%;}
.books .cover a{margin:.3em 0;font-weight:600;padding:.3em;color:#7d8aa5}
.books h2{font-size:2em}
.books .introduction p{font-size:1.1em}
.examples section h1{color:#7d8aa5;font-size:2em;font-weight:200}
.examples section h3{color:#575551}
.examples section p{padding-top:.5em}
.docs{padding-bottom:2em;}
.docs .versions{background:#e5e8ed;-webkit-border-radius:5px;border-radius:5px;color:#3c3a37;margin:0 0 2em;padding:.5em 1em;}
.docs .versions h3{float:left}
.docs .versions ul{float:right;}
.docs .versions ul li{font-weight:400;float:left;margin:0 0 0 .5em;position:relative}
.docs .versions a{background:#fff;-webkit-border-radius:3px;border-radius:3px;color:#dedfdf !important;font-size:.85em;padding:.25em .5em;}
.docs .versions a.selected{background:#fff;color:#777571 !important;}
.docs .versions a.selected:after{background:#fff;bottom:-4px;content:"";display:block;height:6px;left:50%;margin-left:-3px;position:absolute;-webkit-transform-origin:center;-moz-transform-origin:center;-o-transform-origin:center;-ms-transform-origin:center;transform-origin:center;-webkit-transform:rotate(-45deg);-moz-transform:rotate(-45deg);-o-transform:rotate(-45deg);-ms-transform:rotate(-45deg);transform:rotate(-45deg);width:6px}
.docs .toc{-webkit-border-radius:5px;border-radius:5px;border:solid #dedfdf 1px;font-size:.9em;line-height:1em;}
.docs .toc .small{height:1em;}
.docs .toc .small ul{display:none}
.docs .toc ul{border-top:solid #dedfdf 1px;padding:.5em 1em 1em;overflow:none;}
.docs .toc ul:first-child{border-top:none}
.docs .toc ul li ul{border-top:solid #dedfdf 1px;padding:0}
.docs .toc ul h3{padding:.7em 0 .3em 0;color:#575551 !important;font-weight:400}
.docs .toc ul a{color:#575551;display:block;padding:.3em .5em;margin-left:-.2em;}
.docs .toc ul a.top{color:#7d8aa5;font-size:1.2em;margin:0 0 .5em}
.docs .toc a.top:after{color:#dedfdf;content:'\e809';float:right;font-family:"Entypo";font-size:140%}
.docs .toc a.top:active,.docs .toc a.top:focus{background-color:#777571;}
.docs .toc a.top:active:after,.docs .toc a.top:focus:after{color:#fff}
.docs .content{margin:0 0 2em;}
.docs .content .heading:first-child h1{border:0;margin:0;padding:0}
.docs .content .heading:first-child .back-to-top{display:none}
.docs .content h1{border-top:solid 1px #dedfdf;margin:2em 0 0;padding:1.5em 0 0;}
.docs .content h1 a{padding:0 .2em;margin-left:-.2em}
.docs .content h2{background:#5a5d60;-webkit-border-radius:5px;border-radius:5px;margin:2em 0 .5em;padding:.15em .5em .25em;}
.docs .content h2 a{color:#fff !important;padding:0 .2em;margin-left:-.2em;}
.docs .content h2 a:focus,.docs .content h2 a:active{background-color:#fff;color:#5a5d60 !important}
.docs .content h3{-webkit-border-radius:5px;border-radius:5px;border:solid #dedfdf 1px;font-weight:400;margin:1.5em 0 0;padding:.15em .5em .25em}
.docs .content h4{-webkit-border-radius:5px;border-radius:5px;border:solid #f4f1ed 1px;color:#acaaa7;font-size:1.125em;font-weight:400;margin:1.5em 0 .5em;padding:.15em .5em .25em}
.docs .content h5{color:#acaaa7;font-size:1em;font-weight:400;margin:1.5em 0 0}
.docs .content p{margin:.5em 0}
.docs .content ol{counter-reset:li;list-style:none;*list-style:decimal;position:relative;}
.docs .content ol > li{margin-top:.5em;padding-left:1.5em;}
.docs .content ol > li:before{background:#b1b9c9;-webkit-border-radius:3px;border-radius:3px;content:counter(li);counter-increment:li;font-size:.75em;font-weight:600;left:0;padding:.15em .5em;position:absolute;color:#fff;margin-top:.15em}
.docs .content ul li{margin:.5em 0 0 1em;position:relative;}
.docs .content ul li:after{content:'\e80c';font-family:"Entypo";color:#7d8aa5;position:absolute;left:-1em;font-size:100%;margin:.2em .5em 0 0;top:0}
.docs .content pre{margin:.5em 0 0}
.docs .content a.back-to-top:before{color:#fff;content:'\e80a';margin-right:.5em;font-family:"Entypo";font-size:110%}
.docs .content a.back-to-top{color:#fff !important;font-size:.8em;margin-top:-3.4em;padding:.3em .5em;position:absolute !important;right:.5em}
.docs .content a.back-to-top:active,.docs .content a.back-to-top:focus{background-color:#fff;color:#5a5d60 !important;}
.docs .content a.back-to-top:active:before,.docs .content a.back-to-top:focus:before{color:#5a5d60 !important}
.heading{position:relative}
.guides{padding-bottom:2em;}
.guides .content:first-child h1{border:0;margin:0;padding:0}
.guides .content{margin:0 0 2em;}
.guides .content h1{border-top:solid 1px #e5e3df;margin:2em 0 0;padding:1.5em 0 0}
.guides .content h2{background:#777571;-webkit-border-radius:5px;border-radius:5px;margin:2em 0 .5em;padding:.15em .5em .25em;}
.guides .content h2 a{color:#fff !important}
.guides .content h3{-webkit-border-radius:5px;border-radius:5px;border:solid #e5e3df 1px;font-weight:400;margin:1.5em 0 0;padding:.5em}
.guides .content h4{-webkit-border-radius:5px;border-radius:5px;border:solid #f4f1ed 1px;color:#acaaa7;font-size:1.125em;font-weight:400;margin:1.5em 0 .5em;padding:.15em .5em .25em}
.guides .content h5{color:#acaaa7;font-size:1em;font-weight:400;margin:1.5em 0 0}
.guides .content p{margin:.5em 0;padding:.4em}
.guides .content ol{counter-reset:li;list-style:none;*list-style:decimal;position:relative;}
.guides .content ol li{margin-top:.5em;padding-left:1.5em;}
.guides .content ol li:before{background:#f4f1ed;-webkit-border-radius:3px;border-radius:3px;content:counter(li);counter-increment:li;font-size:.75em;font-weight:600;left:0;padding:.15em .5em;position:absolute}
.guides .content ul li{margin:.5em 0 0;}
.guides .content ul li:after{content:'\e80c';float:left;font-family:"Entypo";font-size:100%;margin:.2em .5em 0 0}
.guides .content pre{margin:.5em 0 0;}
.guides .content pre code{padding:.25em .5em}
#global-bar{-webkit-box-shadow:rgba(0,0,0,0.1) 0 0 30px;box-shadow:rgba(0,0,0,0.1) 0 0 30px;padding-bottom:1em;padding-top:1em;position:fixed;width:100%;background-color:#fff;z-index:100;}
#global-bar div.wrapper{position:relative;}
#global-bar div.wrapper div.right{bottom:4px;position:absolute;right:4%}
#global-bar ul > li > a:active,#global-bar ul > li > a:focus{background:#9c9ea0;border-color:#9c9ea0;color:#fff}
#global-bar ul{float:left;}
#global-bar ul li{float:left;margin-right:.5em;position:relative;}
#global-bar ul li a{-webkit-border-radius:3px;border-radius:3px;color:#414347;font-size:1em;padding:.3em .5em .3em .5em;cursor:pointer}
#global-bar ul li.selected > a{background:#414347;border-color:#414347;color:#fff;}
#global-bar ul li.selected > a:active,#global-bar ul li.selected > a:focus{background:#9c9ea0;border-color:#9c9ea0;color:#fff}
body.mootools #global-bar{padding-bottom:2em;padding-top:2em;position:relative;}
body.mootools #global-bar h1{padding:0}
#logo{float:left;}
#logo h1 img{height:70px !important}
#logo p img{width:150px;padding:.5em}
#logo img:focus,#logo img:active{background-color:#fff}
#search{float:left;margin-left:.5em;}
#search label{display:block;position:relative}
#search input{background:transparent;border-color:transparent;color:#fff;border-color:#dedfdf;display:block;font-size:.85em;font-weight:400;padding:.4em .5em;width:12em;}
#search input:focus{border-color:#acaaa7}
#search #search-field{color:#777571}
#header{border-color:#7d8aa5;}
#header nav ul li.selected a{color:#7d8aa5;}
#header nav ul li.selected a:after{border-color:#7d8aa5 #7d8aa5 transparent transparent}
#header div.wrapper div.right{bottom:0}
#header h1 img{height:60px;width:auto;margin-top:1em}
#header a{color:#b1b9c8;font-size:1.125em;}
#header a:active,#header a:focus{background:transparent;border-color:transparent;color:#fff;}
#header a:active span,#header a:focus span{background:#777571;border-color:#777571;color:#fff;-webkit-border-radius:3px;border-radius:3px}
.core > #header,.more > #header{border-bottom:solid #7d8aa5 1px;margin-top:3em}
#menu{-webkit-box-shadow:#9c9ea0 0 0 30px;box-shadow:#9c9ea0 0 0 30px;padding:0 0 1em;}
#menu a{-webkit-border-radius:5px;border-radius:5px;border:solid #e5e3df 1px;display:block;padding:.6em 0 .4em;text-align:center;}
#menu a:active,#menu a:focus{border-color:#e5e3df}
#menu img{height:1.6em}
#sitemap{font-size:.8em;}
#sitemap h3{color:#cbd0db;font-weight:400}
#sitemap ul li a{padding:0 .5em;margin-left:-.5em;display:block;}
#sitemap ul li a span.icon{margin-right:.5em;font-size:100%}
#credits{font-size:.8em;}
#credits p{margin:0 0 1em}
#credits img.mootools{width:150px;padding:.5em;margin-left:-.5em}
#credits p.mediatemple a{background:url("/images/credits/mediatemple.png") no-repeat left top;border-color:url("/images/credits/mediatemple.png") no-repeat left top;color:#fff;-webkit-background-size:auto 16px;-moz-background-size:auto 16px;background-size:auto 16px;color:#dedfdf;font-size:.85em;font-weight:300;padding-left:46px;}
#credits p.mediatemple a:active,#credits p.mediatemple a:focus{color:#dedfdf !important}
@media only screen and (max-width: 47.999em) /* Less than 600 pixels */{.arrow:after{font-size:80%;margin-left:.3em;position:relative;top:0;vertical-align:baseline}
.home-page .arrow:after{top:.08em}
.slider:after{content:'\e808';float:right;font-family:"Entypo";font-size:80%}
.overview{padding-top:2em;padding-bottom:180px;position:relative;}
.overview .big-icon{width:100%;bottom:0;left:0;height:180px;overflow:hidden;position:absolute;z-index:-1;text-align:center;}
.overview .big-icon img{height:auto;opacity:.2;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=20)";filter:alpha(opacity=20);max-width:320px}
.overview .summary{font-size:120%;width:100%}
.overview .description{font-size:100%}
.overview .use li{width:50%}
.overview .previous-version label :after{display:block}
.overview .previous-version select{width:100%}
.modules{padding-top:1em;padding-bottom:1em;}
.modules .docs{margin-top:1em;}
.modules .docs a{display:block}
.features{padding-top:1em;padding-bottom:1em;}
.features section{float:left;margin-top:0;}
.features section:first-child{margin-top:0}
.features section p{padding:.5em 1.5em}
.features section a p{margin-top:.5em}
.guides{padding-top:1em;padding-bottom:1em}
.docs .content{margin-top:2em}
.docs .toc ul a.top{margin-bottom:0}
.docs .toc ul ul{display:none;}
.updates section{margin-top:1em;}
.updates section:nth-of-type(1){margin-top:0}
#logo{float:none;}
#logo h1,#logo p{text-align:center}
.home-page{padding-top:1em;padding-bottom:1em;}
.home-page .big-icon{display:none}
#global-bar .wrapper{padding:0}
#global-bar div.wrapper div.right{position:static;margin-top:1.5em;}
#global-bar div.wrapper div.right ul{float:none;margin:0}
#global-bar div.wrapper div.right ul{margin-bottom:.5em}
#global-bar div.wrapper div.right li{float:none;margin:0;}
#global-bar div.wrapper div.right li a{-webkit-border-radius:0;border-radius:0}
#global-bar div.wrapper div.right ul.opened li,#global-bar div.wrapper div.right li.selected{height:2em}
#global-bar div.wrapper div.right input{width:100%}
#search{float:none;margin:0 4%;position:static;}
#search input{width:100%}
#header .wrapper{padding:0}
#header h1{padding:.5em 4%;}
#header h1 img{margin-top:0}
#main-header{display:none}
#header ul li{overflow:hidden;height:0;opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0);-webkit-transition:height .4s ease;-moz-transition:height .4s ease;-o-transition:height .4s ease;-ms-transition:height .4s ease;transition:height .4s ease;}
#header ul li a{border-top:solid #e5e3df 1px;cursor:pointer;display:block;padding:.5em 4%}
#header ul.opened li,#header ul li.selected{height:2.6em;opacity:1;-ms-filter:none;filter:none}
#menu li{float:left;width:50%;margin:1em 0 0;}
#menu li:nth-of-type(1n) a{margin:0 .5em 0 0}
#menu li:nth-of-type(2n) a{margin:0 0 0 .5em}
#footer.wrapper{padding:0}
#sitemap{width:100%;}
#sitemap div{border-bottom:solid 1px #e5e3df;margin-bottom:1px;overflow:hidden;float:left;min-width:100%;height:4em;-webkit-transition:height .5s ease;-moz-transition:height .5s ease;-o-transition:height .5s ease;-ms-transition:height .5s ease;transition:height .5s ease;}
#sitemap div h3{font-size:2em;background:#fff;border-color:#fff;color:#fff;color:#acaaa7;cursor:pointer;padding:.5em 4%}
#sitemap div ul{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0);padding:0 2em 1em 2em}
#sitemap .opened{height:11em}
#sitemap .opened ul{opacity:1;-ms-filter:none;filter:none}
#credits{padding:1em 4% 2em;clear:both}
}@media only screen and (min-width: 48em) /* More or equal to 768 pixels */{.arrow:after{font-size:80%;margin-left:.3em;position:relative;top:0;vertical-align:baseline}
.overview{padding-top:3em;position:relative;}
.overview .big-icon{bottom:0;height:230px;overflow:hidden;position:absolute;right:4%;width:400px;z-index:-1;padding:50px 50px 0 50px;}
.overview .big-icon img{height:auto;opacity:.4;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=40)";filter:alpha(opacity=40);width:100%;-webkit-transition:-webkit-transform .5s ease;-moz-transition:-moz-transform .5s ease;-o-transition:-o-transform .5s ease;-ms-transition:-ms-transform .5s ease;transition:transform .5s ease}
.overview .use li{width:9.6em}
.overview .previous-version select{width:19.2em}
.modules{padding-top:2em;padding-bottom:2em;}
.modules section{position:relative;clear:both}
.modules div{margin-top:1.5em;width:48%;}
.modules div:nth-of-type(odd){float:left}
.modules div:nth-of-type(even){float:right}
.modules div pre{margin-top:1em}
.modules .docs{position:absolute;right:0;top:0}
.features{padding-top:1em;padding-bottom:1em;}
.features section{float:left;width:33.333%;}
.features section:nth-of-type(1) a{margin:0 1.75em 0 -.6em}
.features section:nth-of-type(2) a{margin:0 1.25em 0}
.features section:nth-of-type(3) a{margin:0 0 0 1.75em}
.features section a{padding:.8em}
.features section p{margin-top:1em}
.guides{padding-top:2em;padding-bottom:2em}
.docs .toc{float:left;width:26%}
.docs .content{float:right;width:70%}
.about{padding-top:1em;padding-bottom:2em;}
.about .introduction{float:left;width:70%}
.about .license{float:right;width:25%}
.home-page{padding-top:2em;padding-bottom:2em}
.updates{padding-top:2em;padding-bottom:2em;}
.updates section{float:left;width:33.333%;}
.updates section:nth-of-type(1) div.box{margin:0 .8em 0 0}
.updates section:nth-of-type(2) div.box{margin:0 .8em 0}
.updates section:nth-of-type(3) div.box{margin:0 0 0 .8em}
#header .wrapper div{position:relative}
#header h1{padding:1em 0}
#header nav{bottom:0;position:absolute;right:0;}
#header nav ul li{float:left;margin-left:1em;}
#header nav ul li:first-child{margin-left:0}
#header nav ul li a{position:relative;}
#header nav ul li a span{position:relative;top:-1em;padding:.1em .5em}
#header nav ul li.selected a{color:#777571;}
#header nav ul li.selected a:after{background:#fff;border-color:#fff;color:#fff;border:solid 1px;border-color:#7d8aa5 #7d8aa5 transparent transparent;bottom:-6px;content:"";display:block;height:10px;left:50%;margin-left:-5px;position:absolute;-webkit-transform-origin:center;-moz-transform-origin:center;-o-transform-origin:center;-ms-transform-origin:center;transform-origin:center;-webkit-transform:rotate(-45deg);-moz-transform:rotate(-45deg);-o-transform:rotate(-45deg);-ms-transform:rotate(-45deg);transform:rotate(-45deg);width:10px}
.main + hr{display:none}
#menu{display:none;padding-top:1em;}
#menu li{float:left;width:20%;}
#menu li:nth-of-type(1) a{margin:0 .6em 0 0}
#menu li:nth-of-type(2) a{margin:0 .45em 0 .3em}
#menu li:nth-of-type(3) a{margin:0 .3em 0 .45em}
#menu li:nth-of-type(4) a{margin:0 .3em 0 .45em}
#menu li:nth-of-type(5) a{margin:0 0 0 .45em}
#footer.wrapper{padding-top:2em;padding-bottom:4em}
#sitemap{float:right;}
#sitemap div{float:left;margin-left:2em;width:8.8em}
#sitemap div first-of-type{margin-left:.5em}
#sitemap h3{margin-bottom:.3em}
#credits{float:left}
.core .big-icon{height:230px;width:340px}
.more .big-icon{height:230px;width:340px}
}pre span.keyword{color:#b05098}
pre span.number{color:#429bc1}
pre span.string{color:#83a440}
pre span.comment{color:#9c9ea0}
.mootools #header{border-bottom:1px solid #fff}
.previous-version{margin-top:1em;}
.previous-version label.select{position:relative}
@media screen and (-webkit-min-device-pixel-ratio: 0) /* Chrome and Safari only */{label.select:after{content:'<>';font:11px "Consolas",monospace;padding:3px;-webkit-transform:rotate(90deg);-moz-transform:rotate(90deg);-ms-transform:rotate(90deg);-webkit-transform:rotate(90deg);-moz-transform:rotate(90deg);-o-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg);right:8px;top:3px;position:absolute;pointer-events:none}
}#googleLink{margin-left:2em;opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0);-webkit-transition:opacity .4s;-moz-transition:opacity .4s;-o-transition:opacity .4s;-ms-transition:opacity .4s;transition:opacity .4s}
#googleLink.visible{opacity:1;-ms-filter:none;filter:none}
.builder{margin-top:2em;margin-bottom:2em;}
.builder .header h1{float:left;margin:1.5em 0 .5em;width:100%}
.builder .header .save{float:left;clear:none;margin-right:1em}
.builder .save{clear:both;}
.builder .save label{display:block;margin-top:1em;position:relative}
.builder .save label.select:after{top:7px}
.builder .save select{width:100%}
.builder .save input[type="checkbox"]{margin-right:.5em;vertical-align:bottom}
.builder .save input[type="submit"]{margin-top:.5em;padding:.5em;width:100%;text-align:left}
.builder .save .icon.download{position:absolute;right:.25em;top:0;line-height:1em}
.builder form{margin-top:1em}
.builder .step{clear:both;font-weight:400;margin-top:1em}
@media only screen and (min-width: 48em) /* More or equal to 768 pixels */{.builder .save{width:35%}
.builder table{width:100%;}
.builder table tr{border-bottom:1px solid #acaaa7;}
.builder table tr td{padding:.3em;}
.builder table tr td:first-child{width:5%}
.builder table tr td + td{width:15%}
.builder table tr td + td + td{width:20%}
.builder table tr td + td + td +td{width:60%}
}div.developers{width:100%;}
div.developers h1{font-size:2em;color:#7d8aa5}
div.developers section{padding:0 0 1em;color:#777571;float:left;width:100%;clear:both}
div.developers img{float:left;height:65px;margin:.4em 1em}
div.developers h3,div.developers p.inline{display:inline}
div.developers p.small{font-size:.9em;}
div.developers p.small a{color:#7d8aa5}
.features{text-align:left;}
.features section{width:50%}
</style>
<title>
MooTools Blog: Get friendly with the Natives
</title>
<meta content="width=device-width, user-scalable=no" name="viewport">
<meta content="AymqwRC7u88Y4JPvfIF2F37QKylC04248hLCdJAsh8xgOfe/dVJPV3XS3wLFca1ZMVOtnBfVjaCMTVudWM//5g4AAAB7eyJvcmlnaW4iOiJodHRwczovL3d3dy5nb29nbGV0YWdtYW5hZ2VyLmNvbTo0NDMiLCJmZWF0dXJlIjoiUHJpdmFjeVNhbmRib3hBZHNBUElzIiwiZXhwaXJ5IjoxNjk1MTY3OTk5LCJpc1RoaXJkUGFydHkiOnRydWV9" http-equiv="origin-trial">
</head>
<body class="mootools">
<header id="header" role="banner">
<div class="clearfix" id="global-bar">
<div class="clearfix wrapper">
<div id="logo">
<h1>
<a>
<img alt="MooTools" src="rick.jpg">
</a>
</h1>
<p class="visually-hidden">
Your resources for every-day JavaScripting
</p>
</div>
<div class="right clearfix" id="main-header">
<ul>
<li>
<a>
Core
</a>
</li>
<li>
<a>
More
</a>
</li>
<li>
<a>
Blog
</a>
</li>
<li>
<a>
Forge
</a>
</li>
</ul>
<form action="/search" id="search" method="get" role="search">
<label for="search-field">
<span aria-hidden="true" class="icon search">
</span>
<input id="search-field" name="q" placeholder="Search in the site" type="search">
</label>
</form>
</div>
</div>
</div>
</header>
<div class="main clearfix" role="main">
<div class="clearfix wrapper blog">
<h2>
Get friendly with the Natives
</h2>
<small>
Written by Ryan Florence on 24 March 2010 – Posted under
<a>
all
</a>
,
<a>
tips
</a>
</small>
<div class="post">
<p>
Have you extended a Native lately? It's an incredibly helpful thing.
</p>
<div class="heading clearfix">
<h3>
The Difference:
</h3>
</div>
<p>
I've seen stuff like this:
</p>
<pre><code class="javascript">fn1(fn2(<span class="number">10</span>, fn3(<span class="string">'house'</span>)));</code></pre>
<p>
Hard to figure out what's happening. Instead you can write code like:
</p>
<pre><code class="javascript">fn3(<span class="string">'house'</span>).fn2(<span class="number">10</span>).fn1();</code></pre>
<div class="heading clearfix">
<h3>
A Useful, Real Example, zeroPad
</h3>
</div>
<p>
I've used this in a couple scripts, it takes a number and returns a string with zeros padded in front: 123 becomes '000123'. Really handy for filenames and the like.
</p>
<div class="heading clearfix">
<h3>
Functionally Based Example
</h3>
</div>
<pre><code class="javascript"><span class="function"><span class="keyword">function</span> <span class="title">zeroPad</span><span class="params">(num, zeros)</span>{</span>
zeros = zeros || <span class="number">3</span>;
<span class="keyword">var</span> str = <span class="string">''</span> + num;
zeros.times(<span class="keyword">function</span>(){ str = <span class="string">'0'</span>+str; });
<span class="keyword">return</span> str;
};
<span class="comment">// usage</span>
doSomething(zeroPad(document.getElementById(<span class="string">'myInput'</span>).value, <span class="number">3</span>));</code></pre>
<div class="heading clearfix">
<h3>
Native Extentions Based Example
</h3>
</div>
<pre><code class="javascript">Number.implement({
zeroPad: <span class="keyword">function</span>(zeros){
<span class="keyword">var</span> str = <span class="string">''</span> + <span class="keyword">this</span>;
zeros.times(<span class="keyword">function</span>(){ str = <span class="string">'0'</span>+str; });
<span class="keyword">return</span> str;
}
});
<span class="comment">// so that it works on both numbers and strings</span>
String.implement({
zeroPad: <span class="keyword">function</span>(zeros){
<span class="keyword">return</span> <span class="keyword">this</span>.toInt().zeroPad(zeros);
}
});
<span class="comment">// usage</span>
$(<span class="string">'myInput'</span>).get(<span class="string">'value'</span>).zeroPad(<span class="number">3</span>).doSomething();</code></pre>
<div class="heading clearfix">
<h3>
Side by Side:
</h3>
</div>
<pre><code class="javascript">doSomething(zeroPad(document.getElementById(<span class="string">'myInput'</span>).value, <span class="number">3</span>));
<span class="comment">// vs</span>
$(<span class="string">'myInput'</span>).get(<span class="string">'value'</span>).zeroPad(<span class="number">3</span>).doSomething();</code></pre>
<p>
Awesome? Yes.
</p>
<ul>
<li>
<a alt="Array">
Array
</a>
</li>
<li>
<a alt="Function">
Function
</a>
</li>
<li>
<a alt="Number">
Number
</a>
</li>
<li>
<a alt="String">
String
</a>
</li>
</ul>
<p>
Some say extending natives is a bad idea. Personally, I think it's awesome--but this topic is a sore spot for some.
</p>
<div class="heading clearfix">
<h3>
Flippin' Sweet Array methods
</h3>
</div>
<p>
Arian Stolwijk created this amazing gem:
<a alt="Array.Math">
Array.Math
</a>
. Code samples often tell the story faster:
</p>
<pre><code class="javascript">[<span class="number">2</span>,<span class="number">5</span>,<span class="number">1</span>,<span class="number">6</span>].sum(); <span class="comment">// 14</span>
[<span class="number">2</span>,<span class="number">5</span>,<span class="number">6</span>,<span class="number">2</span>].product(<span class="number">3</span>); <span class="comment">// [6,15,18,6]</span>
[<span class="number">9</span>,<span class="number">12</span>,<span class="number">15</span>].quotient(<span class="number">3</span>) <span class="comment">// [3,4,5]</span></code></pre>
<p>
This is all made possible by extending the
<code>
Array
</code>
native, see?
</p>
<pre><code class="javascript">Array.implement({
sum: <span class="keyword">function</span>(start,length){
<span class="keyword">var</span> sum = <span class="number">0</span>,
start = start ? start : <span class="number">0</span>,
length = length ? length : <span class="keyword">this</span>.count()-start;
length = start ? length + <span class="number">2</span> : length;
<span class="keyword">for</span>(<span class="keyword">var</span> i=start;i&lt;length;i++) sum += <span class="keyword">this</span>[i];
<span class="keyword">return</span> sum;
},
product: <span class="keyword">function</span>(p){
<span class="keyword">var</span> arr = $type(p) == <span class="string">'array'</span>;
<span class="keyword">return</span> <span class="keyword">this</span>.map(<span class="keyword">function</span>(entity,i){
<span class="keyword">return</span> arr ? (entity * p[i]) : (entity * p);
});
},
quotient: <span class="keyword">function</span>(q){
<span class="keyword">var</span> arr = $type(q) == <span class="string">'array'</span>;
<span class="keyword">return</span> <span class="keyword">this</span>.map(<span class="keyword">function</span>(entity,i){
<span class="keyword">return</span> arr ? (entity / q[i]) : (entity / q);
});
},
<span class="comment">// and a whole lot more awesome ...</span>
});</code></pre>
<div class="heading clearfix">
<h3>
Quick Tips
</h3>
</div>
<ul>
<li>
<code>
this
</code>
is the number or string, or whatever, when inside the method.
</li>
<li>
Return something that makes sense (usually
<code>
this
</code>
).
</li>
<li>
You can implement several methods all in the same code block.
</li>
</ul>
<p>
This is just one more great tool to help keep your code organized and readable.
</p>
<div id="disqus_thread">
</div>
<noscript>
Please enable JavaScript to view the
<a>
comments powered by Disqus.
</a>
</noscript>
</div>
</div>
<hr>
<nav id="menu" role="navigation">
<div class="clearfix wrapper">
<h2 class="visually-hidden">
Projects
</h2>
<ul>
<li class="core">
<a>
<img alt="Core" src="rick.jpg">
</a>
</li>
<li class="more">
<a>
<img alt="More" src="rick.jpg">
</a>
</li>
</ul>
</div>
</nav>
</div>
<hr>
<footer class="clearfix wrapper" id="footer">
<nav id="sitemap" role="navigation">
<div>
<h3>
About
<span aria-hidden="true" class="slider">
</span>
</h3>
<ul>
<li>
<a>
Blog
</a>
</li>
<li>
<a>
Books
</a>
</li>
<li>
<a>
Developers
</a>
</li>
<li>
<a target="_blank">
Merchandising
</a>
</li>
</ul>
</div>
<div>
<h3>
Support
<span aria-hidden="true" class="slider">
</span>
</h3>
<ul>
<li>
<a target="_blank">
User Group
</a>
</li>
<li>
<a target="_blank">
The MooTorial
</a>
</li>
<li>
<a target="_blank">
Stack Overflow
</a>
</li>
</ul>
</div>
<div>
<h3>
Connect with us
<span aria-hidden="true" class="slider">
</span>
</h3>
<ul>
<li>
<a target="_blank">
<span aria-hidden="true" class="icon github">
</span>
GitHub
</a>
</li>
<li>
<a target="_blank">
<span aria-hidden="true" class="icon twitter">
</span>
Twitter
</a>
</li>
<li>
<a target="_blank">
<span aria-hidden="true" class="icon facebook">
</span>
Facebook
</a>
</li>
<li>
<a target="_blank">
<span aria-hidden="true" class="icon googleplus">
</span>
Google+
</a>
</li>
</ul>
</div>
<div>
<h3>
Documentation
<span aria-hidden="true" class="slider">
</span>
</h3>
<ul>
<li>
<a>
MooTools Core
</a>
</li>
<li>
<a>
MooTools More
</a>
</li>
</ul>
</div>
</nav>
<div id="credits" role="contentinfo">
<p>
<a>
<img alt="MooTools" class="mootools" src="rick.jpg">
</a>
</p>
<p>
Copyright © 2006-2023
<br>
Valerio Proietti & MooTools Developers
</p>
</div>
</footer>
</body>
</html>
|