Created
November 1, 2013 17:40
-
-
Save MartijnR/7268994 to your computer and use it in GitHub Desktop.
enketo-hints-tooltip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//add 'hint' icon, could be moved to XSLT, but is very fast even on super large forms - 31 msecs on bench6 form | |
if (!modernizr.touch){ | |
$hint = '<span class="hint" ><i class="icon-question-sign"></i></span>'; | |
$form.find('.jr-hint ~ input, .jr-hint ~ select, .jr-hint ~ textarea').before($hint); | |
$form.find('legend > .jr-hint').parent().find('span:last-child').after($hint); | |
$form.find('.trigger > .jr-hint').parent().find('span:last').after($hint); | |
} | |
/** | |
* setHints updates the hints. It is called whenever the language or output value is changed. | |
* @deprecated ? | |
* @param { {outputsOnly: boolean}=} options options | |
*/ | |
FormView.prototype.setHints = function( options ) { | |
//var profiler = new Profiler('setting hints'); | |
if ( !modernizr.touch ) { | |
var hint, $hint, $hints, $wrapNode, outputsOnly; | |
outputsOnly = ( options && options.outputsOnly ) ? options.outputsOnly : false; | |
$hints = ( outputsOnly ) ? $form.find( '*>.jr-hint>.jr-output' ).parent( ) : $form.find( '*>.jr-hint' ); | |
$hints.parent( ).each( function( ) { | |
if ( $( this ).prop( 'nodeName' ).toLowerCase( ) !== 'label' && $( this ).prop( 'nodeName' ).toLowerCase( ) !== 'fieldset' ) { | |
$wrapNode = $( this ).parent( 'fieldset' ); | |
} else { | |
$wrapNode = $( this ); | |
} | |
$hint = $wrapNode.find( '.hint' ); | |
hint = $( this ).find( '.jr-hint.active' ).text( ).trim( ); | |
if ( hint.length > 0 ) { | |
$hint.attr( 'title', hint ); | |
} else { | |
$hint.removeAttr( 'title' ); | |
} | |
//$hint.tooltip( 'fixTitle' ).tooltip( { | |
// placement: 'right' | |
//} ); | |
} ); | |
} | |
//profiler.report(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment