{"version":3,"file":"src_stimulus_controllers_dynamic_attribute_controller_ts.99e79fb2b1616f0b.js","mappings":"+NAiCc,MAAOA,4BAA4BC,EAAAA,UACxC,KAAAC,QAAU,CACf,eACA,YACA,QAEK,KAAAC,OAAS,CACdC,sBAAuB,CAAEC,KAAMC,OAAQC,QAAS,WAChD,CAOFC,8BAAAA,CAA+BC,GACzBC,KAAKC,YAAYF,KACnBC,KAAKE,2BACLF,KAAKG,cAAcH,KAAKI,iBACxBJ,KAAKG,cAAcH,KAAKK,oBAE5B,CAOQJ,WAAAA,CAAYK,GAClB,OAAQA,EAAEC,YAAcP,KAAKI,gBAAgBG,YAAeD,EAAEE,aACzDF,EAAEG,aAAeH,EAAEI,YAC1B,CAOQR,wBAAAA,GACN,MAAMS,EAAsBC,SAASC,eAAeb,KAAKc,4BACzD,GAAIH,EAAqB,CACvB,MAAMI,EAAkBC,OAAOC,iBAAiBN,GAAqBI,gBACrEf,KAAKI,gBAAgBc,MAAMH,gBAAkBA,EAC7Cf,KAAKI,gBAAgBe,UAAUC,OAAO,SACxC,CACF,CAEQjB,aAAAA,CAAcJ,GACpBA,EAAQoB,UAAUC,OAAO,SAC3B,E","sources":["./src/stimulus/controllers/dynamic/attribute.controller.ts"],"sourcesContent":["/*\n * -- copyright\n * OpenProject is an open source project management software.\n * Copyright (C) the OpenProject GmbH\n *\n * This program is free software; you can redistribute it and/or\n * modify it under the terms of the GNU General Public License version 3.\n *\n * OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:\n * Copyright (C) 2006-2013 Jean-Philippe Lang\n * Copyright (C) 2010-2013 the ChiliProject Team\n *\n * This program is free software; you can redistribute it and/or\n * modify it under the terms of the GNU General Public License\n * as published by the Free Software Foundation; either version 2\n * of the License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program; if not, write to the Free Software\n * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n *\n * See COPYRIGHT and LICENSE files for more details.\n * ++\n *\n */\n\nimport { Controller } from '@hotwired/stimulus';\n\nexport default class AttributeController extends Controller {\n static targets = [\n 'expandButton',\n 'textHider',\n ];\n\n static values = {\n backgroundReferenceId: { type: String, default: 'content' },\n };\n\n declare backgroundReferenceIdValue:string;\n\n declare readonly expandButtonTarget:HTMLButtonElement;\n declare readonly textHiderTarget:HTMLElement;\n\n descriptionTextTargetConnected(element:HTMLParagraphElement) {\n if (this.isEllipssed(element)) {\n this.setBackgroundToReference();\n this.unhideElement(this.textHiderTarget);\n this.unhideElement(this.expandButtonTarget);\n }\n }\n\n // When the displayed field contains a macro only, the ellipsis is being shown all the time,\n // in this case, we should take the textHiderTarget's width into account, otherwise the\n // text will overflow the ellipsis icon. When a text with the exact size of the column is\n // displayed, the textHiderTarget is hidden having the offsedWidth 0. This means we will allow\n // the full width of the column to be used for the text, and not truncate it unnecessarily.\n private isEllipssed(e:HTMLElement) {\n return (e.offsetWidth - this.textHiderTarget.offsetWidth) < e.scrollWidth\n || e.offsetHeight < e.scrollHeight;\n }\n\n // Sets the background of the text hider element (the one below the expand button) to the background of the reference.\n // That reference by default is the `#content` element. This is necessary so that the text hider can actually lay on top\n // of the text and hide it without being obvious. It would have been sufficient to just use the button element for this\n // if that button were not using a background color with an 0.2 alpha value. Without the text hider, the text would\n // shine through.\n private setBackgroundToReference() {\n const backgroundReference = document.getElementById(this.backgroundReferenceIdValue);\n if (backgroundReference) {\n const backgroundColor = window.getComputedStyle(backgroundReference).backgroundColor;\n this.textHiderTarget.style.backgroundColor = backgroundColor;\n this.textHiderTarget.classList.remove('d-none');\n }\n }\n\n private unhideElement(element:HTMLElement) {\n element.classList.remove('d-none');\n }\n}\n"],"names":["AttributeController","Controller","targets","values","backgroundReferenceId","type","String","default","descriptionTextTargetConnected","element","this","isEllipssed","setBackgroundToReference","unhideElement","textHiderTarget","expandButtonTarget","e","offsetWidth","scrollWidth","offsetHeight","scrollHeight","backgroundReference","document","getElementById","backgroundReferenceIdValue","backgroundColor","window","getComputedStyle","style","classList","remove"],"sourceRoot":"webpack:///","x_google_ignoreList":[]}