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

Unified Diff: ui/webui/resources/js/cr/ui/tree.js

Issue 2597013002: Run clang-format on ui/webui/resources (Closed)
Patch Set: remove cr_shared_menu.js Created 4 years 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/cr/ui/tree.js
diff --git a/ui/webui/resources/js/cr/ui/tree.js b/ui/webui/resources/js/cr/ui/tree.js
index 1eed9e1dc9ca2951c7a3716254ab9aa2aec4a57a..04b68ae0df83f09ffd66df64598dd9b07dbf7a0c 100644
--- a/ui/webui/resources/js/cr/ui/tree.js
+++ b/ui/webui/resources/js/cr/ui/tree.js
@@ -64,17 +64,13 @@ cr.define('cr.ui', function() {
/**
* Returns the tree item that are children of this tree.
*/
- get items() {
- return this.children;
- },
+ get items() { return this.children; },
/**
* Adds a tree item to the tree.
* @param {!cr.ui.TreeItem} treeItem The item to add.
*/
- add: function(treeItem) {
- this.addAt(treeItem, 0xffffffff);
- },
+ add: function(treeItem) { this.addAt(treeItem, 0xffffffff); },
/**
* Adds a tree item at the given index.
@@ -95,16 +91,14 @@ cr.define('cr.ui', function() {
* @param {!cr.ui.TreeItem=} treeItem The tree item to remove.
*/
remove: function(treeItem) {
- this.removeChild(/** @type {!cr.ui.TreeItem} */(treeItem));
+ this.removeChild(/** @type {!cr.ui.TreeItem} */ (treeItem));
},
/**
* The depth of the node. This is 0 for the tree itself.
* @type {number}
*/
- get depth() {
- return 0;
- },
+ get depth() { return 0; },
/**
* Handles click events on the tree and forwards the event to the relevant
@@ -112,13 +106,13 @@ cr.define('cr.ui', function() {
* @param {Event} e The click event object.
*/
handleClick: function(e) {
- var treeItem = findTreeItem(/** @type {!Node} */(e.target));
+ var treeItem = findTreeItem(/** @type {!Node} */ (e.target));
if (treeItem)
treeItem.handleClick(e);
},
handleMouseDown: function(e) {
- if (e.button == 2) // right
+ if (e.button == 2) // right
this.handleClick(e);
},
@@ -127,7 +121,7 @@ cr.define('cr.ui', function() {
* @param {Event} e The dblclick event object.
*/
handleDblClick: function(e) {
- var treeItem = findTreeItem(/** @type {!Node} */(e.target));
+ var treeItem = findTreeItem(/** @type {!Node} */ (e.target));
if (treeItem)
treeItem.expanded = !treeItem.expanded;
},
@@ -150,12 +144,11 @@ cr.define('cr.ui', function() {
switch (e.key) {
case 'ArrowUp':
- itemToSelect = item ? getPrevious(item) :
- this.items[this.items.length - 1];
+ itemToSelect =
+ item ? getPrevious(item) : this.items[this.items.length - 1];
break;
case 'ArrowDown':
- itemToSelect = item ? getNext(item) :
- this.items[0];
+ itemToSelect = item ? getNext(item) : this.items[0];
break;
case 'ArrowLeft':
case 'ArrowRight':
@@ -193,9 +186,7 @@ cr.define('cr.ui', function() {
* The selected tree item or null if none.
* @type {cr.ui.TreeItem}
*/
- get selectedItem() {
- return this.selectedItem_ || null;
- },
+ get selectedItem() { return this.selectedItem_ || null; },
set selectedItem(item) {
var oldSelectedItem = this.selectedItem_;
if (oldSelectedItem != item) {
@@ -211,7 +202,7 @@ cr.define('cr.ui', function() {
if (item.id)
this.setAttribute('aria-activedescendant', item.id);
} else {
- this.removeAttribute('aria-activedescendant');
+ this.removeAttribute('aria-activedescendant');
}
cr.dispatchSimpleEvent(this, 'change');
}
@@ -282,8 +273,8 @@ cr.define('cr.ui', function() {
* Initializes the element.
*/
decorate: function() {
- var labelId = 'tree-item-label-autogen-id-' +
- treeItemAutoGeneratedIdCounter;
+ var labelId =
+ 'tree-item-label-autogen-id-' + treeItemAutoGeneratedIdCounter;
this.labelElement.id = labelId;
this.setAttribute('aria-labelledby', labelId);
},
@@ -291,18 +282,13 @@ cr.define('cr.ui', function() {
/**
* The tree items children.
*/
- get items() {
- return this.lastElementChild.children;
- },
+ get items() { return this.lastElementChild.children; },
/**
* The depth of the tree item.
* @type {number}
*/
- depth_: 0,
- get depth() {
- return this.depth_;
- },
+ depth_: 0, get depth() { return this.depth_; },
/**
* Sets the depth.
@@ -311,8 +297,8 @@ cr.define('cr.ui', function() {
*/
setDepth_: function(depth) {
if (depth != this.depth_) {
- this.rowElement.style.WebkitPaddingStart = Math.max(0, depth - 1) *
- INDENT + 'px';
+ this.rowElement.style.WebkitPaddingStart =
+ Math.max(0, depth - 1) * INDENT + 'px';
this.depth_ = depth;
var items = this.items;
for (var i = 0, item; item = items[i]; i++) {
@@ -325,9 +311,7 @@ cr.define('cr.ui', function() {
* Adds a tree item as a child.
* @param {!cr.ui.TreeItem} child The child to add.
*/
- add: function(child) {
- this.addAt(child, 0xffffffff);
- },
+ add: function(child) { this.addAt(child, 0xffffffff); },
/**
* Adds a tree item as a child at a given index.
@@ -353,7 +337,7 @@ cr.define('cr.ui', function() {
if (selectedItem && child.contains(selectedItem))
this.selected = true;
- this.lastElementChild.removeChild(/** @type {!cr.ui.TreeItem} */(child));
+ this.lastElementChild.removeChild(/** @type {!cr.ui.TreeItem} */ (child));
if (this.items.length == 0)
this.hasChildren = false;
},
@@ -386,9 +370,7 @@ cr.define('cr.ui', function() {
* Whether the tree item is expanded or not.
* @type {boolean}
*/
- get expanded() {
- return this.hasAttribute('expanded');
- },
+ get expanded() { return this.hasAttribute('expanded'); },
set expanded(b) {
if (this.expanded == b)
return;
@@ -435,28 +417,20 @@ cr.define('cr.ui', function() {
* The element representing the row that gets highlighted.
* @type {!HTMLElement}
*/
- get rowElement() {
- return this.firstElementChild;
- },
+ get rowElement() { return this.firstElementChild; },
/**
* The element containing the label text and the icon.
* @type {!HTMLElement}
*/
- get labelElement() {
- return this.firstElementChild.lastElementChild;
- },
+ get labelElement() { return this.firstElementChild.lastElementChild; },
/**
* The label text.
* @type {string}
*/
- get label() {
- return this.labelElement.textContent;
- },
- set label(s) {
- this.labelElement.textContent = s;
- },
+ get label() { return this.labelElement.textContent; },
+ set label(s) { this.labelElement.textContent = s; },
/**
* The URL for the icon.
@@ -473,9 +447,7 @@ cr.define('cr.ui', function() {
* Whether the tree item is selected or not.
* @type {boolean}
*/
- get selected() {
- return this.hasAttribute('selected');
- },
+ get selected() { return this.hasAttribute('selected'); },
set selected(b) {
if (this.selected == b)
return;
@@ -500,9 +472,7 @@ cr.define('cr.ui', function() {
* Whether the tree item has children.
* @type {boolean}
*/
- get mayHaveChildren_() {
- return this.hasAttribute('may-have-children');
- },
+ get mayHaveChildren_() { return this.hasAttribute('may-have-children'); },
set mayHaveChildren_(b) {
var rowItem = this.firstElementChild;
if (b) {
@@ -518,9 +488,7 @@ cr.define('cr.ui', function() {
* Whether the tree item has children.
* @type {boolean}
*/
- get hasChildren() {
- return !!this.items[0];
- },
+ get hasChildren() { return !!this.items[0]; },
/**
* Whether the tree item has children.
@@ -573,15 +541,13 @@ cr.define('cr.ui', function() {
switch (e.key) {
case 'Escape':
input.value = text;
- // fall through
+ // fall through
case 'Enter':
self.tree.focus();
}
}
- function stopPropagation(e) {
- e.stopPropagation();
- }
+ function stopPropagation(e) { e.stopPropagation(); }
if (editing) {
this.selected = true;
@@ -598,9 +564,8 @@ cr.define('cr.ui', function() {
labelEl.appendChild(input);
input.addEventListener('keydown', handleKeydown);
- input.addEventListener('blur', (function() {
- this.editing = false;
- }).bind(this));
+ input.addEventListener(
+ 'blur', (function() { this.editing = false; }).bind(this));
// Make sure that double clicks do not expand and collapse the tree
// item.
@@ -638,9 +603,7 @@ cr.define('cr.ui', function() {
}
},
- get editing() {
- return this.hasAttribute('editing');
- }
+ get editing() { return this.hasAttribute('editing'); }
};
/**
@@ -702,8 +665,5 @@ cr.define('cr.ui', function() {
}
// Export
- return {
- Tree: Tree,
- TreeItem: TreeItem
- };
+ return {Tree: Tree, TreeItem: TreeItem};
});

Powered by Google App Engine
This is Rietveld 408576698