mirror of
https://github.com/wekan/wekan.git
synced 2026-02-17 21:48:07 +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');
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
Template.header.helpers({
|
||||
// Reactively set the color of the page from the color of the current board.
|
||||
headerTemplate: function() {
|
||||
headerTemplate() {
|
||||
return 'headerBoard';
|
||||
},
|
||||
|
||||
wrappedHeader: function() {
|
||||
return ! Session.get('currentBoard');
|
||||
}
|
||||
wrappedHeader() {
|
||||
return !Session.get('currentBoard');
|
||||
},
|
||||
});
|
||||
|
||||
Template.header.events({
|
||||
'click .js-create-board': Popup.open('createBoard')
|
||||
'click .js-create-board': Popup.open('createBoard'),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,65 +0,0 @@
|
|||
var Helpers = {
|
||||
error: function() {
|
||||
return Session.get('error');
|
||||
},
|
||||
|
||||
toLowerCase: function(text) {
|
||||
return text && text.toLowerCase();
|
||||
},
|
||||
|
||||
toUpperCase: function(text) {
|
||||
return text && text.toUpperCase();
|
||||
},
|
||||
|
||||
firstChar: function(text) {
|
||||
return text && text[0].toUpperCase();
|
||||
},
|
||||
|
||||
session: function(prop) {
|
||||
return Session.get(prop);
|
||||
},
|
||||
|
||||
getUser: function(userId) {
|
||||
return Users.findOne(userId);
|
||||
}
|
||||
};
|
||||
|
||||
// Register all Helpers
|
||||
_.each(Helpers, function(fn, name) { Blaze.registerHelper(name, fn); });
|
||||
|
||||
// XXX I believe we should compute a HTML rendered field on the server that
|
||||
// would handle markdown, emojies and user mentions. We can simply have two
|
||||
// fields, one source, and one compiled version (in HTML) and send only the
|
||||
// compiled version to most users -- who don't need to edit.
|
||||
// In the meantime, all the transformation are done on the client using the
|
||||
// Blaze API.
|
||||
var at = HTML.CharRef({html: '@', str: '@'});
|
||||
Blaze.Template.registerHelper('mentions', new Template('mentions', function() {
|
||||
var view = this;
|
||||
var content = Blaze.toHTML(view.templateContentBlock);
|
||||
var currentBoard = Session.get('currentBoard');
|
||||
var knowedUsers = _.map(currentBoard.members, function(member) {
|
||||
member.username = Users.findOne(member.userId).username;
|
||||
return member;
|
||||
});
|
||||
|
||||
var mentionRegex = /\B@(\w*)/gi;
|
||||
var currentMention, knowedUser, href, linkClass, linkValue, link;
|
||||
while (!! (currentMention = mentionRegex.exec(content))) {
|
||||
|
||||
knowedUser = _.findWhere(knowedUsers, { username: currentMention[1] });
|
||||
if (! knowedUser)
|
||||
continue;
|
||||
|
||||
linkValue = [' ', at, knowedUser.username];
|
||||
href = Router.url('Profile', { username: knowedUser.username });
|
||||
linkClass = 'atMention';
|
||||
if (knowedUser.userId === Meteor.userId())
|
||||
linkClass += ' me';
|
||||
link = HTML.A({ href: href, 'class': linkClass }, linkValue);
|
||||
|
||||
content = content.replace(currentMention[0], Blaze.toHTML(link));
|
||||
}
|
||||
|
||||
return HTML.Raw(content);
|
||||
}));
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
Meteor.subscribe('boards')
|
||||
Meteor.subscribe('boards');
|
||||
|
||||
BlazeLayout.setRoot('body')
|
||||
BlazeLayout.setRoot('body');
|
||||
|
||||
Template.userFormsLayout.onRendered(function() {
|
||||
EscapeActions.executeAll()
|
||||
})
|
||||
Template.userFormsLayout.onRendered(() => {
|
||||
EscapeActions.executeAll();
|
||||
});
|
||||
|
||||
Template.defaultLayout.events({
|
||||
'click .js-close-modal': () => {
|
||||
Modal.close()
|
||||
}
|
||||
})
|
||||
Modal.close();
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
Popup.template.events({
|
||||
'click .js-back-view': function() {
|
||||
'click .js-back-view'() {
|
||||
Popup.back();
|
||||
},
|
||||
'click .js-close-pop-over': function() {
|
||||
'click .js-close-pop-over'() {
|
||||
Popup.close();
|
||||
},
|
||||
'click .js-confirm': function() {
|
||||
'click .js-confirm'() {
|
||||
this.__afterConfirmAction.call(this);
|
||||
},
|
||||
// This handler intends to solve a pretty tricky bug with our popup
|
||||
|
|
@ -18,22 +18,22 @@ Popup.template.events({
|
|||
// in moving the whole popup container outside of the popup wrapper. To
|
||||
// disable this behavior we have to manually reset the scrollLeft position
|
||||
// whenever it is modified.
|
||||
'scroll .content-wrapper': function(evt) {
|
||||
'scroll .content-wrapper'(evt) {
|
||||
evt.currentTarget.scrollLeft = 0;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
// When a popup content is removed (ie, when the user press the "back" button),
|
||||
// we need to wait for the container translation to end before removing the
|
||||
// actual DOM element. For that purpose we use the undocumented `_uihooks` API.
|
||||
Popup.template.onRendered(function() {
|
||||
var container = this.find('.content-container');
|
||||
Popup.template.onRendered(() => {
|
||||
const container = this.find('.content-container');
|
||||
container._uihooks = {
|
||||
removeElement: function(node) {
|
||||
removeElement(node) {
|
||||
$(node).addClass('no-height');
|
||||
$(container).one(CSSEvents.transitionend, function() {
|
||||
$(container).one(CSSEvents.transitionend, () => {
|
||||
node.parentNode.removeChild(node);
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue