summaryrefslogtreecommitdiffstats
path: root/client/components/main
diff options
context:
space:
mode:
Diffstat (limited to 'client/components/main')
-rw-r--r--client/components/main/editor.js57
-rw-r--r--client/components/main/header.js10
-rw-r--r--client/components/main/helpers.js65
-rw-r--r--client/components/main/layouts.js16
-rw-r--r--client/components/main/popup.js20
5 files changed, 52 insertions, 116 deletions
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 = '<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');
- }
+ },
});
diff --git a/client/components/main/header.js b/client/components/main/header.js
index 7b7e431f..30cb2d8f 100644
--- a/client/components/main/header.js
+++ b/client/components/main/header.js
@@ -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'),
});
diff --git a/client/components/main/helpers.js b/client/components/main/helpers.js
deleted file mode 100644
index 91205351..00000000
--- a/client/components/main/helpers.js
+++ /dev/null
@@ -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: '&commat;', 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);
-}));
diff --git a/client/components/main/layouts.js b/client/components/main/layouts.js
index 11a43313..ab62e76a 100644
--- a/client/components/main/layouts.js
+++ b/client/components/main/layouts.js
@@ -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();
+ },
+});
diff --git a/client/components/main/popup.js b/client/components/main/popup.js
index 5fc4e979..ba20a6d3 100644
--- a/client/components/main/popup.js
+++ b/client/components/main/popup.js
@@ -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);
});
- }
+ },
};
});