Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1922)

Unified Diff: appengine/monorail/static/js/framework/framework-cues.js

Issue 1868553004: Open Source Monorail (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: appengine/monorail/static/js/framework/framework-cues.js
diff --git a/appengine/monorail/static/js/framework/framework-cues.js b/appengine/monorail/static/js/framework/framework-cues.js
new file mode 100644
index 0000000000000000000000000000000000000000..beaa280b226d8f1afd47ece0f0f2f32f005b3333
--- /dev/null
+++ b/appengine/monorail/static/js/framework/framework-cues.js
@@ -0,0 +1,47 @@
+/* Copyright 2016 The Chromium Authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style
+ * license that can be found in the LICENSE file or at
+ * https://developers.google.com/open-source/licenses/bsd
+ */
+
+/**
+ * @fileoverview Simple functions for dismissible on-page help ("cues").
+ */
+
+/**
+ * Dimisses the cue. This both updates the DOM and hits the server to
+ * record the fact that the user has dismissed it, so that it won't
+ * be shown again.
+ *
+ * If no security token is present, only the DOM is updated and
+ * nothing is recorded on the server.
+ *
+ * @param {string} cueId The identifier of the cue to hide.
+ * @return {boolean} false to cancel any event.
+ */
+function CS_dismissCue(cueId) {
+ $('cue').style.display = 'none';
+
+ if (CS_env.token) {
+ CS_setCue(cueId);
+ }
+ return false;
+}
+
+/**
+ * Function to communicate with the server to record the fact that the
+ * user has dismissed a cue. This just passes an object through to the
+ * cues servlet as key-value pairs.
+ *
+ * @param {string} cueId The identifier of the cue to hide.
+ */
+function CS_setCue(cueId) {
+ var setCueUrl = '/hosting/cues.do';
+
+ // Ignore the response, since we can't do anything about failures.
+ CS_doPost(setCueUrl, null, {'cue_id': cueId});
+}
+
+// Exports
+_CS_dismissCue = CS_dismissCue;

Powered by Google App Engine
This is Rietveld 408576698