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

Side by Side 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, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/webapp/me2mom/ui_mode.js ('k') | remoting/webapp/me2mom/wcs_loader.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 /**
6 * @fileoverview
7 * Simple utility functions for Chromoting.
8 */
9
10 /**
11 * @param {string} classes A space-separated list of classes.
12 * @param {string} cls The class to check for.
13 * @return {boolean} True if |cls| is found within |classes|.
14 */
15 function hasClass(classes, cls) {
16 return classes.match(new RegExp('(\\s|^)' + cls + '(\\s|$)')) != null;
17 }
18
19 /**
20 * @param {Element} element The element to which to add the class.
21 * @param {string} cls The new class.
22 * @return {void} Nothing.
23 */
24 function addClass(element, cls) {
25 if (!hasClass(element.className, cls)) {
26 var padded = element.className == '' ? '' : element.className + ' ';
27 element.className = padded + cls;
28 }
29 }
30
31 /**
32 * @param {Element} element The element from which to remove the class.
33 * @param {string} cls The new class.
34 * @return {void} Nothing.
35 */
36 function removeClass(element, cls) {
37 element.className =
38 element.className.replace(new RegExp('\\b' + cls + '\\b', 'g'), '')
39 .replace(' ', ' ');
40 }
OLDNEW
« 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