33c36db157884a27c6557ec816985dfa55675757 hiram Wed Oct 5 22:12:02 2022 -0700 add onclick function to buttons of class copyLink no redmine diff --git src/hg/js/hgGateway.js src/hg/js/hgGateway.js index a83eeac..e9c5bbd 100644 --- src/hg/js/hgGateway.js +++ src/hg/js/hgGateway.js @@ -18,30 +18,38 @@ // slider bar to the left of the phylogenetic tree container. // hgGateway: module of mostly view/controller code (model state comes directly from server). // Globals (pragma for jshint): /* globals dbDbTree, activeGenomes, surveyLink, surveyLabel, surveyLabelImage, cart */ /* globals autoCompleteCat */ /* globals calculateHgTracksWidth */ // function is defined in utils.js window.hgsid = ''; window.activeGenomes = {}; window.surveyLink=null; window.surveyLabel=null; window.surveyLabelImage=null; +function setCopyLinks() { + // add onclick to class 'copyLink' buttons, there could be more than one. + buttons = document.getElementsByClassName('copyLink'); + addOnClick = function(){copyToClipboard(event);}; + for (i = 0; i < buttons.length; i++) { + buttons[i].onclick = addOnClick; + } +} function svgCreateEl(type, config) { // Helper function for creating a new SVG element and initializing its // properties and attributes. Type is something like 'rect', 'text', 'g', etc; // config is an object like { id: 'newThingie', x: 0, y: 10, title: 'blah blah' }. var svgns = 'http://www.w3.org/2000/svg'; var xlinkns = 'http://www.w3.org/1999/xlink'; var el = document.createElementNS(svgns, type); var title, titleEl; if (el) { _.forEach(config, function(value, setting) { if (setting === 'textContent') { // Text content (the text in a text element or title element) is a property: el.textContent = value; } else if (setting === 'href') { @@ -1173,30 +1181,31 @@ $table.removeAttr('height'); } } function updateDescription(description) { // We got the contents of a db's description.html -- tweak its format to fit // the new design. $('#descriptionText').html(description); tweakDescriptionPhotoWidth(); // Apply JWest formatting to all anchors in description. // We can't simply style all tags that way because autocomplete uses 's. $('#descriptionText a').addClass('jwAnchor'); // Apply square bullet style to all ul's in description. $('#descriptionText ul').addClass('jwNoBullet'); $('#descriptionText li').addClass('jwSquareBullet'); + setCopyLinks(); } function initFindPositionContents() { // Unhide contents of Find Position section and adjust layout. $('#findPositionContents').show(); // Set assembly menu's width to same as position input. var posWidth = $('#positionInput').outerWidth(); var $select = $('#selectAssembly'); $select.outerWidth(posWidth); // For some reason, it doesn't set it to posWidth, it sets it to posWidth-2... // detect and adjust. var weirdDiff = posWidth - $select.outerWidth(); if (weirdDiff) { $select.outerWidth(posWidth + weirdDiff); }