| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 /** |
| 5 * @unrestricted |
| 6 */ |
| 7 WebInspector.AddSourceMapURLDialog = class extends WebInspector.HBox { |
| 8 /** |
| 9 * @param {function(string)} callback |
| 10 */ |
| 11 constructor(callback) { |
| 12 super(true); |
| 13 this.registerRequiredCSS('ui_lazy/dialog.css'); |
| 14 this.contentElement.createChild('label').textContent = WebInspector.UIString
('Source map URL: '); |
| 4 | 15 |
| 5 /** | 16 this._input = this.contentElement.createChild('input'); |
| 6 * @constructor | 17 this._input.setAttribute('type', 'text'); |
| 7 * @extends {WebInspector.HBox} | 18 this._input.addEventListener('keydown', this._onKeyDown.bind(this), false); |
| 8 * @param {function(string)} callback | |
| 9 */ | |
| 10 WebInspector.AddSourceMapURLDialog = function(callback) | |
| 11 { | |
| 12 WebInspector.HBox.call(this, true); | |
| 13 this.registerRequiredCSS("ui_lazy/dialog.css"); | |
| 14 this.contentElement.createChild("label").textContent = WebInspector.UIString
("Source map URL: "); | |
| 15 | 19 |
| 16 this._input = this.contentElement.createChild("input"); | 20 var addButton = this.contentElement.createChild('button'); |
| 17 this._input.setAttribute("type", "text"); | 21 addButton.textContent = WebInspector.UIString('Add'); |
| 18 this._input.addEventListener("keydown", this._onKeyDown.bind(this), false); | 22 addButton.addEventListener('click', this._apply.bind(this), false); |
| 19 | |
| 20 var addButton = this.contentElement.createChild("button"); | |
| 21 addButton.textContent = WebInspector.UIString("Add"); | |
| 22 addButton.addEventListener("click", this._apply.bind(this), false); | |
| 23 | 23 |
| 24 this.setDefaultFocusedElement(this._input); | 24 this.setDefaultFocusedElement(this._input); |
| 25 this._callback = callback; | 25 this._callback = callback; |
| 26 this.contentElement.tabIndex = 0; | 26 this.contentElement.tabIndex = 0; |
| 27 }; | 27 } |
| 28 | 28 |
| 29 /** | 29 /** |
| 30 * @param {function(string)} callback | 30 * @param {function(string)} callback |
| 31 */ | 31 */ |
| 32 WebInspector.AddSourceMapURLDialog.show = function(callback) | 32 static show(callback) { |
| 33 { | |
| 34 var dialog = new WebInspector.Dialog(); | 33 var dialog = new WebInspector.Dialog(); |
| 35 var addSourceMapURLDialog = new WebInspector.AddSourceMapURLDialog(done); | 34 var addSourceMapURLDialog = new WebInspector.AddSourceMapURLDialog(done); |
| 36 addSourceMapURLDialog.show(dialog.element); | 35 addSourceMapURLDialog.show(dialog.element); |
| 37 dialog.setWrapsContent(true); | 36 dialog.setWrapsContent(true); |
| 38 dialog.show(); | 37 dialog.show(); |
| 39 | 38 |
| 40 /** | 39 /** |
| 41 * @param {string} value | 40 * @param {string} value |
| 42 */ | 41 */ |
| 43 function done(value) | 42 function done(value) { |
| 44 { | 43 dialog.detach(); |
| 45 dialog.detach(); | 44 callback(value); |
| 46 callback(value); | |
| 47 } | 45 } |
| 46 } |
| 47 |
| 48 _apply() { |
| 49 this._callback(this._input.value); |
| 50 } |
| 51 |
| 52 /** |
| 53 * @param {!Event} event |
| 54 */ |
| 55 _onKeyDown(event) { |
| 56 if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Enter.code) { |
| 57 event.preventDefault(); |
| 58 this._apply(); |
| 59 } |
| 60 } |
| 48 }; | 61 }; |
| 49 | 62 |
| 50 WebInspector.AddSourceMapURLDialog.prototype = { | |
| 51 _apply: function() | |
| 52 { | |
| 53 this._callback(this._input.value); | |
| 54 }, | |
| 55 | 63 |
| 56 /** | |
| 57 * @param {!Event} event | |
| 58 */ | |
| 59 _onKeyDown: function(event) | |
| 60 { | |
| 61 if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Enter.code) { | |
| 62 event.preventDefault(); | |
| 63 this._apply(); | |
| 64 } | |
| 65 }, | |
| 66 | |
| 67 __proto__: WebInspector.HBox.prototype | |
| 68 }; | |
| OLD | NEW |