| 7435 | |
| 7436 | // 绑定事件 |
| 7437 | function bindEvent() { |
| 7438 | // 统一执行命令的方法 |
| 7439 | var commandFn; |
| 7440 | function command(e, callback) { |
| 7441 | // 执行命令之前,先存储html内容 |
| 7442 | html = $txt.html(); |
| 7443 | // 监控内容变化 |
| 7444 | var cb = function () { |
| 7445 | if (callback) { |
| 7446 | callback(); |
| 7447 | } |
| 7448 | if (html !== $txt.html()) { |
| 7449 | $txt.change(); |
| 7450 | } |
| 7451 | }; |
| 7452 | // 执行命令 |
| 7453 | if (commandFn) { |
| 7454 | editor.customCommand(e, commandFn, cb); |
| 7455 | } |
| 7456 | } |
| 7457 | |
| 7458 | // 删除 |
| 7459 | $delete.click(function (e) { |
| 7460 | commandFn = function () { |
| 7461 | $currentTable.remove(); |
| 7462 | }; |
| 7463 | command(e, function () { |
| 7464 | setTimeout(hide, 100); |
| 7465 | }); |
| 7466 | }); |
| 7467 | |
| 7468 | // 放大 |
| 7469 | $zoomBig.click(function (e) { |
| 7470 | commandFn = function () { |
| 7471 | $currentTable.css({ |
| 7472 | width: '100%' |
| 7473 | }); |
| 7474 | }; |
| 7475 | command(e, function () { |
| 7476 | setTimeout(show); |
| 7477 | }); |
| 7478 | }); |
| 7479 | |
| 7480 | // 缩小 |
| 7481 | $zoomSmall.click(function (e) { |
| 7482 | commandFn = function () { |
| 7483 | $currentTable.css({ |
| 7484 | width: 'auto' |
| 7485 | }); |
| 7486 | }; |
| 7487 | command(e, function () { |
| 7488 | setTimeout(show); |
| 7489 | }); |
| 7490 | }); |
| 7491 | } |
| 7492 | |
| 7493 | // 显示 toolbar |
| 7494 | function show() { |