Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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: 'history-item', | 6 is: 'history-item', |
| 7 | 7 |
| 8 properties: { | 8 properties: { |
| 9 timeAccessed_: { | 9 // The date of these history items. |
| 10 historyDate: { | |
| 10 type: String, | 11 type: String, |
| 11 value: '' | 12 value: '' |
| 12 }, | 13 }, |
| 13 | 14 |
| 14 websiteTitle_: { | 15 timeAccessed: { |
| 15 type: String, | 16 type: String, |
| 16 value: '' | 17 value: '' |
| 17 }, | 18 }, |
| 19 | |
| 20 websiteTitle: { | |
| 21 type: String, | |
| 22 value: '' | |
| 23 }, | |
| 18 | 24 |
| 19 // Domain is the website text shown on the history-item next to the title. | 25 // Domain is the website text shown on the history-item next to the title. |
| 20 // Gives the user some idea of which history items are different pages | 26 // Gives the user some idea of which history items are different pages |
| 21 // belonging to the same site, and can be used to look for more items | 27 // belonging to the same site, and can be used to look for more items |
| 22 // from the same site. | 28 // from the same site. |
| 23 websiteDomain_: { | 29 websiteDomain: { |
| 24 type: String, | 30 type: String, |
| 25 value: '' | 31 value: '' |
| 26 }, | 32 }, |
| 27 | 33 |
| 28 // The website url is used to define where the link should take you if | 34 // The website url is used to define where the link should take you if |
| 29 // you click on the title, and also to define which icon the history-item | 35 // you click on the title, and also to define which icon the history-item |
| 30 // should display. | 36 // should display. |
| 31 websiteUrl_: { | 37 websiteUrl: { |
| 32 type: String, | 38 type: String, |
| 33 value: '', | 39 value: '', |
| 34 observer: 'showIcon_' | 40 observer: 'showIcon_' |
| 35 }, | 41 }, |
| 36 | 42 |
| 37 // If the website is a bookmarked page starred is true. | 43 // If the website is a bookmarked page starred is true. |
| 38 starred: { | 44 starred: { |
| 39 type: Boolean, | 45 type: Boolean, |
| 40 value: false, | 46 value: false, |
| 41 reflectToAttribute: true | 47 reflectToAttribute: true |
| 42 }, | 48 }, |
| 43 | 49 |
| 44 // The time in seconds of when the website was accessed. | 50 // The time in seconds of when the website was accessed. |
| 45 timestamp_: { | 51 timestamp: { |
| 46 type: Number, | 52 type: Number, |
| 47 value: 0 | 53 value: 0 |
| 48 }, | 54 }, |
| 49 | 55 |
| 50 selected: { | 56 selected: { |
| 51 type: Boolean, | 57 type: Boolean, |
| 52 value: false, | 58 value: false, |
| 53 notify: true | 59 notify: true |
| 60 }, | |
| 61 | |
| 62 isCardStart: { | |
| 63 type: Boolean, | |
| 64 value: false, | |
| 65 reflectToAttribute: true | |
| 66 }, | |
| 67 | |
| 68 isCardEnd: { | |
| 69 type: Boolean, | |
| 70 value: false, | |
| 71 reflectToAttribute: true | |
| 72 }, | |
| 73 | |
| 74 hasTimeGap: { | |
| 75 type: Boolean, | |
| 76 value: false | |
| 54 } | 77 } |
| 55 }, | 78 }, |
| 56 | 79 |
| 57 /** | 80 /** |
| 58 * When a history-item is selected the toolbar is notified and increases | 81 * When a history-item is selected the toolbar is notified and increases |
| 59 * or decreases its count of selected items accordingly. | 82 * or decreases its count of selected items accordingly. |
| 60 * @private | 83 * @private |
| 61 */ | 84 */ |
| 62 onCheckboxSelected_: function() { | 85 onCheckboxSelected_: function() { |
| 63 this.fire('history-checkbox-select', { | 86 this.fire('history-checkbox-select', { |
| 64 countAddition: this.$.checkbox.checked ? 1 : -1 | 87 countAddition: this.$.checkbox.checked ? 1 : -1 |
| 65 }); | 88 }); |
| 66 }, | 89 }, |
| 67 | 90 |
| 68 /** | 91 /** |
| 69 * When the url for the history-item is set, the icon associated with this | 92 * When the url for the history-item is set, the icon associated with this |
| 70 * website is also set. | 93 * website is also set. |
| 71 * @private | 94 * @private |
| 72 */ | 95 */ |
| 73 showIcon_: function() { | 96 showIcon_: function() { |
| 74 this.$['website-icon'].style.backgroundImage = | 97 this.$['website-icon'].style.backgroundImage = |
| 75 getFaviconImageSet(this.websiteUrl_); | 98 getFaviconImageSet(this.websiteUrl); |
| 76 }, | 99 }, |
| 77 | 100 |
| 78 /** | 101 /** |
| 79 * Fires a custom event when the menu button is clicked. Sends the details of | 102 * Fires a custom event when the menu button is clicked. Sends the details of |
| 80 * the history item and where the menu should appear. | 103 * the history item and where the menu should appear. |
| 81 */ | 104 */ |
| 82 onMenuButtonTap_: function(e) { | 105 onMenuButtonTap_: function(e) { |
| 83 var position = this.$['menu-button'].getBoundingClientRect(); | 106 var position = this.$['menu-button'].getBoundingClientRect(); |
| 84 | 107 |
| 85 this.fire('toggle-menu', { | 108 this.fire('toggle-menu', { |
| 86 x: position.left, | 109 x: position.left, |
| 87 y: position.top, | 110 y: position.top, |
| 88 accessTime: this.timestamp_ | 111 accessTime: this.timestamp |
| 89 }); | 112 }); |
| 90 | 113 |
| 91 // Stops the 'tap' event from closing the menu when it opens. | 114 // Stops the 'tap' event from closing the menu when it opens. |
| 92 e.stopPropagation(); | 115 e.stopPropagation(); |
| 93 }, | 116 }, |
| 94 | 117 |
| 95 selectionNotAllowed_: function() { | 118 selectionNotAllowed_: function() { |
| 119 // return false; | |
|
tsergeant
2016/02/11 02:43:02
Remove this.
yingran
2016/02/12 02:03:05
Done.
| |
| 96 return !loadTimeData.getBoolean('allowDeletingHistory'); | 120 return !loadTimeData.getBoolean('allowDeletingHistory'); |
| 97 } | 121 } |
| 98 }); | 122 }); |
| OLD | NEW |