mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 23:40:13 +01:00
Enforce a consistent ES6 coding style
Replace the old (and broken) jshint + jscsrc by eslint and configure it to support some of the ES6 features. The command `eslint` currently has one error which is a bug that was discovered by its static analysis and should be fixed (usage of a dead object).
This commit is contained in:
parent
039cfe7edf
commit
b3851817ec
60 changed files with 1604 additions and 1692 deletions
|
|
@ -1,7 +1,7 @@
|
|||
var dropdownMenuIsOpened = false;
|
||||
let dropdownMenuIsOpened = false;
|
||||
|
||||
Template.editor.onRendered(function() {
|
||||
var $textarea = this.$('textarea');
|
||||
Template.editor.onRendered(() => {
|
||||
const $textarea = this.$('textarea');
|
||||
|
||||
autosize($textarea);
|
||||
|
||||
|
|
@ -9,39 +9,40 @@ Template.editor.onRendered(function() {
|
|||
// Emojies
|
||||
{
|
||||
match: /\B:([\-+\w]*)$/,
|
||||
search: function(term, callback) {
|
||||
callback($.map(Emoji.values, function(emoji) {
|
||||
search(term, callback) {
|
||||
callback($.map(Emoji.values, (emoji) => {
|
||||
return emoji.indexOf(term) === 0 ? emoji : null;
|
||||
}));
|
||||
},
|
||||
template: function(value) {
|
||||
var image = '<img src="' + Emoji.baseImagePath + value + '.png"></img>';
|
||||
template(value) {
|
||||
const imgSrc = Emoji.baseImagePath + value;
|
||||
const image = `<img src="${imgSrc}.png" />`;
|
||||
return image + value;
|
||||
},
|
||||
replace: function(value) {
|
||||
return ':' + value + ':';
|
||||
replace(value) {
|
||||
return `:${value}:`;
|
||||
},
|
||||
index: 1
|
||||
index: 1,
|
||||
},
|
||||
|
||||
// User mentions
|
||||
{
|
||||
match: /\B@(\w*)$/,
|
||||
search: function(term, callback) {
|
||||
var currentBoard = Boards.findOne(Session.get('currentBoard'));
|
||||
callback($.map(currentBoard.members, function(member) {
|
||||
var username = Users.findOne(member.userId).username;
|
||||
search(term, callback) {
|
||||
const currentBoard = Boards.findOne(Session.get('currentBoard'));
|
||||
callback($.map(currentBoard.members, (member) => {
|
||||
const username = Users.findOne(member.userId).username;
|
||||
return username.indexOf(term) === 0 ? username : null;
|
||||
}));
|
||||
},
|
||||
template: function(value) {
|
||||
template(value) {
|
||||
return value;
|
||||
},
|
||||
replace: function(username) {
|
||||
return '@' + username + ' ';
|
||||
replace(username) {
|
||||
return `@${username} `;
|
||||
},
|
||||
index: 1
|
||||
}
|
||||
index: 1,
|
||||
},
|
||||
]);
|
||||
|
||||
// Since commit d474017 jquery-textComplete automatically closes a potential
|
||||
|
|
@ -51,27 +52,27 @@ Template.editor.onRendered(function() {
|
|||
// 'open' and 'hide' events, and create a ghost escapeAction when the dropdown
|
||||
// is opened (and rely on textComplete to execute the actual action).
|
||||
$textarea.on({
|
||||
'textComplete:show': function() {
|
||||
'textComplete:show'() {
|
||||
dropdownMenuIsOpened = true;
|
||||
},
|
||||
'textComplete:hide': function() {
|
||||
Tracker.afterFlush(function() {
|
||||
'textComplete:hide'() {
|
||||
Tracker.afterFlush(() => {
|
||||
dropdownMenuIsOpened = false;
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
EscapeActions.register('textcomplete',
|
||||
function() {},
|
||||
function() { return dropdownMenuIsOpened; }
|
||||
() => {},
|
||||
() => dropdownMenuIsOpened
|
||||
);
|
||||
|
||||
Template.viewer.events({
|
||||
// Viewer sometimes have click-able wrapper around them (for instance to edit
|
||||
// the corresponding text). Clicking a link shouldn't fire these actions, stop
|
||||
// we stop these event at the viewer component level.
|
||||
'click a': function(evt) {
|
||||
'click a'(evt) {
|
||||
evt.stopPropagation();
|
||||
|
||||
// XXX We hijack the build-in browser action because we currently don't have
|
||||
|
|
@ -79,7 +80,7 @@ Template.viewer.events({
|
|||
// handled by a third party package that we can't configure easily. Fix that
|
||||
// by using directly `_blank` attribute in the rendered HTML.
|
||||
evt.preventDefault();
|
||||
let href = evt.currentTarget.href;
|
||||
const href = evt.currentTarget.href;
|
||||
window.open(href, '_blank');
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue