Index: chrome/browser/resources/bookmark_manager/js/bmm/bookmark_list.js |
diff --git a/chrome/browser/resources/bookmark_manager/js/bmm/bookmark_list.js b/chrome/browser/resources/bookmark_manager/js/bmm/bookmark_list.js |
index a678d379e4116695cf56fe9ce3f6fd3896c1a7aa..2518ff8403c69e809d9c66af089f6ad00470d41f 100644 |
--- a/chrome/browser/resources/bookmark_manager/js/bmm/bookmark_list.js |
+++ b/chrome/browser/resources/bookmark_manager/js/bmm/bookmark_list.js |
@@ -5,14 +5,27 @@ |
// TODO(arv): Now that this is driven by a data model, implement a data model |
// that handles the loading and the events from the bookmark backend. |
+/** |
+ * @typedef {{childIds: Array.<string>}} |
+ * |
+ * @see chrome/common/extensions/api/bookmarks.json |
+ */ |
+var ReorderInfo; |
+ |
+/** |
+ * @typedef {{parentId: string, index: number, oldParentId: string, |
+ * oldIndex: number}} |
+ * |
+ * @see chrome/common/extensions/api/bookmarks.json |
+ */ |
+var MoveInfo; |
+ |
cr.define('bmm', function() { |
var List = cr.ui.List; |
var ListItem = cr.ui.ListItem; |
var ArrayDataModel = cr.ui.ArrayDataModel; |
var ContextMenuButton = cr.ui.ContextMenuButton; |
- var list; |
- |
/** |
* Basic array data model for use with bookmarks. |
* @param {!Array.<!BookmarkTreeNode>} items The bookmark items. |
@@ -57,7 +70,7 @@ cr.define('bmm', function() { |
* Creates a new bookmark list. |
* @param {Object=} opt_propertyBag Optional properties. |
* @constructor |
- * @extends {HTMLButtonElement} |
+ * @extends {cr.ui.List} |
*/ |
var BookmarkList = cr.ui.define('list'); |
@@ -75,10 +88,12 @@ cr.define('bmm', function() { |
// We could add the ContextMenuButton in the BookmarkListItem but it slows |
// down redraws a lot so we do this on mouseovers instead. |
this.addEventListener('mouseover', this.handleMouseOver_.bind(this)); |
- |
- bmm.list = this; |
}, |
+ /** |
+ * @param {!BookmarkTreeNode} bookmarkNode |
+ * @override |
+ */ |
createItem: function(bookmarkNode) { |
return new BookmarkListItem(bookmarkNode); |
}, |
@@ -198,9 +213,10 @@ cr.define('bmm', function() { |
* Handles mousedown events so that we can prevent the auto scroll as |
* necessary. |
* @private |
- * @param {!MouseEvent} e The mousedown event object. |
+ * @param {!Event} e The mousedown event object. |
*/ |
handleMouseDown_: function(e) { |
+ e = /** @type {!MouseEvent} */(e); |
if (e.button == 1) { |
// WebKit no longer fires click events for middle clicks so we manually |
// listen to mouse up to dispatch a click event. |
@@ -220,9 +236,10 @@ cr.define('bmm', function() { |
* WebKit no longer dispatches click events for middle clicks so we need |
* to emulate it. |
* @private |
- * @param {!MouseEvent} e The mouse up event object. |
+ * @param {!Event} e The mouse up event object. |
*/ |
handleMiddleMouseUp_: function(e) { |
+ e = /** @type {!MouseEvent} */(e); |
this.removeEventListener('mouseup', this.handleMiddleMouseUp_); |
if (e.button == 1) { |
var el = e.target; |
@@ -250,6 +267,10 @@ cr.define('bmm', function() { |
} |
}, |
+ /** |
+ * @param {string} id |
+ * @param {ReorderInfo} reorderInfo |
+ */ |
handleChildrenReordered: function(id, reorderInfo) { |
if (this.parentId == id) { |
// We create a new data model with updated items in the right order. |
@@ -274,6 +295,10 @@ cr.define('bmm', function() { |
this.dataModel.splice(bookmarkNode.index, 0, bookmarkNode); |
}, |
+ /** |
+ * @param {string} id |
+ * @param {MoveInfo} moveInfo |
+ */ |
handleMoved: function(id, moveInfo) { |
if (moveInfo.parentId == this.parentId || |
moveInfo.oldParentId == this.parentId) { |
@@ -344,7 +369,6 @@ cr.define('bmm', function() { |
/** |
* The ID of the bookmark folder we are displaying. |
- * @type {string} |
*/ |
cr.defineProperty(BookmarkList, 'parentId', cr.PropertyKind.JS, |
function() { |
@@ -353,9 +377,10 @@ cr.define('bmm', function() { |
/** |
* The contextMenu property. |
- * @type {cr.ui.Menu} |
*/ |
cr.ui.contextMenuHandler.addContextMenuProperty(BookmarkList); |
+ /** @type {cr.ui.Menu} */ |
+ BookmarkList.prototype.contextMenu; |
/** |
* Creates a new bookmark list item. |
@@ -507,14 +532,14 @@ cr.define('bmm', function() { |
this.setAttribute('editing', ''); |
this.draggable = false; |
- labelInput = doc.createElement('input'); |
+ labelInput = /** @type {HTMLElement} */(doc.createElement('input')); |
labelInput.placeholder = |
loadTimeData.getString('name_input_placeholder'); |
replaceAllChildren(labelEl, labelInput); |
labelInput.value = title; |
if (!isFolder) { |
- urlInput = doc.createElement('input'); |
+ urlInput = /** @type {HTMLElement} */(doc.createElement('input')); |
urlInput.type = 'url'; |
urlInput.required = true; |
urlInput.placeholder = |
@@ -522,13 +547,13 @@ cr.define('bmm', function() { |
// We also need a name for the input for the CSS to work. |
urlInput.name = '-url-input-' + cr.createUid(); |
- replaceAllChildren(urlEl, urlInput); |
+ replaceAllChildren(assert(urlEl), urlInput); |
urlInput.value = url; |
} |
- function stopPropagation(e) { |
+ var stopPropagation = function(e) { |
e.stopPropagation(); |
- } |
+ }; |
var eventsToStop = |
['mousedown', 'mouseup', 'contextmenu', 'dblclick', 'paste']; |
@@ -601,6 +626,8 @@ cr.define('bmm', function() { |
return { |
BookmarkList: BookmarkList, |
- list: list |
+ get list() { |
+ return $('list'); |
+ }, |
Dan Beam
2014/09/25 04:27:18
what about:
list: /** @type {Element} */(null),
Vitaly Pavlenko
2014/09/25 15:37:15
Done.
|
}; |
}); |