| | @@ -694,10 +694,13 @@ |
| 694 | 694 | |
| 695 | 695 | 3 arguments: 3rd may be a flash delay time or a callback |
| 696 | 696 | function. |
| 697 | 697 | |
| 698 | 698 | Returns this object but the flashing is asynchronous. |
| 699 | + |
| 700 | + Depending on system load and related factors, a multi-flash |
| 701 | + animation might stutter and look suboptimal. |
| 699 | 702 | */ |
| 700 | 703 | dom.flashNTimes = function(e,n,howLongMs,afterFlashCallback){ |
| 701 | 704 | const args = argsToArray(arguments); |
| 702 | 705 | args.splice(1,1); |
| 703 | 706 | if(arguments.length===3 && 'function'===typeof howLongMs){ |
| | @@ -717,11 +720,40 @@ |
| 717 | 720 | } |
| 718 | 721 | }; |
| 719 | 722 | this.flashOnce.apply(this, args); |
| 720 | 723 | return this; |
| 721 | 724 | }; |
| 722 | | - |
| 725 | + |
| 726 | + /** |
| 727 | + Adds the given CSS class or array of CSS classes to the given |
| 728 | + element or forEach-capable list of elements for howLongMs, then |
| 729 | + removes it. If afterCallack is a function, it is called after the |
| 730 | + CSS class is removed from all elements. If called with 3 |
| 731 | + arguments and the 3rd is a function, the 3rd is treated as a |
| 732 | + callback and the default time (addClassBriefly.defaultTimeMs) is |
| 733 | + used. If called with only 2 arguments, a time of |
| 734 | + addClassBriefly.defaultTimeMs is used. |
| 735 | + |
| 736 | + Returns this object but the CSS removal is asynchronous. |
| 737 | + */ |
| 738 | + dom.addClassBriefly = function f(e, className, howLongMs, afterCallback){ |
| 739 | + if(arguments.length<4 && 'function'===typeof howLongMs){ |
| 740 | + afterCallback = howLongMs; |
| 741 | + howLongMs = f.defaultTimeMs; |
| 742 | + }else if(arguments.length<3 || !+howLongMs){ |
| 743 | + howLongMs = f.defaultTimeMs; |
| 744 | + } |
| 745 | + if(!e.forEach) e = [e]; |
| 746 | + this.addClass(e, className); |
| 747 | + setTimeout(function(){ |
| 748 | + dom.removeClass(e, className); |
| 749 | + if(afterCallback) afterCallback(); |
| 750 | + }, howLongMs); |
| 751 | + return this; |
| 752 | + }; |
| 753 | + dom.addClassBriefly.defaultTimeMs = 1000; |
| 754 | + |
| 723 | 755 | /** |
| 724 | 756 | Attempts to copy the given text to the system clipboard. Returns |
| 725 | 757 | true if it succeeds, else false. |
| 726 | 758 | */ |
| 727 | 759 | dom.copyTextToClipboard = function(text){ |
| 728 | 760 | |