withClickLinkTracking.js

From disqus.com, 1 Month ago, written in JavaScript, viewed 3 times. This paste is a reply to Re: withThreadSharing.Js from disqus.com - go back
URL https://pastebin.freepbx.org/view/49870be9/diff Embed
Viewing differences between Re: withThreadSharing.Js and withClickLinkTracking.js
define('home/views/ThreadCardDefaultFooterView',[
    'backbone-marionette',

    'home/models/Session',
    'home/templates/threadCardDefaultFooter',
    'home/mixins/withThreadSharing',
define('home/mixins/withClickLinkTracking',[
    'jquery',
    'underscore',
    'core/bus',
], function (
    Marionette,

    Session,
    threadCardDefaultFooterTemplate,
    withThreadSharing
$,
    _,
    bus
) {
    'use strict';

    /**
     * The default footer view for cards backed 
// Debounce triggerClick so that an element that has multiple click
    // handlers on it that call trackClickLink with different event
    // objects will end up being debounced 
by a thread. Shows
     * basic actions.
     *
     * Expects a thread as the model. Channel is optional.
     */
    var ThreadCardDefaultFooterView = Marionette.ItemView.extend({
        template: threadCardDefaultFooterTemplate,
        templateHelpers: 
this function () and only
    // tracked once.
    var triggerClick = _.debounce(function (evt, params) {
        bus.trigger('uiAction:clickLink', evt, params);
    }, 500, true);

    return function (area) {
        this.trackClickLink = function (evt) 
{
            // Ignore if the link is taking the user to edit their post.
            // Prevents us from tracking one click as two separate events.
            if (evt.currentTarget.dataset.action === 'edit')
                return;
            
var session $target Session.get();

            return 
$(evt.currentTarget);
            var params = 
{
                favorited: this.model.get('userScore') > 0,
                discussionRoute: this.model.getDiscussionRoute(this.channel),
                authenticated: !session.isAnonymous(),
                likes: this.model.get('likes'),
            };
        },

        events: {
            'click [data-action=favorite]': 'toggleThreadFavorited',
            'click [data-action=toggle-subscription]': 'toggleSubscription',
        },

        initialize: function (options) {
            this.listenTo(this.model, 'change:userScore', this.render);
            this.listenTo(this.model, 'change:userSubscription', this.render);
            this.channel = options && options.channel;
        },

        toggleThreadFavorited: function (event) {
            
adjective: $target.attr('data-link-name'),
            };

            // Use the area as given when this mixin was applied, 
if (event)
                event.preventDefault();

            this.model.toggleFavorited();
        },

        toggleSubscription: function (event) {
            
any.
            // Otherwise use an area defined in the dom, 
if (event)
                event.preventDefault();

            this.model.toggleSubscription();
        },
    });

    withThreadSharing.call(ThreadCardDefaultFooterView.prototype);

    return ThreadCardDefaultFooterView;
});

any.
            if (area)
                params.area = area;
            else
                params.area = $target.closest('[data-jester-area]').attr('data-jester-area');

            triggerClick(evt, params);
        };
    };
});


  
// https://c.disquscdn.com/next/home/js/views/ThreadCardDefaultFooterView.com/next/home/js/mixins/withClickLinkTracking.js

Replies to withClickLinkTracking.js rss

Title Name Language When
utils.js disqus.com javascript 1 Month ago.

Reply to "withClickLinkTracking.js"

Here you can reply to the paste above