withClickLinkTracking.js

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

Replies to withClickLinkTracking.js rss

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

Reply to "withClickLinkTracking.js"

Here you can reply to the paste above