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