forked from rapheld/ember_inspector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
devtools.html
61 lines (57 loc) · 1.54 KB
/
devtools.html
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
<html>
<body>
<script type="text/javascript">
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;
data.templateName = view.get('templateName')
data.vars = []
var recurChildViews = function( tview ){
if (tview.path){
var temp = {}
temp[ tview.path ] = tview.pathRoot.getPath(tview.path)
data.vars.push(temp);
}
_.each( tview._childViews, recurChildViews )
}
_.each( minispade.modules, function( mod, key ){
if (mod.search( 'Ember\.TEMPLATES\\["' + data.templateName ) > 0){
data.templateLocation = key;
}
})
recurChildViews( view )
}
return data;
};
chrome.devtools.panels.elements.createSidebarPane(
"Ember View (_V)",
function(sidebar) {
function updatePanel() {
sidebar.setExpression("(" + getSelectedEmberView.toString() + ")()");
}
updatePanel();
chrome.devtools.panels.elements.onSelectionChanged.addListener(updatePanel);
}
);
</script>
</body>
</html>