|
26 | 26 | </div> |
27 | 27 | <div id="floating-hover" onmouseover="hover()" onmouseleave="unhover()" ontouchstart="semihover()"> |
28 | 28 | <div class="small" id="floating-stopper" style="margin-top: 8px;"> |
29 | | - <a id="stopper" href="javascript:stopper()" class="text-muted" draggable="false"> |
| 29 | + <a id="stopper" href="#" role="button" class="text-muted" draggable="false"> |
30 | 30 | <i class="iconfont icon-pause"></i> |
31 | 31 | </a> |
32 | 32 | <div id="stopper-spacing"><br /><br /></div> |
|
58 | 58 | $('#skipper').attr('title', i18n.__('skipper')); |
59 | 59 | $('#recover').attr('title', i18n.__('recover')); |
60 | 60 | $('#exit').attr('title', i18n.__('exit')); |
| 61 | + (function () { |
| 62 | + var el = document.getElementById('stopper'); |
| 63 | + function handleStopper(e) { |
| 64 | + e.preventDefault(); |
| 65 | + e.stopPropagation(); |
| 66 | + stopper(e); |
| 67 | + return false; |
| 68 | + } |
| 69 | + el.addEventListener('mousedown', handleStopper, true); |
| 70 | + el.addEventListener('click', handleStopper, true); |
| 71 | + })(); |
61 | 72 | </script> |
62 | 73 | </div> |
63 | 74 | </div><!-- for things with 'work' mark, when it's resting, the color should be changed --> |
|
91 | 102 | } |
92 | 103 | } |
93 | 104 |
|
94 | | - function stopper() { |
| 105 | + const STOPPER_DEBOUNCE_MS = 320; |
| 106 | + function stopper(ev) { |
| 107 | + if (ev && ev.preventDefault) ev.preventDefault(); |
| 108 | + var now = Date.now(); |
| 109 | + if (lastActionAt && now - lastActionAt < STOPPER_DEBOUNCE_MS) return false; |
| 110 | + |
95 | 111 | let baseWorking = lastMessageWorking; |
96 | 112 | if (baseWorking === null) baseWorking = isWorking; |
97 | | - if (baseWorking === null) { |
98 | | - return; |
99 | | - } |
| 113 | + if (baseWorking === null) baseWorking = true; |
100 | 114 |
|
101 | 115 | desiredWorking = !baseWorking; |
102 | 116 | isWorking = desiredWorking; |
103 | | - lastActionAt = Date.now(); |
| 117 | + lastActionAt = now; |
104 | 118 | stopSyncPending = true; |
105 | 119 | renderStopperIcon(isWorking); |
106 | 120 | ipc.send("floating-conversation", { topic: "stop-set", desiredWorking: desiredWorking }); |
| 121 | + return false; |
107 | 122 | } |
108 | 123 |
|
109 | 124 | function skipper() { |
|
0 commit comments