| Index: chrome/browser/resources/media_router/elements/media_router_container/media_router_container.js
|
| diff --git a/chrome/browser/resources/media_router/elements/media_router_container/media_router_container.js b/chrome/browser/resources/media_router/elements/media_router_container/media_router_container.js
|
| index 6580294638ba2f3ab524a089e1d75703735d21cc..2e8e246d3a6e4fad5f3663d8195c40dbc02a4061 100644
|
| --- a/chrome/browser/resources/media_router/elements/media_router_container/media_router_container.js
|
| +++ b/chrome/browser/resources/media_router/elements/media_router_container/media_router_container.js
|
| @@ -434,13 +434,17 @@ Polymer({
|
| that.putSearchAtBottom_();
|
| }
|
| };
|
| - this.importHref('chrome://resources/polymer/v1_0/neon-animation/' +
|
| - 'web-animations.html', onload);
|
| - this.importHref(this.resolveUrl(
|
| - '../issue_banner/issue_banner.html'), onload);
|
| - this.importHref(this.resolveUrl(
|
| - '../media_router_search_highlighter/' +
|
| - 'media_router_search_highlighter.html'), onload);
|
| + this.importHref(
|
| + 'chrome://resources/polymer/v1_0/neon-animation/' +
|
| + 'web-animations.html',
|
| + onload);
|
| + this.importHref(
|
| + this.resolveUrl('../issue_banner/issue_banner.html'), onload);
|
| + this.importHref(
|
| + this.resolveUrl(
|
| + '../media_router_search_highlighter/' +
|
| + 'media_router_search_highlighter.html'),
|
| + onload);
|
|
|
| // If this is not on a Mac platform, remove the placeholder. See
|
| // onFocus_() for more details. ready() is only called once, so no need
|
| @@ -484,7 +488,8 @@ Polymer({
|
| // Only set |userOptedIntoCloudServices| if the user was shown the cloud
|
| // services preferences option.
|
| var userOptedIntoCloudServices = this.showFirstRunFlowCloudPref ?
|
| - this.$$('#first-run-cloud-checkbox').checked : undefined;
|
| + this.$$('#first-run-cloud-checkbox').checked :
|
| + undefined;
|
| this.fire('acknowledge-first-run-flow', {
|
| optedIntoCloudServices: userOptedIntoCloudServices,
|
| });
|
| @@ -703,8 +708,8 @@ Polymer({
|
| */
|
| computeHeaderHidden_: function(view, issue) {
|
| return view == media_router.MediaRouterView.ROUTE_DETAILS ||
|
| - (view == media_router.MediaRouterView.SINK_LIST &&
|
| - !!issue && issue.isBlocking);
|
| + (view == media_router.MediaRouterView.SINK_LIST && !!issue &&
|
| + issue.isBlocking);
|
| },
|
|
|
| /**
|
| @@ -721,7 +726,8 @@ Polymer({
|
| return this.i18n('issueHeaderText');
|
| case media_router.MediaRouterView.ROUTE_DETAILS:
|
| return this.currentRoute_ && this.sinkMap_[this.currentRoute_.sinkId] ?
|
| - this.sinkMap_[this.currentRoute_.sinkId].name : '';
|
| + this.sinkMap_[this.currentRoute_.sinkId].name :
|
| + '';
|
| case media_router.MediaRouterView.SINK_LIST:
|
| case media_router.MediaRouterView.FILTER:
|
| return this.headerText;
|
| @@ -781,7 +787,7 @@ Polymer({
|
| */
|
| computeNoMatchesHidden_: function(searchResultsToShow, isSearchListHidden) {
|
| return isSearchListHidden || this.searchInputText_.length == 0 ||
|
| - searchResultsToShow.length != 0;
|
| + searchResultsToShow.length != 0;
|
| },
|
|
|
| /**
|
| @@ -853,8 +859,8 @@ Polymer({
|
| * @return {boolean} Whether the search results list should be hidden.
|
| * @private
|
| */
|
| - computeSearchResultsHidden_: function(searchResultsToShow,
|
| - isSearchListHidden) {
|
| + computeSearchResultsHidden_: function(
|
| + searchResultsToShow, isSearchListHidden) {
|
| return isSearchListHidden || searchResultsToShow.length == 0;
|
| },
|
|
|
| @@ -1056,8 +1062,8 @@ Polymer({
|
| computeTotalSearchHeight_: function(
|
| deviceMissing, noMatches, results, searchOffsetHeight, maxHeight) {
|
| var contentHeight = deviceMissing.offsetHeight +
|
| - ((noMatches.hasAttribute('hidden')) ?
|
| - results.offsetHeight : noMatches.offsetHeight);
|
| + ((noMatches.hasAttribute('hidden')) ? results.offsetHeight :
|
| + noMatches.offsetHeight);
|
| return Math.min(contentHeight, maxHeight) + searchOffsetHeight;
|
| },
|
|
|
| @@ -1095,13 +1101,12 @@ Polymer({
|
| var searchResultsToShow = [];
|
| for (var i = 0; i < this.sinksToShow_.length; ++i) {
|
| var matchSubstrings = this.computeSearchMatches_(
|
| - searchInputText,
|
| - this.sinksToShow_[i].name);
|
| + searchInputText, this.sinksToShow_[i].name);
|
| if (!matchSubstrings) {
|
| continue;
|
| }
|
| - searchResultsToShow.push({sinkItem: this.sinksToShow_[i],
|
| - substrings: matchSubstrings});
|
| + searchResultsToShow.push(
|
| + {sinkItem: this.sinksToShow_[i], substrings: matchSubstrings});
|
| }
|
| searchResultsToShow.sort(this.compareSearchMatches_);
|
|
|
| @@ -1118,17 +1123,24 @@ Polymer({
|
| // the pseudo sink for the search will be treated like a real sink because
|
| // it will actually be in |sinksToShow_| until a real sink is returned by
|
| // search. So the filter here shouldn't treat it like a pseudo sink.
|
| - searchResultsToShow = this.pseudoSinks_.filter(function(pseudoSink) {
|
| - return (!pendingPseudoSink || pseudoSink.id != pendingPseudoSink.id) &&
|
| - !searchResultsToShow.find(function(searchResult) {
|
| - return searchResult.sinkItem.name == searchInputText &&
|
| - searchResult.sinkItem.iconType == pseudoSink.iconType;
|
| - });
|
| - }).map(function(pseudoSink) {
|
| - pseudoSink.name = searchInputText;
|
| - return {sinkItem: pseudoSink,
|
| - substrings: [[0, searchInputText.length - 1]]};
|
| - }).concat(searchResultsToShow);
|
| + searchResultsToShow =
|
| + this.pseudoSinks_
|
| + .filter(function(pseudoSink) {
|
| + return (!pendingPseudoSink ||
|
| + pseudoSink.id != pendingPseudoSink.id) &&
|
| + !searchResultsToShow.find(function(searchResult) {
|
| + return searchResult.sinkItem.name == searchInputText &&
|
| + searchResult.sinkItem.iconType == pseudoSink.iconType;
|
| + });
|
| + })
|
| + .map(function(pseudoSink) {
|
| + pseudoSink.name = searchInputText;
|
| + return {
|
| + sinkItem: pseudoSink,
|
| + substrings: [[0, searchInputText.length - 1]]
|
| + };
|
| + })
|
| + .concat(searchResultsToShow);
|
| this.searchResultsToShow_ = searchResultsToShow;
|
| },
|
|
|
| @@ -1154,8 +1166,10 @@ Polymer({
|
| */
|
| getElementVerticalPadding_: function(element) {
|
| var style = window.getComputedStyle(element);
|
| - return [parseInt(style.getPropertyValue('padding-bottom'), 10) || 0,
|
| - parseInt(style.getPropertyValue('padding-top'), 10) || 0];
|
| + return [
|
| + parseInt(style.getPropertyValue('padding-bottom'), 10) || 0,
|
| + parseInt(style.getPropertyValue('padding-top'), 10) || 0
|
| + ];
|
| },
|
|
|
| /**
|
| @@ -1166,7 +1180,8 @@ Polymer({
|
| */
|
| getFirstRunFlowCloudPrefText_: function() {
|
| return loadTimeData.valueExists('firstRunFlowCloudPrefText') ?
|
| - this.i18n('firstRunFlowCloudPrefText') : '';
|
| + this.i18n('firstRunFlowCloudPrefText') :
|
| + '';
|
| },
|
|
|
| /**
|
| @@ -1385,34 +1400,55 @@ Polymer({
|
| // This GroupEffect does the reverse of |moveSearchToTop_|. It fades the
|
| // sink list in while sliding the search input and search results list down.
|
| // The dialog height is also adjusted smoothly to the sink list height.
|
| - var deviceMissingEffect = new KeyframeEffect(deviceMissing,
|
| - [{'marginBottom': searchInitialOffsetHeight},
|
| - {'marginBottom': searchFinalOffsetHeight}],
|
| - timing);
|
| - var listEffect = new KeyframeEffect(list,
|
| - [{'opacity': '0'}, {'opacity': '1'}],
|
| + var deviceMissingEffect = new KeyframeEffect(
|
| + deviceMissing,
|
| + [
|
| + {'marginBottom': searchInitialOffsetHeight},
|
| + {'marginBottom': searchFinalOffsetHeight}
|
| + ],
|
| timing);
|
| - var resultsEffect = new KeyframeEffect(resultsContainer,
|
| - [{'top': resultsInitialTop + 'px',
|
| - 'paddingTop': resultsContainer.style['padding-top']},
|
| - {'top': '100%', 'paddingTop': '0px'}],
|
| + var listEffect =
|
| + new KeyframeEffect(list, [{'opacity': '0'}, {'opacity': '1'}], timing);
|
| + var resultsEffect = new KeyframeEffect(
|
| + resultsContainer,
|
| + [
|
| + {
|
| + 'top': resultsInitialTop + 'px',
|
| + 'paddingTop': resultsContainer.style['padding-top']
|
| + },
|
| + {'top': '100%', 'paddingTop': '0px'}
|
| + ],
|
| timing);
|
| - var searchEffect = new KeyframeEffect(search,
|
| - [{'top': searchInitialTop + 'px', 'marginTop': '0px',
|
| - 'paddingBottom': searchInitialPaddingBottom + 'px',
|
| - 'paddingTop': searchInitialPaddingTop + 'px'},
|
| - {'top': '100%', 'marginTop': '-' + searchFinalOffsetHeight + 'px',
|
| - 'paddingBottom': searchFinalPaddingBottom + 'px',
|
| - 'paddingTop': searchFinalPaddingTop + 'px'}],
|
| + var searchEffect = new KeyframeEffect(
|
| + search,
|
| + [
|
| + {
|
| + 'top': searchInitialTop + 'px',
|
| + 'marginTop': '0px',
|
| + 'paddingBottom': searchInitialPaddingBottom + 'px',
|
| + 'paddingTop': searchInitialPaddingTop + 'px'
|
| + },
|
| + {
|
| + 'top': '100%',
|
| + 'marginTop': '-' + searchFinalOffsetHeight + 'px',
|
| + 'paddingBottom': searchFinalPaddingBottom + 'px',
|
| + 'paddingTop': searchFinalPaddingTop + 'px'
|
| + }
|
| + ],
|
| timing);
|
| - var viewEffect = new KeyframeEffect(view,
|
| - [{'height': initialHeight + 'px', 'paddingBottom': '0px'},
|
| - {'height': finalHeight + 'px',
|
| - 'paddingBottom': searchFinalOffsetHeight + 'px'}],
|
| + var viewEffect = new KeyframeEffect(
|
| + view,
|
| + [
|
| + {'height': initialHeight + 'px', 'paddingBottom': '0px'}, {
|
| + 'height': finalHeight + 'px',
|
| + 'paddingBottom': searchFinalOffsetHeight + 'px'
|
| + }
|
| + ],
|
| timing);
|
| - var player = document.timeline.play(new GroupEffect(hasList ?
|
| - [listEffect, resultsEffect, searchEffect, viewEffect] :
|
| - [deviceMissingEffect, resultsEffect, searchEffect, viewEffect]));
|
| + var player = document.timeline.play(new GroupEffect(
|
| + hasList ?
|
| + [listEffect, resultsEffect, searchEffect, viewEffect] :
|
| + [deviceMissingEffect, resultsEffect, searchEffect, viewEffect]));
|
|
|
| var that = this;
|
| var finalizeAnimation = function() {
|
| @@ -1488,34 +1524,55 @@ Polymer({
|
| // This GroupEffect will cause the sink list to fade out while the search
|
| // input and search results list slide up. The dialog will also resize
|
| // smoothly to the new search result list height.
|
| - var deviceMissingEffect = new KeyframeEffect(deviceMissing,
|
| - [{'marginBottom': searchInitialOffsetHeight},
|
| - {'marginBottom': searchFinalOffsetHeight}],
|
| + var deviceMissingEffect = new KeyframeEffect(
|
| + deviceMissing,
|
| + [
|
| + {'marginBottom': searchInitialOffsetHeight},
|
| + {'marginBottom': searchFinalOffsetHeight}
|
| + ],
|
| timing);
|
| - var listEffect = new KeyframeEffect(list,
|
| - [{'opacity': '1'}, {'opacity': '0'}],
|
| + var listEffect =
|
| + new KeyframeEffect(list, [{'opacity': '1'}, {'opacity': '0'}], timing);
|
| + var resultsEffect = new KeyframeEffect(
|
| + resultsContainer,
|
| + [
|
| + {'top': '100%', 'paddingTop': '0px'}, {
|
| + 'top': searchFinalTop + 'px',
|
| + 'paddingTop': searchFinalOffsetHeight + 'px'
|
| + }
|
| + ],
|
| timing);
|
| - var resultsEffect = new KeyframeEffect(resultsContainer,
|
| - [{'top': '100%', 'paddingTop': '0px'},
|
| - {'top': searchFinalTop + 'px',
|
| - 'paddingTop': searchFinalOffsetHeight + 'px'}],
|
| + var searchEffect = new KeyframeEffect(
|
| + search,
|
| + [
|
| + {
|
| + 'top': '100%',
|
| + 'marginTop': '-' + searchInitialOffsetHeight + 'px',
|
| + 'paddingBottom': searchInitialPaddingBottom + 'px',
|
| + 'paddingTop': searchInitialPaddingTop + 'px'
|
| + },
|
| + {
|
| + 'top': searchFinalTop + 'px',
|
| + 'marginTop': '0px',
|
| + 'paddingBottom': searchFinalPaddingBottom + 'px',
|
| + 'paddingTop': searchFinalPaddingTop + 'px'
|
| + }
|
| + ],
|
| timing);
|
| - var searchEffect = new KeyframeEffect(search,
|
| - [{'top': '100%', 'marginTop': '-' + searchInitialOffsetHeight + 'px',
|
| - 'paddingBottom': searchInitialPaddingBottom + 'px',
|
| - 'paddingTop': searchInitialPaddingTop + 'px'},
|
| - {'top': searchFinalTop + 'px', 'marginTop': '0px',
|
| - 'paddingBottom': searchFinalPaddingBottom + 'px',
|
| - 'paddingTop': searchFinalPaddingTop + 'px'}],
|
| + var viewEffect = new KeyframeEffect(
|
| + view,
|
| + [
|
| + {
|
| + 'height': initialHeight + 'px',
|
| + 'paddingBottom': searchInitialOffsetHeight + 'px'
|
| + },
|
| + {'height': finalHeight + 'px', 'paddingBottom': '0px'}
|
| + ],
|
| timing);
|
| - var viewEffect = new KeyframeEffect(view,
|
| - [{'height': initialHeight + 'px',
|
| - 'paddingBottom': searchInitialOffsetHeight + 'px'},
|
| - {'height': finalHeight + 'px', 'paddingBottom': '0px'}],
|
| - timing);
|
| - var player = document.timeline.play(new GroupEffect(hasList ?
|
| - [listEffect, resultsEffect, searchEffect, viewEffect] :
|
| - [deviceMissingEffect, resultsEffect, searchEffect, viewEffect]));
|
| + var player = document.timeline.play(new GroupEffect(
|
| + hasList ?
|
| + [listEffect, resultsEffect, searchEffect, viewEffect] :
|
| + [deviceMissingEffect, resultsEffect, searchEffect, viewEffect]));
|
|
|
| var that = this;
|
| var finalizeAnimation = function() {
|
| @@ -1556,7 +1613,7 @@ Polymer({
|
| // defaultCastModeList and nonDefaultCastModeList.
|
| var clickedMode =
|
| this.$$('#defaultCastModeList').itemForElement(event.target) ||
|
| - this.$$('#nonDefaultCastModeList').itemForElement(event.target);
|
| + this.$$('#nonDefaultCastModeList').itemForElement(event.target);
|
|
|
| if (!clickedMode)
|
| return;
|
| @@ -1639,9 +1696,9 @@ Polymer({
|
|
|
| // Regardless of whether the route is for display, it was resolved
|
| // successfully.
|
| - this.fire('report-resolved-route', {
|
| - outcome: media_router.MediaRouterRouteCreationOutcome.SUCCESS
|
| - });
|
| + this.fire(
|
| + 'report-resolved-route',
|
| + {outcome: media_router.MediaRouterRouteCreationOutcome.SUCCESS});
|
|
|
| if (isForDisplay) {
|
| this.showRouteDetails_(route);
|
| @@ -1687,8 +1744,8 @@ Polymer({
|
| // handled on the C++ side instead of the JS side on non-mac platforms,
|
| // which uses toolkit-views. Handle the expected behavior on all platforms
|
| // here.
|
| - if (e.key == media_router.KEY_ESC && !e.shiftKey &&
|
| - !e.ctrlKey && !e.altKey && !e.metaKey) {
|
| + if (e.key == media_router.KEY_ESC && !e.shiftKey && !e.ctrlKey &&
|
| + !e.altKey && !e.metaKey) {
|
| // When searching, allow ESC as a mechanism to leave the filter view.
|
| if (this.currentView_ == media_router.MediaRouterView.FILTER) {
|
| // If the user tabbed to an item in the search results, or otherwise has
|
| @@ -1823,15 +1880,22 @@ Polymer({
|
| this.searchUseBottomPadding =
|
| this.shouldSearchUseBottomPadding_(deviceMissing);
|
| var resultsPadding = this.computeElementVerticalPadding_(results);
|
| - var finalHeight = this.computeTotalSearchHeight_(deviceMissing, noMatches,
|
| - results, search.offsetHeight, this.sinkListMaxHeight_ + resultsPadding);
|
| + var finalHeight = this.computeTotalSearchHeight_(
|
| + deviceMissing, noMatches, results, search.offsetHeight,
|
| + this.sinkListMaxHeight_ + resultsPadding);
|
| if (finalHeight != view.offsetHeight) {
|
| - var viewEffect = new KeyframeEffect(view,
|
| - [{'height': view.offsetHeight + 'px'},
|
| - {'height': finalHeight + 'px'}],
|
| - {duration:
|
| - this.computeAnimationDuration_(finalHeight - view.offsetHeight),
|
| - easing: 'ease-in-out', fill: 'forwards'});
|
| + var viewEffect = new KeyframeEffect(
|
| + view,
|
| + [
|
| + {'height': view.offsetHeight + 'px'},
|
| + {'height': finalHeight + 'px'}
|
| + ],
|
| + {
|
| + duration:
|
| + this.computeAnimationDuration_(finalHeight - view.offsetHeight),
|
| + easing: 'ease-in-out',
|
| + fill: 'forwards'
|
| + });
|
| var player = document.timeline.play(viewEffect);
|
| if (this.heightAdjustmentPlayer_) {
|
| this.heightAdjustmentPlayer_.cancel();
|
| @@ -1981,7 +2045,7 @@ Polymer({
|
| // are compatible with current cast mode or sinks that are active.
|
| updatedSinkList = updatedSinkList.filter(function(element) {
|
| return (element.castModes & this.shownCastModeValue_) ||
|
| - this.sinkToRouteMap_[element.id];
|
| + this.sinkToRouteMap_[element.id];
|
| }, this);
|
| } else {
|
| // If user did not select a cast mode, then:
|
| @@ -1999,7 +2063,8 @@ Polymer({
|
| if (this.sinksToShow_) {
|
| for (var i = this.sinksToShow_.length - 1; i >= 0; i--) {
|
| var index = updatedSinkList.findIndex(function(updatedSink) {
|
| - return this.sinksToShow_[i].id == updatedSink.id; }.bind(this));
|
| + return this.sinksToShow_[i].id == updatedSink.id;
|
| + }.bind(this));
|
| if (index < 0) {
|
| // Remove any sinks that are no longer discovered.
|
| this.sinksToShow_.splice(i, 1);
|
| @@ -2212,7 +2277,8 @@ Polymer({
|
| // Allow one launch at a time.
|
| var selectedCastModeValue =
|
| this.shownCastModeValue_ == media_router.CastModeType.AUTO ?
|
| - sink.castModes & -sink.castModes : this.shownCastModeValue_;
|
| + sink.castModes & -sink.castModes :
|
| + this.shownCastModeValue_;
|
| if (sink.isPseudoSink) {
|
| this.pseudoSinkSearchState_ = new PseudoSinkSearchState(sink);
|
| this.fire('search-sinks-and-create-route', {
|
| @@ -2325,11 +2391,13 @@ Polymer({
|
| // element can have a fractional height. So we use getBoundingClientRect()
|
| // to avoid rounding errors.
|
| var firstRunFlowHeight = this.$$('#first-run-flow') &&
|
| - this.$$('#first-run-flow').style.display != 'none' ?
|
| - this.$$('#first-run-flow').getBoundingClientRect().height : 0;
|
| + this.$$('#first-run-flow').style.display != 'none' ?
|
| + this.$$('#first-run-flow').getBoundingClientRect().height :
|
| + 0;
|
| var issueHeight = this.$$('#issue-banner') &&
|
| - this.$$('#issue-banner').style.display != 'none' ?
|
| - this.$$('#issue-banner').offsetHeight : 0;
|
| + this.$$('#issue-banner').style.display != 'none' ?
|
| + this.$$('#issue-banner').offsetHeight :
|
| + 0;
|
| var search = this.$$('#sink-search');
|
| var hasSearch = this.hasConditionalElement_(search);
|
| var searchHeight = hasSearch ? search.offsetHeight : 0;
|
|
|