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,38 +429,50 @@ 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
items: "[data-tooltip]", if (!jQuery(this).data('uiTooltip'))
content: function() {
{ jQuery(this).tooltip({
var elem = jQuery(this); items: "[data-tooltip]",
if (elem.is("[data-tooltip]")) show: false,
return this.getAttribute('data-tooltip') ; content: function()
}, {
track:true, var elem = jQuery(this);
if (elem.is("[data-tooltip]"))
return this.getAttribute('data-tooltip') ;
},
track:true,
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
ui.tooltip.hover( jQuery(this).on("tooltipclose", function (event, ui){
function () { // bind hover handler on tooltip helper in order to be able to freeze the tooltip and scrolling
if (this.scrollHeight > this.clientHeight) jQuery(this).stop(true).fadeTo(100, 1); ui.tooltip.hover(
}, function () {
function () { if (this.scrollHeight > this.clientHeight) jQuery(this).stop(true).fadeTo(100, 1);
jQuery(this).fadeOut("100", function(){ jQuery(this).remove();}); },
function () {
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(){
jQuery(this).tooltip("disable"); // Make sure the tooltip initialized before calling it
if (jQuery(this).data('uiTooltip'))
{
jQuery(this).tooltip("disable");
}
}) })
//onClick event handler for calendar Events //onClick event handler for calendar Events