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

Side by Side Diff: chrome/browser/resources/md_bookmarks/item.js

Issue 2704983002: MD Bookmarks: Proof-of-concept reimplementation of data storage/binding layer (Closed)
Patch Set: Add doc comments Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 Polymer({ 5 Polymer({
6 is: 'bookmarks-item', 6 is: 'bookmarks-item',
7 7
8 behaviors: [
9 bookmarks.StoreClient,
10 ],
11
8 properties: { 12 properties: {
9 /** @type {BookmarkTreeNode} */ 13 /** @type {BookmarkNode} */
10 item: { 14 item: {
11 type: Object, 15 type: Object,
12 observer: 'onItemChanged_', 16 observer: 'onItemChanged_',
13 }, 17 },
14 18
19 itemId: {
20 type: String,
21 observer: 'updateFromStore',
22 },
23
15 isFolder_: Boolean, 24 isFolder_: Boolean,
16 25
17 isSelectedItem: { 26 isSelectedItem: {
18 type: Boolean, 27 type: Boolean,
19 reflectToAttribute: true, 28 reflectToAttribute: true,
20 }, 29 },
21 }, 30 },
22 31
23 observers: [ 32 observers: [
24 'updateFavicon_(item.url)', 33 'updateFavicon_(item.url)',
25 ], 34 ],
26 35
27 listeners: { 36 listeners: {
28 'click': 'onClick_', 37 'click': 'onClick_',
29 'dblclick': 'onDblClick_', 38 'dblclick': 'onDblClick_',
30 }, 39 },
31 40
41 attached: function() {
42 this.observe('item', function(store) {
43 return store.nodes[this.itemId];
44 }.bind(this));
45 this.observe('isSelectedItem', function(store) {
46 return store.selection.items[this.itemId];
47 }.bind(this));
48
49 this.updateFromStore();
50 },
51
32 /** 52 /**
33 * @param {Event} e 53 * @param {Event} e
34 * @private 54 * @private
35 */ 55 */
36 onMenuButtonOpenClick_: function(e) { 56 onMenuButtonOpenClick_: function(e) {
37 e.stopPropagation(); 57 e.stopPropagation();
38 this.fire('open-item-menu', { 58 this.fire('open-item-menu', {
39 target: e.target, 59 target: e.target,
40 item: this.item, 60 item: this.item,
41 }); 61 });
42 }, 62 },
43 63
44 /** @private */ 64 /** @private */
45 onItemChanged_: function() { 65 onItemChanged_: function() {
46 this.isFolder_ = !(this.item.url); 66 this.isFolder_ = !(this.item.url);
47 }, 67 },
48 68
49 /** 69 /**
50 * @param {Event} e 70 * @param {Event} e
51 * @private 71 * @private
52 */ 72 */
53 onClick_: function(e) { 73 onClick_: function(e) {
54 this.fire('select-item', { 74 this.dispatch(bookmarks.actions.selectItem(
55 item: this.item, 75 this.itemId, e.ctrlKey, e.shiftKey, this.getState()));
56 range: e.shiftKey,
57 add: e.ctrlKey,
58 });
59 }, 76 },
60 77
61 /** 78 /**
62 * @param {Event} e 79 * @param {Event} e
63 * @private 80 * @private
64 */ 81 */
65 onDblClick_: function(e) { 82 onDblClick_: function(e) {
66 if (!this.item.url) 83 if (!this.item.url)
67 this.fire('selected-folder-changed', this.item.id); 84 this.dispatch(bookmarks.actions.selectFolder(this.item.id));
68 else 85 else
69 chrome.tabs.create({url: this.item.url}); 86 chrome.tabs.create({url: this.item.url});
70 }, 87 },
71 88
72 /** 89 /**
73 * @param {string} url 90 * @param {string} url
74 * @private 91 * @private
75 */ 92 */
76 updateFavicon_: function(url) { 93 updateFavicon_: function(url) {
77 this.$.icon.style.backgroundImage = cr.icon.getFavicon(url); 94 this.$.icon.style.backgroundImage = cr.icon.getFavicon(url);
78 }, 95 },
79 }); 96 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/md_bookmarks/item.html ('k') | chrome/browser/resources/md_bookmarks/list.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698