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

Unified Diff: ui/webui/resources/js/util.js

Issue 369643002: Lay groudwork to Closure compile JavaScript (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more compiled Created 6 years, 5 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: ui/webui/resources/js/util.js
diff --git a/ui/webui/resources/js/util.js b/ui/webui/resources/js/util.js
index 8bf3059bed1987c90143fcc7dc7f216780b2403a..410f38f1aebbee5977b0813a4f6a6f326798b74f 100644
--- a/ui/webui/resources/js/util.js
+++ b/ui/webui/resources/js/util.js
@@ -2,14 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-<include src="assert.js">
-
-/**
- * The global object.
- * @type {!Object}
- * @const
- */
-var global = this;
+// <include src="assert.js">
/**
* Alias for document.getElementById.
@@ -60,7 +53,7 @@ function chromeSend(name, params, callbackName, callback) {
/**
* Returns the scale factors supported by this platform.
- * @return {array} The supported scale factors.
+ * @return {Array} The supported scale factors.
*/
function getSupportedScaleFactors() {
var supportedScaleFactors = [];
@@ -97,8 +90,8 @@ function url(s) {
* Returns the URL of the image, or an image set of URLs for the profile avatar.
* Default avatars have resources available for multiple scalefactors, whereas
* the GAIA profile image only comes in one size.
-
- * @param {string} url The path of the image.
+ *
+ * @param {string} path The path of the image.
* @return {string} The url, or an image set of URLs of the avatar image.
*/
function getProfileAvatarIcon(path) {
@@ -140,8 +133,8 @@ function imageset(path) {
/**
* Parses query parameters from Location.
- * @param {string} location The URL to generate the CSS url for.
- * @return {object} Dictionary containing name value pairs for URL
+ * @param {Location} location The URL to generate the CSS url for.
+ * @return {Object} Dictionary containing name value pairs for URL
*/
function parseQueryParams(location) {
var params = {};
@@ -157,7 +150,7 @@ function parseQueryParams(location) {
/**
* Creates a new URL by appending or replacing the given query key and value.
* Not supporting URL with username and password.
- * @param {object} location The original URL.
+ * @param {Location} location The original URL.
* @param {string} key The query parameter name.
* @param {string} value The query parameter value.
* @return {string} The constructed new URL.
@@ -174,11 +167,14 @@ function setQueryParam(location, key, value) {
return location.origin + location.pathname + newQuery + location.hash;
}
+/**
+ * @param {Node} el An element to search for ancestors with |className|.
+ * @param {string} className A class to search for.
+ * @return {Node} A node with class of |className| or null if none is found.
+ */
function findAncestorByClass(el, className) {
return findAncestor(el, function(el) {
- if (el.classList)
- return el.classList.contains(className);
- return null;
+ return el.classList && el.classList.contains(className);
});
}
@@ -236,7 +232,7 @@ function disableTextSelectAndDrag(opt_allowSelectStart, opt_allowDragStart) {
*/
function preventDefaultOnPoundLinkClicks() {
document.addEventListener('click', function(e) {
- var anchor = findAncestor(e.target, function(el) {
+ var anchor = findAncestor(/** @type {Element} */(e.target), function(el) {
arv (Not doing code reviews) 2014/07/16 18:33:03 e.target might be a Document too.
Dan Beam 2014/07/19 02:28:40 Changed to Node (document instanceof Node; // tru
return el.tagName == 'A';
});
// Use getAttribute() to prevent URL normalization.
@@ -263,7 +259,7 @@ function isRTL() {
function getRequiredElement(id) {
var element = $(id);
assert(element, 'Missing required element: ' + id);
- return element;
+ return /** @type {!Element} */(element);
}
// Handle click on a link. If the link points to a chrome: or file: url, then
« ui/webui/resources/js/parse_html_subset.js ('K') | « ui/webui/resources/js/template_data_externs.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698