Commit 853946c5 authored by jlklein's avatar jlklein Committed by Commit bot

Convert search page to Polymer 0.8.

BUG=485381

Review URL: https://codereview.chromium.org/1125343005

Cr-Commit-Position: refs/heads/master@{#329568}
parent 48060cf4
<link rel="import" href="chrome://resources/polymer/polymer/polymer.html"> /* Copyright 2015 The Chromium Authors. All rights reserved.
<link rel="import" href="chrome://resources/polymer/core-style/core-style.html"> * Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file. */
<core-style id="searchPageStyle">
.manage-search-engines { .manage-search-engines {
-webkit-margin-start: 10px; -webkit-margin-start: 10px;
} }
.search-engines { .search-engines {
align-items: center;
display: flex;
margin-top: 20px; margin-top: 20px;
} }
.search-engines-dropdown { #searchEnginesMenu {
min-width: 150px; min-width: 150px;
} }
</core-style> \ No newline at end of file
<link rel="import" href="chrome://resources/polymer/polymer/polymer.html"> <link rel="import" href="chrome://resources/polymer/v0_8/polymer/polymer.html">
<link rel="import" href="chrome://resources/polymer/core-menu/core-menu.html"> <link rel="import" href="chrome://resources/polymer/v0_8/paper-material/paper-material.html">
<link rel="import" href="chrome://resources/polymer/core-style/core-style.html"> <link rel="import" href="chrome://resources/polymer/v0_8/more-routing/more-routing.html">
<link rel="import" href="chrome://resources/polymer/paper-item/paper-item.html"> <link rel="import" href="chrome://resources/cr_elements/v0_8/cr_button/cr_button.html">
<link rel="import" href="chrome://resources/polymer/paper-shadow/paper-shadow.html">
<link rel="import" href="chrome://resources/cr_elements/cr_dropdown_menu/cr_dropdown_menu.html">
<link rel="import" href="chrome://md-settings/checkbox/checkbox.html"> <link rel="import" href="chrome://md-settings/checkbox/checkbox.html">
<link rel="import" href="search_page_style.html">
<polymer-element name="cr-settings-search-page"> <dom-module id="cr-settings-search-page">
<link rel="import" type="css" href="chrome://md-settings/settings_page/settings_page.css">
<link rel="import" type="css" href="search_page.css">
<template> <template>
<link rel="stylesheet" href="chrome://md-settings/settings_page/settings_page.css"> <paper-material>
<core-style ref="searchPageStyle"></core-style>
<paper-shadow layout vertical cross-fade>
<p i18n-content="searchExplanation"></p> <p i18n-content="searchExplanation"></p>
<div class="search-engines" layout horizontal center> <div class="search-engines">
<cr-dropdown-menu class="search-engines-dropdown"> <select id="searchEnginesMenu" on-change="defaultEngineGuidChanged_">
<core-menu id="searchEnginesMenu" class="menu" valueAttr="guid" <template is="x-repeat" items="[[searchEngines]]">
selected="{{defaultEngineGuid}}"> <option value="[[item.guid]]">{{item.name}}</option>
<template repeat="{{engine in searchEngines}}"> </template>
<paper-item guid="{{engine.guid}}">{{engine.name}}</paper-item> </select>
</template>
</core-menu>
</cr-dropdown-menu>
<cr-button class="manage-search-engines" <cr-button class="manage-search-engines"
i18n-content="searchManageButtonLabel" i18n-content="searchManageButtonLabel"
on-click="{{manageSearchEngines_}}" raised> on-click="manageSearchEngines_" raised>
</cr-button> </cr-button>
</div> </div>
</paper-shadow> </paper-material>
</template> </template>
<script src="search_page.js"></script> <script src="search_page.js"></script>
</polymer-element> </dom-module>
...@@ -8,95 +8,76 @@ ...@@ -8,95 +8,76 @@
* *
* Example: * Example:
* *
* <core-animated-pages> * <iron-animated-pages>
* <cr-settings-search-page prefs="{{prefs}}"></cr-settings-search-page> * <cr-settings-search-page prefs="{{prefs}}"></cr-settings-search-page>
* ... other pages ... * ... other pages ...
* </core-animated-pages> * </iron-animated-pages>
* *
* @group Chrome Settings Elements * @group Chrome Settings Elements
* @element cr-settings-search-page * @element cr-settings-search-page
*/ */
Polymer('cr-settings-search-page', { Polymer({
publish: { is: 'cr-settings-search-page',
properties: {
/** /**
* Preferences state. * Preferences state.
* * @type {?CrSettingsPrefsElement}
* @attribute prefs
* @type {CrSettingsPrefsElement}
* @default null
*/ */
prefs: null, prefs: {
type: Object,
notify: true,
},
/** /**
* Route for the page. * Route for the page.
*
* @attribute route
* @type {string}
* @default ''
*/ */
route: '', route: String,
/** /**
* Whether the page is a subpage. * Whether the page is a subpage.
*
* @attribute subpage
* @type {boolean}
* @default false
*/ */
subpage: false, subpage: {
type: Boolean,
value: false,
},
/** /**
* ID of the page. * ID of the page.
*
* @attribute PAGE_ID
* @const {string}
* @default 'search'
*/ */
PAGE_ID: 'search', PAGE_ID: {
type: String,
value: 'search',
},
/** /**
* Title for the page header and navigation menu. * Title for the page header and navigation menu.
*
* @attribute pageTitle
* @type {string}
*/ */
pageTitle: loadTimeData.getString('searchPageTitle'), pageTitle: {
type: String,
value: function() { return loadTimeData.getString('searchPageTitle'); },
},
/** /**
* Name of the 'core-icon' to be shown in the settings-page-header. * Name of the 'iron-icon' to be shown in the settings-page-header.
*
* @attribute icon
* @type {string}
* @default 'search'
*/ */
icon: 'search', icon: {
type: Boolean,
value: 'search',
},
/** /**
* List of default search engines available. * List of default search engines available.
* * @type {?Array<!SearchEngine>}
* @attribute searchEngines
* @type {Array<!SearchEngine>}
* @default null
*/
searchEngines: null,
/**
* GUID of the currently selected default search engine.
*
* @attribute defaultEngineGuid
* @type {string}
* @default ''
*/ */
defaultEngineGuid: '', searchEngines: {
type: Array,
value: function() { return []; },
},
}, },
/** @override */ /** @override */
created: function() { created: function() {
this.searchEngines = [];
},
/** @override */
domReady: function() {
chrome.searchEnginesPrivate.onSearchEnginesChanged.addListener( chrome.searchEnginesPrivate.onSearchEnginesChanged.addListener(
this.updateSearchEngines_.bind(this)); this.updateSearchEngines_.bind(this));
chrome.searchEnginesPrivate.getSearchEngines( chrome.searchEnginesPrivate.getSearchEngines(
...@@ -106,9 +87,11 @@ Polymer('cr-settings-search-page', { ...@@ -106,9 +87,11 @@ Polymer('cr-settings-search-page', {
/** /**
* Persists the new default search engine back to Chrome. Called when the * Persists the new default search engine back to Chrome. Called when the
* user selects a new default in the search engines dropdown. * user selects a new default in the search engines dropdown.
* @private
*/ */
defaultEngineGuidChanged: function() { defaultEngineGuidChanged_: function() {
chrome.searchEnginesPrivate.setSelectedSearchEngine(this.defaultEngineGuid); chrome.searchEnginesPrivate.setSelectedSearchEngine(
this.$.searchEnginesMenu.value);
}, },
...@@ -125,7 +108,7 @@ Polymer('cr-settings-search-page', { ...@@ -125,7 +108,7 @@ Polymer('cr-settings-search-page', {
chrome.searchEnginesPrivate.SearchEngineType.DEFAULT) { chrome.searchEnginesPrivate.SearchEngineType.DEFAULT) {
defaultEngines.push(engine); defaultEngines.push(engine);
if (engine.isSelected) { if (engine.isSelected) {
this.defaultEngineGuid = engine.guid; this.$.searchEnginesMenu.value = engine.guid;
} }
} }
}, this); }, this);
......
...@@ -151,8 +151,8 @@ ...@@ -151,8 +151,8 @@
type="chrome_html" type="chrome_html"
flattenhtml="true" flattenhtml="true"
allowexternalscript="true" /> allowexternalscript="true" />
<structure name="IDR_SETTINGS_SEARCH_PAGE_STYLE_HTML" <structure name="IDR_SETTINGS_SEARCH_PAGE_CSS"
file="search_page/search_page_style.html" file="search_page/search_page.css"
type="chrome_html" /> type="chrome_html" />
<structure name="IDR_SETTINGS_SETTINGS_HTML" <structure name="IDR_SETTINGS_SETTINGS_HTML"
file="settings.html" file="settings.html"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment