Add: Tiny Navigation bar setting

This commit is contained in:
surunzi
2016-07-01 15:49:23 +08:00
parent 9070971b76
commit b821ac9ff1
10 changed files with 41 additions and 3 deletions

View File

@@ -102,11 +102,13 @@ export default class DevTools extends util.Emitter
cfg.set(util.defaults(cfg.get(), {
transparency: '100%',
displaySize: '100%',
tinyNavBar: false,
activeEruda: false
}));
this._setTransparency(cfg.get('transparency'));
this._setDisplaySize(cfg.get('displaySize'));
this._setNavBarHeight(cfg.get('tinyNavBar') ? 30 : 55);
cfg.on('change', (key, val) =>
{
@@ -115,9 +117,15 @@ export default class DevTools extends util.Emitter
case 'transparency': return this._setTransparency(val);
case 'displaySize': return this._setDisplaySize(val);
case 'activeEruda': return activeEruda(val);
case 'tinyNavBar': return this._setNavBarHeight(val ? 30 : 55);
}
});
}
_setNavBarHeight(height)
{
this._$el.css('paddingTop', height);
this._navBar.setHeight(height);
}
_setTransparency(opacity)
{
opacity = +opacity.replace('%', '') / 100;

View File

@@ -7,7 +7,6 @@
height: 100%;
left: 0;
bottom: 0;
padding-top: 55px !important;
background: #fff;
z-index: 500;
display: none;

View File

@@ -13,6 +13,7 @@ export default class NavBar extends util.Emitter
this._$ul = $el.find('ul');
this._$bottomBar = $el.find('.eruda-bottom-bar');
this._len = 0;
this._height = 55;
this._bindEvent();
}
@@ -20,7 +21,12 @@ export default class NavBar extends util.Emitter
{
this._len++;
this._$ul.prepend(`<li class="${name}" ontouchstart>${name}</li>`);
this._resetWidth();
this._resetStyle();
}
setHeight(height)
{
this._height = height;
this._resetStyle();
}
activeTool(name)
{
@@ -40,9 +46,16 @@ export default class NavBar extends util.Emitter
}
});
}
_resetWidth()
_resetStyle()
{
var height = this._height;
this._$el.css('height', height);
this._$ul.css({width: this._len * ITEM_WIDTH});
this._$ul.find('li').css({
'height': height,
'lineHeight': height
});
}
_bindEvent()
{