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

Unified Diff: remoting/webapp/me2mom/util.js

Issue 8416007: Refactored web-app (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 9 years, 2 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
« no previous file with comments | « remoting/webapp/me2mom/ui_mode.js ('k') | remoting/webapp/me2mom/wcs_loader.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/me2mom/util.js
diff --git a/remoting/webapp/me2mom/util.js b/remoting/webapp/me2mom/util.js
new file mode 100644
index 0000000000000000000000000000000000000000..0c15c0c1075dc7b1110ebb3deb5940f3b67ef830
--- /dev/null
+++ b/remoting/webapp/me2mom/util.js
@@ -0,0 +1,40 @@
+// Copyright (c) 2011 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.
+
+/**
+ * @fileoverview
+ * Simple utility functions for Chromoting.
+ */
+
+/**
+ * @param {string} classes A space-separated list of classes.
+ * @param {string} cls The class to check for.
+ * @return {boolean} True if |cls| is found within |classes|.
+ */
+function hasClass(classes, cls) {
+ return classes.match(new RegExp('(\\s|^)' + cls + '(\\s|$)')) != null;
+}
+
+/**
+ * @param {Element} element The element to which to add the class.
+ * @param {string} cls The new class.
+ * @return {void} Nothing.
+ */
+function addClass(element, cls) {
+ if (!hasClass(element.className, cls)) {
+ var padded = element.className == '' ? '' : element.className + ' ';
+ element.className = padded + cls;
+ }
+}
+
+/**
+ * @param {Element} element The element from which to remove the class.
+ * @param {string} cls The new class.
+ * @return {void} Nothing.
+ */
+function removeClass(element, cls) {
+ element.className =
+ element.className.replace(new RegExp('\\b' + cls + '\\b', 'g'), '')
+ .replace(' ', ' ');
+}
« no previous file with comments | « remoting/webapp/me2mom/ui_mode.js ('k') | remoting/webapp/me2mom/wcs_loader.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698