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

Side by Side Diff: chrome/browser/resources/md_history/app.crisper.js

Issue 2311093002: MD WebUI: Use dom-if to control hidden elements in <cr-toolbar> (Closed)
Patch Set: Fix tests Created 4 years, 3 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 function PromiseResolver() { 4 function PromiseResolver() {
5 this.resolve_; 5 this.resolve_;
6 this.reject_; 6 this.reject_;
7 this.promise_ = new Promise(function(resolve, reject) { 7 this.promise_ = new Promise(function(resolve, reject) {
8 this.resolve_ = resolve; 8 this.resolve_ = resolve;
9 this.reject_ = reject; 9 this.reject_ = reject;
10 }.bind(this)); 10 }.bind(this));
(...skipping 4434 matching lines...) Expand 10 before | Expand all | Expand 10 after
4445 narrow: { 4445 narrow: {
4446 type: Boolean, 4446 type: Boolean,
4447 reflectToAttribute: true 4447 reflectToAttribute: true
4448 }, 4448 },
4449 label: String, 4449 label: String,
4450 clearLabel: String, 4450 clearLabel: String,
4451 spinnerActive: { 4451 spinnerActive: {
4452 type: Boolean, 4452 type: Boolean,
4453 reflectToAttribute: true 4453 reflectToAttribute: true
4454 }, 4454 },
4455 hasSearchText_: Boolean 4455 hasSearchText_: Boolean,
4456 isSpinnerShown_: {
4457 type: Boolean,
4458 computed: 'computeIsSpinnerShown_(spinnerActive, showingSearch)'
4459 }
4456 }, 4460 },
4457 listeners: { 4461 listeners: {
4458 tap: 'showSearch_', 4462 tap: 'showSearch_',
4459 'searchInput.bind-value-changed': 'onBindValueChanged_' 4463 'searchInput.bind-value-changed': 'onBindValueChanged_'
4460 }, 4464 },
4461 getSearchInput: function() { 4465 getSearchInput: function() {
4462 return this.$.searchInput; 4466 return this.$.searchInput;
4463 }, 4467 },
4464 isSearchFocused: function() { 4468 isSearchFocused: function() {
4465 return this.$.searchTerm.focused; 4469 return this.$.searchTerm.focused;
4466 }, 4470 },
4467 computeIconTabIndex_: function(narrow) { 4471 computeIconTabIndex_: function(narrow) {
4468 return narrow ? 0 : -1; 4472 return narrow ? 0 : -1;
4469 }, 4473 },
4470 isSpinnerShown_: function(spinnerActive, showingSearch) { 4474 computeIsSpinnerShown_: function() {
4471 return spinnerActive && showingSearch; 4475 return this.spinnerActive && this.showingSearch;
4472 }, 4476 },
4473 onInputBlur_: function() { 4477 onInputBlur_: function() {
4474 if (!this.hasSearchText_) this.showingSearch = false; 4478 if (!this.hasSearchText_) this.showingSearch = false;
4475 }, 4479 },
4476 onBindValueChanged_: function() { 4480 onBindValueChanged_: function() {
4477 var newValue = this.$.searchInput.bindValue; 4481 var newValue = this.$.searchInput.bindValue;
4478 this.hasSearchText_ = newValue != ''; 4482 this.hasSearchText_ = newValue != '';
4479 if (newValue != '') this.showingSearch = true; 4483 if (newValue != '') this.showingSearch = true;
4480 }, 4484 },
4481 showSearch_: function(e) { 4485 showSearch_: function(e) {
(...skipping 2196 matching lines...) Expand 10 before | Expand all | Expand 10 after
6678 } 6682 }
6679 } 6683 }
6680 }); 6684 });
6681 6685
6682 // Copyright 2016 The Chromium Authors. All rights reserved. 6686 // Copyright 2016 The Chromium Authors. All rights reserved.
6683 // Use of this source code is governed by a BSD-style license that can be 6687 // Use of this source code is governed by a BSD-style license that can be
6684 // found in the LICENSE file. 6688 // found in the LICENSE file.
6685 cr.define('cr.icon', function() { 6689 cr.define('cr.icon', function() {
6686 function getSupportedScaleFactors() { 6690 function getSupportedScaleFactors() {
6687 var supportedScaleFactors = []; 6691 var supportedScaleFactors = [];
6692 if (!cr.isIOS) {
6693 supportedScaleFactors.push(1);
6694 }
6688 if (cr.isMac || cr.isChromeOS || cr.isWindows || cr.isLinux) { 6695 if (cr.isMac || cr.isChromeOS || cr.isWindows || cr.isLinux) {
6689 supportedScaleFactors.push(1);
6690 supportedScaleFactors.push(2); 6696 supportedScaleFactors.push(2);
6691 } else { 6697 } else {
6692 supportedScaleFactors.push(window.devicePixelRatio); 6698 supportedScaleFactors.push(window.devicePixelRatio);
6693 } 6699 }
6694 return supportedScaleFactors; 6700 return supportedScaleFactors;
6695 } 6701 }
6696 function getProfileAvatarIcon(path) { 6702 function getImageSet(path) {
6697 var chromeThemePath = 'chrome://theme';
6698 var isDefaultAvatar = path.slice(0, chromeThemePath.length) == chromeThemePa th;
6699 return isDefaultAvatar ? imageset(path + '@scalefactorx') : url(path);
6700 }
6701 function imageset(path) {
6702 var supportedScaleFactors = getSupportedScaleFactors(); 6703 var supportedScaleFactors = getSupportedScaleFactors();
6703 var replaceStartIndex = path.indexOf('scalefactor'); 6704 var replaceStartIndex = path.indexOf('scalefactor');
6704 if (replaceStartIndex < 0) return url(path); 6705 if (replaceStartIndex < 0) return url(path);
6705 var s = ''; 6706 var s = '';
6706 for (var i = 0; i < supportedScaleFactors.length; ++i) { 6707 for (var i = 0; i < supportedScaleFactors.length; ++i) {
6707 var scaleFactor = supportedScaleFactors[i]; 6708 var scaleFactor = supportedScaleFactors[i];
6708 var pathWithScaleFactor = path.substr(0, replaceStartIndex) + scaleFactor + path.substr(replaceStartIndex + 'scalefactor'.length); 6709 var pathWithScaleFactor = path.substr(0, replaceStartIndex) + scaleFactor + path.substr(replaceStartIndex + 'scalefactor'.length);
6709 s += url(pathWithScaleFactor) + ' ' + scaleFactor + 'x'; 6710 s += url(pathWithScaleFactor) + ' ' + scaleFactor + 'x';
6710 if (i != supportedScaleFactors.length - 1) s += ', '; 6711 if (i != supportedScaleFactors.length - 1) s += ', ';
6711 } 6712 }
6712 return '-webkit-image-set(' + s + ')'; 6713 return '-webkit-image-set(' + s + ')';
6713 } 6714 }
6715 function getImage(path) {
6716 var chromeThemePath = 'chrome://theme';
6717 var isChromeThemeUrl = path.slice(0, chromeThemePath.length) == chromeThemeP ath;
6718 return isChromeThemeUrl ? getImageSet(path + '@scalefactorx') : url(path);
6719 }
6714 var FAVICON_URL_REGEX = /\.ico$/i; 6720 var FAVICON_URL_REGEX = /\.ico$/i;
6715 function getFaviconImageSet(url, opt_size, opt_type) { 6721 function getFavicon(url, opt_size, opt_type) {
6716 var size = opt_size || 16; 6722 var size = opt_size || 16;
6717 var type = opt_type || 'favicon'; 6723 var type = opt_type || 'favicon';
6718 return imageset('chrome://' + type + '/size/' + size + '@scalefactorx/' + (F AVICON_URL_REGEX.test(url) ? 'iconurl/' : '') + url); 6724 return getImageSet('chrome://' + type + '/size/' + size + '@scalefactorx/' + (FAVICON_URL_REGEX.test(url) ? 'iconurl/' : '') + url);
6719 } 6725 }
6720 return { 6726 return {
6721 getSupportedScaleFactors: getSupportedScaleFactors, 6727 getImage: getImage,
6722 getProfileAvatarIcon: getProfileAvatarIcon, 6728 getFavicon: getFavicon
6723 getFaviconImageSet: getFaviconImageSet
6724 }; 6729 };
6725 }); 6730 });
6726 6731
6727 // Copyright 2016 The Chromium Authors. All rights reserved. 6732 // Copyright 2016 The Chromium Authors. All rights reserved.
6728 // Use of this source code is governed by a BSD-style license that can be 6733 // Use of this source code is governed by a BSD-style license that can be
6729 // found in the LICENSE file. 6734 // found in the LICENSE file.
6730 Polymer({ 6735 Polymer({
6731 is: 'history-searched-label', 6736 is: 'history-searched-label',
6732 properties: { 6737 properties: {
6733 title: String, 6738 title: String,
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
6837 if (this.index == undefined) return; 6842 if (this.index == undefined) return;
6838 browserService.recordHistogram('HistoryPage.ClickPosition', this.index, UM A_MAX_BUCKET_VALUE); 6843 browserService.recordHistogram('HistoryPage.ClickPosition', this.index, UM A_MAX_BUCKET_VALUE);
6839 if (this.index <= UMA_MAX_SUBSET_BUCKET_VALUE) { 6844 if (this.index <= UMA_MAX_SUBSET_BUCKET_VALUE) {
6840 browserService.recordHistogram('HistoryPage.ClickPositionSubset', this.i ndex, UMA_MAX_SUBSET_BUCKET_VALUE); 6845 browserService.recordHistogram('HistoryPage.ClickPositionSubset', this.i ndex, UMA_MAX_SUBSET_BUCKET_VALUE);
6841 } 6846 }
6842 }, 6847 },
6843 onLinkRightClick_: function() { 6848 onLinkRightClick_: function() {
6844 md_history.BrowserService.getInstance().recordAction('EntryLinkRightClick' ); 6849 md_history.BrowserService.getInstance().recordAction('EntryLinkRightClick' );
6845 }, 6850 },
6846 showIcon_: function() { 6851 showIcon_: function() {
6847 this.$.icon.style.backgroundImage = cr.icon.getFaviconImageSet(this.item.u rl); 6852 this.$.icon.style.backgroundImage = cr.icon.getFavicon(this.item.url);
6848 }, 6853 },
6849 selectionNotAllowed_: function() { 6854 selectionNotAllowed_: function() {
6850 return !loadTimeData.getBoolean('allowDeletingHistory'); 6855 return !loadTimeData.getBoolean('allowDeletingHistory');
6851 }, 6856 },
6852 cardTitle_: function(numberOfItems, historyDate, search) { 6857 cardTitle_: function(numberOfItems, historyDate, search) {
6853 if (!search) return this.item.dateRelativeDay; 6858 if (!search) return this.item.dateRelativeDay;
6854 var resultId = numberOfItems == 1 ? 'searchResult' : 'searchResults'; 6859 var resultId = numberOfItems == 1 ? 'searchResult' : 'searchResults';
6855 return loadTimeData.getStringF('foundSearchResults', numberOfItems, loadTi meData.getString(resultId), search); 6860 return loadTimeData.getStringF('foundSearchResults', numberOfItems, loadTi meData.getString(resultId), search);
6856 }, 6861 },
6857 cropItemTitle_: function(title) { 6862 cropItemTitle_: function(title) {
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
7086 }, 0); 7091 }, 0);
7087 }, 7092 },
7088 needsTimeGap_: function(groupIndex, domainIndex, itemIndex) { 7093 needsTimeGap_: function(groupIndex, domainIndex, itemIndex) {
7089 var visits = this.groupedHistoryData_[groupIndex].domains[domainIndex].visit s; 7094 var visits = this.groupedHistoryData_[groupIndex].domains[domainIndex].visit s;
7090 return md_history.HistoryItem.needsTimeGap(visits, itemIndex, this.searchedT erm); 7095 return md_history.HistoryItem.needsTimeGap(visits, itemIndex, this.searchedT erm);
7091 }, 7096 },
7092 pathForItem_: function(groupIndex, domainIndex, itemIndex) { 7097 pathForItem_: function(groupIndex, domainIndex, itemIndex) {
7093 return [ 'groupedHistoryData_', groupIndex, 'domains', domainIndex, 'visits' , itemIndex ].join('.'); 7098 return [ 'groupedHistoryData_', groupIndex, 'domains', domainIndex, 'visits' , itemIndex ].join('.');
7094 }, 7099 },
7095 getWebsiteIconStyle_: function(domain) { 7100 getWebsiteIconStyle_: function(domain) {
7096 return 'background-image: ' + cr.icon.getFaviconImageSet(domain.visits[0].ur l); 7101 return 'background-image: ' + cr.icon.getFavicon(domain.visits[0].url);
7097 }, 7102 },
7098 getDropdownIcon_: function(expanded) { 7103 getDropdownIcon_: function(expanded) {
7099 return expanded ? 'cr:expand-less' : 'cr:expand-more'; 7104 return expanded ? 'cr:expand-less' : 'cr:expand-more';
7100 } 7105 }
7101 }); 7106 });
7102 7107
7103 (function() { 7108 (function() {
7104 var IOS = navigator.userAgent.match(/iP(?:hone|ad;(?: U;)? CPU) OS (\d+)/); 7109 var IOS = navigator.userAgent.match(/iP(?:hone|ad;(?: U;)? CPU) OS (\d+)/);
7105 var IOS_TOUCH_SCROLLING = IOS && IOS[1] >= 8; 7110 var IOS_TOUCH_SCROLLING = IOS && IOS[1] >= 8;
7106 var DEFAULT_PHYSICAL_COUNT = 3; 7111 var DEFAULT_PHYSICAL_COUNT = 3;
(...skipping 1233 matching lines...) Expand 10 before | Expand all | Expand 10 after
8340 toggleTabCard: function() { 8345 toggleTabCard: function() {
8341 var histogramValue = this.$.collapse.opened ? SyncedTabsHistogram.COLLAPSE_S ESSION : SyncedTabsHistogram.EXPAND_SESSION; 8346 var histogramValue = this.$.collapse.opened ? SyncedTabsHistogram.COLLAPSE_S ESSION : SyncedTabsHistogram.EXPAND_SESSION;
8342 md_history.BrowserService.getInstance().recordHistogram(SYNCED_TABS_HISTOGRA M_NAME, histogramValue, SyncedTabsHistogram.LIMIT); 8347 md_history.BrowserService.getInstance().recordHistogram(SYNCED_TABS_HISTOGRA M_NAME, histogramValue, SyncedTabsHistogram.LIMIT);
8343 this.$.collapse.toggle(); 8348 this.$.collapse.toggle();
8344 this.$['dropdown-indicator'].icon = this.$.collapse.opened ? 'cr:expand-less ' : 'cr:expand-more'; 8349 this.$['dropdown-indicator'].icon = this.$.collapse.opened ? 'cr:expand-less ' : 'cr:expand-more';
8345 }, 8350 },
8346 updateIcons_: function() { 8351 updateIcons_: function() {
8347 this.async(function() { 8352 this.async(function() {
8348 var icons = Polymer.dom(this.root).querySelectorAll('.website-icon'); 8353 var icons = Polymer.dom(this.root).querySelectorAll('.website-icon');
8349 for (var i = 0; i < this.tabs.length; i++) { 8354 for (var i = 0; i < this.tabs.length; i++) {
8350 icons[i].style.backgroundImage = cr.icon.getFaviconImageSet(this.tabs[i] .url); 8355 icons[i].style.backgroundImage = cr.icon.getFavicon(this.tabs[i].url);
8351 } 8356 }
8352 }); 8357 });
8353 }, 8358 },
8354 isWindowSeparatorIndex_: function(index, separatorIndexes) { 8359 isWindowSeparatorIndex_: function(index, separatorIndexes) {
8355 return this.separatorIndexes.indexOf(index) != -1; 8360 return this.separatorIndexes.indexOf(index) != -1;
8356 }, 8361 },
8357 getCollapseIcon_: function(opened) { 8362 getCollapseIcon_: function(opened) {
8358 return opened ? 'cr:expand-less' : 'cr:expand-more'; 8363 return opened ? 'cr:expand-less' : 'cr:expand-more';
8359 }, 8364 },
8360 getCollapseTitle_: function(opened) { 8365 getCollapseTitle_: function(opened) {
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
8790 8795
8791 case HistoryRange.MONTH: 8796 case HistoryRange.MONTH:
8792 histogramValue = HistoryPageViewHistogram.GROUPED_MONTH; 8797 histogramValue = HistoryPageViewHistogram.GROUPED_MONTH;
8793 break; 8798 break;
8794 } 8799 }
8795 break; 8800 break;
8796 } 8801 }
8797 md_history.BrowserService.getInstance().recordHistogram('History.HistoryPage View', histogramValue, HistoryPageViewHistogram.END); 8802 md_history.BrowserService.getInstance().recordHistogram('History.HistoryPage View', histogramValue, HistoryPageViewHistogram.END);
8798 } 8803 }
8799 }); 8804 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/md_downloads/vulcanized.html ('k') | chrome/browser/resources/md_history/app.vulcanized.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698