mirror of
https://github.com/liriliri/eruda.git
synced 2026-04-01 10:18:35 +08:00
Dev: Refactoring
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "eruda",
|
||||
"version": "0.4.0",
|
||||
"version": "0.4.1",
|
||||
"description": "Console for mobile JavaScript",
|
||||
"main": "dist/eruda.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -5,11 +5,6 @@ import config from '../lib/config.es6'
|
||||
|
||||
require('./DevTools.scss');
|
||||
|
||||
function activeEruda(flag)
|
||||
{
|
||||
window.localStorage.setItem('active-eruda', flag);
|
||||
}
|
||||
|
||||
export default class DevTools extends util.Emitter
|
||||
{
|
||||
constructor($parent)
|
||||
@@ -147,9 +142,7 @@ export default class DevTools extends util.Emitter
|
||||
}
|
||||
_setHalfScreen(flag)
|
||||
{
|
||||
this._$el.css({
|
||||
height: flag ? '50%': '100%'
|
||||
});
|
||||
this._$el.css({height: flag ? '50%': '100%'});
|
||||
}
|
||||
_appendTpl()
|
||||
{
|
||||
@@ -163,9 +156,9 @@ export default class DevTools extends util.Emitter
|
||||
_initNavBar()
|
||||
{
|
||||
this._navBar = new NavBar(this._$el.find('.eruda-nav-bar ul'));
|
||||
this._navBar.on('showTool', (name) =>
|
||||
{
|
||||
this.showTool(name);
|
||||
});
|
||||
this._navBar.on('showTool', name => this.showTool(name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var activeEruda = flag => window.localStorage.setItem('active-eruda', flag);
|
||||
|
||||
|
||||
@@ -36,16 +36,14 @@ export default class NavBar extends util.Emitter
|
||||
{
|
||||
var $this = util.$(this);
|
||||
|
||||
$this.text() === name ? $this.addClass('eruda-active') : $this.rmClass('eruda-active');
|
||||
$this[$this.text() === name ? 'addClass' : 'rmClass']('eruda-active');
|
||||
});
|
||||
}
|
||||
_bindEvent()
|
||||
{
|
||||
var $el = this._$el;
|
||||
|
||||
var self = this;
|
||||
|
||||
$el.on('click', 'li', function ()
|
||||
this._$el.on('click', 'li', function ()
|
||||
{
|
||||
self.emit('showTool', util.$(this).text());
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@ function formatStyle(style)
|
||||
{
|
||||
var ret = {};
|
||||
|
||||
for (var i = 0, len = style.length; i < len; i++)
|
||||
for (let i = 0, len = style.length; i < len; i++)
|
||||
{
|
||||
var name = style[i];
|
||||
|
||||
|
||||
@@ -31,10 +31,7 @@ export default class Features extends Tool
|
||||
if (specialNames[feature]) feature = specialNames[feature];
|
||||
feature = feature.replace(/\//g, '');
|
||||
|
||||
modernizr.on(feature, (result) =>
|
||||
{
|
||||
this._add(feature, result);
|
||||
});
|
||||
modernizr.on(feature, (result) => this._add(feature, result));
|
||||
});
|
||||
}
|
||||
_add(name, result)
|
||||
@@ -45,8 +42,6 @@ export default class Features extends Tool
|
||||
}
|
||||
_render()
|
||||
{
|
||||
this._$el.html(this._tpl({
|
||||
features: this._features
|
||||
}));
|
||||
this._$el.html(this._tpl({features: this._features}));
|
||||
}
|
||||
}
|
||||
@@ -21,10 +21,7 @@ export default class Info extends Tool
|
||||
}
|
||||
add(name, val)
|
||||
{
|
||||
this._msgs.push({
|
||||
name: name,
|
||||
val: val
|
||||
});
|
||||
this._msgs.push({name, val});
|
||||
|
||||
this._render();
|
||||
|
||||
@@ -32,15 +29,10 @@ export default class Info extends Tool
|
||||
}
|
||||
_addDefInfo()
|
||||
{
|
||||
util.each(defInfo, (info) =>
|
||||
{
|
||||
this.add(info.name, info.val);
|
||||
});
|
||||
util.each(defInfo, info => this.add(info.name, info.val));
|
||||
}
|
||||
_render()
|
||||
{
|
||||
this._$el.html(this._tpl({
|
||||
messages: this._msgs
|
||||
}));
|
||||
this._$el.html(this._tpl({messages: this._msgs}));
|
||||
}
|
||||
}
|
||||
@@ -260,7 +260,4 @@ function getState(type, len)
|
||||
|
||||
var origin = window.location.origin;
|
||||
|
||||
function isCrossOrig(url)
|
||||
{
|
||||
return !util.startWith(url, origin);
|
||||
}
|
||||
var isCrossOrig = url => !util.startWith(url, origin);
|
||||
@@ -85,7 +85,4 @@ function createEl(key, val)
|
||||
</li>`;
|
||||
}
|
||||
|
||||
function encode(str)
|
||||
{
|
||||
return util.escape(util.toStr(str));
|
||||
}
|
||||
var encode = str => util.escape(util.toStr(str));
|
||||
@@ -53,10 +53,7 @@ export default class Sources extends Tool
|
||||
return;
|
||||
}
|
||||
|
||||
this._data = {
|
||||
type: type,
|
||||
val: val
|
||||
};
|
||||
this._data = {type, val};
|
||||
|
||||
this._render();
|
||||
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
<div class="eruda-img-container">
|
||||
<img src="{{src}}">
|
||||
</div>
|
||||
<div class="eruda-img-info">{{width}}px × {{height}}px</div>
|
||||
<div class="eruda-img-info">{{width}} × {{height}}</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user