mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-09-20 07:35:55 +08:00
Small code optimization
This commit is contained in:
parent
9fb0304f79
commit
062483f078
|
@ -3,6 +3,7 @@ import window from 'window';
|
|||
import _ from '_';
|
||||
import $ from '$';
|
||||
import {htmlEditorDefaultConfig, htmlEditorLangsMap} from 'Common/Globals';
|
||||
import {EventKeyCode} from 'Common/Enums';
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
class HtmlEditor
|
||||
|
@ -268,7 +269,7 @@ class HtmlEditor
|
|||
this.editor = window.CKEDITOR.appendTo(this.$element[0], config);
|
||||
|
||||
this.editor.on('key', (event) => {
|
||||
if (event && event.data && 9 /* Tab */ === event.data.keyCode)
|
||||
if (event && event.data && EventKeyCode.Tab === event.data.keyCode)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -412,4 +413,3 @@ class HtmlEditor
|
|||
}
|
||||
|
||||
export {HtmlEditor, HtmlEditor as default};
|
||||
module.exports = HtmlEditor;
|
||||
|
|
2
dev/External/ko.js
vendored
2
dev/External/ko.js
vendored
|
@ -65,7 +65,7 @@ ko.bindingHandlers.editor = {
|
|||
fUpdateEditorValue();
|
||||
},
|
||||
|
||||
HtmlEditor = require('Common/HtmlEditor');
|
||||
HtmlEditor = require('Common/HtmlEditor').default;
|
||||
|
||||
if (ko.isObservable(fValue) && HtmlEditor)
|
||||
{
|
||||
|
|
|
@ -14,7 +14,7 @@ var
|
|||
Globals = require('Common/Globals'),
|
||||
Events = require('Common/Events'),
|
||||
Links = require('Common/Links'),
|
||||
HtmlEditor = require('Common/HtmlEditor'),
|
||||
HtmlEditor = require('Common/HtmlEditor').default,
|
||||
|
||||
Translator = require('Common/Translator'),
|
||||
Momentor = require('Common/Momentor'),
|
||||
|
|
|
@ -6,7 +6,7 @@ var
|
|||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
Translator = require('Common/Translator'),
|
||||
HtmlEditor = require('Common/HtmlEditor'),
|
||||
HtmlEditor = require('Common/HtmlEditor').default,
|
||||
|
||||
Remote = require('Remote/User/Ajax'),
|
||||
|
||||
|
|
87
gulpfile.js
87
gulpfile.js
|
@ -33,6 +33,9 @@ var
|
|||
path = require('path'),
|
||||
notifier = require('node-notifier'),
|
||||
|
||||
webpack = require('webpack'),
|
||||
webpackCfg = require('./webpack.config.js'),
|
||||
|
||||
gulp = require('gulp'),
|
||||
concat = require('gulp-concat-util'),
|
||||
header = require('gulp-header'),
|
||||
|
@ -50,6 +53,38 @@ var
|
|||
gutil = require('gulp-util')
|
||||
;
|
||||
|
||||
// webpack
|
||||
if (webpackCfg && webpackCfg.output)
|
||||
{
|
||||
webpackCfg.output.publicPath = cfg.paths.staticJS;
|
||||
}
|
||||
|
||||
if (webpackCfg && webpackCfg.plugins)
|
||||
{
|
||||
webpackCfg.plugins.push(new webpack.DefinePlugin({
|
||||
'RL_COMMUNITY': !!cfg.community,
|
||||
'process.env': {
|
||||
NODE_ENV: '"production"'
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
function webpackError(err) {
|
||||
if (err)
|
||||
{
|
||||
gutil.log('[webpack]', '---');
|
||||
gutil.log('[webpack]', err.error ? err.error.toString() : '');
|
||||
gutil.log('[webpack]', err.message || '');
|
||||
gutil.log('[webpack]', '---');
|
||||
|
||||
notifier.notify({
|
||||
'sound': true,
|
||||
'title': 'webpack',
|
||||
'message': err.error ? err.error.toString() : err.message
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function getHead()
|
||||
{
|
||||
return !cfg.community ? head.rainloop : head.agpl;
|
||||
|
@ -330,67 +365,25 @@ gulp.task('js:ckeditor:beautify', function() {
|
|||
.pipe(gulp.dest(cfg.paths.static + 'ckeditor/'));
|
||||
});
|
||||
|
||||
gulp.task('js:webpack', [], function(callback) {
|
||||
|
||||
var
|
||||
webpack = require('webpack'),
|
||||
webpackCfg = require('./webpack.config.js')
|
||||
;
|
||||
|
||||
if (webpackCfg && webpackCfg.output)
|
||||
{
|
||||
webpackCfg.output.publicPath = cfg.paths.staticJS;
|
||||
}
|
||||
|
||||
if (webpackCfg && webpackCfg.plugins)
|
||||
{
|
||||
webpackCfg.plugins.push(new webpack.DefinePlugin({
|
||||
'RL_COMMUNITY': !!cfg.community,
|
||||
'process.env': {
|
||||
NODE_ENV: '"production"'
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
gulp.task('js:webpack', function(callback) {
|
||||
webpack(webpackCfg, function(err, stats) {
|
||||
|
||||
var
|
||||
fN = function (err) {
|
||||
if (err)
|
||||
{
|
||||
gutil.log('[webpack]', '---');
|
||||
gutil.log('[webpack]', err.error ? err.error.toString() : '');
|
||||
gutil.log('[webpack]', err.message || '');
|
||||
gutil.log('[webpack]', '---');
|
||||
|
||||
notifier.notify({
|
||||
'sound': true,
|
||||
'title': 'webpack',
|
||||
'message': err.error ? err.error.toString() : err.message
|
||||
});
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
if (err)
|
||||
if (err)
|
||||
{
|
||||
if (cfg.watch)
|
||||
{
|
||||
fN(err);
|
||||
webpackError(err);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new gutil.PluginError('webpack', err);
|
||||
}
|
||||
}
|
||||
else if (stats && stats.compilation && stats.compilation.errors &&
|
||||
stats.compilation.errors[0])
|
||||
else if (stats && stats.compilation && stats.compilation.errors && stats.compilation.errors[0])
|
||||
{
|
||||
if (cfg.watch)
|
||||
{
|
||||
_.each(stats.compilation.errors, function (err) {
|
||||
fN(err);
|
||||
});
|
||||
_.each(stats.compilation.errors, webpackError);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue