1(function ($, Drupal) { 2 'use strict'; 3 4 /** 5 * Scrolls the document to the said position. 6 * 7 * @param options 8 * Object specifying various options. 9 * 10 * "y" position 11 * "context" document context from drupal behaviors. 12 */ 13 function stReferencesScrollTo(options) { 14 // To ensure some gap between the top and the element. 15 var exPad = 15; 16 var navBar = $('#navbar', options.context).length ? $('#navbar', options.context).height() : 0; 17 var toolBar = $('#toolbar-bar', options.context).length ? $('#toolbar-bar', options.context).height() : 0; 18 var toolBarAdminTray = $('#toolbar-item-administration-tray', options.context).length ? $('#toolbar-item-administration-tray', options.context).height() : 0; 19 var yFix = parseInt(0 - exPad - navBar - toolBar - toolBarAdminTray); 20 // Determine final y offsets. 21 var y = parseInt(options.y) + yFix; 22 $('html, body', options.context).animate({ 23 scrollTop: y 24 }, 500); 25 }; 26 27 /** 28 * Listen for anchors links & scroll to anchor in the references component. 29 * 30 * @type {Drupal~behavior} 31 */ 32 Drupal.behaviors.stReferences = { 33 attach: function (context) { 34 var anchors = $('.site-studio-page.full a[href^="#"]', context); 35 anchors.click(function(e) { 36 var target = $('.coh-style-references-accordion---wrapper ' + this.getAttribute('href') + ':not(.coh-accordion-tabs-content)'); 37 if (target.length) { 38 e.preventDefault(); 39 var accordion = target.closest('.coh-style-references-accordion---wrapper', context); 40 accordion.find('.coh-accordion-title:not(.is-active) a').click(); 41 42 stReferencesScrollTo({ 43 x: target.offset().left, 44 y: target.offset().top, 45 context: context, 46 }); 47 } 48 }); 49 } 50 }; 51})(jQuery, Drupal);
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.