Best JavaScript code snippet using cypress
index.js
Source:index.js
...129 assert: function() { return Date.today().last().sunday().equals(Date.parse('last su')) }130 }, 131'prev monday': {132 run: function() { },133 assert: function() { return Date.today().prev().monday().equals(Date.parse('prev monday')) }134 },135 'prev mon': {136 run: function() { },137 assert: function() { return Date.today().prev().monday().equals(Date.parse('prev mon')) }138 },139'prev mo': {140 run: function() { },141 assert: function() { return Date.today().prev().monday().equals(Date.parse('prev mo')) }142 }, 143 'prev tuesday': {144 run: function() { },145 assert: function() { return Date.today().prev().tuesday().equals(Date.parse('prev tuesday')) }146 },147 'prev tues': {148 run: function() { },149 assert: function() { return Date.today().prev().tuesday().equals(Date.parse('prev tues')) }150 },151 'prev tue': {152 run: function() { },153 assert: function() { return Date.today().prev().tuesday().equals(Date.parse('prev tue')) }154 }, 155 'prev tu': {156 run: function() { },157 assert: function() { return Date.today().prev().tuesday().equals(Date.parse('prev tu')) }158 }, 159 'prev wednesday': {160 run: function() { },161 assert: function() { return Date.today().prev().wednesday().equals(Date.parse('prev wednesday')) }162 },163 'prev wed': {164 run: function() { },165 assert: function() { return Date.today().prev().wednesday().equals(Date.parse('prev wed')) }166 }, 167 'prev we': {168 run: function() { },169 assert: function() { return Date.today().prev().wednesday().equals(Date.parse('prev we')) }170 }, 171 'prev thursday': {172 run: function() { },173 assert: function() { return Date.today().prev().thursday().equals(Date.parse('prev thursday')) }174 },175 'prev thurs': {176 run: function() { },177 assert: function() { return Date.today().prev().thursday().equals(Date.parse('prev thurs')) }178 }, 179 'prev thur': {180 run: function() { },181 assert: function() { return Date.today().prev().thursday().equals(Date.parse('prev thur')) }182 },183 'prev thu': {184 run: function() { },185 assert: function() { return Date.today().prev().thursday().equals(Date.parse('prev thu')) }186 },187// 'prev th': {188// run: function() { },189// assert: function() { return Date.today().prev().thursday().equals(Date.parse('prev th')) }190// }, 191 'prev friday': {192 run: function() { },193 assert: function() { return Date.today().prev().friday().equals(Date.parse('prev friday')) }194 },195 'prev fri': {196 run: function() { },197 assert: function() { return Date.today().prev().friday().equals(Date.parse('prev fri')) }198 },199 'prev fr': {200 run: function() { },201 assert: function() { return Date.today().prev().friday().equals(Date.parse('prev fr')) }202 }, 203 'prev saturday': {204 run: function() { },205 assert: function() { return Date.today().prev().saturday().equals(Date.parse('prev saturday')) }206 },207 'prev sat': {208 run: function() { },209 assert: function() { return Date.today().prev().saturday().equals(Date.parse('prev sat')) }210 }, 211 'prev sa': {212 run: function() { },213 assert: function() { return Date.today().prev().saturday().equals(Date.parse('prev sa')) }214 }, 215 'prev sunday': {216 run: function() { },217 assert: function() { return Date.today().prev().sunday().equals(Date.parse('prev sunday')) }218 },219 'prev sun': {220 run: function() { },221 assert: function() { return Date.today().prev().sunday().equals(Date.parse('prev sun')) }222 },223 'prev su': {224 run: function() { },225 assert: function() { return Date.today().prev().sunday().equals(Date.parse('prev su')) }226 }, 227 228'previous monday': {229 run: function() { },230 assert: function() { return Date.today().previous().monday().equals(Date.parse('previous monday')) }231 },232 'previous mon': {233 run: function() { },234 assert: function() { return Date.today().previous().monday().equals(Date.parse('previous mon')) }235 },236 'previous mo': {237 run: function() { },238 assert: function() { return Date.today().previous().monday().equals(Date.parse('previous mo')) }239 }, 240 'previous tuesday': {241 run: function() { },242 assert: function() { return Date.today().previous().tuesday().equals(Date.parse('previous tuesday')) }243 },244 'previous tues': {245 run: function() { },246 assert: function() { return Date.today().previous().tuesday().equals(Date.parse('previous tues')) }247 },248 'previous tue': {249 run: function() { },250 assert: function() { return Date.today().previous().tuesday().equals(Date.parse('previous tue')) }251 }, 252 'previous tu': {253 run: function() { },254 assert: function() { return Date.today().previous().tuesday().equals(Date.parse('previous tu')) }255 }, 256 'previous wednesday': {257 run: function() { },258 assert: function() { return Date.today().previous().wednesday().equals(Date.parse('previous wednesday')) }259 },260 'previous wed': {261 run: function() { },262 assert: function() { return Date.today().previous().wednesday().equals(Date.parse('previous wed')) }263 }, 264 'previous we': {265 run: function() { },266 assert: function() { return Date.today().previous().wednesday().equals(Date.parse('previous we')) }267 }, 268 'previous thursday': {269 run: function() { },270 assert: function() { return Date.today().previous().thursday().equals(Date.parse('previous thursday')) }271 },272 'previous thurs': {273 run: function() { },274 assert: function() { return Date.today().previous().thursday().equals(Date.parse('previous thurs')) }275 }, 276 'previous thur': {277 run: function() { },278 assert: function() { return Date.today().previous().thursday().equals(Date.parse('previous thur')) }279 },280 'previous thu': {281 run: function() { },282 assert: function() { return Date.today().previous().thursday().equals(Date.parse('previous thu')) }283 },284// 'previous th': {285// run: function() { },286// assert: function() { return Date.today().previous().thursday().equals(Date.parse('previous th')) }287// }, 288 'previous friday': {289 run: function() { },290 assert: function() { return Date.today().previous().friday().equals(Date.parse('previous friday')) }291 },292 'previous fri': {293 run: function() { },294 assert: function() { return Date.today().previous().friday().equals(Date.parse('previous fri')) }295 },296 'previous fr': {297 run: function() { },298 assert: function() { return Date.today().previous().friday().equals(Date.parse('previous fr')) }299 }, 300 'previous saturday': {301 run: function() { },302 assert: function() { return Date.today().previous().saturday().equals(Date.parse('previous saturday')) }303 },304 'previous sat': {305 run: function() { },306 assert: function() { return Date.today().previous().saturday().equals(Date.parse('previous sat')) }307 },308'previous sa': {309 run: function() { },310 assert: function() { return Date.today().previous().saturday().equals(Date.parse('previous sa')) }311 }, 312 'previous sunday': {313 run: function() { },314 assert: function() { return Date.today().previous().sunday().equals(Date.parse('previous sunday')) }315 },316 'previous sun': {317 run: function() { },318 assert: function() { return Date.today().previous().sunday().equals(Date.parse('previous sun')) }319 },320 'previous su': {321 run: function() { },322 assert: function() { return Date.today().previous().sunday().equals(Date.parse('previous su')) }323 }, 324'next monday': {325 run: function() { },326 assert: function() { return Date.today().next().monday().equals(Date.parse('next monday')) }327 },328 'next mon': {329 run: function() { },330 assert: function() { return Date.today().next().monday().equals(Date.parse('next mon')) }331 },332 'next mo': {333 run: function() { },334 assert: function() { return Date.today().next().monday().equals(Date.parse('next mo')) }335 }, 336 'next tuesday': {337 run: function() { },338 assert: function() { return Date.today().next().tuesday().equals(Date.parse('next tuesday')) }339 },340 'next tues': {341 run: function() { },342 assert: function() { return Date.today().next().tuesday().equals(Date.parse('next tues')) }343 },344 'next tue': {345 run: function() { },346 assert: function() { return Date.today().next().tuesday().equals(Date.parse('next tue')) }347 }, 348 'next tu': {349 run: function() { },350 assert: function() { return Date.today().next().tuesday().equals(Date.parse('next tu')) }351 }, 352 'next wednesday': {353 run: function() { },354 assert: function() { return Date.today().next().wednesday().equals(Date.parse('next wednesday')) }355 },356 'next wed': {357 run: function() { },358 assert: function() { return Date.today().next().wednesday().equals(Date.parse('next wed')) }359 }, 360 'next we': {361 run: function() { },362 assert: function() { return Date.today().next().wednesday().equals(Date.parse('next we')) }363 }, 364 'next thursday': {365 run: function() { },366 assert: function() { return Date.today().next().thursday().equals(Date.parse('next thursday')) }367 },368 'next thurs': {369 run: function() { },370 assert: function() { return Date.today().next().thursday().equals(Date.parse('next thurs')) }371 }, 372 'next thur': {373 run: function() { },374 assert: function() { return Date.today().next().thursday().equals(Date.parse('next thur')) }375 },376 'next thu': {377 run: function() { },378 assert: function() { return Date.today().next().thursday().equals(Date.parse('next thu')) }379 },380// 'next th': {381// run: function() { },382// assert: function() { return Date.today().next().thursday().equals(Date.parse('next th')) }383// }, 384 'next friday': {385 run: function() { },386 assert: function() { return Date.today().next().friday().equals(Date.parse('next friday')) }387 },388 'next fri': {389 run: function() { },390 assert: function() { return Date.today().next().friday().equals(Date.parse('next fri')) }391 },392 'next fr': {393 run: function() { },394 assert: function() { return Date.today().next().friday().equals(Date.parse('next fr')) }395 },396 'next saturday': {397 run: function() { },398 assert: function() { return Date.today().next().saturday().equals(Date.parse('next saturday')) }399 },400 'next sat': {401 run: function() { },402 assert: function() { return Date.today().next().saturday().equals(Date.parse('next sat')) }403 }, 404 'next sa': {405 run: function() { },406 assert: function() { return Date.today().next().saturday().equals(Date.parse('next sa')) }407 }, 408 'next sunday': {409 run: function() { },410 assert: function() { return Date.today().next().sunday().equals(Date.parse('next sunday')) }411 },412 'next sun': {413 run: function() { },414 assert: function() { return Date.today().next().sunday().equals(Date.parse('next sun')) }415 },416 'next su': {417 run: function() { },418 assert: function() { return Date.today().next().sunday().equals(Date.parse('next su')) }419 } 420 421 },422'Relative Months': {423 setup: function() { },424 'last january': {425 run: function() { },426 assert: function() { return Date.today().last().january().equals(Date.parse('last january')) }427 },428 'last jan': {429 run: function() { },430 assert: function() { return Date.today().last().january().equals(Date.parse('last jan')) }431 }, 432 'last february': {433 run: function() { },434 assert: function() { return Date.today().last().february().equals(Date.parse('last february')) }435 }, 436 'last feb': {437 run: function() { },438 assert: function() { return Date.today().last().february().equals(Date.parse('last feb')) }439 }, 440 'last march': {441 run: function() { },442 assert: function() { return Date.today().last().march().equals(Date.parse('last march')) }443 }, 444 'last mar': {445 run: function() { },446 assert: function() { return Date.today().last().march().equals(Date.parse('last mar')) }447 },448 'last april': {449 run: function() { },450 assert: function() { return Date.today().last().april().equals(Date.parse('last april')) }451 },452 'last apr': {453 run: function() { },454 assert: function() { return Date.today().last().apr().equals(Date.parse('last apr')) }455 },456 'last may': {457 run: function() { },458 assert: function() { return Date.today().last().may().equals(Date.parse('last may')) }459 }, 460 'last june': {461 run: function() { },462 assert: function() { return Date.today().last().june().equals(Date.parse('last june')) }463 }, 464 'last jun': {465 run: function() { },466 assert: function() { return Date.today().last().june().equals(Date.parse('last jun')) }467 }, 468 'last july': {469 run: function() { },470 assert: function() { return Date.today().last().july().equals(Date.parse('last july')) }471 },472 'last jul': {473 run: function() { },474 assert: function() { return Date.today().last().july().equals(Date.parse('last july')) }475 },476 'last august': {477 run: function() { },478 assert: function() { return Date.today().last().august().equals(Date.parse('last august')) }479 },480 'last aug': {481 run: function() { },482 assert: function() { return Date.today().last().august().equals(Date.parse('last aug')) }483 },484 'last september': {485 run: function() { },486 assert: function() { return Date.today().last().september().equals(Date.parse('last september')) }487 },488 'last sept': {489 run: function() { },490 assert: function() { return Date.today().last().september().equals(Date.parse('last sept')) }491 },492 'last sep': {493 run: function() { },494 assert: function() { return Date.today().last().sep().equals(Date.parse('last sep')) }495 },496 'last october': {497 run: function() { },498 assert: function() { return Date.today().last().october().equals(Date.parse('last october')) }499 }, 500 'last oct': {501 run: function() { },502 assert: function() { return Date.today().last().october().equals(Date.parse('last oct')) }503 },504 'last november': {505 run: function() { },506 assert: function() { return Date.today().last().november().equals(Date.parse('last november')) }507 }, 508 'last nov': {509 run: function() { },510 assert: function() { return Date.today().last().november().equals(Date.parse('last nov')) }511 }, 512 'last december': {513 run: function() { },514 assert: function() { return Date.today().last().december().equals(Date.parse('last december')) }515 },516 'last dec': {517 run: function() { },518 assert: function() { return Date.today().last().december().equals(Date.parse('last dec')) }519 },520'prev january': {521 run: function() { },522 assert: function() { return Date.today().prev().january().equals(Date.parse('prev january')) }523 },524 'prev jan': {525 run: function() { },526 assert: function() { return Date.today().prev().january().equals(Date.parse('prev jan')) }527 }, 528 'prev february': {529 run: function() { },530 assert: function() { return Date.today().prev().february().equals(Date.parse('prev february')) }531 }, 532 'prev feb': {533 run: function() { },534 assert: function() { return Date.today().prev().february().equals(Date.parse('prev feb')) }535 }, 536 'prev march': {537 run: function() { },538 assert: function() { return Date.today().prev().march().equals(Date.parse('prev march')) }539 }, 540 'prev mar': {541 run: function() { },542 assert: function() { return Date.today().prev().march().equals(Date.parse('prev mar')) }543 },544 'prev april': {545 run: function() { },546 assert: function() { return Date.today().prev().april().equals(Date.parse('prev april')) }547 },548 'prev apr': {549 run: function() { },550 assert: function() { return Date.today().prev().apr().equals(Date.parse('prev apr')) }551 },552 'prev may': {553 run: function() { },554 assert: function() { return Date.today().prev().may().equals(Date.parse('prev may')) }555 }, 556 'prev june': {557 run: function() { },558 assert: function() { return Date.today().prev().june().equals(Date.parse('prev june')) }559 }, 560 'prev jun': {561 run: function() { },562 assert: function() { return Date.today().prev().june().equals(Date.parse('prev jun')) }563 }, 564 'prev july': {565 run: function() { },566 assert: function() { return Date.today().prev().july().equals(Date.parse('prev july')) }567 },568 'prev jul': {569 run: function() { },570 assert: function() { return Date.today().prev().july().equals(Date.parse('prev july')) }571 },572 'prev august': {573 run: function() { },574 assert: function() { return Date.today().prev().august().equals(Date.parse('prev august')) }575 },576 'prev aug': {577 run: function() { },578 assert: function() { return Date.today().prev().august().equals(Date.parse('prev aug')) }579 },580 'prev september': {581 run: function() { },582 assert: function() { return Date.today().prev().september().equals(Date.parse('prev september')) }583 },584 'prev sept': {585 run: function() { },586 assert: function() { return Date.today().prev().september().equals(Date.parse('prev sept')) }587 },588 'prev sep': {589 run: function() { },590 assert: function() { return Date.today().prev().sep().equals(Date.parse('prev sep')) }591 },592 'prev october': {593 run: function() { },594 assert: function() { return Date.today().prev().october().equals(Date.parse('prev october')) }595 }, 596 'prev oct': {597 run: function() { },598 assert: function() { return Date.today().prev().october().equals(Date.parse('prev oct')) }599 },600 'prev november': {601 run: function() { },602 assert: function() { return Date.today().prev().november().equals(Date.parse('prev november')) }603 }, 604 'prev nov': {605 run: function() { },606 assert: function() { return Date.today().prev().november().equals(Date.parse('prev nov')) }607 }, 608 'prev december': {609 run: function() { },610 assert: function() { return Date.today().prev().december().equals(Date.parse('prev december')) }611 },612 'prev dec': {613 run: function() { },614 assert: function() { return Date.today().prev().december().equals(Date.parse('prev dec')) }615 },616'previous january': {617 run: function() { },618 assert: function() { return Date.today().previous().january().equals(Date.parse('previous january')) }619 },620 'previous jan': {621 run: function() { },622 assert: function() { return Date.today().previous().january().equals(Date.parse('previous jan')) }623 }, 624 'previous february': {625 run: function() { },626 assert: function() { return Date.today().previous().february().equals(Date.parse('previous february')) }627 }, 628 'previous feb': {629 run: function() { },630 assert: function() { return Date.today().previous().february().equals(Date.parse('previous feb')) }631 }, 632 'previous march': {633 run: function() { },634 assert: function() { return Date.today().previous().march().equals(Date.parse('previous march')) }635 }, 636 'previous mar': {637 run: function() { },638 assert: function() { return Date.today().previous().march().equals(Date.parse('previous mar')) }639 },640 'previous april': {641 run: function() { },642 assert: function() { return Date.today().previous().april().equals(Date.parse('previous april')) }643 },644 'previous apr': {645 run: function() { },646 assert: function() { return Date.today().previous().apr().equals(Date.parse('previous apr')) }647 },648 'previous may': {649 run: function() { },650 assert: function() { return Date.today().previous().may().equals(Date.parse('previous may')) }651 }, 652 'previous june': {653 run: function() { },654 assert: function() { return Date.today().previous().june().equals(Date.parse('previous june')) }655 }, 656 'previous jun': {657 run: function() { },658 assert: function() { return Date.today().previous().june().equals(Date.parse('previous jun')) }659 }, 660 'previous july': {661 run: function() { },662 assert: function() { return Date.today().previous().july().equals(Date.parse('previous july')) }663 },664 'previous jul': {665 run: function() { },666 assert: function() { return Date.today().previous().july().equals(Date.parse('previous july')) }667 },668 'previous august': {669 run: function() { },670 assert: function() { return Date.today().previous().august().equals(Date.parse('previous august')) }671 },672 'previous aug': {673 run: function() { },674 assert: function() { return Date.today().previous().august().equals(Date.parse('previous aug')) }675 },676 'previous september': {677 run: function() { },678 assert: function() { return Date.today().previous().september().equals(Date.parse('previous september')) }679 },680 'previous sept': {681 run: function() { },682 assert: function() { return Date.today().previous().september().equals(Date.parse('previous sept')) }683 },684 'previous sep': {685 run: function() { },686 assert: function() { return Date.today().previous().sep().equals(Date.parse('previous sep')) }687 },688 'previous october': {689 run: function() { },690 assert: function() { return Date.today().previous().october().equals(Date.parse('previous october')) }691 }, 692 'previous oct': {693 run: function() { },694 assert: function() { return Date.today().previous().october().equals(Date.parse('previous oct')) }695 },696 'previous november': {697 run: function() { },698 assert: function() { return Date.today().previous().november().equals(Date.parse('previous november')) }699 }, 700 'previous nov': {701 run: function() { },702 assert: function() { return Date.today().previous().november().equals(Date.parse('previous nov')) }703 }, 704 'previous december': {705 run: function() { },706 assert: function() { return Date.today().previous().december().equals(Date.parse('previous december')) }707 },708 'previous dec': {709 run: function() { },710 assert: function() { return Date.today().previous().december().equals(Date.parse('previous dec')) }711 },712 'next january': {713 run: function() { },714 assert: function() { return Date.today().next().january().equals(Date.parse('next january')) }715 },716 'next jan': {717 run: function() { },718 assert: function() { return Date.today().next().january().equals(Date.parse('next jan')) }719 }, 720 'next february': {721 run: function() { },722 assert: function() { return Date.today().next().february().equals(Date.parse('next february')) }723 }, 724 'next feb': {725 run: function() { },726 assert: function() { return Date.today().next().february().equals(Date.parse('next feb')) }727 }, 728 'next march': {729 run: function() { },730 assert: function() { return Date.today().next().march().equals(Date.parse('next march')) }731 }, 732 'next mar': {733 run: function() { },734 assert: function() { return Date.today().next().march().equals(Date.parse('next mar')) }735 },736 'next april': {737 run: function() { },738 assert: function() { return Date.today().next().april().equals(Date.parse('next april')) }739 },740 'next apr': {741 run: function() { },742 assert: function() { return Date.today().next().apr().equals(Date.parse('next apr')) }743 },744 'next may': {745 run: function() { },746 assert: function() { return Date.today().next().may().equals(Date.parse('next may')) }747 }, 748 'next june': {749 run: function() { },750 assert: function() { return Date.today().next().june().equals(Date.parse('next june')) }751 }, 752 'next jun': {753 run: function() { },754 assert: function() { return Date.today().next().june().equals(Date.parse('next jun')) }755 }, 756 'next july': {757 run: function() { },758 assert: function() { return Date.today().next().july().equals(Date.parse('next july')) }759 },760 'next jul': {761 run: function() { },762 assert: function() { return Date.today().next().july().equals(Date.parse('next july')) }763 },764 'next august': {765 run: function() { },766 assert: function() { return Date.today().next().august().equals(Date.parse('next august')) }767 },768 'next aug': {769 run: function() { },770 assert: function() { return Date.today().next().august().equals(Date.parse('next aug')) }771 },772 'next september': {773 run: function() { },774 assert: function() { return Date.today().next().september().equals(Date.parse('next september')) }775 },776 'next sept': {777 run: function() { },778 assert: function() { return Date.today().next().september().equals(Date.parse('next sept')) }779 },780 'next sep': {781 run: function() { },782 assert: function() { return Date.today().next().sep().equals(Date.parse('next sep')) }783 },784 'next october': {785 run: function() { },786 assert: function() { return Date.today().next().october().equals(Date.parse('next october')) }787 }, 788 'next oct': {789 run: function() { },790 assert: function() { return Date.today().next().october().equals(Date.parse('next oct')) }791 },792 'next november': {793 run: function() { },794 assert: function() { return Date.today().next().november().equals(Date.parse('next november')) }795 }, 796 'next nov': {797 run: function() { },798 assert: function() { return Date.today().next().november().equals(Date.parse('next nov')) }799 }, 800 'next december': {801 run: function() { },802 assert: function() { return Date.today().next().december().equals(Date.parse('next december')) }803 },804 'next dec': {805 run: function() { },806 assert: function() { return Date.today().next().december().equals(Date.parse('next dec')) }807 } 808 },809'Relative Date Element Parts': {810 setup: function() { },811 'last seconds': {812 run: function() { },813 assert: function() { return new Date().last().second().set({millisecond: 0}).equals(Date.parse('last seconds').set({millisecond: 0})) }814 }, 815 'last second': {816 run: function() { },817 assert: function() { return new Date().last().second().set({millisecond: 0}).equals(Date.parse('last second').set({millisecond: 0})) }818 },819 'last sec': {820 run: function() { },821 assert: function() { return new Date().last().second().set({millisecond: 0}).equals(Date.parse('last sec').set({millisecond: 0})) }822 },823 'last minutes': {824 run: function() { },825 assert: function() { return new Date().last().minute().set({millisecond: 0}).equals(Date.parse('last minutes').set({millisecond: 0})) }826 },827 'last minute': {828 run: function() { },829 assert: function() { return new Date().last().minute().set({millisecond: 0}).equals(Date.parse('last minute').set({millisecond: 0})) }830 },831 'last min': {832 run: function() { },833 assert: function() { return new Date().last().minute().set({millisecond: 0}).equals(Date.parse('last min').set({millisecond: 0})) }834 },835 'last mn': {836 run: function() { },837 assert: function() { return new Date().last().minute().set({millisecond: 0}).equals(Date.parse('last mn').set({millisecond: 0})) }838 }, 839 'last hours': {840 run: function() { },841 assert: function() { return new Date().last().hour().set({millisecond: 0}).equals(Date.parse('last hours').set({millisecond: 0})) }842 },843 'last hour': {844 run: function() { },845 assert: function() { return new Date().last().hour().set({millisecond: 0}).equals(Date.parse('last hour').set({millisecond: 0})) }846 },847 'last days': {848 run: function() { },849 assert: function() { return Date.today().last().day().equals(Date.parse('last days')) }850 },851 'last day': {852 run: function() { },853 assert: function() { return Date.today().last().day().equals(Date.parse('last day')) }854 },855 'last weeks': {856 run: function() { },857 assert: function() { return Date.today().last().week().equals(Date.parse('last weeks')) }858 }, 859 'last week': {860 run: function() { },861 assert: function() { return Date.today().last().week().equals(Date.parse('last week')) }862 },863 'last months': {864 run: function() { },865 assert: function() { return Date.today().last().month().equals(Date.parse('last months')) }866 },867 'last month': {868 run: function() { },869 assert: function() { return Date.today().last().month().equals(Date.parse('last month')) }870 },871 'last years': {872 run: function() { },873 assert: function() { return Date.today().last().year().equals(Date.parse('last years')) }874 },875 'last year': {876 run: function() { },877 assert: function() { return Date.today().last().year().equals(Date.parse('last year')) }878 },879'prev seconds': {880 run: function() { },881 assert: function() { return new Date().prev().second().set({millisecond: 0}).equals(Date.parse('prev seconds').set({millisecond: 0})) }882 }, 883 'prev second': {884 run: function() { },885 assert: function() { return new Date().prev().second().set({millisecond: 0}).equals(Date.parse('prev second').set({millisecond: 0})) }886 },887 'prev sec': {888 run: function() { },889 assert: function() { return new Date().prev().second().set({millisecond: 0}).equals(Date.parse('prev sec').set({millisecond: 0})) }890 },891 'prev minutes': {892 run: function() { },893 assert: function() { return new Date().prev().minute().set({millisecond: 0}).equals(Date.parse('prev minutes').set({millisecond: 0})) }894 },895 'prev minute': {896 run: function() { },897 assert: function() { return new Date().prev().minute().set({millisecond: 0}).equals(Date.parse('prev minute').set({millisecond: 0})) }898 },899 'prev min': {900 run: function() { },901 assert: function() { return new Date().prev().minute().set({millisecond: 0}).equals(Date.parse('prev min').set({millisecond: 0})) }902 },903 'prev mn': {904 run: function() { },905 assert: function() { return new Date().prev().minute().set({millisecond: 0}).equals(Date.parse('prev mn').set({millisecond: 0})) }906 }, 907 'prev hours': {908 run: function() { },909 assert: function() { return new Date().prev().hour().set({millisecond: 0}).equals(Date.parse('prev hours').set({millisecond: 0})) }910 },911 'prev hour': {912 run: function() { },913 assert: function() { return new Date().prev().hour().set({millisecond: 0}).equals(Date.parse('prev hour').set({millisecond: 0})) }914 },915 'prev days': {916 run: function() { },917 assert: function() { return Date.today().prev().day().equals(Date.parse('prev days')) }918 },919 'prev day': {920 run: function() { },921 assert: function() { return Date.today().prev().day().equals(Date.parse('prev day')) }922 },923 'prev weeks': {924 run: function() { },925 assert: function() { return Date.today().prev().week().equals(Date.parse('prev weeks')) }926 }, 927 'prev week': {928 run: function() { },929 assert: function() { return Date.today().prev().week().equals(Date.parse('prev week')) }930 },931 'prev months': {932 run: function() { },933 assert: function() { return Date.today().prev().month().equals(Date.parse('prev months')) }934 },935 'prev month': {936 run: function() { },937 assert: function() { return Date.today().prev().month().equals(Date.parse('prev month')) }938 },939 'prev years': {940 run: function() { },941 assert: function() { return Date.today().prev().year().equals(Date.parse('prev years')) }942 },943 'prev year': {944 run: function() { },945 assert: function() { return Date.today().prev().year().equals(Date.parse('prev year')) }946 }, 947 948'previous seconds': {949 run: function() { },950 assert: function() { return new Date().previous().second().set({millisecond: 0}).equals(Date.parse('previous seconds').set({millisecond: 0})) }951 }, 952 'previous second': {953 run: function() { },954 assert: function() { return new Date().previous().second().set({millisecond: 0}).equals(Date.parse('previous second').set({millisecond: 0})) }955 },956 'previous sec': {957 run: function() { },958 assert: function() { return new Date().previous().second().set({millisecond: 0}).equals(Date.parse('previous sec').set({millisecond: 0})) }959 },...
slideshow.js
Source:slideshow.js
1/*! UIkit 3.6.16 | https://www.getuikit.com | (c) 2014 - 2021 YOOtheme | MIT License */2(function (global, factory) {3 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('uikit-util')) :4 typeof define === 'function' && define.amd ? define('uikitslideshow', ['uikit-util'], factory) :5 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.UIkitSlideshow = factory(global.UIkit.util));6}(this, (function (uikitUtil) { 'use strict';7 var Class = {8 connected: function() {9 !uikitUtil.hasClass(this.$el, this.$name) && uikitUtil.addClass(this.$el, this.$name);10 }11 };12 var Animations$1 = {13 slide: {14 show: function(dir) {15 return [16 {transform: translate(dir * -100)},17 {transform: translate()}18 ];19 },20 percent: function(current) {21 return translated(current);22 },23 translate: function(percent, dir) {24 return [25 {transform: translate(dir * -100 * percent)},26 {transform: translate(dir * 100 * (1 - percent))}27 ];28 }29 }30 };31 function translated(el) {32 return Math.abs(uikitUtil.css(el, 'transform').split(',')[4] / el.offsetWidth) || 0;33 }34 function translate(value, unit) {35 if ( value === void 0 ) value = 0;36 if ( unit === void 0 ) unit = '%';37 value += value ? unit : '';38 return uikitUtil.isIE ? ("translateX(" + value + ")") : ("translate3d(" + value + ", 0, 0)"); // currently not translate3d in IE, translate3d within translate3d does not work while transitioning39 }40 function scale3d(value) {41 return ("scale3d(" + value + ", " + value + ", 1)");42 }43 function Transitioner(prev, next, dir, ref) {44 var animation = ref.animation;45 var easing = ref.easing;46 var percent = animation.percent;47 var translate = animation.translate;48 var show = animation.show; if ( show === void 0 ) show = uikitUtil.noop;49 var props = show(dir);50 var deferred = new uikitUtil.Deferred();51 return {52 dir: dir,53 show: function(duration, percent, linear) {54 var this$1 = this;55 if ( percent === void 0 ) percent = 0;56 var timing = linear ? 'linear' : easing;57 duration -= Math.round(duration * uikitUtil.clamp(percent, -1, 1));58 this.translate(percent);59 triggerUpdate(next, 'itemin', {percent: percent, duration: duration, timing: timing, dir: dir});60 triggerUpdate(prev, 'itemout', {percent: 1 - percent, duration: duration, timing: timing, dir: dir});61 uikitUtil.Promise.all([62 uikitUtil.Transition.start(next, props[1], duration, timing),63 uikitUtil.Transition.start(prev, props[0], duration, timing)64 ]).then(function () {65 this$1.reset();66 deferred.resolve();67 }, uikitUtil.noop);68 return deferred.promise;69 },70 cancel: function() {71 uikitUtil.Transition.cancel([next, prev]);72 },73 reset: function() {74 for (var prop in props[0]) {75 uikitUtil.css([next, prev], prop, '');76 }77 },78 forward: function(duration, percent) {79 if ( percent === void 0 ) percent = this.percent();80 uikitUtil.Transition.cancel([next, prev]);81 return this.show(duration, percent, true);82 },83 translate: function(percent) {84 this.reset();85 var props = translate(percent, dir);86 uikitUtil.css(next, props[1]);87 uikitUtil.css(prev, props[0]);88 triggerUpdate(next, 'itemtranslatein', {percent: percent, dir: dir});89 triggerUpdate(prev, 'itemtranslateout', {percent: 1 - percent, dir: dir});90 },91 percent: function() {92 return percent(prev || next, next, dir);93 },94 getDistance: function() {95 return prev && prev.offsetWidth;96 }97 };98 }99 function triggerUpdate(el, type, data) {100 uikitUtil.trigger(el, uikitUtil.createEvent(type, false, false, data));101 }102 var SliderAutoplay = {103 props: {104 autoplay: Boolean,105 autoplayInterval: Number,106 pauseOnHover: Boolean107 },108 data: {109 autoplay: false,110 autoplayInterval: 7000,111 pauseOnHover: true112 },113 connected: function() {114 this.autoplay && this.startAutoplay();115 },116 disconnected: function() {117 this.stopAutoplay();118 },119 update: function() {120 uikitUtil.attr(this.slides, 'tabindex', '-1');121 },122 events: [123 {124 name: 'visibilitychange',125 el: function() {126 return document;127 },128 filter: function() {129 return this.autoplay;130 },131 handler: function() {132 if (document.hidden) {133 this.stopAutoplay();134 } else {135 this.startAutoplay();136 }137 }138 }139 ],140 methods: {141 startAutoplay: function() {142 var this$1 = this;143 this.stopAutoplay();144 this.interval = setInterval(145 function () { return (!this$1.draggable || !uikitUtil.$(':focus', this$1.$el))146 && (!this$1.pauseOnHover || !uikitUtil.matches(this$1.$el, ':hover'))147 && !this$1.stack.length148 && this$1.show('next'); },149 this.autoplayInterval150 );151 },152 stopAutoplay: function() {153 this.interval && clearInterval(this.interval);154 }155 }156 };157 var SliderDrag = {158 props: {159 draggable: Boolean160 },161 data: {162 draggable: true,163 threshold: 10164 },165 created: function() {166 var this$1 = this;167 ['start', 'move', 'end'].forEach(function (key) {168 var fn = this$1[key];169 this$1[key] = function (e) {170 var pos = uikitUtil.getEventPos(e).x * (uikitUtil.isRtl ? -1 : 1);171 this$1.prevPos = pos !== this$1.pos ? this$1.pos : this$1.prevPos;172 this$1.pos = pos;173 fn(e);174 };175 });176 },177 events: [178 {179 name: uikitUtil.pointerDown,180 delegate: function() {181 return this.selSlides;182 },183 handler: function(e) {184 if (!this.draggable185 || !uikitUtil.isTouch(e) && hasTextNodesOnly(e.target)186 || uikitUtil.closest(e.target, uikitUtil.selInput)187 || e.button > 0188 || this.length < 2189 ) {190 return;191 }192 this.start(e);193 }194 },195 {196 name: 'dragstart',197 handler: function(e) {198 e.preventDefault();199 }200 }201 ],202 methods: {203 start: function() {204 this.drag = this.pos;205 if (this._transitioner) {206 this.percent = this._transitioner.percent();207 this.drag += this._transitioner.getDistance() * this.percent * this.dir;208 this._transitioner.cancel();209 this._transitioner.translate(this.percent);210 this.dragging = true;211 this.stack = [];212 } else {213 this.prevIndex = this.index;214 }215 uikitUtil.on(document, uikitUtil.pointerMove, this.move, {passive: false});216 uikitUtil.on(document, (uikitUtil.pointerUp + " " + uikitUtil.pointerCancel), this.end, true);217 uikitUtil.css(this.list, 'userSelect', 'none');218 },219 move: function(e) {220 var this$1 = this;221 var distance = this.pos - this.drag;222 if (distance === 0 || this.prevPos === this.pos || !this.dragging && Math.abs(distance) < this.threshold) {223 return;224 }225 // prevent click event226 uikitUtil.css(this.list, 'pointerEvents', 'none');227 e.cancelable && e.preventDefault();228 this.dragging = true;229 this.dir = (distance < 0 ? 1 : -1);230 var ref = this;231 var slides = ref.slides;232 var ref$1 = this;233 var prevIndex = ref$1.prevIndex;234 var dis = Math.abs(distance);235 var nextIndex = this.getIndex(prevIndex + this.dir, prevIndex);236 var width = this._getDistance(prevIndex, nextIndex) || slides[prevIndex].offsetWidth;237 while (nextIndex !== prevIndex && dis > width) {238 this.drag -= width * this.dir;239 prevIndex = nextIndex;240 dis -= width;241 nextIndex = this.getIndex(prevIndex + this.dir, prevIndex);242 width = this._getDistance(prevIndex, nextIndex) || slides[prevIndex].offsetWidth;243 }244 this.percent = dis / width;245 var prev = slides[prevIndex];246 var next = slides[nextIndex];247 var changed = this.index !== nextIndex;248 var edge = prevIndex === nextIndex;249 var itemShown;250 [this.index, this.prevIndex].filter(function (i) { return !uikitUtil.includes([nextIndex, prevIndex], i); }).forEach(function (i) {251 uikitUtil.trigger(slides[i], 'itemhidden', [this$1]);252 if (edge) {253 itemShown = true;254 this$1.prevIndex = prevIndex;255 }256 });257 if (this.index === prevIndex && this.prevIndex !== prevIndex || itemShown) {258 uikitUtil.trigger(slides[this.index], 'itemshown', [this]);259 }260 if (changed) {261 this.prevIndex = prevIndex;262 this.index = nextIndex;263 !edge && uikitUtil.trigger(prev, 'beforeitemhide', [this]);264 uikitUtil.trigger(next, 'beforeitemshow', [this]);265 }266 this._transitioner = this._translate(Math.abs(this.percent), prev, !edge && next);267 if (changed) {268 !edge && uikitUtil.trigger(prev, 'itemhide', [this]);269 uikitUtil.trigger(next, 'itemshow', [this]);270 }271 },272 end: function() {273 uikitUtil.off(document, uikitUtil.pointerMove, this.move, {passive: false});274 uikitUtil.off(document, (uikitUtil.pointerUp + " " + uikitUtil.pointerCancel), this.end, true);275 if (this.dragging) {276 this.dragging = null;277 if (this.index === this.prevIndex) {278 this.percent = 1 - this.percent;279 this.dir *= -1;280 this._show(false, this.index, true);281 this._transitioner = null;282 } else {283 var dirChange = (uikitUtil.isRtl ? this.dir * (uikitUtil.isRtl ? 1 : -1) : this.dir) < 0 === this.prevPos > this.pos;284 this.index = dirChange ? this.index : this.prevIndex;285 if (dirChange) {286 this.percent = 1 - this.percent;287 }288 this.show(this.dir > 0 && !dirChange || this.dir < 0 && dirChange ? 'next' : 'previous', true);289 }290 }291 uikitUtil.css(this.list, {userSelect: '', pointerEvents: ''});292 this.drag293 = this.percent294 = null;295 }296 }297 };298 function hasTextNodesOnly(el) {299 return !el.children.length && el.childNodes.length;300 }301 var SliderNav = {302 data: {303 selNav: false304 },305 computed: {306 nav: function(ref, $el) {307 var selNav = ref.selNav;308 return uikitUtil.$(selNav, $el);309 },310 selNavItem: function(ref) {311 var attrItem = ref.attrItem;312 return ("[" + attrItem + "],[data-" + attrItem + "]");313 },314 navItems: function(_, $el) {315 return uikitUtil.$$(this.selNavItem, $el);316 }317 },318 update: {319 write: function() {320 var this$1 = this;321 if (this.nav && this.length !== this.nav.children.length) {322 uikitUtil.html(this.nav, this.slides.map(function (_, i) { return ("<li " + (this$1.attrItem) + "=\"" + i + "\"><a href></a></li>"); }).join(''));323 }324 this.navItems.concat(this.nav).forEach(function (el) { return el && (el.hidden = !this$1.maxIndex); });325 this.updateNav();326 },327 events: ['resize']328 },329 events: [330 {331 name: 'click',332 delegate: function() {333 return this.selNavItem;334 },335 handler: function(e) {336 e.preventDefault();337 this.show(uikitUtil.data(e.current, this.attrItem));338 }339 },340 {341 name: 'itemshow',342 handler: 'updateNav'343 }344 ],345 methods: {346 updateNav: function() {347 var this$1 = this;348 var i = this.getValidIndex();349 this.navItems.forEach(function (el) {350 var cmd = uikitUtil.data(el, this$1.attrItem);351 uikitUtil.toggleClass(el, this$1.clsActive, uikitUtil.toNumber(cmd) === i);352 uikitUtil.toggleClass(el, 'uk-invisible', this$1.finite && (cmd === 'previous' && i === 0 || cmd === 'next' && i >= this$1.maxIndex));353 });354 }355 }356 };357 var Slider = {358 mixins: [SliderAutoplay, SliderDrag, SliderNav],359 props: {360 clsActivated: Boolean,361 easing: String,362 index: Number,363 finite: Boolean,364 velocity: Number,365 selSlides: String366 },367 data: function () { return ({368 easing: 'ease',369 finite: false,370 velocity: 1,371 index: 0,372 prevIndex: -1,373 stack: [],374 percent: 0,375 clsActive: 'uk-active',376 clsActivated: false,377 Transitioner: false,378 transitionOptions: {}379 }); },380 connected: function() {381 this.prevIndex = -1;382 this.index = this.getValidIndex(this.$props.index);383 this.stack = [];384 },385 disconnected: function() {386 uikitUtil.removeClass(this.slides, this.clsActive);387 },388 computed: {389 duration: function(ref, $el) {390 var velocity = ref.velocity;391 return speedUp($el.offsetWidth / velocity);392 },393 list: function(ref, $el) {394 var selList = ref.selList;395 return uikitUtil.$(selList, $el);396 },397 maxIndex: function() {398 return this.length - 1;399 },400 selSlides: function(ref) {401 var selList = ref.selList;402 var selSlides = ref.selSlides;403 return (selList + " " + (selSlides || '> *'));404 },405 slides: {406 get: function() {407 return uikitUtil.$$(this.selSlides, this.$el);408 },409 watch: function() {410 this.$reset();411 }412 },413 length: function() {414 return this.slides.length;415 }416 },417 events: {418 itemshown: function() {419 this.$update(this.list);420 }421 },422 methods: {423 show: function(index, force) {424 var this$1 = this;425 if ( force === void 0 ) force = false;426 if (this.dragging || !this.length) {427 return;428 }429 var ref = this;430 var stack = ref.stack;431 var queueIndex = force ? 0 : stack.length;432 var reset = function () {433 stack.splice(queueIndex, 1);434 if (stack.length) {435 this$1.show(stack.shift(), true);436 }437 };438 stack[force ? 'unshift' : 'push'](index);439 if (!force && stack.length > 1) {440 if (stack.length === 2) {441 this._transitioner.forward(Math.min(this.duration, 200));442 }443 return;444 }445 var prevIndex = this.getIndex(this.index);446 var prev = uikitUtil.hasClass(this.slides, this.clsActive) && this.slides[prevIndex];447 var nextIndex = this.getIndex(index, this.index);448 var next = this.slides[nextIndex];449 if (prev === next) {450 reset();451 return;452 }453 this.dir = getDirection(index, prevIndex);454 this.prevIndex = prevIndex;455 this.index = nextIndex;456 if (prev && !uikitUtil.trigger(prev, 'beforeitemhide', [this])457 || !uikitUtil.trigger(next, 'beforeitemshow', [this, prev])458 ) {459 this.index = this.prevIndex;460 reset();461 return;462 }463 var promise = this._show(prev, next, force).then(function () {464 prev && uikitUtil.trigger(prev, 'itemhidden', [this$1]);465 uikitUtil.trigger(next, 'itemshown', [this$1]);466 return new uikitUtil.Promise(function (resolve) {467 uikitUtil.fastdom.write(function () {468 stack.shift();469 if (stack.length) {470 this$1.show(stack.shift(), true);471 } else {472 this$1._transitioner = null;473 }474 resolve();475 });476 });477 });478 prev && uikitUtil.trigger(prev, 'itemhide', [this]);479 uikitUtil.trigger(next, 'itemshow', [this]);480 return promise;481 },482 getIndex: function(index, prev) {483 if ( index === void 0 ) index = this.index;484 if ( prev === void 0 ) prev = this.index;485 return uikitUtil.clamp(uikitUtil.getIndex(index, this.slides, prev, this.finite), 0, this.maxIndex);486 },487 getValidIndex: function(index, prevIndex) {488 if ( index === void 0 ) index = this.index;489 if ( prevIndex === void 0 ) prevIndex = this.prevIndex;490 return this.getIndex(index, prevIndex);491 },492 _show: function(prev, next, force) {493 this._transitioner = this._getTransitioner(494 prev,495 next,496 this.dir,497 uikitUtil.assign({498 easing: force499 ? next.offsetWidth < 600500 ? 'cubic-bezier(0.25, 0.46, 0.45, 0.94)' /* easeOutQuad */501 : 'cubic-bezier(0.165, 0.84, 0.44, 1)' /* easeOutQuart */502 : this.easing503 }, this.transitionOptions)504 );505 if (!force && !prev) {506 this._translate(1);507 return uikitUtil.Promise.resolve();508 }509 var ref = this.stack;510 var length = ref.length;511 return this._transitioner[length > 1 ? 'forward' : 'show'](length > 1 ? Math.min(this.duration, 75 + 75 / (length - 1)) : this.duration, this.percent);512 },513 _getDistance: function(prev, next) {514 return this._getTransitioner(prev, prev !== next && next).getDistance();515 },516 _translate: function(percent, prev, next) {517 if ( prev === void 0 ) prev = this.prevIndex;518 if ( next === void 0 ) next = this.index;519 var transitioner = this._getTransitioner(prev !== next ? prev : false, next);520 transitioner.translate(percent);521 return transitioner;522 },523 _getTransitioner: function(prev, next, dir, options) {524 if ( prev === void 0 ) prev = this.prevIndex;525 if ( next === void 0 ) next = this.index;526 if ( dir === void 0 ) dir = this.dir || 1;527 if ( options === void 0 ) options = this.transitionOptions;528 return new this.Transitioner(529 uikitUtil.isNumber(prev) ? this.slides[prev] : prev,530 uikitUtil.isNumber(next) ? this.slides[next] : next,531 dir * (uikitUtil.isRtl ? -1 : 1),532 options533 );534 }535 }536 };537 function getDirection(index, prevIndex) {538 return index === 'next'539 ? 1540 : index === 'previous'541 ? -1542 : index < prevIndex543 ? -1544 : 1;545 }546 function speedUp(x) {547 return .5 * x + 300; // parabola through (400,500; 600,600; 1800,1200)548 }549 var Slideshow = {550 mixins: [Slider],551 props: {552 animation: String553 },554 data: {555 animation: 'slide',556 clsActivated: 'uk-transition-active',557 Animations: Animations$1,558 Transitioner: Transitioner559 },560 computed: {561 animation: function(ref) {562 var animation = ref.animation;563 var Animations = ref.Animations;564 return uikitUtil.assign(Animations[animation] || Animations.slide, {name: animation});565 },566 transitionOptions: function() {567 return {animation: this.animation};568 }569 },570 events: {571 'itemshow itemhide itemshown itemhidden': function(ref) {572 var target = ref.target;573 this.$update(target);574 },575 beforeitemshow: function(ref) {576 var target = ref.target;577 uikitUtil.addClass(target, this.clsActive);578 },579 itemshown: function(ref) {580 var target = ref.target;581 uikitUtil.addClass(target, this.clsActivated);582 },583 itemhidden: function(ref) {584 var target = ref.target;585 uikitUtil.removeClass(target, this.clsActive, this.clsActivated);586 }587 }588 };589 var Animations = uikitUtil.assign({}, Animations$1, {590 fade: {591 show: function() {592 return [593 {opacity: 0, zIndex: 0},594 {zIndex: -1}595 ];596 },597 percent: function(current) {598 return 1 - uikitUtil.css(current, 'opacity');599 },600 translate: function(percent) {601 return [602 {opacity: 1 - percent, zIndex: 0},603 {zIndex: -1}604 ];605 }606 },607 scale: {608 show: function() {609 return [610 {opacity: 0, transform: scale3d(1 + .5), zIndex: 0},611 {zIndex: -1}612 ];613 },614 percent: function(current) {615 return 1 - uikitUtil.css(current, 'opacity');616 },617 translate: function(percent) {618 return [619 {opacity: 1 - percent, transform: scale3d(1 + .5 * percent), zIndex: 0},620 {zIndex: -1}621 ];622 }623 },624 pull: {625 show: function(dir) {626 return dir < 0627 ? [628 {transform: translate(30), zIndex: -1},629 {transform: translate(), zIndex: 0}630 ]631 : [632 {transform: translate(-100), zIndex: 0},633 {transform: translate(), zIndex: -1}634 ];635 },636 percent: function(current, next, dir) {637 return dir < 0638 ? 1 - translated(next)639 : translated(current);640 },641 translate: function(percent, dir) {642 return dir < 0643 ? [644 {transform: translate(30 * percent), zIndex: -1},645 {transform: translate(-100 * (1 - percent)), zIndex: 0}646 ]647 : [648 {transform: translate(-percent * 100), zIndex: 0},649 {transform: translate(30 * (1 - percent)), zIndex: -1}650 ];651 }652 },653 push: {654 show: function(dir) {655 return dir < 0656 ? [657 {transform: translate(100), zIndex: 0},658 {transform: translate(), zIndex: -1}659 ]660 : [661 {transform: translate(-30), zIndex: -1},662 {transform: translate(), zIndex: 0}663 ];664 },665 percent: function(current, next, dir) {666 return dir > 0667 ? 1 - translated(next)668 : translated(current);669 },670 translate: function(percent, dir) {671 return dir < 0672 ? [673 {transform: translate(percent * 100), zIndex: 0},674 {transform: translate(-30 * (1 - percent)), zIndex: -1}675 ]676 : [677 {transform: translate(-30 * percent), zIndex: -1},678 {transform: translate(100 * (1 - percent)), zIndex: 0}679 ];680 }681 }682 });683 var SliderReactive = {684 update: {685 write: function() {686 if (this.stack.length || this.dragging) {687 return;688 }689 var index = this.getValidIndex(this.index);690 if (!~this.prevIndex || this.index !== index) {691 this.show(index);692 }693 },694 events: ['resize']695 }696 };697 var Component = {698 mixins: [Class, Slideshow, SliderReactive],699 props: {700 ratio: String,701 minHeight: Number,702 maxHeight: Number703 },704 data: {705 ratio: '16:9',706 minHeight: false,707 maxHeight: false,708 selList: '.uk-slideshow-items',709 attrItem: 'uk-slideshow-item',710 selNav: '.uk-slideshow-nav',711 Animations: Animations712 },713 update: {714 read: function() {715 var ref = this.ratio.split(':').map(Number);716 var width = ref[0];717 var height = ref[1];718 height = height * this.list.offsetWidth / width || 0;719 if (this.minHeight) {720 height = Math.max(this.minHeight, height);721 }722 if (this.maxHeight) {723 height = Math.min(this.maxHeight, height);724 }725 return {height: height - uikitUtil.boxModelAdjust(this.list, 'height', 'content-box')};726 },727 write: function(ref) {728 var height = ref.height;729 height > 0 && uikitUtil.css(this.list, 'minHeight', height);730 },731 events: ['resize']732 }733 };734 if (typeof window !== 'undefined' && window.UIkit) {735 window.UIkit.component('slideshow', Component);736 }737 return Component;...
ScrollableTabBarNode.js
Source:ScrollableTabBarNode.js
1'use strict';2Object.defineProperty(exports, "__esModule", {3 value: true4});5var _babelHelperVueJsxMergeProps = require('babel-helper-vue-jsx-merge-props');6var _babelHelperVueJsxMergeProps2 = _interopRequireDefault(_babelHelperVueJsxMergeProps);7var _defineProperty2 = require('babel-runtime/helpers/defineProperty');8var _defineProperty3 = _interopRequireDefault(_defineProperty2);9var _extends2 = require('babel-runtime/helpers/extends');10var _extends3 = _interopRequireDefault(_extends2);11var _debounce = require('lodash/debounce');12var _debounce2 = _interopRequireDefault(_debounce);13var _resizeObserverPolyfill = require('resize-observer-polyfill');14var _resizeObserverPolyfill2 = _interopRequireDefault(_resizeObserverPolyfill);15var _vueTypes = require('../../_util/vue-types');16var _vueTypes2 = _interopRequireDefault(_vueTypes);17var _BaseMixin = require('../../_util/BaseMixin');18var _BaseMixin2 = _interopRequireDefault(_BaseMixin);19var _propsUtil = require('../../_util/props-util');20var _utils = require('./utils');21function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }22function noop() {}23exports['default'] = {24 name: 'ScrollableTabBarNode',25 mixins: [_BaseMixin2['default']],26 props: {27 activeKey: _vueTypes2['default'].any,28 getRef: _vueTypes2['default'].func.def(function () {}),29 saveRef: _vueTypes2['default'].func.def(function () {}),30 tabBarPosition: _vueTypes2['default'].oneOf(['left', 'right', 'top', 'bottom']).def('left'),31 prefixCls: _vueTypes2['default'].string.def(''),32 scrollAnimated: _vueTypes2['default'].bool.def(true),33 navWrapper: _vueTypes2['default'].func.def(function (arg) {34 return arg;35 }),36 prevIcon: _vueTypes2['default'].any,37 nextIcon: _vueTypes2['default'].any,38 direction: _vueTypes2['default'].string39 },40 data: function data() {41 this.offset = 0;42 this.prevProps = (0, _extends3['default'])({}, this.$props);43 return {44 next: false,45 prev: false46 };47 },48 watch: {49 tabBarPosition: function tabBarPosition() {50 var _this = this;51 this.tabBarPositionChange = true;52 this.$nextTick(function () {53 _this.setOffset(0);54 });55 }56 },57 mounted: function mounted() {58 var _this2 = this;59 this.$nextTick(function () {60 _this2.updatedCal();61 _this2.debouncedResize = (0, _debounce2['default'])(function () {62 _this2.setNextPrev();63 _this2.scrollToActiveTab();64 }, 200);65 _this2.resizeObserver = new _resizeObserverPolyfill2['default'](_this2.debouncedResize);66 _this2.resizeObserver.observe(_this2.$props.getRef('container'));67 });68 },69 updated: function updated() {70 var _this3 = this;71 this.$nextTick(function () {72 _this3.updatedCal(_this3.prevProps);73 _this3.prevProps = (0, _extends3['default'])({}, _this3.$props);74 });75 },76 beforeDestroy: function beforeDestroy() {77 if (this.resizeObserver) {78 this.resizeObserver.disconnect();79 }80 if (this.debouncedResize && this.debouncedResize.cancel) {81 this.debouncedResize.cancel();82 }83 },84 methods: {85 updatedCal: function updatedCal(prevProps) {86 var _this4 = this;87 var props = this.$props;88 if (prevProps && prevProps.tabBarPosition !== props.tabBarPosition) {89 this.setOffset(0);90 return;91 }92 // wait next, prev show hide93 if (this.isNextPrevShown(this.$data) !== this.isNextPrevShown(this.setNextPrev())) {94 this.$forceUpdate();95 this.$nextTick(function () {96 _this4.scrollToActiveTab();97 });98 } else if (!prevProps || props.activeKey !== prevProps.activeKey) {99 // can not use props.activeKey100 this.scrollToActiveTab();101 }102 },103 setNextPrev: function setNextPrev() {104 var navNode = this.$props.getRef('nav');105 var navTabsContainer = this.$props.getRef('navTabsContainer');106 var navNodeWH = this.getScrollWH(navTabsContainer || navNode);107 // Add 1px to fix `offsetWidth` with decimal in Chrome not correct handle108 // https://github.com/ant-design/ant-design/issues/13423109 var containerWH = this.getOffsetWH(this.$props.getRef('container')) + 1;110 var navWrapNodeWH = this.getOffsetWH(this.$props.getRef('navWrap'));111 var offset = this.offset;112 var minOffset = containerWH - navNodeWH;113 var next = this.next,114 prev = this.prev;115 if (minOffset >= 0) {116 next = false;117 this.setOffset(0, false);118 offset = 0;119 } else if (minOffset < offset) {120 next = true;121 } else {122 next = false;123 // Fix https://github.com/ant-design/ant-design/issues/8861124 // Test with container offset which is stable125 // and set the offset of the nav wrap node126 var realOffset = navWrapNodeWH - navNodeWH;127 this.setOffset(realOffset, false);128 offset = realOffset;129 }130 if (offset < 0) {131 prev = true;132 } else {133 prev = false;134 }135 this.setNext(next);136 this.setPrev(prev);137 return {138 next: next,139 prev: prev140 };141 },142 getOffsetWH: function getOffsetWH(node) {143 var tabBarPosition = this.$props.tabBarPosition;144 var prop = 'offsetWidth';145 if (tabBarPosition === 'left' || tabBarPosition === 'right') {146 prop = 'offsetHeight';147 }148 return node[prop];149 },150 getScrollWH: function getScrollWH(node) {151 var tabBarPosition = this.tabBarPosition;152 var prop = 'scrollWidth';153 if (tabBarPosition === 'left' || tabBarPosition === 'right') {154 prop = 'scrollHeight';155 }156 return node[prop];157 },158 getOffsetLT: function getOffsetLT(node) {159 var tabBarPosition = this.$props.tabBarPosition;160 var prop = 'left';161 if (tabBarPosition === 'left' || tabBarPosition === 'right') {162 prop = 'top';163 }164 return node.getBoundingClientRect()[prop];165 },166 setOffset: function setOffset(offset) {167 var checkNextPrev = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;168 var target = Math.min(0, offset);169 if (this.offset !== target) {170 this.offset = target;171 var navOffset = {};172 var tabBarPosition = this.$props.tabBarPosition;173 var navStyle = this.$props.getRef('nav').style;174 var transformSupported = (0, _utils.isTransform3dSupported)(navStyle);175 if (tabBarPosition === 'left' || tabBarPosition === 'right') {176 if (transformSupported) {177 navOffset = {178 value: 'translate3d(0,' + target + 'px,0)'179 };180 } else {181 navOffset = {182 name: 'top',183 value: target + 'px'184 };185 }186 } else if (transformSupported) {187 if (this.$props.direction === 'rtl') {188 target = -target;189 }190 navOffset = {191 value: 'translate3d(' + target + 'px,0,0)'192 };193 } else {194 navOffset = {195 name: 'left',196 value: target + 'px'197 };198 }199 if (transformSupported) {200 (0, _utils.setTransform)(navStyle, navOffset.value);201 } else {202 navStyle[navOffset.name] = navOffset.value;203 }204 if (checkNextPrev) {205 this.setNextPrev();206 }207 }208 },209 setPrev: function setPrev(v) {210 if (this.prev !== v) {211 this.prev = v;212 }213 },214 setNext: function setNext(v) {215 if (!v) {216 // debugger217 }218 if (this.next !== v) {219 this.next = v;220 }221 },222 isNextPrevShown: function isNextPrevShown(state) {223 if (state) {224 return state.next || state.prev;225 }226 return this.next || this.prev;227 },228 prevTransitionEnd: function prevTransitionEnd(e) {229 if (e.propertyName !== 'opacity') {230 return;231 }232 var container = this.$props.getRef('container');233 this.scrollToActiveTab({234 target: container,235 currentTarget: container236 });237 },238 scrollToActiveTab: function scrollToActiveTab(e) {239 var activeTab = this.$props.getRef('activeTab');240 var navWrap = this.$props.getRef('navWrap');241 if (e && e.target !== e.currentTarget || !activeTab) {242 return;243 }244 // when not scrollable or enter scrollable first time, don't emit scrolling245 var needToSroll = this.isNextPrevShown() && this.lastNextPrevShown;246 this.lastNextPrevShown = this.isNextPrevShown();247 if (!needToSroll) {248 return;249 }250 var activeTabWH = this.getScrollWH(activeTab);251 var navWrapNodeWH = this.getOffsetWH(navWrap);252 var offset = this.offset;253 var wrapOffset = this.getOffsetLT(navWrap);254 var activeTabOffset = this.getOffsetLT(activeTab);255 if (wrapOffset > activeTabOffset) {256 offset += wrapOffset - activeTabOffset;257 this.setOffset(offset);258 } else if (wrapOffset + navWrapNodeWH < activeTabOffset + activeTabWH) {259 offset -= activeTabOffset + activeTabWH - (wrapOffset + navWrapNodeWH);260 this.setOffset(offset);261 }262 },263 prevClick: function prevClick(e) {264 this.__emit('prevClick', e);265 var navWrapNode = this.$props.getRef('navWrap');266 var navWrapNodeWH = this.getOffsetWH(navWrapNode);267 var offset = this.offset;268 this.setOffset(offset + navWrapNodeWH);269 },270 nextClick: function nextClick(e) {271 this.__emit('nextClick', e);272 var navWrapNode = this.$props.getRef('navWrap');273 var navWrapNodeWH = this.getOffsetWH(navWrapNode);274 var offset = this.offset;275 this.setOffset(offset - navWrapNodeWH);276 }277 },278 render: function render() {279 var _ref, _ref2, _navClasses, _ref3;280 var h = arguments[0];281 var next = this.next,282 prev = this.prev;283 var _$props = this.$props,284 prefixCls = _$props.prefixCls,285 scrollAnimated = _$props.scrollAnimated,286 navWrapper = _$props.navWrapper;287 var prevIcon = (0, _propsUtil.getComponentFromProp)(this, 'prevIcon');288 var nextIcon = (0, _propsUtil.getComponentFromProp)(this, 'nextIcon');289 var showNextPrev = prev || next;290 var prevButton = h(291 'span',292 {293 on: {294 'click': prev ? this.prevClick : noop,295 'transitionend': this.prevTransitionEnd296 },297 attrs: {298 unselectable: 'unselectable'299 },300 'class': (_ref = {}, (0, _defineProperty3['default'])(_ref, prefixCls + '-tab-prev', 1), (0, _defineProperty3['default'])(_ref, prefixCls + '-tab-btn-disabled', !prev), (0, _defineProperty3['default'])(_ref, prefixCls + '-tab-arrow-show', showNextPrev), _ref)301 },302 [prevIcon || h('span', { 'class': prefixCls + '-tab-prev-icon' })]303 );304 var nextButton = h(305 'span',306 {307 on: {308 'click': next ? this.nextClick : noop309 },310 attrs: {311 unselectable: 'unselectable'312 },313 'class': (_ref2 = {}, (0, _defineProperty3['default'])(_ref2, prefixCls + '-tab-next', 1), (0, _defineProperty3['default'])(_ref2, prefixCls + '-tab-btn-disabled', !next), (0, _defineProperty3['default'])(_ref2, prefixCls + '-tab-arrow-show', showNextPrev), _ref2)314 },315 [nextIcon || h('span', { 'class': prefixCls + '-tab-next-icon' })]316 );317 var navClassName = prefixCls + '-nav';318 var navClasses = (_navClasses = {}, (0, _defineProperty3['default'])(_navClasses, navClassName, true), (0, _defineProperty3['default'])(_navClasses, scrollAnimated ? navClassName + '-animated' : navClassName + '-no-animated', true), _navClasses);319 return h(320 'div',321 (0, _babelHelperVueJsxMergeProps2['default'])([{322 'class': (_ref3 = {}, (0, _defineProperty3['default'])(_ref3, prefixCls + '-nav-container', 1), (0, _defineProperty3['default'])(_ref3, prefixCls + '-nav-container-scrolling', showNextPrev), _ref3),323 key: 'container'324 }, {325 directives: [{326 name: 'ant-ref',327 value: this.saveRef('container')328 }]329 }]),330 [prevButton, nextButton, h(331 'div',332 (0, _babelHelperVueJsxMergeProps2['default'])([{333 'class': prefixCls + '-nav-wrap'334 }, {335 directives: [{336 name: 'ant-ref',337 value: this.saveRef('navWrap')338 }]339 }]),340 [h(341 'div',342 { 'class': prefixCls + '-nav-scroll' },343 [h(344 'div',345 (0, _babelHelperVueJsxMergeProps2['default'])([{346 'class': navClasses347 }, {348 directives: [{349 name: 'ant-ref',350 value: this.saveRef('nav')351 }]352 }]),353 [navWrapper(this.$slots['default'])]354 )]355 )]356 )]357 );358 }...
slider.js
Source:slider.js
1import SliderAutoplay from './slider-autoplay';2import SliderDrag from './slider-drag';3import SliderNav from './slider-nav';4import {$, $$, assign, clamp, fastdom, getIndex, hasClass, isNumber, isRtl, Promise, removeClass, trigger} from 'uikit-util';5export default {6 mixins: [SliderAutoplay, SliderDrag, SliderNav],7 props: {8 clsActivated: Boolean,9 easing: String,10 index: Number,11 finite: Boolean,12 velocity: Number,13 selSlides: String14 },15 data: () => ({16 easing: 'ease',17 finite: false,18 velocity: 1,19 index: 0,20 prevIndex: -1,21 stack: [],22 percent: 0,23 clsActive: 'uk-active',24 clsActivated: false,25 Transitioner: false,26 transitionOptions: {}27 }),28 connected() {29 this.prevIndex = -1;30 this.index = this.getValidIndex(this.$props.index);31 this.stack = [];32 },33 disconnected() {34 removeClass(this.slides, this.clsActive);35 },36 computed: {37 duration({velocity}, $el) {38 return speedUp($el.offsetWidth / velocity);39 },40 list({selList}, $el) {41 return $(selList, $el);42 },43 maxIndex() {44 return this.length - 1;45 },46 selSlides({selList, selSlides}) {47 return `${selList} ${selSlides || '> *'}`;48 },49 slides: {50 get() {51 return $$(this.selSlides, this.$el);52 },53 watch() {54 this.$reset();55 }56 },57 length() {58 return this.slides.length;59 }60 },61 events: {62 itemshown() {63 this.$update(this.list);64 }65 },66 methods: {67 show(index, force = false) {68 if (this.dragging || !this.length) {69 return;70 }71 const {stack} = this;72 const queueIndex = force ? 0 : stack.length;73 const reset = () => {74 stack.splice(queueIndex, 1);75 if (stack.length) {76 this.show(stack.shift(), true);77 }78 };79 stack[force ? 'unshift' : 'push'](index);80 if (!force && stack.length > 1) {81 if (stack.length === 2) {82 this._transitioner.forward(Math.min(this.duration, 200));83 }84 return;85 }86 const prevIndex = this.getIndex(this.index);87 const prev = hasClass(this.slides, this.clsActive) && this.slides[prevIndex];88 const nextIndex = this.getIndex(index, this.index);89 const next = this.slides[nextIndex];90 if (prev === next) {91 reset();92 return;93 }94 this.dir = getDirection(index, prevIndex);95 this.prevIndex = prevIndex;96 this.index = nextIndex;97 if (prev && !trigger(prev, 'beforeitemhide', [this])98 || !trigger(next, 'beforeitemshow', [this, prev])99 ) {100 this.index = this.prevIndex;101 reset();102 return;103 }104 const promise = this._show(prev, next, force).then(() => {105 prev && trigger(prev, 'itemhidden', [this]);106 trigger(next, 'itemshown', [this]);107 return new Promise(resolve => {108 fastdom.write(() => {109 stack.shift();110 if (stack.length) {111 this.show(stack.shift(), true);112 } else {113 this._transitioner = null;114 }115 resolve();116 });117 });118 });119 prev && trigger(prev, 'itemhide', [this]);120 trigger(next, 'itemshow', [this]);121 return promise;122 },123 getIndex(index = this.index, prev = this.index) {124 return clamp(getIndex(index, this.slides, prev, this.finite), 0, this.maxIndex);125 },126 getValidIndex(index = this.index, prevIndex = this.prevIndex) {127 return this.getIndex(index, prevIndex);128 },129 _show(prev, next, force) {130 this._transitioner = this._getTransitioner(131 prev,132 next,133 this.dir,134 assign({135 easing: force136 ? next.offsetWidth < 600137 ? 'cubic-bezier(0.25, 0.46, 0.45, 0.94)' /* easeOutQuad */138 : 'cubic-bezier(0.165, 0.84, 0.44, 1)' /* easeOutQuart */139 : this.easing140 }, this.transitionOptions)141 );142 if (!force && !prev) {143 this._translate(1);144 return Promise.resolve();145 }146 const {length} = this.stack;147 return this._transitioner[length > 1 ? 'forward' : 'show'](length > 1 ? Math.min(this.duration, 75 + 75 / (length - 1)) : this.duration, this.percent);148 },149 _getDistance(prev, next) {150 return this._getTransitioner(prev, prev !== next && next).getDistance();151 },152 _translate(percent, prev = this.prevIndex, next = this.index) {153 const transitioner = this._getTransitioner(prev !== next ? prev : false, next);154 transitioner.translate(percent);155 return transitioner;156 },157 _getTransitioner(prev = this.prevIndex, next = this.index, dir = this.dir || 1, options = this.transitionOptions) {158 return new this.Transitioner(159 isNumber(prev) ? this.slides[prev] : prev,160 isNumber(next) ? this.slides[next] : next,161 dir * (isRtl ? -1 : 1),162 options163 );164 }165 }166};167function getDirection(index, prevIndex) {168 return index === 'next'169 ? 1170 : index === 'previous'171 ? -1172 : index < prevIndex173 ? -1174 : 1;175}176export function speedUp(x) {177 return .5 * x + 300; // parabola through (400,500; 600,600; 1800,1200)...
slider-drag.js
Source:slider-drag.js
1import {closest, css, getEventPos, includes, isRtl, isTouch, off, on, pointerCancel, pointerDown, pointerMove, pointerUp, selInput, trigger} from 'uikit-util';2export default {3 props: {4 draggable: Boolean5 },6 data: {7 draggable: true,8 threshold: 109 },10 created() {11 ['start', 'move', 'end'].forEach(key => {12 const fn = this[key];13 this[key] = e => {14 const pos = getEventPos(e).x * (isRtl ? -1 : 1);15 this.prevPos = pos !== this.pos ? this.pos : this.prevPos;16 this.pos = pos;17 fn(e);18 };19 });20 },21 events: [22 {23 name: pointerDown,24 delegate() {25 return this.selSlides;26 },27 handler(e) {28 if (!this.draggable29 || !isTouch(e) && hasTextNodesOnly(e.target)30 || closest(e.target, selInput)31 || e.button > 032 || this.length < 233 ) {34 return;35 }36 this.start(e);37 }38 },39 {40 name: 'dragstart',41 handler(e) {42 e.preventDefault();43 }44 }45 ],46 methods: {47 start() {48 this.drag = this.pos;49 if (this._transitioner) {50 this.percent = this._transitioner.percent();51 this.drag += this._transitioner.getDistance() * this.percent * this.dir;52 this._transitioner.cancel();53 this._transitioner.translate(this.percent);54 this.dragging = true;55 this.stack = [];56 } else {57 this.prevIndex = this.index;58 }59 on(document, pointerMove, this.move, {passive: false});60 on(document, `${pointerUp} ${pointerCancel}`, this.end, true);61 css(this.list, 'userSelect', 'none');62 },63 move(e) {64 const distance = this.pos - this.drag;65 if (distance === 0 || this.prevPos === this.pos || !this.dragging && Math.abs(distance) < this.threshold) {66 return;67 }68 // prevent click event69 css(this.list, 'pointerEvents', 'none');70 e.cancelable && e.preventDefault();71 this.dragging = true;72 this.dir = (distance < 0 ? 1 : -1);73 const {slides} = this;74 let {prevIndex} = this;75 let dis = Math.abs(distance);76 let nextIndex = this.getIndex(prevIndex + this.dir, prevIndex);77 let width = this._getDistance(prevIndex, nextIndex) || slides[prevIndex].offsetWidth;78 while (nextIndex !== prevIndex && dis > width) {79 this.drag -= width * this.dir;80 prevIndex = nextIndex;81 dis -= width;82 nextIndex = this.getIndex(prevIndex + this.dir, prevIndex);83 width = this._getDistance(prevIndex, nextIndex) || slides[prevIndex].offsetWidth;84 }85 this.percent = dis / width;86 const prev = slides[prevIndex];87 const next = slides[nextIndex];88 const changed = this.index !== nextIndex;89 const edge = prevIndex === nextIndex;90 let itemShown;91 [this.index, this.prevIndex].filter(i => !includes([nextIndex, prevIndex], i)).forEach(i => {92 trigger(slides[i], 'itemhidden', [this]);93 if (edge) {94 itemShown = true;95 this.prevIndex = prevIndex;96 }97 });98 if (this.index === prevIndex && this.prevIndex !== prevIndex || itemShown) {99 trigger(slides[this.index], 'itemshown', [this]);100 }101 if (changed) {102 this.prevIndex = prevIndex;103 this.index = nextIndex;104 !edge && trigger(prev, 'beforeitemhide', [this]);105 trigger(next, 'beforeitemshow', [this]);106 }107 this._transitioner = this._translate(Math.abs(this.percent), prev, !edge && next);108 if (changed) {109 !edge && trigger(prev, 'itemhide', [this]);110 trigger(next, 'itemshow', [this]);111 }112 },113 end() {114 off(document, pointerMove, this.move, {passive: false});115 off(document, `${pointerUp} ${pointerCancel}`, this.end, true);116 if (this.dragging) {117 this.dragging = null;118 if (this.index === this.prevIndex) {119 this.percent = 1 - this.percent;120 this.dir *= -1;121 this._show(false, this.index, true);122 this._transitioner = null;123 } else {124 const dirChange = (isRtl ? this.dir * (isRtl ? 1 : -1) : this.dir) < 0 === this.prevPos > this.pos;125 this.index = dirChange ? this.index : this.prevIndex;126 if (dirChange) {127 this.percent = 1 - this.percent;128 }129 this.show(this.dir > 0 && !dirChange || this.dir < 0 && dirChange ? 'next' : 'previous', true);130 }131 }132 css(this.list, {userSelect: '', pointerEvents: ''});133 this.drag134 = this.percent135 = null;136 }137 }138};139function hasTextNodesOnly(el) {140 return !el.children.length && el.childNodes.length;...
navigation.js
Source:navigation.js
1import $ from '../../utils/dom';2import Utils from '../../utils/utils';3const Navigation = {4 update() {5 // Update Navigation Buttons6 const swiper = this;7 const params = swiper.params.navigation;8 if (swiper.params.loop) return;9 const { $nextEl, $prevEl } = swiper.navigation;10 if ($prevEl && $prevEl.length > 0) {11 if (swiper.isBeginning) {12 $prevEl.addClass(params.disabledClass);13 } else {14 $prevEl.removeClass(params.disabledClass);15 }16 $prevEl[swiper.params.watchOverflow && swiper.isLocked ? 'addClass' : 'removeClass'](params.lockClass);17 }18 if ($nextEl && $nextEl.length > 0) {19 if (swiper.isEnd) {20 $nextEl.addClass(params.disabledClass);21 } else {22 $nextEl.removeClass(params.disabledClass);23 }24 $nextEl[swiper.params.watchOverflow && swiper.isLocked ? 'addClass' : 'removeClass'](params.lockClass);25 }26 },27 onPrevClick(e) {28 const swiper = this;29 e.preventDefault();30 if (swiper.isBeginning && !swiper.params.loop) return;31 swiper.slidePrev();32 },33 onNextClick(e) {34 const swiper = this;35 e.preventDefault();36 if (swiper.isEnd && !swiper.params.loop) return;37 swiper.slideNext();38 },39 init() {40 const swiper = this;41 const params = swiper.params.navigation;42 if (!(params.nextEl || params.prevEl)) return;43 let $nextEl;44 let $prevEl;45 if (params.nextEl) {46 $nextEl = $(params.nextEl);47 if (48 swiper.params.uniqueNavElements49 && typeof params.nextEl === 'string'50 && $nextEl.length > 151 && swiper.$el.find(params.nextEl).length === 152 ) {53 $nextEl = swiper.$el.find(params.nextEl);54 }55 }56 if (params.prevEl) {57 $prevEl = $(params.prevEl);58 if (59 swiper.params.uniqueNavElements60 && typeof params.prevEl === 'string'61 && $prevEl.length > 162 && swiper.$el.find(params.prevEl).length === 163 ) {64 $prevEl = swiper.$el.find(params.prevEl);65 }66 }67 if ($nextEl && $nextEl.length > 0) {68 $nextEl.on('click', swiper.navigation.onNextClick);69 }70 if ($prevEl && $prevEl.length > 0) {71 $prevEl.on('click', swiper.navigation.onPrevClick);72 }73 Utils.extend(swiper.navigation, {74 $nextEl,75 nextEl: $nextEl && $nextEl[0],76 $prevEl,77 prevEl: $prevEl && $prevEl[0],78 });79 },80 destroy() {81 const swiper = this;82 const { $nextEl, $prevEl } = swiper.navigation;83 if ($nextEl && $nextEl.length) {84 $nextEl.off('click', swiper.navigation.onNextClick);85 $nextEl.removeClass(swiper.params.navigation.disabledClass);86 }87 if ($prevEl && $prevEl.length) {88 $prevEl.off('click', swiper.navigation.onPrevClick);89 $prevEl.removeClass(swiper.params.navigation.disabledClass);90 }91 },92};93export default {94 name: 'navigation',95 params: {96 navigation: {97 nextEl: null,98 prevEl: null,99 hideOnClick: false,100 disabledClass: 'swiper-button-disabled',101 hiddenClass: 'swiper-button-hidden',102 lockClass: 'swiper-button-lock',103 },104 },105 create() {106 const swiper = this;107 Utils.extend(swiper, {108 navigation: {109 init: Navigation.init.bind(swiper),110 update: Navigation.update.bind(swiper),111 destroy: Navigation.destroy.bind(swiper),112 onNextClick: Navigation.onNextClick.bind(swiper),113 onPrevClick: Navigation.onPrevClick.bind(swiper),114 },115 });116 },117 on: {118 init() {119 const swiper = this;120 swiper.navigation.init();121 swiper.navigation.update();122 },123 toEdge() {124 const swiper = this;125 swiper.navigation.update();126 },127 fromEdge() {128 const swiper = this;129 swiper.navigation.update();130 },131 destroy() {132 const swiper = this;133 swiper.navigation.destroy();134 },135 click(e) {136 const swiper = this;137 const { $nextEl, $prevEl } = swiper.navigation;138 if (139 swiper.params.navigation.hideOnClick140 && !$(e.target).is($prevEl)141 && !$(e.target).is($nextEl)142 ) {143 if ($nextEl) $nextEl.toggleClass(swiper.params.navigation.hiddenClass);144 if ($prevEl) $prevEl.toggleClass(swiper.params.navigation.hiddenClass);145 }146 },147 },...
paginations.js
Source:paginations.js
1/**2 * Generated by "@vuepress/plugin-blog"3 */4import sorters from './pageSorters'5import filters from './pageFilters'6export default [{7 pid: "post",8 id: "post",9 filter: filters.post,10 sorter: sorters.post,11 pages: [{"path":"/list/","interval":[0,19]},{"path":"/list/page/2/","interval":[20,24]}],12 prevText: "Prev",13 nextText: "Next",14},15{16 pid: "tags",17 id: "ngxin",18 filter: filters.tags,19 sorter: sorters.tags,20 pages: [{"path":"/tag/ngxin/","interval":[0,1]}],21 prevText: "Prev",22 nextText: "Next",23},24{25 pid: "tags",26 id: "Mac",27 filter: filters.tags,28 sorter: sorters.tags,29 pages: [{"path":"/tag/Mac/","interval":[0,1]}],30 prevText: "Prev",31 nextText: "Next",32},33{34 pid: "tags",35 id: "Koa",36 filter: filters.tags,37 sorter: sorters.tags,38 pages: [{"path":"/tag/Koa/","interval":[0,1]}],39 prevText: "Prev",40 nextText: "Next",41},42{43 pid: "tags",44 id: "Sequelize",45 filter: filters.tags,46 sorter: sorters.tags,47 pages: [{"path":"/tag/Sequelize/","interval":[0,1]}],48 prevText: "Prev",49 nextText: "Next",50},51{52 pid: "tags",53 id: "JavaScript",54 filter: filters.tags,55 sorter: sorters.tags,56 pages: [{"path":"/tag/JavaScript/","interval":[0,3]}],57 prevText: "Prev",58 nextText: "Next",59},60{61 pid: "tags",62 id: "é¢è¯é¢",63 filter: filters.tags,64 sorter: sorters.tags,65 pages: [{"path":"/tag/é¢è¯é¢/","interval":[0,1]}],66 prevText: "Prev",67 nextText: "Next",68},69{70 pid: "tags",71 id: "git",72 filter: filters.tags,73 sorter: sorters.tags,74 pages: [{"path":"/tag/git/","interval":[0,1]}],75 prevText: "Prev",76 nextText: "Next",77},78{79 pid: "tags",80 id: "npm",81 filter: filters.tags,82 sorter: sorters.tags,83 pages: [{"path":"/tag/npm/","interval":[0,1]}],84 prevText: "Prev",85 nextText: "Next",86},87{88 pid: "tags",89 id: "yarn",90 filter: filters.tags,91 sorter: sorters.tags,92 pages: [{"path":"/tag/yarn/","interval":[0,1]}],93 prevText: "Prev",94 nextText: "Next",95},96{97 pid: "tags",98 id: "Vue",99 filter: filters.tags,100 sorter: sorters.tags,101 pages: [{"path":"/tag/Vue/","interval":[0,1]}],102 prevText: "Prev",103 nextText: "Next",104},105{106 pid: "tags",107 id: "Axios",108 filter: filters.tags,109 sorter: sorters.tags,110 pages: [{"path":"/tag/Axios/","interval":[0,1]}],111 prevText: "Prev",112 nextText: "Next",113},114{115 pid: "tags",116 id: "Windows",117 filter: filters.tags,118 sorter: sorters.tags,119 pages: [{"path":"/tag/Windows/","interval":[0,1]}],120 prevText: "Prev",121 nextText: "Next",122},123{124 pid: "tags",125 id: "MacOS",126 filter: filters.tags,127 sorter: sorters.tags,128 pages: [{"path":"/tag/MacOS/","interval":[0,1]}],129 prevText: "Prev",130 nextText: "Next",131},132{133 pid: "tags",134 id: "vuepress",135 filter: filters.tags,136 sorter: sorters.tags,137 pages: [{"path":"/tag/vuepress/","interval":[0,12]}],138 prevText: "Prev",139 nextText: "Next",140},141{142 pid: "tags",143 id: "markdown",144 filter: filters.tags,145 sorter: sorters.tags,146 pages: [{"path":"/tag/markdown/","interval":[0,5]}],147 prevText: "Prev",148 nextText: "Next",149},150{151 pid: "tags",152 id: "CSS",153 filter: filters.tags,154 sorter: sorters.tags,155 pages: [{"path":"/tag/CSS/","interval":[0,1]}],156 prevText: "Prev",157 nextText: "Next",158},159{160 pid: "tags",161 id: "ç®æ³",162 filter: filters.tags,163 sorter: sorters.tags,164 pages: [{"path":"/tag/ç®æ³/","interval":[0,1]}],165 prevText: "Prev",166 nextText: "Next",167},168{169 pid: "tags",170 id: "LeetCode",171 filter: filters.tags,172 sorter: sorters.tags,173 pages: [{"path":"/tag/LeetCode/","interval":[0,1]}],174 prevText: "Prev",175 nextText: "Next",176},177{178 pid: "tags",179 id: "frontmatter",180 filter: filters.tags,181 sorter: sorters.tags,182 pages: [{"path":"/tag/frontmatter/","interval":[0,3]}],183 prevText: "Prev",184 nextText: "Next",185},186{187 pid: "tags",188 id: "js",189 filter: filters.tags,190 sorter: sorters.tags,191 pages: [{"path":"/tag/js/","interval":[0,1]}],192 prevText: "Prev",193 nextText: "Next",194},195{196 pid: "tags",197 id: "theme",198 filter: filters.tags,199 sorter: sorters.tags,200 pages: [{"path":"/tag/theme/","interval":[0,4]}],201 prevText: "Prev",202 nextText: "Next",203},204{205 pid: "tags",206 id: "blog",207 filter: filters.tags,208 sorter: sorters.tags,209 pages: [{"path":"/tag/blog/","interval":[0,4]}],210 prevText: "Prev",211 nextText: "Next",...
stats.js
Source:stats.js
1'use strict';2const Table = require('cli-table');3const filesize = require('filesize');4const chalk = require('chalk');5const join = require('path').join;6const fs = require('fs');7const prevBuildResults = fs.existsSync(__dirname + '/results.json')8 ? require('./results.json')9 : {bundleSizes: []};10const currentBuildResults = {11 // Mutated inside build.js during a build run.12 // We make a copy so that partial rebuilds don't erase other stats.13 bundleSizes: [...prevBuildResults.bundleSizes],14};15function saveResults() {16 fs.writeFileSync(17 join('scripts', 'rollup', 'results.json'),18 JSON.stringify(currentBuildResults, null, 2)19 );20}21function fractionalChange(prev, current) {22 return (current - prev) / prev;23}24function percentChangeString(change) {25 if (!isFinite(change)) {26 // When a new package is created27 return 'n/a';28 }29 const formatted = (change * 100).toFixed(1);30 if (/^-|^0(?:\.0+)$/.test(formatted)) {31 return `${formatted}%`;32 } else {33 return `+${formatted}%`;34 }35}36const resultsHeaders = [37 'Bundle',38 'Prev Size',39 'Current Size',40 'Diff',41 'Prev Gzip',42 'Current Gzip',43 'Diff',44];45function generateResultsArray(current, prevResults) {46 return current.bundleSizes47 .map(result => {48 const prev = prevResults.bundleSizes.filter(49 res =>50 res.filename === result.filename &&51 res.bundleType === result.bundleType52 )[0];53 if (result === prev) {54 // We didn't rebuild this bundle.55 return;56 }57 const size = result.size;58 const gzip = result.gzip;59 let prevSize = prev ? prev.size : 0;60 let prevGzip = prev ? prev.gzip : 0;61 return {62 filename: result.filename,63 bundleType: result.bundleType,64 packageName: result.packageName,65 prevSize: filesize(prevSize),66 prevFileSize: filesize(size),67 prevFileSizeChange: fractionalChange(prevSize, size),68 prevFileSizeAbsoluteChange: size - prevSize,69 prevGzip: filesize(prevGzip),70 prevGzipSize: filesize(gzip),71 prevGzipSizeChange: fractionalChange(prevGzip, gzip),72 prevGzipSizeAbsoluteChange: gzip - prevGzip,73 };74 // Strip any nulls75 })76 .filter(f => f);77}78function printResults() {79 const table = new Table({80 head: resultsHeaders.map(label => chalk.gray.yellow(label)),81 });82 const results = generateResultsArray(currentBuildResults, prevBuildResults);83 results.forEach(result => {84 table.push([85 chalk.white.bold(`${result.filename} (${result.bundleType})`),86 chalk.gray.bold(result.prevSize),87 chalk.white.bold(result.prevFileSize),88 percentChangeString(result.prevFileSizeChange),89 chalk.gray.bold(result.prevGzip),90 chalk.white.bold(result.prevGzipSize),91 percentChangeString(result.prevGzipSizeChange),92 ]);93 });94 return table.toString();95}96module.exports = {97 currentBuildResults,98 generateResultsArray,99 printResults,100 saveResults,101 resultsHeaders,...
Using AI Code Generation
1Cypress.Commands.add("prev", { prevSubject: true }, (subject) => {2 return cy.wrap(subject).prev();3});4Cypress.Commands.add("next", { prevSubject: true }, (subject) => {5 return cy.wrap(subject).next();6});7Cypress.Commands.add("closest", { prevSubject: true }, (subject) => {8 return cy.wrap(subject).closest();9});10Cypress.Commands.add("find", { prevSubject: true }, (subject) => {11 return cy.wrap(subject).find();12});13Cypress.Commands.add("first", { prevSubject: true }, (subject) => {14 return cy.wrap(subject).first();15});16Cypress.Commands.add("last", { prevSubject: true }, (subject) => {17 return cy.wrap(subject).last();18});19Cypress.Commands.add("eq", { prevSubject: true }, (subject) => {20 return cy.wrap(subject).eq();21});22Cypress.Commands.add("filter", { prevSubject: true }, (subject) => {23 return cy.wrap(subject).filter();24});25Cypress.Commands.add("not", { prevSubject: true }, (subject) => {26 return cy.wrap(subject).not();27});28Cypress.Commands.add("contains", { prevSubject: true }, (subject) => {29 return cy.wrap(subject).contains();30});31Cypress.Commands.add("children", { prevSubject: true }, (subject) => {32 return cy.wrap(subject).children();33});34Cypress.Commands.add("parent", { prevSubject: true }, (subject) => {35 return cy.wrap(subject).parent();36});37Cypress.Commands.add("parents", { prevSubject: true }, (subject) => {38 return cy.wrap(subject).parents();39});40Cypress.Commands.add("siblings", { prevSubject: true }, (subject) => {41 return cy.wrap(subject).siblings();42});
Using AI Code Generation
1Cypress.Commands.add('prev', { prevSubject: 'element' }, (subject, selector) => {2 return subject.prev(selector)3})4Cypress.Commands.add('next', { prevSubject: 'element' }, (subject, selector) => {5 return subject.next(selector)6})7Cypress.Commands.add('click', { prevSubject: 'element' }, (subject, selector) => {8 return subject.click(selector)9})10Cypress.Commands.add('click', { prevSubject: 'element' }, (subject, selector) => {11 return subject.click(selector)12})13Cypress.Commands.add('click', { prevSubject: 'element' }, (subject, selector) => {14 return subject.click(selector)15})16Cypress.Commands.add('click', { prevSubject: 'element' }, (subject, selector) => {17 return subject.click(selector)18})19Cypress.Commands.add('click', { prevSubject: 'element' }, (subject, selector) => {20 return subject.click(selector)21})22Cypress.Commands.add('click', { prevSubject: 'element' }, (subject, selector) => {23 return subject.click(selector)24})25Cypress.Commands.add('click', { prevSubject: 'element' }, (subject, selector) => {26 return subject.click(selector)27})28Cypress.Commands.add('click', { prevSubject: 'element' }, (subject, selector) => {29 return subject.click(selector)30})31Cypress.Commands.add('click', { prevSubject: 'element' }, (subject, selector) => {32 return subject.click(selector)33})34Cypress.Commands.add('click', { prevSubject: 'element' },
Using AI Code Generation
1describe('My First Test', function() {2 it('Does not do much!', function() {3 cy.contains('type').click()4 cy.url().should('include', '/commands/actions')5 cy.go('back')6 cy.url().should('include', '/commands/actions')7 })8})9describe('My First Test', function() {10 it('Does not do much!', function() {11 cy.contains('type').click()12 cy.url().should('include', '/commands/actions')13 cy.reload()14 cy.url().should('include', '/commands/actions')15 })16})17describe('My First Test', function() {18 it('Does not do much!', function() {19 cy.contains('type').click()20 cy.get('.action-clear').type('clear this text')21 cy.get('.action-clear').clear()22 cy.get('.action-clear').should('have.value', '')23 })24})25describe('My First Test', function() {26 it('Does not do much!', function() {27 cy.contains('check').click()28 cy.get('.action-checkboxes [type="checkbox"]').check(['checkbox1', 'checkbox2'])29 })30})31describe('My First Test', function() {32 it('Does not do much!', function() {33 cy.contains('check').click()34 cy.get('.action-checkboxes [type="checkbox"]').check(['checkbox1', 'checkbox2'])35 cy.get('.action-checkboxes [type="checkbox"]').uncheck('checkbox1')36 })37})
Using AI Code Generation
1Cypress.Commands.add('prev', () => {2 cy.window().then((win) => {3 win.history.back();4 });5});6Cypress.Commands.add('next', () => {7 cy.window().then((win) => {8 win.history.forward();9 });10});11Cypress.Commands.add('go', (num) => {12 cy.window().then((win) => {13 win.history.go(num);14 });15});16Cypress.Commands.add('replace', (url) => {17 cy.window().then((win) => {18 win.history.replaceState(null, null, url);19 });20});21Cypress.Commands.add('reload', () => {22 cy.window().then((win) => {23 win.location.reload();24 });25});26Cypress.Commands.add('location', () => {27 cy.window().then((win) => {28 win.location.href;29 });30});31Cypress.Commands.add('title', () => {32 cy.window().then((win) => {33 win.document.title;34 });35});36Cypress.Commands.add('length', () => {37 cy.window().then((win) => {38 win.history.length;39 });40});41Cypress.Commands.add('state', () => {42 cy.window().then((win) => {43 win.history.state;44 });45});
Using AI Code Generation
1describe('test', () => {2 it('test', () => {3 cy.get('a').first().prev()4 })5})6describe('test', () => {7 it('test', () => {8 cy.get('a').first().next()9 })10})11describe('test', () => {12 it('test', () => {13 cy.get('a').first().siblings()14 })15})16describe('test', () => {17 it('test', () => {18 cy.get('a').first().children()19 })20})21describe('test', () => {22 it('test', () => {23 cy.get('a').first().parents()24 })25})26describe('test', () => {27 it('test', () => {28 cy.get('a').first().parent()29 })30})31describe('test', () => {32 it('test', () => {33 cy.get('a').first().closest('div')34 })35})36describe('test', () => {37 it('test', () => {38 cy.get('a').first().find('div')39 })40})41describe('test', () => {42 it('test', () => {43 cy.get('a').first().contains('div')44 })45})46describe('test', () => {
Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.
You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.
Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.
Get 100 minutes of automation test minutes FREE!!