From b3851817ecd59b039f2c2228d08a1c6fd8e60d60 Mon Sep 17 00:00:00 2001 From: Maxime Quandalle Date: Thu, 3 Sep 2015 23:12:46 +0200 Subject: 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). --- client/components/main/editor.js | 57 ++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 28 deletions(-) (limited to 'client/components/main/editor.js') diff --git a/client/components/main/editor.js b/client/components/main/editor.js index 7966ff60..c34539b3 100644 --- a/client/components/main/editor.js +++ b/client/components/main/editor.js @@ -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 = ''; + template(value) { + const imgSrc = Emoji.baseImagePath + value; + const image = ``; 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'); - } + }, }); -- cgit v1.2.3-1-g7c22