| OLD | NEW |
| 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 | 4 |
| 5 cr.define('extensions', function() { | 5 cr.define('extensions', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 var MAX_HEIGHT = 600; | 8 var MAX_HEIGHT = 600; |
| 9 var MAX_WIDTH = 600; | 9 var MAX_WIDTH = 600; |
| 10 var MIN_HEIGHT = 300; | 10 var MIN_HEIGHT = 300; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 this.data_ = data; | 30 this.data_ = data; |
| 31 if (!this.extensionOptions_) | 31 if (!this.extensionOptions_) |
| 32 this.extensionOptions_ = document.createElement('ExtensionOptions'); | 32 this.extensionOptions_ = document.createElement('ExtensionOptions'); |
| 33 this.extensionOptions_.extension = this.data_.id; | 33 this.extensionOptions_.extension = this.data_.id; |
| 34 this.extensionOptions_.onclose = this.close.bind(this); | 34 this.extensionOptions_.onclose = this.close.bind(this); |
| 35 var bounded = function(min, max, val) { | 35 var bounded = function(min, max, val) { |
| 36 return Math.min(Math.max(min, val), max); | 36 return Math.min(Math.max(min, val), max); |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 var onSizeChanged = function(e) { | 39 var onSizeChanged = function(e) { |
| 40 var minHeaderWidth = | 40 var minHeaderWidth = this.$['icon-and-name-wrapper'].offsetWidth + |
| 41 this.$['icon-and-name-wrapper'].offsetWidth + | 41 this.$['close-button'].offsetWidth + HEADER_PADDING; |
| 42 this.$['close-button'].offsetWidth + | |
| 43 HEADER_PADDING; | |
| 44 var minWidth = Math.max(minHeaderWidth, MIN_WIDTH); | 42 var minWidth = Math.max(minHeaderWidth, MIN_WIDTH); |
| 45 this.$.main.style.height = | 43 this.$.main.style.height = |
| 46 bounded(MIN_HEIGHT, MAX_HEIGHT, e.height) + 'px'; | 44 bounded(MIN_HEIGHT, MAX_HEIGHT, e.height) + 'px'; |
| 47 this.$.main.style.width = | 45 this.$.main.style.width = bounded(minWidth, MAX_WIDTH, e.width) + 'px'; |
| 48 bounded(minWidth, MAX_WIDTH, e.width) + 'px'; | |
| 49 }.bind(this); | 46 }.bind(this); |
| 50 | 47 |
| 51 this.extensionOptions_.onpreferredsizechanged = onSizeChanged; | 48 this.extensionOptions_.onpreferredsizechanged = onSizeChanged; |
| 52 this.$.main.appendChild(this.extensionOptions_); | 49 this.$.main.appendChild(this.extensionOptions_); |
| 53 this.$$('dialog').showModal(); | 50 this.$$('dialog').showModal(); |
| 54 onSizeChanged({height: 0, width: 0}); | 51 onSizeChanged({height: 0, width: 0}); |
| 55 }, | 52 }, |
| 56 | 53 |
| 57 close: function() { | 54 close: function() { |
| 58 this.$$('dialog').close(); | 55 this.$$('dialog').close(); |
| 59 }, | 56 }, |
| 60 }); | 57 }); |
| 61 | 58 |
| 62 return {OptionsDialog: OptionsDialog}; | 59 return {OptionsDialog: OptionsDialog}; |
| 63 }); | 60 }); |
| OLD | NEW |