summaryrefslogtreecommitdiffstats
path: root/client/components/boards/events.js
diff options
context:
space:
mode:
Diffstat (limited to 'client/components/boards/events.js')
-rw-r--r--client/components/boards/events.js96
1 files changed, 96 insertions, 0 deletions
diff --git a/client/components/boards/events.js b/client/components/boards/events.js
new file mode 100644
index 00000000..6f9d7fc6
--- /dev/null
+++ b/client/components/boards/events.js
@@ -0,0 +1,96 @@
+var toggleBoardStar = function(boardId) {
+ var queryType = Meteor.user().hasStarred(boardId) ? '$pull' : '$addToSet';
+ var query = {};
+ query[queryType] = {
+ 'profile.starredBoards': boardId
+ };
+ Meteor.users.update(Meteor.userId(), query);
+};
+
+Template.boards.events({
+ 'click .js-star-board': function(evt) {
+ toggleBoardStar(this._id);
+ evt.preventDefault();
+ }
+});
+
+Template.headerBoard.events({
+ 'click .js-star-board': function() {
+ toggleBoardStar(this._id);
+ },
+ 'click .js-open-board-menu': Popup.open('boardMenu'),
+ 'click #permission-level:not(.no-edit)': Popup.open('boardChangePermission'),
+ 'click .js-filter-cards-indicator': function(evt) {
+ Session.set('currentWidget', 'filter');
+ evt.preventDefault();
+ },
+ 'click .js-filter-card-clear': function(evt) {
+ Filter.reset();
+ evt.stopPropagation();
+ }
+});
+
+Template.boardMenuPopup.events({
+ 'click .js-rename-board': Popup.open('boardChangeTitle'),
+ 'click .js-change-board-color': Popup.open('boardChangeColor')
+});
+
+Template.createBoardPopup.events({
+ 'submit #CreateBoardForm': function(evt, t) {
+ var title = t.$('#boardNewTitle');
+
+ // trim value title
+ if ($.trim(title.val())) {
+ // İnsert Board title
+ var boardId = Boards.insert({
+ title: title.val(),
+ permission: 'public'
+ });
+
+ // Go to Board _id
+ Utils.goBoardId(boardId);
+ }
+ evt.preventDefault();
+ }
+});
+
+Template.boardChangeTitlePopup.events({
+ 'submit #ChangeBoardTitleForm': function(evt, t) {
+ var title = t.$('.js-board-name').val().trim();
+ if (title) {
+ Boards.update(this._id, {
+ $set: {
+ title: title
+ }
+ });
+ Popup.close();
+ }
+ evt.preventDefault();
+ }
+});
+
+Template.boardChangePermissionPopup.events({
+ 'click .js-select': function(evt) {
+ var $this = $(evt.currentTarget);
+ var permission = $this.attr('name');
+
+ Boards.update(this._id, {
+ $set: {
+ permission: permission
+ }
+ });
+ Popup.close();
+ }
+});
+
+Template.boardChangeColorPopup.events({
+ 'click .js-select-background': function(evt) {
+ var currentBoardId = Session.get('currentBoard');
+ Boards.update(currentBoardId, {
+ $set: {
+ color: this.toString()
+ }
+ });
+ evt.preventDefault();
+ }
+});