forked from rapheld/ember_inspector
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdevtools.js
41 lines (37 loc) · 999 Bytes
/
devtools.js
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
(function(){
var getSelectedEmberView = function() {
// _V is a global of the selected view for experimentation in the console
_V = undefined;
var level;
function findView(elm, n) {
if (elm == null) { return undefined; }
level = n || 0;
var found = Ember.View.views[elm.id];
if (found == null) {
level++;
found = findView(elm.parentElement, level);
}
return found;
}
var view = findView($0),
data = { __proto__: null };
if (view) {
_V = view;
if (level > 0) { data.distance = level; }
data.id = view.get('elementId');
data.type = view.toString().match(/^<(.*):/)[1];
data.view = view;
}
return data;
};
chrome.devtools.panels.elements.createSidebarPane(
"Ember View",
function(sidebar) {
function updatePanel() {
sidebar.setExpression("(" + getSelectedEmberView.toString() + ")()");
}
updatePanel();
chrome.devtools.panels.elements.onSelectionChanged.addListener(updatePanel);
}
);
})();