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/boards/boardBody.js | 92 +++++++++++++++++------------------ 1 file changed, 46 insertions(+), 46 deletions(-) (limited to 'client/components/boards/boardBody.js') diff --git a/client/components/boards/boardBody.js b/client/components/boards/boardBody.js index fd9ee6bc..980a9015 100644 --- a/client/components/boards/boardBody.js +++ b/client/components/boards/boardBody.js @@ -1,11 +1,11 @@ -var subManager = new SubsManager(); +const subManager = new SubsManager(); BlazeComponent.extendComponent({ - template: function() { + template() { return 'board'; }, - onCreated: function() { + onCreated() { this.draggingActive = new ReactiveVar(false); this.showOverlay = new ReactiveVar(false); this.isBoardReady = new ReactiveVar(false); @@ -15,15 +15,15 @@ BlazeComponent.extendComponent({ // XXX The boardId should be readed from some sort the component "props", // unfortunatly, Blaze doesn't have this notion. this.autorun(() => { - let currentBoardId = Session.get('currentBoard'); - if (! currentBoardId) + const currentBoardId = Session.get('currentBoard'); + if (!currentBoardId) return; - var handle = subManager.subscribe('board', currentBoardId); + const handle = subManager.subscribe('board', currentBoardId); Tracker.nonreactive(() => { Tracker.autorun(() => { this.isBoardReady.set(handle.ready()); - }) - }) + }); + }); }); this._isDragging = false; @@ -33,52 +33,52 @@ BlazeComponent.extendComponent({ this.mouseHasEnterCardDetails = false; }, - openNewListForm: function() { + openNewListForm() { this.componentChildren('addListForm')[0].open(); }, // XXX Flow components allow us to avoid creating these two setter methods by // exposing a public API to modify the component state. We need to investigate // best practices here. - setIsDragging: function(bool) { + setIsDragging(bool) { this.draggingActive.set(bool); }, - scrollLeft: function(position = 0) { + scrollLeft(position = 0) { this.$('.js-lists').animate({ - scrollLeft: position + scrollLeft: position, }); }, - currentCardIsInThisList: function() { - var currentCard = Cards.findOne(Session.get('currentCard')); - var listId = this.currentData()._id; + currentCardIsInThisList() { + const currentCard = Cards.findOne(Session.get('currentCard')); + const listId = this.currentData()._id; return currentCard && currentCard.listId === listId; }, - events: function() { + events() { return [{ // XXX The board-overlay div should probably be moved to the parent // component. - 'mouseenter .board-overlay': function() { + 'mouseenter .board-overlay'() { if (this.mouseHasEnterCardDetails) { this.showOverlay.set(false); } }, // Click-and-drag action - 'mousedown .board-canvas': function(evt) { + 'mousedown .board-canvas'(evt) { if ($(evt.target).closest('a,.js-list-header').length === 0) { this._isDragging = true; this._lastDragPositionX = evt.clientX; } }, - 'mouseup': function(evt) { + 'mouseup'() { if (this._isDragging) { this._isDragging = false; } }, - 'mousemove': function(evt) { + 'mousemove'(evt) { if (this._isDragging) { // Update the canvas position this.listsDom.scrollLeft -= evt.clientX - this._lastDragPositionX; @@ -91,40 +91,40 @@ BlazeComponent.extendComponent({ EscapeActions.executeUpTo('popup-close'); EscapeActions.preventNextClick(); } - } + }, }]; - } + }, }).register('board'); Template.boardBody.onRendered(function() { - var self = BlazeComponent.getComponentForElement(this.firstNode); + const self = BlazeComponent.getComponentForElement(this.firstNode); self.listsDom = this.find('.js-lists'); - if (! Session.get('currentCard')) { + if (!Session.get('currentCard')) { self.scrollLeft(); } // We want to animate the card details window closing. We rely on CSS // transition for the actual animation. self.listsDom._uihooks = { - removeElement: function(node) { - var removeNode = _.once(function() { + removeElement(node) { + const removeNode = _.once(() => { node.parentNode.removeChild(node); }); if ($(node).hasClass('js-card-details')) { $(node).css({ flexBasis: 0, - padding: 0 + padding: 0, }); $(self.listsDom).one(CSSEvents.transitionend, removeNode); } else { removeNode(); } - } + }, }; - if (! Meteor.user() || ! Meteor.user().isBoardMember()) + if (!Meteor.user() || !Meteor.user().isBoardMember()) return; self.$(self.listsDom).sortable({ @@ -134,63 +134,63 @@ Template.boardBody.onRendered(function() { items: '.js-list:not(.js-list-composer)', placeholder: 'list placeholder', distance: 7, - start: function(evt, ui) { + start(evt, ui) { ui.placeholder.height(ui.helper.height()); Popup.close(); }, - stop: function() { + stop() { self.$('.js-lists').find('.js-list:not(.js-list-composer)').each( - function(i, list) { - var data = Blaze.getData(list); + (i, list) => { + const data = Blaze.getData(list); Lists.update(data._id, { $set: { - sort: i - } + sort: i, + }, }); } ); - } + }, }); // Disable drag-dropping while in multi-selection mode - self.autorun(function() { + self.autorun(() => { self.$(self.listsDom).sortable('option', 'disabled', MultiSelection.isActive()); }); // If there is no data in the board (ie, no lists) we autofocus the list // creation form by clicking on the corresponding element. - var currentBoard = Boards.findOne(Session.get('currentBoard')); + const currentBoard = Boards.findOne(Session.get('currentBoard')); if (currentBoard.lists().count() === 0) { self.openNewListForm(); } }); BlazeComponent.extendComponent({ - template: function() { + template() { return 'addListForm'; }, // Proxy - open: function() { + open() { this.componentChildren('inlinedForm')[0].open(); }, - events: function() { + events() { return [{ - submit: function(evt) { + submit(evt) { evt.preventDefault(); - var title = this.find('.list-name-input'); + const title = this.find('.list-name-input'); if ($.trim(title.value)) { Lists.insert({ title: title.value, boardId: Session.get('currentBoard'), - sort: $('.list').length + sort: $('.list').length, }); title.value = ''; } - } + }, }]; - } + }, }).register('addListForm'); -- cgit v1.2.3-1-g7c22