123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- BlazeComponent.extendComponent({
- template: function() {
- return 'cardSidebar';
- },
- mixins: function() {
- return [Mixins.InfiniteScrolling];
- },
- calculateNextPeak: function() {
- var altitude = this.find('.js-card-sidebar-content').scrollHeight;
- this.callFirstWith(this, 'setNextPeak', altitude);
- },
- reachNextPeak: function() {
- var activitiesComponent = this.componentChildren('activities')[0];
- activitiesComponent.loadNextPage();
- },
- events: function() {
- return [{
- 'click .js-move-card': Popup.open('moveCard'),
- 'submit .js-card-description': function(evt) {
- evt.preventDefault();
- var cardId = Session.get('currentCard');
- var form = this.componentChildren('inlinedForm')[0];
- var newDescription = form.getValue();
- Cards.update(cardId, {
- $set: {
- description: newDescription
- }
- });
- form.close();
- },
- 'click .js-close-card-detail': function() {
- Utils.goBoardId(Session.get('currentBoard'));
- },
- 'click .editable .js-card-title': function(event, t) {
- var editable = t.$('.card-detail-title');
- // add class editing and focus
- $('.editing').removeClass('editing');
- editable.addClass('editing');
- editable.find('#title').focus();
- },
- 'click .js-edit-desc': function(event, t) {
- var editable = t.$('.card-detail-item');
- // editing remove based and add current editing.
- $('.editing').removeClass('editing');
- editable.addClass('editing');
- editable.find('#desc').focus();
- event.preventDefault();
- },
- 'click .js-cancel-edit': function(event, t) {
- // remove editing hide.
- $('.editing').removeClass('editing');
- },
- 'submit #WindowTitleEdit': function(event, t) {
- var title = t.find('#title').value;
- if ($.trim(title)) {
- Cards.update(this.card._id, {
- $set: {
- title: title
- }
- }, function (err, res) {
- if (!err) $('.editing').removeClass('editing');
- });
- }
- event.preventDefault();
- },
- 'submit #WindowDescEdit': function(event, t) {
- Cards.update(this.card._id, {
- $set: {
- description: t.find('#desc').value
- }
- }, function(err) {
- if (!err) $('.editing').removeClass('editing');
- });
- event.preventDefault();
- },
- 'click .member': Popup.open('cardMember'),
- 'click .js-details-edit-members': Popup.open('cardMembers'),
- 'click .js-details-edit-labels': Popup.open('cardLabels')
- }];
- }
- }).register('cardSidebar');
- Template.moveCardPopup.events({
- 'click .js-select-list': function() {
- // XXX We should *not* get the currentCard from the global state, but
- // instead from a “component” state.
- var cardId = Session.get('currentCard');
- var newListId = this._id;
- Cards.update(cardId, {
- $set: {
- listId: newListId
- }
- });
- }
- });
|