Re: withThreadSharing.Js

From disqus.com, 5 Days ago, written in JavaScript, viewed 3 times. This paste is a reply to withThreadSharing.Js from disqus.com - view diff
URL https://pastebin.freepbx.org/view/ea541186 Embed
Download Paste or View Raw
  1. define('home/views/ThreadCardDefaultFooterView',[
  2.     'backbone-marionette',
  3.  
  4.     'home/models/Session',
  5.     'home/templates/threadCardDefaultFooter',
  6.     'home/mixins/withThreadSharing',
  7. ], function (
  8.     Marionette,
  9.  
  10.     Session,
  11.     threadCardDefaultFooterTemplate,
  12.     withThreadSharing
  13. ) {
  14.     'use strict';
  15.  
  16.     /**
  17.      * The default footer view for cards backed by a thread. Shows
  18.      * basic actions.
  19.      *
  20.      * Expects a thread as the model. Channel is optional.
  21.      */
  22.     var ThreadCardDefaultFooterView = Marionette.ItemView.extend({
  23.         template: threadCardDefaultFooterTemplate,
  24.         templateHelpers: function () {
  25.             var session = Session.get();
  26.  
  27.             return {
  28.                 favorited: this.model.get('userScore') > 0,
  29.                 discussionRoute: this.model.getDiscussionRoute(this.channel),
  30.                 authenticated: !session.isAnonymous(),
  31.                 likes: this.model.get('likes'),
  32.             };
  33.         },
  34.  
  35.         events: {
  36.             'click [data-action=favorite]': 'toggleThreadFavorited',
  37.             'click [data-action=toggle-subscription]': 'toggleSubscription',
  38.         },
  39.  
  40.         initialize: function (options) {
  41.             this.listenTo(this.model, 'change:userScore', this.render);
  42.             this.listenTo(this.model, 'change:userSubscription', this.render);
  43.             this.channel = options && options.channel;
  44.         },
  45.  
  46.         toggleThreadFavorited: function (event) {
  47.             if (event)
  48.                 event.preventDefault();
  49.  
  50.             this.model.toggleFavorited();
  51.         },
  52.  
  53.         toggleSubscription: function (event) {
  54.             if (event)
  55.                 event.preventDefault();
  56.  
  57.             this.model.toggleSubscription();
  58.         },
  59.     });
  60.  
  61.     withThreadSharing.call(ThreadCardDefaultFooterView.prototype);
  62.  
  63.     return ThreadCardDefaultFooterView;
  64. });
  65.  
  66. // https://c.disquscdn.com/next/home/js/views/ThreadCardDefaultFooterView.js

Replies to Re: withThreadSharing.Js rss

Title Name Language When
withClickLinkTracking.js disqus.com javascript 5 Days ago.

Reply to "Re: withThreadSharing.Js"

Here you can reply to the paste above