gerd
11/7/2016 - 6:10 PM

contextHelp.js

/**
 * popover class to handle contextual help with bootstrap popovers
 * @class pop
 */
lexisnexis.component.contextHelp = lexisnexis.component.Component
		.extend({
			data : {
	
			},
		/**
		 * Displays the help popover with the help content
		 * @function hideAllPopOvers
		 * @function close
		 * @function popover
		 * @param id
		 * @param title
		 * @param message
		 * @param placement
		 **/
			
		ready : function() {
		var cs = this;
			//close on keypress
			$(document).on("keyup", function (event) {
				// on any key
				$('.popover').each(function() {
					$(this).popover('hide');
				}); 
				/*
				 * only on esc key
			    if (event.which === 27) {
			        $(this).popover('hide');
			    }
			    */
			}); 
			
	  	   
			// click needs work - delegation does not seem to work
			/*
		  	$('body').on('click', function (e) {
		  	    $('.fa-question').each(function () {
		  	        //the 'is' for buttons that trigger popups
		  	        //the 'has' for icons within a button that triggers a popup
		  	        if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {
		  	            $(this).popover('hide');
		  	        }
		  	    });
		  	});
		  	*/
			
		}, // end ready
		
        hideAllPopOvers:function (){
        	$('.popover').each(function() {
   	            $(this).popover('hide');
   	        });  
        },
        
        close: function (){
        	this.hideAllPopOvers();   	
        },
        
        popOver:function(id,helptitle,message,placement) {
        	/* 
            var cs=this;
            this.hideAllPopOvers();
            var titletag = $(id).attr("title"); // get the html title tag value
            $(id).prop('title', helptitle);
            $(id).popover({	html: true, trigger: 'manual', title : helptitle, content : message, placement: placement });
            $(id).popover('show');
            $('.popover-title').append('<button type="button" class="close" onclick="contextHelp.close()">&times;</button>');
            // reset to original value of the html title tag for mouseovers 
     	    $(document).on("mouseover", id, function () {
	   	         $(id).prop('title', titletag);
     	    });
           $('.popover').on('click', function(e){
        	   e.stopPropagation();
           });
           */
        }
        
});