-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdevtools.js
More file actions
63 lines (53 loc) · 1.6 KB
/
devtools.js
File metadata and controls
63 lines (53 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// The function below is executed in the context of the inspected page.
var page_getProperties = function() {
var page_copyCmpProperties = function(copy, cmp){
["$className"].map(function(prop){
copy[prop] = cmp[prop];
});
var items = [];
items.__proto__ = null;
if (typeof(cmp.getItems) == 'function'){
cmp.getItems().items.map(function(item, i){
items[i] = item.rendered && item.element ? item.element.dom : "not rendered yet";
});
}
copy["items"] = items;
};
var page_findParentCmp = function(elem){
var parent = elem.parentNode;
if (parent){
var cmp = Ext.getCmp(parent.id);
if (cmp){
return cmp;
} else if (parent){
return page_findParentCmp(parent);
}
}
};
var data = {};
var copy = { __proto__: null};
if (window.Ext && $0){
var cmp = Ext.getCmp($0.id);
if (cmp){
page_copyCmpProperties(copy, cmp);
}
var parentCmp = page_findParentCmp($0);
if (parentCmp && parentCmp.element){
copy["parent"] = parentCmp.element.dom;
}
}
return copy;
};
chrome.devtools.panels.elements.createSidebarPane(
"Ext.Component Properties",
function(sidebar) {
function updateElementProperties() {
sidebar.setExpression("(" + page_getProperties.toString() + ")()");
}
updateElementProperties();
chrome.devtools.panels.elements.onSelectionChanged.addListener(updateElementProperties);
}
);