Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 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 Polymer({ | |
| 6 is: 'history-item', | |
|
Dan Beam
2016/01/27 03:07:31
nit: \n
yingran
2016/01/27 05:05:04
Done.
| |
| 7 properties: { | |
| 8 timeAccessed: { | |
| 9 type: String, | |
| 10 value: '' | |
| 11 }, | |
| 12 | |
| 13 websiteTitle: { | |
| 14 type: String, | |
| 15 value: '' | |
| 16 }, | |
| 17 | |
| 18 // Domain is the website text shown on the history-item next to the title. | |
| 19 // Gives the user some idea of which history items are different pages | |
| 20 // belonging to the same site, and can be used to look for more items | |
| 21 // from the same site. | |
| 22 websiteDomain: { | |
| 23 type: String, | |
| 24 value: '' | |
| 25 }, | |
| 26 | |
| 27 // The website url is used to define where the link should take you if | |
| 28 // you click on the title, and also to define which icon the history-item | |
| 29 // should display. | |
| 30 websiteUrl: { | |
| 31 type: String, | |
| 32 value: '', | |
| 33 observer: 'showIcon_' | |
| 34 }, | |
| 35 | |
| 36 // If the website is a bookmarked page starred is true. | |
| 37 starred: { | |
| 38 type: Boolean, | |
| 39 value: false, | |
| 40 reflectToAttribute: true | |
| 41 }, | |
| 42 | |
| 43 // The time in seconds of when the website was accessed. | |
| 44 timestamp: { | |
| 45 type: Number, | |
| 46 value: 0 | |
| 47 }, | |
| 48 | |
| 49 selected: { | |
| 50 type: Boolean, | |
| 51 value: false, | |
| 52 notify: true | |
| 53 } | |
| 54 }, | |
| 55 | |
| 56 /** | |
| 57 * When a history-item is selected the toolbar is notified and increases | |
| 58 * or decreases its count of selected items accordingly. | |
| 59 * @private | |
| 60 */ | |
| 61 onCheckboxSelected_: function() { | |
| 62 this.fire('history-checkbox-select', { | |
| 63 countAddition: this.$.checkbox.checked ? 1 : -1 | |
| 64 }); | |
| 65 }, | |
| 66 | |
| 67 /** | |
| 68 * When the url for the history-item is set, the icon associated with this | |
| 69 * website is also set. | |
| 70 * @private | |
| 71 */ | |
| 72 showIcon_: function() { | |
| 73 this.$['website-icon'].style.backgroundImage = '-webkit-image-set(' + | |
| 74 'url("chrome://favicon/size/16@1x/' + this.websiteUrl + '") 1x,' + | |
| 75 'url("chrome://favicon/size/16@2x/' + this.websiteUrl + '") 2x)'; | |
|
Dan Beam
2016/01/27 03:07:31
can this use getFaviconImageSet?
https://code.goo
yingran
2016/01/28 00:51:00
Done.
| |
| 76 }, | |
| 77 | |
| 78 /** | |
| 79 * Fires a custom event when the menu button is clicked. Sends the details of | |
| 80 * the history item and where the menu should appear. | |
| 81 */ | |
| 82 onMenuButtonTap_: function(e) { | |
| 83 var position = this.$['menu-button'].getBoundingClientRect(); | |
| 84 | |
| 85 this.fire('toggle-menu', { | |
| 86 x: position.left, | |
| 87 y: position.top, | |
| 88 accessTime: this.timestamp | |
| 89 }); | |
|
Dan Beam
2016/01/27 03:07:31
nit: \n
yingran
2016/01/27 05:05:04
Done.
| |
| 90 // Stops the 'tap' event from closing the menu when it opens. | |
| 91 e.stopPropagation(); | |
| 92 } | |
| 93 }); | |
| OLD | NEW |