Re: forum.js

From disqus.com, 2 Months ago, written in JavaScript, viewed 3 times. This paste is a reply to Re: forum.js from Chartreuse Guinea Pig - view diff
URL https://pastebin.freepbx.org/view/a7696f81 Embed
Download Paste or View Raw
  1. define('core/models/Forum',[
  2.     'backbone',
  3.  
  4.     'core/UniqueModel',
  5.     'core/api',
  6. ], function (
  7.     Backbone,
  8.  
  9.     UniqueModel,
  10.     api
  11. ) {
  12.     'use strict';
  13.  
  14.     var Forum = Backbone.Model.extend({
  15.         defaults: {
  16.             settings: {},
  17.             followUrl: 'forums/follow',
  18.             unfollowUrl: 'forums/unfollow',
  19.             isFollowing: false,
  20.         },
  21.  
  22.         initialize: function (_attributes, options) {
  23.             if (options && options.channel)
  24.                 this.channel = options.channel;
  25.  
  26.             this.getFeatures();
  27.             this.on('change:id', this.getFeatures);
  28.         },
  29.  
  30.         _changeFollowingState: function (path) {
  31.             return api.call(path, {
  32.                 method: 'POST',
  33.                 data: {
  34.                     target: this.get('id'),
  35.                 },
  36.             });
  37.         },
  38.  
  39.         follow: function () {
  40.             this.set('isFollowing', true);
  41.  
  42.             return this._changeFollowingState(this.get('followUrl'));
  43.         },
  44.  
  45.         unfollow: function () {
  46.             this.set('isFollowing', false);
  47.  
  48.             return this._changeFollowingState(this.get('unfollowUrl'));
  49.         },
  50.  
  51.         toggleFollowed: function () {
  52.             if (this.channel && this.channel.get('options').isCurationOnlyChannel)
  53.                 return this.channel.toggleFollowed();
  54.  
  55.             var retval = this.get('isFollowing') ?
  56.                 this.unfollow() :
  57.                 this.follow();
  58.  
  59.             this.trigger('toggled:isFollowing');
  60.  
  61.             return retval;
  62.         },
  63.  
  64.         // This api call lets us see what features are enabled for a forum. There are
  65.         // a couple of features that require us to check if the feature is enabled
  66.         // at an org level in addition to (or instead of) at the forum level.
  67.         //
  68.         // It checks to make sure that we have a forum id, which all forums should have.
  69.         // The only time we don't have a forum id should be when initializing
  70.         // the forum in the embed. We don't need to worry about the forum changing
  71.         // because when that happens the embed has to have reloaded as well.
  72.         getFeatures: function () {
  73.             var self = this;
  74.             if (self.id) {
  75.                 api.call('forums/details', {
  76.                     data: {
  77.                         forum: this.id,
  78.                         attach: 'forumFeatures',
  79.                     },
  80.                     success: function (response) {
  81.                         if (response && response.response)
  82.                             self.set('features', response.response.features);
  83.                     },
  84.                 });
  85.             }
  86.         },
  87.     });
  88.  
  89.     UniqueModel.addType('Forum', Forum);
  90.  
  91.     return Forum;
  92. });
  93.  
  94. // https://c.disquscdn.com/next/next-core/core/models/Forum.js

Replies to Re: forum.js rss

Title Name Language When
Re: mediaconfig.js disqus.com javascript 2 Months ago.

Reply to "Re: forum.js"

Here you can reply to the paste above