Re: withClickLinkTracking.js

From disqus.com, 2 Months ago, written in JavaScript, viewed 3 times. This paste is a reply to withClickLinkTracking.js from disqus.com - view diff
URL https://pastebin.freepbx.org/view/979f741d Embed
Download Paste or View Raw
  1. define('home/mixins/withClickLinkTracking',[
  2.     'jquery',
  3.     'underscore',
  4.     'core/bus',
  5. ], function (
  6.     $,
  7.     _,
  8.     bus
  9. ) {
  10.     'use strict';
  11.  
  12.     // Debounce triggerClick so that an element that has multiple click
  13.     // handlers on it that call trackClickLink with different event
  14.     // objects will end up being debounced by this function and only
  15.     // tracked once.
  16.     var triggerClick = _.debounce(function (evt, params) {
  17.         bus.trigger('uiAction:clickLink', evt, params);
  18.     }, 500, true);
  19.  
  20.     return function (area) {
  21.         this.trackClickLink = function (evt) {
  22.             // Ignore if the link is taking the user to edit their post.
  23.             // Prevents us from tracking one click as two separate events.
  24.             if (evt.currentTarget.dataset.action === 'edit')
  25.                 return;
  26.             var $target = $(evt.currentTarget);
  27.             var params = {
  28.                 adjective: $target.attr('data-link-name'),
  29.             };
  30.  
  31.             // Use the area as given when this mixin was applied, if any.
  32.             // Otherwise use an area defined in the dom, if any.
  33.             if (area)
  34.                 params.area = area;
  35.             else
  36.                 params.area = $target.closest('[data-jester-area]').attr('data-jester-area');
  37.  
  38.             triggerClick(evt, params);
  39.         };
  40.     };
  41. });
  42.  
  43. // https://c.disquscdn.com/next/home/js/mixins/withClickLinkTracking.js

Replies to Re: withClickLinkTracking.js rss

Title Name Language When
dropdown.js disqus.com javascript 2 Months ago.

Reply to "Re: withClickLinkTracking.js"

Here you can reply to the paste above