Performance improvment for calender tooltip

This commit is contained in:
Hadi Nategh 2014-10-23 12:59:19 +00:00
parent 4acbbf81c1
commit 16e6f807de

View File

@ -429,8 +429,12 @@ app.classes.calendar = AppJS.extend(
jQuery("body") jQuery("body")
//mouseover event handler for calendar tooltip //mouseover event handler for calendar tooltip
.on("mouseover", "div[data-tooltip]",function(){ .on("mouseover", "div[data-tooltip]",function(){
var ttp = jQuery(this).tooltip({ //Check if the tooltip is already initialized
if (!jQuery(this).data('uiTooltip'))
{
jQuery(this).tooltip({
items: "[data-tooltip]", items: "[data-tooltip]",
show: false,
content: function() content: function()
{ {
var elem = jQuery(this); var elem = jQuery(this);
@ -442,9 +446,11 @@ app.classes.calendar = AppJS.extend(
open: function(event,ui){ open: function(event,ui){
ui.tooltip.removeClass("ui-tooltip"); ui.tooltip.removeClass("ui-tooltip");
ui.tooltip.addClass("calendar_uitooltip"); ui.tooltip.addClass("calendar_uitooltip");
}, if (this.scrollHeight > this.clientHeight)
close: function( event, ui )
{ {
// bind on tooltip close event
jQuery(this).on("tooltipclose", function (event, ui){
// bind hover handler on tooltip helper in order to be able to freeze the tooltip and scrolling
ui.tooltip.hover( ui.tooltip.hover(
function () { function () {
if (this.scrollHeight > this.clientHeight) jQuery(this).stop(true).fadeTo(100, 1); if (this.scrollHeight > this.clientHeight) jQuery(this).stop(true).fadeTo(100, 1);
@ -453,14 +459,20 @@ app.classes.calendar = AppJS.extend(
jQuery(this).fadeOut("100", function(){ jQuery(this).remove();}); jQuery(this).fadeOut("100", function(){ jQuery(this).remove();});
} }
); );
});
}
} }
}); });
ttp.tooltip("enable"); }
}) })
// mousedown event handler for calendar tooltip to remove disable tooltip // mousedown event handler for calendar tooltip to remove disable tooltip
.on("mousedown", "div[data-tooltip]", function(){ .on("mousedown", "div[data-tooltip]", function(){
// Make sure the tooltip initialized before calling it
if (jQuery(this).data('uiTooltip'))
{
jQuery(this).tooltip("disable"); jQuery(this).tooltip("disable");
}
}) })
//onClick event handler for calendar Events //onClick event handler for calendar Events