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