提交 086b1ec5 编写于 作者: N nem035

Modularized top menu functionality into its own module

上级 cf924db0
const app = require('../../app');
const Server = require('../../server');
const Toast = require('../toast');
const TopMenu = require('../top_menu');
module.exports = () => {
......@@ -31,20 +32,14 @@ module.exports = () => {
const $btnNext = $('#btn_next');
const $btnDesc = $('#btn_desc');
const flowControlBtns = [ $btnPause, $btnPrev, $btnNext ];
const setFlowControlState = (isDisabled) => {
flowControlBtns.forEach($btn => $btn.attr('disabled', isDisabled));
};
// initially, control buttons are disabled
setFlowControlState(true);
TopMenu.disableFlowControl();
$btnRun.click(() => {
$btnTrace.click();
$btnPause.removeClass('active');
$btnRun.addClass('active');
setFlowControlState(false);
TopMenu.enableFlowControl();
var err = app.getEditor().execute();
if (err) {
console.error(err);
......
'use strict';
const flowControlBtns = [ $('#btn_pause'), $('#btn_prev'), $('#btn_next') ];
const setFlowControlState = (isDisabled) => {
flowControlBtns.forEach($btn => $btn.attr('disabled', isDisabled));
};
const enableFlowControl = () => {
setFlowControlState(false);
};
const disableFlowControl = () => {
setFlowControlState(true);
};
const resetTopMenuButtons = () => {
$('.top-menu-buttons button').removeClass('active');
disableFlowControl();
};
module.exports = {
enableFlowControl,
disableFlowControl,
resetTopMenuButtons
};
'use strict';
const TopMenu = require('../dom/top_menu');
const stepLimit = 1e6;
const TracerManager = function () {
......@@ -180,7 +182,7 @@ TracerManager.prototype = {
this.timer = setTimeout(() => {
if (!tracer.nextStep(options)) {
$('#btn_run').removeClass('active');
TopMenu.resetTopMenuButtons();
}
}, this.interval);
},
......@@ -242,4 +244,4 @@ TracerManager.prototype = {
}
};
module.exports = TracerManager;
\ No newline at end of file
module.exports = TracerManager;
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册