Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / Source / devtools / front_end / devices / DevicesDialog.js
blobf504111df62c1957e6703f3c0d82445c3eae09af
1 // Copyright 2015 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.
5 /**
6  * @constructor
7  * @extends {WebInspector.DialogDelegate}
8  */
9 WebInspector.DevicesDialog = function()
11     WebInspector.DialogDelegate.call(this);
12     this.element.classList.add("devices-dialog");
13     this._view = new WebInspector.DevicesView();
14     this._view.markAsRoot();
16     this._closeButton = createElementWithClass("div", "dialog-close-button", "dt-close-button");
17     this._closeButton.gray = true;
18     this._closeButton.addEventListener("click", WebInspector.Dialog.hide.bind(WebInspector.Dialog), false);
19     this.element.appendChild(this._closeButton);
22 /** @type {?WebInspector.DevicesDialog} */
23 WebInspector.DevicesDialog._instance = null;
25 WebInspector.DevicesDialog.show = function()
27     if (!WebInspector.DevicesDialog._instance)
28         WebInspector.DevicesDialog._instance = new WebInspector.DevicesDialog();
29     WebInspector.Dialog.show(null, WebInspector.DevicesDialog._instance);
32 WebInspector.DevicesDialog.prototype = {
33     /**
34      * @param {!Element} element
35      * @override
36      */
37     show: function(element)
38     {
39         WebInspector.DialogDelegate.prototype.show.call(this, element);
40         this._view.show(this.element, this._closeButton);
41     },
43     /**
44      * @override
45      */
46     willHide: function()
47     {
48         WebInspector.DialogDelegate.prototype.willHide.call(this);
49         this._view.detach();
50     },
52     __proto__: WebInspector.DialogDelegate.prototype
55 /**
56  * @constructor
57  * @implements {WebInspector.ActionDelegate}
58  */
59 WebInspector.DevicesDialog.ActionDelegate = function()
63 WebInspector.DevicesDialog.ActionDelegate.prototype = {
64     /**
65      * @override
66      * @param {!WebInspector.Context} context
67      * @param {string} actionId
68      */
69     handleAction: function(context, actionId)
70     {
71         if (actionId === "devices.dialog.show")
72             WebInspector.DevicesDialog.show();
73     }