{"version":3,"sources":["blocks/a-context-help.js"],"names":["define","utility","modal","aContextHelpFn","init","elm","parentSplit","contains","classList","add","aContextHelp","parent","formrow","innerHTML","split","setAttribute","targetHref","getAttribute","substring","document","getElementById","textContent","trimmedContent","content","length","standard","close","modalInstance","closeStandard","label","id","accessibleText","elInnerHTML","FRAMEWORK","locale","settings","formText","removeAttribute","nodeName","labelOuter","htmlStringToElement","insertAdjacentElement","insertAdjacentHTML","contextHelpLink","append","remove","text","heading","onResizeRefresh","wrapper","querySelector","wrapperAdditions","linkInner","outerHTML","parentNode","display","elWrapperInner","elWrapperInnerHTML","inner","iconElement","closeDuplicate","cursor","trigger","insertBefore","cursorPos","getBoundingClientRect","createElement","breakLine","centreTriangle","cursorLeft","left","window","addEventListener","debounce","triggerActive","e","slideToggle","callback","timings","current","t350ms","preventDefault","closeFunc","interval","clearInterval","breaker","triggerParent","indentLeft","parentWidth","initInstance","breakTextFlag","joinWords","breakWords","getCursorPos","tagName","wrapperLink","breakText","lastWord","trim","pop","parentPos","parentLeft","indent","correction","wrapperUI","style","wrapperUIleft","parseInt"],"mappings":"aACAA,OAAQ,CAAE,UAAW,kBAAoB,SAAcC,EAASC,GAC/D,IAAAC,EAAA,CAGCC,KAAO,SAAUC,GA6ChB,OA5CAA,EAAIC,UAAaC,SAAA,uBAGhBF,EAAIG,UAAUC,IAAK,qBAAnBJ,EAAAA,aAAcI,GAIdJ,EAAAA,aAAIK,OAAaC,EAASN,WAC1BA,EAAAA,aAAIK,SAAaE,EAEjBP,EAAKA,UAAIG,SAAUD,gCAClBJ,EAAAA,QAAeS,IAIW,KAD1BN,EAAWI,aAAOA,OAAaC,UAAOE,MAAUC,eAC9B,IAAlBT,EAAAU,aAAKT,eAA0B,SAK/BD,EAAIK,aAAaM,WAAaX,EAAIY,aAAc,QAASC,UAAW,GAApEb,EAAAA,aAAIK,QAAaM,SAAaX,eAAkBA,EAAAK,aAAlBM,YAC9BX,EAAAA,aAAIK,eAAuBS,EAAAA,aAASC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,WAOCoF,EAAA,WADDL,EAAKF,EAAaQ,OAAKpF,MAAS,MAC/BqF,MACAb,EAAAA,EAAczE,KAAd,KAA0B8E,EAG1B,SAAAD,GAEArF,EAAIK,UAAaC,EACjB2E,EAAM1C,OAAAvC,EAAAK,aAAAoD,UACN,WAAA4B,GAEArF,EAAAK,aAAAC,OAAAE,UAAA8E,EACDtF,EAAAK,aAAAC,OAAAiC,OAAAvC,IAID0F,EAAIK,UACHC,IAWDD,aAAS,SAAO1F,GAChB2F,IAOAC,EAGDlC,EAAAA,SAAiBF,cAAA,QAWhB,OAVAL,EAAI0C,UAAU9F,IAAd,UAdAkD,EAActD,EAAIK,aAAaoD,QAAQZ,cAAe,yBAcjC7C,EAAAK,aAAAoD,QAAAC,aAAAF,EAAAF,GAArB0C,EACUhG,EAAGA,aAAIK,QAAauC,WAAQC,wBACrB/C,KAvYnBkE,GAwYEmC,EAAAA,EAAUC,aAAaC,QAAAA,cAAvB,YACAzC,wBAzYFK,KA4YAgC,EAAOK,SAAAtC,EAAAgC,EAAA,IACNZ,EAAAA,SAECa,GAXDlC,eAAiB,SAAU/D,GAC1B,IACCmG,EAAYnG,EAAIK,aAAauC,QAAQC,cAAe,+BACpDwD,EAAgBvG,EAAe0F,aAAcxF,GAF7B,GAGjBmG,EAAUC,MAAMnC,KAAOoC,EAAgB,OAIzC,MAAO,CACNjB,aAAe,SAAUpF,GACxB,OAAOF,EAAeC,KAAMC","file":"blocks/a-context-help.js","sourcesContent":["// eslint-disable-next-line max-lines-per-function\r\ndefine( [ 'utility', 'blocks/o-modal' ], function run( utility, modal ) {\r\n\t'use strict';\r\n\r\n\tvar aContextHelpFn = {\r\n\t\tinit : function( elm ) {\r\n\t\t\tvar parentSplit; // Splitting point within element parent innerHTML\r\n\r\n\t\t\tif ( !elm.classList.contains( 'js-a-context-help' ) ) {\r\n\t\t\t\telm.classList.add( 'js-a-context-help' );\r\n\r\n\t\t\t\telm.aContextHelp = {};\r\n\r\n\t\t\t\telm.aContextHelp.parent = elm.parentNode;\r\n\t\t\t\telm.aContextHelp.formrow = false;\r\n\r\n\t\t\t\tif ( elm.classList.contains( 'm-form-row__explanatory-text' ) ) {\r\n\t\t\t\t\taContextHelpFn.formrow( elm );\r\n\t\t\t\t} else {\r\n\t\t\t\t\t// Check for prohibited inline use; force modal as eajit prevention\r\n\t\t\t\t\tparentSplit = elm.aContextHelp.parent.innerHTML.split( '' );\r\n\t\t\t\t\tif ( parentSplit[ 1 ] !== '' ) {\r\n\t\t\t\t\t\telm.setAttribute( 'data-variant', 'modal' );\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t// Other stuff\r\n\t\t\t\t\telm.aContextHelp.targetHref = elm.getAttribute( 'href' ).substring( 1 );\r\n\t\t\t\t\telm.aContextHelp.content = document.getElementById( elm.aContextHelp.targetHref );\r\n\t\t\t\t\telm.aContextHelp.trimmedContent = elm.aContextHelp.content.textContent.replace( /[\\t\\n\\r]+/g, '' );\r\n\t\t\t\t\telm.aContextHelp.length = elm.aContextHelp.trimmedContent.length;\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// Check variant and setup for modal if required\r\n\t\t\t\tif ( elm.getAttribute( 'data-variant' ) === 'modal' || elm.aContextHelp.length > 175 ) {\r\n\t\t\t\t\taContextHelpFn.modal( elm );\r\n\t\t\t\t} else {\r\n\t\t\t\t\taContextHelpFn.standard( elm );\r\n\t\t\t\t}\r\n\r\n\t\t\t\telm.aContextHelp.close = function close() {\r\n\t\t\t\t\tif ( elm.getAttribute( 'data-variant' ) === 'modal' || elm.aContextHelp.length > 175 ) {\r\n\t\t\t\t\t\tif ( elm.aContextHelp.modalInstance ) {\r\n\t\t\t\t\t\t\telm.aContextHelp.modalInstance.close();\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\taContextHelpFn.closeStandard( elm );\r\n\t\t\t\t\t}\r\n\t\t\t\t};\r\n\t\t\t}\r\n\r\n\t\t\treturn elm.aContextHelp;\r\n\t\t},\r\n\r\n\t\tformrow : function( elm ) {\r\n\t\t\tvar id = elm.id, // Element ID\r\n\t\t\t\tlabel, // Label within element parent\r\n\t\t\t\tlabelOuter, // Wrapping div for label element\r\n\t\t\t\tcontextHelpLink, // Contextual help link to be added beside the label\r\n\t\t\t\telInnerHTML, // Element innerHtML\r\n\t\t\t\telWrapper, // Element wrapper\r\n\t\t\t\taccessibleText; // Hidden accessible text for screen readers\r\n\r\n\t\t\tif ( elm.getAttribute( 'data-accessible-text' ) && elm.getAttribute( 'data-accessible-text' ) !== '' ) {\r\n\t\t\t\taccessibleText = elm.getAttribute( 'data-accessible-text' );\r\n\t\t\t} else {\r\n\t\t\t\taccessibleText = FRAMEWORK.locale.settings.aContextHelp.formText;\r\n\t\t\t}\r\n\r\n\t\t\telm.removeAttribute( 'id' );\r\n\r\n\t\t\t// Add icon and link to trigger (label / legend)\r\n\t\t\tlabel = elm.aContextHelp.parent.querySelector( '.a-label' );\r\n\t\t\tif ( label.nodeName === 'LABEL' ) {\r\n\t\t\t\tlabelOuter = utility.htmlStringToElement( '
' ); // Create new wrapping element\r\n\t\t\t\tutility.wrap( label, labelOuter ); // Wrap label in new wrapper\r\n\t\t\t\tlabel.removeAttribute( 'class' ); // Remove any classes that were on the original label\r\n\t\t\t} else if ( label.nodeName === 'LEGEND' ) {\r\n\t\t\t\tlabelOuter = utility.htmlStringToElement( '
' +\r\n\t\t\t\tlabel.innerHTML + '
' ); // Create visual label element\r\n\t\t\t\tlabel.insertAdjacentElement( 'afterend', labelOuter ); // Insert visible label after legend\r\n\t\t\t\tlabel.classList.add( 'u-hidden--visually' ); // Visually hide the original legend\r\n\t\t\t} else {\r\n\t\t\t\tlabelOuter = label;\r\n\t\t\t}\r\n\r\n\t\t\tcontextHelpLink = utility.htmlStringToElement( '' + accessibleText + '' );\r\n\t\t\tlabelOuter.append( contextHelpLink );\r\n\r\n\t\t\t// Setup html in preparation\r\n\t\t\telInnerHTML = elm.innerHTML;\r\n\t\t\telWrapper = '

' + elInnerHTML + '

';\r\n\t\t\telm.insertAdjacentHTML( 'afterend', elWrapper );\r\n\r\n\t\t\telm.aContextHelp.content = document.getElementById( elm.aContextHelp.targetHref );\r\n\t\t\telm.aContextHelp.length = elm.textContent.length;\r\n\t\t\telm.remove();\r\n\t\t\telm.aContextHelp.formrow = true;\r\n\t\t},\r\n\r\n\t\tstandard : function( elm ) {\r\n\t\t\tvar elWrapperInnerHTML,\r\n\t\t\t\telWrapperInner, // Element wrapper\r\n\t\t\t\ttext, // Element inner text element\r\n\t\t\t\theading, // Context help heading element\r\n\t\t\t\tcloseDuplicate, // Duplicated close element\r\n\t\t\t\tcursor, // Cursor element\r\n\t\t\t\tcursorPos, // Cursor element bounding rectangle\r\n\t\t\t\tonResizeRefresh, // Resize / refresh function\r\n\t\t\t\twrapperClose; // Wrapper close button\r\n\r\n\r\n\t\t\tif ( elm.aContextHelp.formrow === true ) {\r\n\t\t\t\t// Just get wrapper and inner divs, as form row pre-processor has already set up tooltip and content\r\n\t\t\t\telm.aContextHelp.wrapper = elm.aContextHelp.parent.querySelector( '.a-context-help-wrapper' );\r\n\t\t\t\telm.aContextHelp.wrapperAdditions = '
' + elm.aContextHelp.wrapper.innerHTML +\r\n\t\t\t\t\t'
';\r\n\t\t\t\telm.aContextHelp.wrapper.innerHTML = elm.aContextHelp.wrapperAdditions;\r\n\t\t\t\telm.aContextHelp.inner = elm.aContextHelp.wrapper.querySelector( '.a-context-help-inner' );\r\n\t\t\t} else {\r\n\t\t\t\telm.aContextHelp.linkInner = elm.querySelector( '.a-link-icon__inner' );\r\n\t\t\t\tif ( elm.aContextHelp.linkInner.classList.contains( 'u-hidden--visually' ) ) {\r\n\t\t\t\t\telm.classList.add( 'a-context-help--hidden-text' );\r\n\t\t\t\t}\r\n\r\n\t\t\t\telm.aContextHelp.linkInner.classList.add( 'a-context-help__link' );\r\n\r\n\t\t\t\t// Set up tooltip, insert content from elsewhere on page and remove original content\r\n\t\t\t\telm.aContextHelp.parent.insertAdjacentHTML( 'afterend', elm.aContextHelp.content.outerHTML );\r\n\t\t\t\telm.aContextHelp.wrapper = elm.aContextHelp.parent.parentNode.querySelector( '.a-context-help-content' );\r\n\t\t\t\telm.aContextHelp.wrapper.classList.remove( 'a-context-help-content' );\r\n\t\t\t\telm.aContextHelp.wrapper.classList.add( 'a-context-help-wrapper' );\r\n\t\t\t\telm.aContextHelp.wrapper.classList.add( 't-accent-light' );\r\n\t\t\t\telm.aContextHelp.wrapper.style.display = 'none';\r\n\t\t\t\telm.aContextHelp.wrapper.setAttribute( 'aria-hidden', 'true' );\r\n\t\t\t\telm.aContextHelp.content.remove();\r\n\r\n\t\t\t\t// Wrap inner content and hide visually ready to transition in when active\r\n\t\t\t\telWrapperInnerHTML = elm.aContextHelp.wrapper.innerHTML;\r\n\t\t\t\telWrapperInner = '
' + elWrapperInnerHTML +\r\n\t\t\t\t\t'
';\r\n\t\t\t\telm.aContextHelp.wrapper.innerHTML = elWrapperInner;\r\n\t\t\t\telm.aContextHelp.inner = elm.aContextHelp.wrapper.querySelector( '.a-context-help-inner' );\r\n\r\n\t\t\t\ttext = elm.aContextHelp.inner.querySelector( '.a-context-help-content__text' );\r\n\t\t\t\ttext.classList.remove( 'a-context-help-content__text' );\r\n\t\t\t\ttext.classList.add( 'a-context-help-wrapper__text' );\r\n\r\n\t\t\t\t// Remove unneeded heading\r\n\t\t\t\theading = elm.aContextHelp.inner.querySelector( '.a-context-help-content__heading' );\r\n\t\t\t\theading.remove();\r\n\r\n\t\t\t\telm.aContextHelp.iconElement = document.createElement( 'span' );\r\n\t\t\t\telm.aContextHelp.iconElement.classList.add( 'a-context-help__icon' );\r\n\t\t\t\telm.append( elm.aContextHelp.iconElement );\r\n\t\t\t}\r\n\r\n\t\t\tcloseDuplicate = elm.aContextHelp.inner.parentNode.querySelector( '.a-context-help-inner + .a-context-help-wrapper__close' );\r\n\t\t\tif ( closeDuplicate ) {\r\n\t\t\t\tcloseDuplicate.remove();\r\n\t\t\t}\r\n\r\n\t\t\telm.aContextHelp.trigger = elm.aContextHelp.parent.querySelector( '.a-context-help' );\r\n\t\t\telm.aContextHelp.trigger.setAttribute( 'aria-controls', elm.aContextHelp.wrapper.getAttribute( 'id' ) );\r\n\t\t\telm.aContextHelp.trigger.setAttribute( 'aria-expanded', 'false' );\r\n\r\n\t\t\tcursor = document.createElement( 'span' );\r\n\t\t\tcursor.classList.add( 'cursor' );\r\n\t\t\telm.aContextHelp.trigger.insertBefore( cursor, elm.aContextHelp.iconElement );\r\n\t\t\tcursorPos = cursor.getBoundingClientRect();\r\n\t\t\telm.aContextHelp.cursorLeft = cursorPos.left;\r\n\t\t\tcursor.remove();\r\n\r\n\t\t\t// Break line if necessary, then centre triangle under icon\r\n\t\t\taContextHelpFn.breakLine( elm );\r\n\t\t\taContextHelpFn.centreTriangle( elm );\r\n\r\n\t\t\t// Resize/refresh function\r\n\t\t\tonResizeRefresh = utility.debounce( function listener() {\r\n\t\t\t\taContextHelpFn.breakLine( elm );\r\n\t\t\t\taContextHelpFn.centreTriangle( elm );\r\n\t\t\t}, 10 );\r\n\t\t\twindow.addEventListener( 'resize', onResizeRefresh );\r\n\r\n\t\t\t// Create refresh event and associated eventListener\r\n\t\t\twindow.addEventListener( 'refresh', onResizeRefresh, false );\r\n\r\n\t\t\t// Function for main trigger\r\n\t\t\telm.aContextHelp.triggerActive = false;\r\n\t\t\telm.aContextHelp.trigger.addEventListener( 'click', function listener( e ) {\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\tif ( elm.aContextHelp.triggerActive === false ) {\r\n\t\t\t\t\telm.aContextHelp.triggerActive = true;\r\n\t\t\t\t\tif ( elm.aContextHelp.trigger.classList.contains( 'a-context-help--active' ) ) {\r\n\t\t\t\t\t\telm.aContextHelp.trigger.classList.remove( 'a-context-help--active' );\r\n\t\t\t\t\t\telm.aContextHelp.trigger.setAttribute( 'aria-expanded', 'false' );\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\telm.aContextHelp.trigger.classList.add( 'a-context-help--active' );\r\n\t\t\t\t\t\telm.aContextHelp.trigger.setAttribute( 'aria-expanded', 'true' );\r\n\t\t\t\t\t}\r\n\t\t\t\t\tutility.slideToggle( elm.aContextHelp.wrapper, FRAMEWORK.timings.current.t350ms, {\r\n\t\t\t\t\t\tcallback : function() {\r\n\t\t\t\t\t\t\telm.aContextHelp.triggerActive = false;\r\n\t\t\t\t\t\t},\r\n\t\t\t\t\t});\r\n\t\t\t\t\tif ( elm.aContextHelp.inner.classList.contains( 'a-context-help-inner--active' ) ) {\r\n\t\t\t\t\t\telm.aContextHelp.inner.classList.remove( 'a-context-help-inner--active' );\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\telm.aContextHelp.inner.classList.add( 'a-context-help-inner--active' );\r\n\t\t\t\t\t}\r\n\t\t\t\t} else {\r\n\t\t\t\t\t// Do nothing - triggerActive is true, so click is disbled until animation has completed\r\n\t\t\t\t}\r\n\t\t\t});\r\n\r\n\t\t\t// Function for close button within element\r\n\t\t\twrapperClose = elm.aContextHelp.wrapper.querySelector( '.a-context-help-wrapper__close' );\r\n\t\t\twrapperClose.addEventListener( 'click', function listener( e ) {\r\n\t\t\t\te.preventDefault();\r\n\r\n\t\t\t\taContextHelpFn.closeStandard( elm, function callbackFn() {\r\n\t\t\t\t\telm.aContextHelp.trigger.focus();\r\n\t\t\t\t});\r\n\t\t\t}, false );\r\n\t\t},\r\n\r\n\t\tcloseStandard : function( elm, callback ) {\r\n\t\t\tvar closeFunc = function closeFunc() {\r\n\t\t\t\t\tif ( elm.aContextHelp.trigger.classList.contains( 'a-context-help--active' ) ) {\r\n\t\t\t\t\t\telm.aContextHelp.triggerActive = true;\r\n\t\t\t\t\t\telm.aContextHelp.trigger.classList.remove( 'a-context-help--active' );\r\n\t\t\t\t\t\telm.aContextHelp.trigger.setAttribute( 'aria-expanded', 'false' );\r\n\t\t\t\t\t\tutility.slideToggle( elm.aContextHelp.wrapper, FRAMEWORK.timings.current.t350ms, {\r\n\t\t\t\t\t\t\tvariant : 'up',\r\n\t\t\t\t\t\t\tcallback : function() {\r\n\t\t\t\t\t\t\t\telm.aContextHelp.triggerActive = false;\r\n\t\t\t\t\t\t\t\tif ( typeof callback === 'function' ) {\r\n\t\t\t\t\t\t\t\t\tcallback();\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t},\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t\telm.aContextHelp.inner.classList.remove( 'a-context-help-inner--active' );\r\n\t\t\t\t\t}\r\n\t\t\t\t},\r\n\t\t\t\tinterval;\r\n\r\n\t\t\tif ( elm.aContextHelp.triggerActive ) {\r\n\t\t\t\tinterval = setInterval( function intervalFn() {\r\n\t\t\t\t\tif ( elm.aContextHelp.triggerActive ) {\r\n\t\t\t\t\t\t// Do nothing just wait\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\tclearInterval( interval );\r\n\t\t\t\t\t\tcloseFunc();\r\n\t\t\t\t\t}\r\n\t\t\t\t}, 50 );\r\n\t\t\t} else {\r\n\t\t\t\tcloseFunc();\r\n\t\t\t}\r\n\t\t},\r\n\r\n\t\tmodal : function( elm ) {\r\n\t\t\tvar onResizeRefresh; // Resize/refresh function\r\n\r\n\t\t\t// Set up modal\r\n\t\t\tif ( elm.aContextHelp.formrow === true ) {\r\n\t\t\t\telm.aContextHelp.trigger = elm.aContextHelp.parent.querySelector( '.a-context-help' );\r\n\t\t\t\telm.aContextHelp.trigger.querySelector( '.a-link-icon__inner' ).classList.add( 'a-context-help__link' );\r\n\t\t\t\telm.aContextHelp.trigger.setAttribute( 'data-module', 'o-modal' );\r\n\t\t\t\telm.aContextHelp.wrapper = elm.aContextHelp.trigger.parentNode.parentNode.querySelector( '.a-context-help-wrapper' );\r\n\t\t\t\telm.aContextHelp.wrapper.classList.add( 'o-modal__content-container' );\r\n\t\t\t} else {\r\n\t\t\t\telm.querySelector( '.a-link-icon__inner' ).classList.add( 'a-context-help__link' );\r\n\t\t\t\telm.setAttribute( 'data-module', 'o-modal' );\r\n\t\t\t\telm.aContextHelp.content.classList.add( 'o-modal__content-container' );\r\n\t\t\t\telm.aContextHelp.trigger = elm.aContextHelp.parent.querySelector( '.a-context-help' );\r\n\t\t\t}\r\n\r\n\t\t\telm.aContextHelp.iconElement = document.createElement( 'span' );\r\n\t\t\telm.aContextHelp.iconElement.classList.add( 'a-context-help__icon' );\r\n\t\t\telm.append( elm.aContextHelp.iconElement );\r\n\r\n\t\t\t// Break line if necessary\r\n\t\t\taContextHelpFn.breakLine( elm );\r\n\r\n\t\t\t// Resize/refresh function\r\n\t\t\tonResizeRefresh = utility.debounce( function listener() {\r\n\t\t\t\taContextHelpFn.breakLine( elm );\r\n\t\t\t}, 10 );\r\n\t\t\twindow.addEventListener( 'resize', onResizeRefresh );\r\n\r\n\t\t\t// Create refresh event and associated eventListener\r\n\t\t\twindow.addEventListener( 'refresh', onResizeRefresh, false );\r\n\r\n\t\t\t// Initialise modal instance\r\n\t\t\telm.aContextHelp.modalInstance = modal.initInstance();\r\n\t\t},\r\n\r\n\t\tbreakLine : function( elm ) {\r\n\t\t\tvar triggerParent = elm.aContextHelp.trigger.parentNode, // Trigger parent\r\n\t\t\t\tbreaker = triggerParent.querySelector( 'br' ), // Line break within trigger parent\r\n\t\t\t\tindentLeft, // Element left indent\r\n\t\t\t\tparentPos, // Position of triggerParent's parent\r\n\t\t\t\tparentWidth, // TriggerParent's parent's width\r\n\t\t\t\twrapperLink, // Trigger link\r\n\t\t\t\tbreakText, // WrapperLink innerHTML\r\n\t\t\t\tbreakTextFlag, // BreakText variant\r\n\t\t\t\tbreakWords, // BreakText split\r\n\t\t\t\tlastWord, // Last word\r\n\t\t\t\tjoinWords; // Joined back text\r\n\r\n\t\t\tif ( breaker ) {\r\n\t\t\t\tbreaker.remove();\r\n\t\t\t}\r\n\r\n\t\t\t// Work out if line break is necessary...\r\n\t\t\tindentLeft = aContextHelpFn.getCursorPos( elm ) + 36; /* Indent + icon width + left padding */\r\n\r\n\t\t\tif ( triggerParent.tagName === 'LEGEND' ) {\r\n\t\t\t\tparentPos = triggerParent.parentNode.getBoundingClientRect();\r\n\t\t\t} else {\r\n\t\t\t\tparentPos = triggerParent.getBoundingClientRect();\r\n\t\t\t}\r\n\t\t\tparentWidth = parentPos.width;\r\n\t\t\twrapperLink = elm.aContextHelp.trigger.querySelector( '.a-context-help__link' );\r\n\r\n\t\t\t// ...and break the line as required (indent > than parent's width / icon is at the extreme left of the parent's bounding box (icons with no supporting text content)\r\n\t\t\tif ( indentLeft > parentWidth || indentLeft === 36 ) {\r\n\t\t\t\t// Break the line before the last word\r\n\t\t\t\tbreakText = wrapperLink.innerHTML;\r\n\t\t\t\tbreakTextFlag = 'content';\r\n\r\n\t\t\t\tif ( elm.aContextHelp.trigger.classList.contains( 'a-context-help--hidden-text' ) ) {\r\n\t\t\t\t\t// Trigger has no text content attached, so get text from wrapperLink (form) or parent (other cases)\r\n\t\t\t\t\telm.aContextHelp.trigger.remove();\r\n\t\t\t\t\tif ( elm.aContextHelp.formrow === true ) {\r\n\t\t\t\t\t\tbreakText = triggerParent.innerHTML;\r\n\t\t\t\t\t\tbreakTextFlag = 'form';\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\tbreakText = elm.aContextHelp.parent.innerHTML;\r\n\t\t\t\t\t\tbreakTextFlag = 'parent';\r\n\t\t\t\t\t}\r\n\t\t\t\t} else {\r\n\t\t\t\t\t// Inner link has text content, so already have it\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// Split, add break...\r\n\t\t\t\tbreakWords = breakText.trim().split( ' ' );\r\n\t\t\t\tlastWord = '
' + breakWords.pop();\r\n\t\t\t\tjoinWords = breakWords.join( ' ' ) + lastWord;\r\n\r\n\t\t\t\t// ...and reassemble\r\n\t\t\t\tif ( breakTextFlag === 'form' ) {\r\n\t\t\t\t\t// Add recreated text + original element back into parent link\r\n\t\t\t\t\ttriggerParent.innerHTML = joinWords;\r\n\t\t\t\t\ttriggerParent.append( elm.aContextHelp.trigger );\r\n\t\t\t\t} else if ( breakTextFlag === 'parent' ) {\r\n\t\t\t\t\t// Add recreated text + original element back into parent link\r\n\t\t\t\t\telm.aContextHelp.parent.innerHTML = joinWords;\r\n\t\t\t\t\telm.aContextHelp.parent.append( elm );\r\n\t\t\t\t} else {\r\n\t\t\t\t\t// Flag is 'content', so just add recreated text back into link\r\n\t\t\t\t\twrapperLink.innerHTML = joinWords;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t},\r\n\r\n\t\tgetCursorPos : function( elm ) {\r\n\t\t\tvar parentPos,\r\n\t\t\t\tparentLeft,\r\n\t\t\t\ticonElement,\r\n\t\t\t\tcursor,\r\n\t\t\t\tcursorPos,\r\n\t\t\t\tcursorLeft,\r\n\t\t\t\tindent;\r\n\r\n\t\t\tcursor = document.createElement( 'span' );\r\n\t\t\tcursor.classList.add( 'cursor' );\r\n\t\t\ticonElement = elm.aContextHelp.trigger.querySelector( '.a-context-help__icon' );\r\n\t\t\telm.aContextHelp.trigger.insertBefore( cursor, iconElement );\r\n\t\t\tparentPos = elm.aContextHelp.trigger.parentNode.getBoundingClientRect();\r\n\t\t\tparentLeft = parentPos.left;\r\n\t\t\tcursor = elm.aContextHelp.trigger.querySelector( '.cursor' );\r\n\t\t\tcursorPos = cursor.getBoundingClientRect();\r\n\t\t\tcursorLeft = cursorPos.left;\r\n\t\t\tindent = parseInt( cursorLeft - parentLeft, 10 );\r\n\t\t\tcursor.remove();\r\n\r\n\t\t\treturn indent;\r\n\t\t},\r\n\r\n\t\tcentreTriangle : function( elm ) {\r\n\t\t\tvar correction = 12, /* Correction required to pull triangle in from the right */\r\n\t\t\t\twrapperUI = elm.aContextHelp.wrapper.querySelector( '.a-context-help-wrapper__ui' ),\r\n\t\t\t\twrapperUIleft = aContextHelpFn.getCursorPos( elm ) + correction;\r\n\t\t\twrapperUI.style.left = wrapperUIleft + 'px';\r\n\t\t},\r\n\t};\r\n\r\n\treturn {\r\n\t\tinitInstance : function( elm ) {\r\n\t\t\treturn aContextHelpFn.init( elm );\r\n\t\t},\r\n\t};\r\n});\r\n"]}