Commit 0c50834d authored by antoor's avatar antoor

Rewriting class binding method

重写类绑定方法
parent 78755518
...@@ -93,13 +93,13 @@ class ASP { ...@@ -93,13 +93,13 @@ class ASP {
{ {
text: '添加配置', text: '添加配置',
icon: 'fa fa-plus-circle', icon: 'fa fa-plus-circle',
action: this::this.addConf action: this.addConf.bind(this)
}, { }, {
divider: true divider: true
}, { }, {
text: '删除配置', text: '删除配置',
icon: 'fa fa-remove', icon: 'fa fa-remove',
action: this::this.delConf action: this.delConf.bind(this)
} }
], event); ], event);
}); });
...@@ -456,7 +456,7 @@ class ASP { ...@@ -456,7 +456,7 @@ class ASP {
// 禁用SQL编辑框 // 禁用SQL编辑框
disableEditor() { disableEditor() {
['exec', 'clear'].map( ['exec', 'clear'].map(
this.manager.query.toolbar::this.manager.query.toolbar.disableItem this.manager.query.toolbar.disableItem.bind(this.manager.query.toolbar)
); );
this.manager.query.editor.setReadOnly(true); this.manager.query.editor.setReadOnly(true);
} }
...@@ -464,7 +464,7 @@ class ASP { ...@@ -464,7 +464,7 @@ class ASP {
// 启用SQL编辑框 // 启用SQL编辑框
enableEditor() { enableEditor() {
['exec', 'clear'].map( ['exec', 'clear'].map(
this.manager.query.toolbar::this.manager.query.toolbar.enableItem this.manager.query.toolbar.enableItem.bind(this.manager.query.toolbar)
); );
this.manager.query.editor.setReadOnly(false); this.manager.query.editor.setReadOnly(false);
} }
......
...@@ -89,13 +89,13 @@ class ASP { ...@@ -89,13 +89,13 @@ class ASP {
{ {
text: '添加配置', text: '添加配置',
icon: 'fa fa-plus-circle', icon: 'fa fa-plus-circle',
action: this::this.addConf action: this.addConf.bind(this)
}, { }, {
divider: true divider: true
}, { }, {
text: '删除配置', text: '删除配置',
icon: 'fa fa-remove', icon: 'fa fa-remove',
action: this::this.delConf action: this.delConf.bind(this)
} }
], event); ], event);
}); });
...@@ -455,7 +455,7 @@ class ASP { ...@@ -455,7 +455,7 @@ class ASP {
// 禁用SQL编辑框 // 禁用SQL编辑框
disableEditor() { disableEditor() {
['exec', 'clear'].map( ['exec', 'clear'].map(
this.manager.query.toolbar::this.manager.query.toolbar.disableItem this.manager.query.toolbar.disableItem.bind(this.manager.query.toolbar)
); );
this.manager.query.editor.setReadOnly(true); this.manager.query.editor.setReadOnly(true);
} }
...@@ -463,7 +463,7 @@ class ASP { ...@@ -463,7 +463,7 @@ class ASP {
// 启用SQL编辑框 // 启用SQL编辑框
enableEditor() { enableEditor() {
['exec', 'clear'].map( ['exec', 'clear'].map(
this.manager.query.toolbar::this.manager.query.toolbar.enableItem this.manager.query.toolbar.enableItem.bind(this.manager.query.toolbar)
); );
this.manager.query.editor.setReadOnly(false); this.manager.query.editor.setReadOnly(false);
} }
......
...@@ -84,13 +84,13 @@ class PHP { ...@@ -84,13 +84,13 @@ class PHP {
{ {
text: LANG['list']['menu']['add'], text: LANG['list']['menu']['add'],
icon: 'fa fa-plus-circle', icon: 'fa fa-plus-circle',
action: this::this.addConf action: this.addConf.bind(this)
}, { }, {
divider: true divider: true
}, { }, {
text: LANG['list']['menu']['del'], text: LANG['list']['menu']['del'],
icon: 'fa fa-remove', icon: 'fa fa-remove',
action: this::this.delConf action: this.delConf.bind(this)
} }
], event); ], event);
}); });
...@@ -481,7 +481,7 @@ class PHP { ...@@ -481,7 +481,7 @@ class PHP {
// 禁用SQL编辑框 // 禁用SQL编辑框
disableEditor() { disableEditor() {
['exec', 'clear'].map( ['exec', 'clear'].map(
this.manager.query.toolbar::this.manager.query.toolbar.disableItem this.manager.query.toolbar.disableItem.bind(this.manager.query.toolbar)
); );
this.manager.query.editor.setReadOnly(true); this.manager.query.editor.setReadOnly(true);
} }
...@@ -489,7 +489,7 @@ class PHP { ...@@ -489,7 +489,7 @@ class PHP {
// 启用SQL编辑框 // 启用SQL编辑框
enableEditor() { enableEditor() {
['exec', 'clear'].map( ['exec', 'clear'].map(
this.manager.query.toolbar::this.manager.query.toolbar.enableItem this.manager.query.toolbar.enableItem.bind(this.manager.query.toolbar)
); );
this.manager.query.editor.setReadOnly(false); this.manager.query.editor.setReadOnly(false);
} }
......
...@@ -837,7 +837,7 @@ class FileManager { ...@@ -837,7 +837,7 @@ class FileManager {
editor.session.setValue(ret); editor.session.setValue(ret);
// 定时刷新 // 定时刷新
const inter = setInterval(editor::editor.resize, 200); const inter = setInterval(editor.resize.bind(editor), 200);
win.attachEvent('onClose', () => { win.attachEvent('onClose', () => {
clearInterval(inter); clearInterval(inter);
return true; return true;
......
...@@ -8,7 +8,7 @@ const LANG_T = antSword['language']['toastr']; ...@@ -8,7 +8,7 @@ const LANG_T = antSword['language']['toastr'];
class Plugin { class Plugin {
constructor() { constructor() {
antSword['menubar'].reg('plugin', this::this.open); antSword['menubar'].reg('plugin', this.open.bind(this));
this.homepage = 'http://u.uyu.us/'; this.homepage = 'http://u.uyu.us/';
} }
...@@ -39,8 +39,8 @@ class Plugin { ...@@ -39,8 +39,8 @@ class Plugin {
// 开始加载web // 开始加载web
cell.progressOn(); cell.progressOn();
const frame = cell.attachURI(this.homepage); const frame = cell.attachURI(this.homepage);
frame.addEventListener('did-start-loading', cell::cell.progressOn); frame.addEventListener('did-start-loading', cell.progressOn.bind(cell));
frame.addEventListener('did-finish-load', cell::cell.progressOff); frame.addEventListener('did-finish-load', cell.progressOff.bind(cell));
frame.addEventListener('did-fail-load', (err) => { frame.addEventListener('did-fail-load', (err) => {
cell.progressOff(); cell.progressOff();
// cell.close(); // cell.close();
......
...@@ -10,7 +10,7 @@ import AProxy from './aproxy' ...@@ -10,7 +10,7 @@ import AProxy from './aproxy'
class Settings { class Settings {
constructor() { constructor() {
antSword['menubar'].reg('settings', this::this.open); antSword['menubar'].reg('settings', this.open.bind(this));
['about', 'update', 'language', 'aproxy'].map((_) => { ['about', 'update', 'language', 'aproxy'].map((_) => {
antSword['menubar'].reg(`settings-${_}`, this.setActive.bind(this, _)); antSword['menubar'].reg(`settings-${_}`, this.setActive.bind(this, _));
}); });
......
// /**
// 右侧目录管理模块 * 右侧目录管理模块
// */
'use strict'; 'use strict';
...@@ -95,7 +95,7 @@ class Category { ...@@ -95,7 +95,7 @@ class Category {
sidebar.callEvent('onSelect', ['default']); sidebar.callEvent('onSelect', ['default']);
// 3. 删除侧边栏 // 3. 删除侧边栏
sidebar.items(category).remove(); sidebar.items(category).remove();
setTimeout(this::this.updateTitle, 100); setTimeout(this.updateTitle.bind(this), 100);
}else{ }else{
return toastr.error(LANG['category']['del']['error'](category, ret.toString()), LANG_T['error']); return toastr.error(LANG['category']['del']['error'](category, ret.toString()), LANG_T['error']);
} }
......
// /**
// Shell管理模块 * Shell管理模块
// */
'use strict'; 'use strict';
...@@ -37,7 +37,7 @@ class ShellManager { ...@@ -37,7 +37,7 @@ class ShellManager {
this.win.attachViewportTo(cell.cell); this.win.attachViewportTo(cell.cell);
// 监听菜单栏消息 // 监听菜单栏消息
antSword['menubar'].reg('shell-add', this::this.addData); antSword['menubar'].reg('shell-add', this.addData.bind(this));
this.loadData(); this.loadData();
......
// /**
// 左侧shell数据管理模块 * 左侧shell数据管理模块
// */
// import Db from '../../database/';
import Terminal from '../terminal/'; import Terminal from '../terminal/';
import Database from '../database/'; import Database from '../database/';
import FileManager from '../filemanager/'; import FileManager from '../filemanager/';
...@@ -82,7 +81,7 @@ class List { ...@@ -82,7 +81,7 @@ class List {
{ text: LANG['contextmenu']['plugin'], icon: 'fa fa-puzzle-piece', disabled: !id || ids.length !== 1 || true, subMenu: [] }, { text: LANG['contextmenu']['plugin'], icon: 'fa fa-puzzle-piece', disabled: !id || ids.length !== 1 || true, subMenu: [] },
{ text: LANG['contextmenu']['pluginCenter'], icon: 'fa fa-cart-arrow-down', action: antSword['menubar'].run.bind(antSword['menubar'], 'plugin') }, { text: LANG['contextmenu']['pluginCenter'], icon: 'fa fa-cart-arrow-down', action: antSword['menubar'].run.bind(antSword['menubar'], 'plugin') },
{ divider: true }, { divider: true },
{ text: LANG['contextmenu']['add'], icon: 'fa fa-plus-circle', action: manager::manager.addData }, { text: LANG['contextmenu']['add'], icon: 'fa fa-plus-circle', action: manager.addData.bind(manager) },
{ text: LANG['contextmenu']['edit'], icon: 'fa fa-edit', disabled: !id || ids.length !== 1, action: () => { { text: LANG['contextmenu']['edit'], icon: 'fa fa-edit', disabled: !id || ids.length !== 1, action: () => {
manager.editData(id); manager.editData(id);
} }, } },
...@@ -118,12 +117,12 @@ class List { ...@@ -118,12 +117,12 @@ class List {
}); });
return ret; return ret;
})() }, })() },
{ text: LANG['contextmenu']['search'], icon: 'fa fa-search', action: manager::manager.searchData, disabled: true }, { text: LANG['contextmenu']['search'], icon: 'fa fa-search', action: manager.searchData.bind(manager), disabled: true },
{ divider: true }, { divider: true },
{ text: LANG['contextmenu']['clearCache'], icon: 'fa fa-trash-o', disabled: !id, action: () => { { text: LANG['contextmenu']['clearCache'], icon: 'fa fa-trash-o', disabled: !id, action: () => {
manager.clearCache(id); manager.clearCache(id);
} }, } },
{ text: LANG['contextmenu']['clearAllCache'], icon: 'fa fa-trash', action: manager::manager.clearAllCache } { text: LANG['contextmenu']['clearAllCache'], icon: 'fa fa-trash', action: manager.clearAllCache.bind(manager) }
], event); ], event);
return true; return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment