Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / devtools / front_end / sources / AddSourceMapURLDialog.js
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
3 // found in the LICENSE file.
4
5 /**
6  * @constructor
7  * @extends {WebInspector.DialogDelegate}
8  * @param {function(string)} callback
9  */
10 WebInspector.AddSourceMapURLDialog = function(callback)
11 {
12     WebInspector.DialogDelegate.call(this);
13
14     this.element = document.createElementWithClass("div", "go-to-line-dialog");
15     this.element.createChild("label").textContent = WebInspector.UIString("Source map URL: ");
16
17     this._input = this.element.createChild("input");
18     this._input.setAttribute("type", "text");
19
20     this._goButton = this.element.createChild("button");
21     this._goButton.textContent = WebInspector.UIString("Go");
22     this._goButton.addEventListener("click", this._onGoClick.bind(this), false);
23
24     this._callback = callback;
25 }
26
27 /**
28  * @param {!Element} element
29  * @param {function(string)} callback
30  */
31 WebInspector.AddSourceMapURLDialog.show = function(element, callback)
32 {
33     WebInspector.Dialog.show(element, new WebInspector.AddSourceMapURLDialog(callback));
34 }
35
36 WebInspector.AddSourceMapURLDialog.prototype = {
37     focus: function()
38     {
39         WebInspector.setCurrentFocusElement(this._input);
40         this._input.select();
41     },
42
43     _onGoClick: function()
44     {
45         this._apply();
46         WebInspector.Dialog.hide();
47     },
48
49     _apply: function()
50     {
51         var value = this._input.value;
52         this._callback(value);
53     },
54
55     onEnter: function()
56     {
57         this._apply();
58     },
59
60     __proto__: WebInspector.DialogDelegate.prototype
61 }