1(function ($, window, Drupal, drupalSettings) { 2 // Scroll to given element. 3 Drupal.AjaxCommands.prototype.ajaxCommentsScrollToElement = function ( 4 ajax, 5 response, 6 status, 7 ) { 8 try { 9 const pos = $(response.selector).offset(); 10 window.scrollTo({ 11 top: pos.top, 12 behavior: 'smooth', 13 }); 14 } catch (e) { 15 console.log(`ajaxComments-ScrollToElementError: ${e.name}`); 16 } 17 }; 18 19 /** 20 * Add the dummy div if they are not exist. 21 * On the server side we have a current state of node and comments, but on client side we may have a outdated state 22 * and some div's may be not present 23 */ 24 Drupal.AjaxCommands.prototype.ajaxCommentsAddDummyDivAfter = function ( 25 ajax, 26 response, 27 status, 28 ) { 29 try { 30 if (!$(response.selector).next().hasClass(response.class)) { 31 $(`<div class="${response.class}"></div>`).insertAfter( 32 response.selector, 33 ); 34 } 35 } catch (e) { 36 console.log(`ajaxComments-AddDummyDivAfter: ${e.name}`); 37 } 38 }; 39 40 /** 41 * Override and extend the functionality of Drupal.Ajax.prototype.beforeSerialize. 42 */ 43 (function (beforeSerialize) { 44 Drupal.Ajax.prototype.beforeSerialize = function (element, options) { 45 beforeSerialize.call(this, element, options); 46 const wrapperHtmlId = $(element).data('wrapper-html-id') || null; 47 if (wrapperHtmlId) { 48 options.data.wrapper_html_id = wrapperHtmlId; 49 } 50 }; 51 })(Drupal.Ajax.prototype.beforeSerialize); 52})(jQuery, this, Drupal, drupalSettings);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.