| <!-- |
| Copyright (C) 2016 The Android Open Source Project |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| --> |
| |
| <link rel="import" href="../bower_components/polymer/polymer.html"> |
| <link rel="import" href="../bower_components/iron-input/iron-input.html"> |
| |
| <dom-module id="gr-diff-preferences"> |
| <template> |
| <style> |
| :host { |
| display: block; |
| } |
| :host[disabled] { |
| opacity: .5; |
| pointer-events: none; |
| } |
| button, |
| input, |
| select { |
| font: inherit; |
| } |
| input[type="number"] { |
| width: 4em; |
| } |
| button { |
| background-color: #f1f2f3; |
| border: 1px solid #aaa; |
| border-radius: 2px; |
| cursor: pointer; |
| font: inherit; |
| padding: .2em .75em; |
| } |
| button.primary { |
| background: #448aff; |
| border: none; |
| color: #fff; |
| } |
| .header, |
| .actions { |
| padding: 1em 1.5em; |
| } |
| .header { |
| border-bottom: 1px solid #ddd; |
| font-weight: bold; |
| } |
| .mainContainer { |
| padding: 1em 0; |
| } |
| .pref { |
| align-items: center; |
| display: flex; |
| padding: .35em 1.5em; |
| width: 20em; |
| } |
| .pref:hover { |
| background-color: #ebf5fb; |
| } |
| .pref label { |
| cursor: pointer; |
| flex: 1; |
| } |
| .actions { |
| border-top: 1px solid #ddd; |
| display: flex; |
| } |
| .cancel { |
| display: flex; |
| flex: 1; |
| justify-content: flex-end; |
| } |
| </style> |
| <div class="header"> |
| Diff View Preferences |
| </div> |
| <div class="mainContainer"> |
| <div class="pref"> |
| <label for="contextSelect">Context</label> |
| <select id="contextSelect" on-change="_handleContextSelectChange"> |
| <option value="3">3 lines</option> |
| <option value="10">10 lines</option> |
| <option value="25">25 lines</option> |
| <option value="50">50 lines</option> |
| <option value="75">75 lines</option> |
| <option value="100">100 lines</option> |
| <option value="-1">Whole file</option> |
| </select> |
| </div> |
| <div class="pref"> |
| <label for="columnsInput">Columns</label> |
| <input is="iron-input" type="number" id="columnsInput" |
| prevent-invalid-input |
| allowed-pattern="[0-9]" |
| bind-value="{{prefs.line_length}}"> |
| </div> |
| <div class="pref"> |
| <label for="tabSizeInput">Tab width</label> |
| <input is="iron-input" type="number" id="tabSizeInput" |
| prevent-invalid-input |
| allowed-pattern="[0-9]" |
| bind-value="{{prefs.tab_size}}"> |
| </div> |
| <div class="pref"> |
| <label for="showTabsInput">Show tabs</label> |
| <input is="iron-input" type="checkbox" id="showTabsInput" |
| on-tap="_handleShowTabsTap"> |
| </div> |
| </div> |
| <div class="actions"> |
| <button class="primary" on-tap="_handleSave">Save</button> |
| <div class="cancel"> |
| <button on-tap="_handleCancel">Cancel</button> |
| </div> |
| </div> |
| </template> |
| <script> |
| (function() { |
| 'use strict'; |
| |
| Polymer({ |
| is: 'gr-diff-preferences', |
| |
| /** |
| * Fired when the user presses the save button. |
| * |
| * @event save |
| */ |
| |
| /** |
| * Fired when the user presses the cancel button. |
| * |
| * @event cancel |
| */ |
| |
| properties: { |
| prefs: { |
| type: Object, |
| notify: true, |
| value: function() { return {}; }, |
| }, |
| disabled: { |
| type: Boolean, |
| value: false, |
| reflectToAttribute: true, |
| }, |
| }, |
| |
| observers: [ |
| '_prefsChanged(prefs.*)', |
| ], |
| |
| _prefsChanged: function(changeRecord) { |
| var prefs = changeRecord.base; |
| this.$.contextSelect.value = prefs.context; |
| this.$.showTabsInput.checked = prefs.show_tabs; |
| }, |
| |
| _handleContextSelectChange: function(e) { |
| var selectEl = Polymer.dom(e).rootTarget; |
| this.set('prefs.context', parseInt(selectEl.value, 10)); |
| }, |
| |
| _handleShowTabsTap: function(e) { |
| this.set('prefs.show_tabs', Polymer.dom(e).rootTarget.checked); |
| }, |
| |
| _handleSave: function() { |
| this.fire('save', null, {bubble: false}); |
| }, |
| |
| _handleCancel: function() { |
| this.fire('cancel', null, {bubble: false}); |
| }, |
| }); |
| })(); |
| </script> |
| </dom-module> |