Add: Text node support

This commit is contained in:
surunzi
2016-05-08 16:55:55 +08:00
parent b7e64d0002
commit 915596f708
9 changed files with 86 additions and 35 deletions

View File

@@ -1,4 +1,6 @@
import Tool from '../DevTools/Tool.es6'
import TreeView from './TreeView.es6'
import util from '../lib/util'
require('./Sources.scss');
@@ -9,11 +11,8 @@ export default class Sources extends Tool
super();
this.name = 'sources';
this._data = {
type: ''
};
this._loadTpl();
this._reset();
}
init($el)
{
@@ -25,16 +24,40 @@ export default class Sources extends Tool
{
this._data = data;
}
_reset()
{
this._data = {
type: 'html',
val: document.documentElement
};
}
_loadTpl()
{
this._emptyTpl = require('./empty.hbs');
this._htmlTpl = require('./html.hbs');
}
_render()
{
var data = this._data;
var tpl = this._emptyTpl;
this._$el.html(tpl(data));
switch (data.type)
{
case 'html': return this._renderHtml();
}
}
_renderHtml()
{
var data = this._data;
var rootNode = data.val;
this._$el.html(this._htmlTpl);
new TreeView(this._$el.find('.eruda-tree'), getNodeChildren(rootNode));
}
}
function getNodeChildren(rootNode)
{
var ret = [];
var children = rootNode.childNodes;
}

10
src/Sources/TreeView.es6 Normal file
View File

@@ -0,0 +1,10 @@
require('./TreeView.scss');
export default class TreeView
{
constructor($parent, initialData)
{
this._$parent = $parent;
this._data = initialData;
}
}

View File

View File

@@ -1,5 +0,0 @@
<div class="eruda-empty">
<div class="eruda-content">
Used for displaying html, javaScript, css and image.
</div>
</div>

3
src/Sources/html.hbs Normal file
View File

@@ -0,0 +1,3 @@
<div class="eruda-html">
<div class="eruda-tree"></div>
</div>