Dev: Rename ext es6 to js

This commit is contained in:
surunzi
2017-10-01 11:30:10 +08:00
parent 55ccdd1b6d
commit 5bbebb686b
34 changed files with 53 additions and 50 deletions

87
src/DevTools/NavBar.js Normal file
View File

@@ -0,0 +1,87 @@
import util from '../lib/util'
export default class NavBar extends util.Emitter
{
constructor($el)
{
super();
util.evalCss(require('./NavBar.scss'));
this._$el = $el;
$el.html('<div class="eruda-bottom-bar"></div>');
this._$bottomBar = $el.find('.eruda-bottom-bar');
this._len = 0;
this._height = 55;
this._bindEvent();
}
add(name)
{
this._len++;
this._$el.prepend(`<div class="eruda-nav-bar-item">${name}</div>`);
this.resetStyle();
}
setHeight(height)
{
this._height = height;
this.resetStyle();
}
activeTool(name)
{
let self = this;
this._$el.find('.eruda-nav-bar-item').each(function ()
{
let $this = util.$(this);
if ($this.text() === name)
{
$this.addClass('eruda-active');
self._resetBottomBar();
} else
{
$this.rmClass('eruda-active');
}
});
}
_resetBottomBar()
{
let $bottomBar = this._$bottomBar;
let li = this._$el.find('.eruda-active').get(0);
if (!li) return;
$bottomBar.css({
width: li.offsetWidth,
left: li.offsetLeft
});
}
resetStyle()
{
let height = this._height;
this._$el.css('height', height);
let $el = this._$el;
this._resetBottomBar();
$el.css({
height: height
});
$el.find('.eruda-nav-bar-item').css({
'height': height,
'lineHeight': height
});
}
_bindEvent()
{
let self = this;
this._$el.on('click', '.eruda-nav-bar-item', function ()
{
self.emit('showTool', util.$(this).text());
});
}
}