Picture of Chris Gillison
making adapt-hint compulsory for completion
by Chris Gillison - Tuesday, 18 April 2017, 2:50 PM
 

Hi all,

I really like the adapt-hint extension, but I desparately need to make it 'compulsory'.

By that I mean I have some simple text blocks with adapt-hints on them and I want each block to be marked as 'complete' only after the hint icon has been clicked.

Could someone offer a suggestion on how I could achieve this? I'm working with the framework.

Many thanks,

Chris

Picture of Matt Leathes
Re: making adapt-hint compulsory for completion
by Matt Leathes - Tuesday, 18 April 2017, 3:46 PM
 

hmmm, interesting one... If I were going to go about doing this I would think about trying something like getting adapt-hint to override contrib-text's getInviewElementSelector function so that it will return ".hint-extension-item-body" instead?? Not 100% sure it would work but worth a try.

Picture of Chris Gillison
Re: making adapt-hint compulsory for completion
by Chris Gillison - Tuesday, 18 April 2017, 6:36 PM
 

Thanks Matt.

I added if(this.model.get('_hint')) return '.hint-extension-item-body'; to the top of the list in getInviewElementSelector. That bit seems to be working as the trickle button isn't now displaying immediately when I run the text component with the hint in it.

But then clicking the hint icon changes nothing so I'm stuck with a component that won't complete! I added this.setCompletionStatus(); to the onSpecButtonClicked() function in adapt-hint.js after the line

Adapt.trigger('hint-extension-widget:open', this.model.get('_id'));but it had no effect.

Really I'd rather the whole thing was kept in the coding for hint if at all possible, rather than altering other components (e.g. I'm sure I'm going to need this functionality on a graphic component soon).

Picture of Matt Leathes
Re: making adapt-hint compulsory for completion
by Matt Leathes - Tuesday, 18 April 2017, 7:47 PM
 
Really I'd rather the whole thing was kept in the coding for hint if at all possible, rather than altering other components

Yep totally, I'm pretty sure you should be able to override this function from inside adapt-hint, I think by doing something like

view.getInviewElementSelector = function () {return '.hint-extension-item-body' }

in between the current lines 118 & 119 of adapt-hint.js

If that doesn't work it'll be something like messing around with Text.prototype.getInviewElementSelector

I suspect the inview library is just not getting triggered when you open the hint, forcing a $(window).resize() might do it, if not you weren't far off with doing setCompletionStatus you were just doing it to the wrong thing - it needs to call the text component's setCompletionStatus, not adapt-hint's (which doesn't actually have such a function)