Adrià Vilanova MartÃnez | f19ea43 | 2024-01-23 20:20:52 +0100 | [diff] [blame] | 1 | // Copyright 2016 The Chromium Authors |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 4 | |
| 5 | /** |
| 6 | * @fileoverview Simple functions for dismissible on-page help ("cues"). |
| 7 | */ |
| 8 | |
| 9 | /** |
| 10 | * Dimisses the cue. This both updates the DOM and hits the server to |
| 11 | * record the fact that the user has dismissed it, so that it won't |
| 12 | * be shown again. |
| 13 | * |
| 14 | * If no security token is present, only the DOM is updated and |
| 15 | * nothing is recorded on the server. |
| 16 | * |
| 17 | * @param {string} cueId The identifier of the cue to hide. |
| 18 | * @return {boolean} false to cancel any event. |
| 19 | */ |
| 20 | function CS_dismissCue(cueId) { |
| 21 | let cueElements = document.querySelectorAll('.cue'); |
| 22 | for (let i = 0; i < cueElements.length; ++i) { |
| 23 | cueElements[i].style.display = 'none'; |
| 24 | } |
| 25 | |
| 26 | if (CS_env.token) { |
| 27 | window.prpcClient.call( |
| 28 | 'monorail.Users', 'SetUserPrefs', |
| 29 | {prefs: [{name: cueId, value: 'true'}]}); |
| 30 | } |
| 31 | return false; |
| 32 | } |
| 33 | |
| 34 | // Exports |
| 35 | _CS_dismissCue = CS_dismissCue; |