Change multiple jquery statements to single jquery with on() method to handle events

This commit is contained in:
Hadi Nategh 2014-02-21 16:37:39 +00:00
parent 82704bd0d2
commit cbae6e5722

View File

@ -148,9 +148,11 @@ app.classes.calendar = AppJS.extend(
{
var that = this;
//Draggable
jQuery("div[id^='drag_']").draggable(
{
//Draggable & Resizable selector
jQuery("div[id^='drag_']")
//draggable event handler
.draggable
({
stack: jQuery("div[id^='drag_']"),
revert: "invalid",
delay: 50,
@ -198,7 +200,11 @@ app.classes.calendar = AppJS.extend(
oldWidth = ui.helper.width();
ui.helper.width(jQuery("#calColumn").width());
}
}).resizable({
})
//Resizable event handler
.resizable
({
distance: 10,
@ -281,9 +287,11 @@ app.classes.calendar = AppJS.extend(
}
});
//Droppable
jQuery("div[id^='drop_']").droppable(
{
//Droppable selector
jQuery("div[id^='drop_']")
//Droppable event handler
.droppable
({
/**
* Make all draggable calEvents acceptable
*
@ -342,9 +350,35 @@ app.classes.calendar = AppJS.extend(
}
});
//onClick Handler for calender entries
jQuery("div.calendar_calEvent").on({
click:function(ev){
//jQuery Calendar Event selector
jQuery("body")
//mouseover event handler for calendar tooltip
.on("mouseover", "div[data-tooltip]",function(){
var ttp = jQuery(this).tooltip({
items: "[data-tooltip]",
content: function()
{
var elem = jQuery(this);
if (elem.is("[data-tooltip]"))
return this.getAttribute('data-tooltip') ;
},
track:true,
open: function(event,ui){
ui.tooltip.removeClass("ui-tooltip");
ui.tooltip.addClass("calendar_uitooltip");
}
});
ttp.tooltip("enable");
})
// mousedown event handler for calendar tooltip to remove disable tooltip
.on("mousedown", "div[data-tooltip]", function(){
jQuery(this).tooltip("disable");
})
//onClick event handler for calendar Events
.on("click", "div.calendar_calEvent", function(ev){
var Id = ev.currentTarget.id.replace(/drag_/g,'').split("_")[0];
var eventId = Id.match(/-?\d+\.?\d*/g)[0];
var appName = Id.replace(/-?\d+\.?\d*/g,'');
@ -358,45 +392,10 @@ app.classes.calendar = AppJS.extend(
{
that.edit_series(eventId,startDate);
}
},
mouseover: function(){
})
var ttp = jQuery(this).tooltip({
items: "[data-tooltip]",
content: function()
{
var elem = jQuery(this);
if (elem.is("[data-tooltip]"))
return this.getAttribute('data-tooltip') ;
},
track:true,
open: function(event,ui){
ui.tooltip.removeClass("ui-tooltip");
ui.tooltip.addClass("calendar_uitooltip");
}
});
ttp.tooltip("enable");
},
mousedown: function(){
jQuery(this).tooltip("disable");
}
});
//Click handler for calendar todos
jQuery("div.calendar_calDayTodos").find("[data-todo^='app|']").on({
click:function(ev)
{
var windowSize = ev.currentTarget.getAttribute('data-todo').split("|")[1];
var link = ev.currentTarget.getAttribute('href');
that.egw.open_link(link,'_blank',windowSize);
return false;
}
});
//Click Handler for calendar planner
jQuery("div.calendar_plannerEvent").on({
click:function(ev){
//Click event handler for integrated apps
.on("click","div.calendar_plannerEvent",function(ev){
var eventId = ev.currentTarget.getAttribute('data-date').split("|")[1];
var startDate = ev.currentTarget.getAttribute('data-date').split("|")[0];
var recurrFlag = ev.currentTarget.getAttribute('data-date').split("|")[2];
@ -408,34 +407,10 @@ app.classes.calendar = AppJS.extend(
{
that.edit_series(eventId,startDate);
}
},
mouseover: function(){
})
var ttp = jQuery(this).tooltip({
items: "[data-tooltip]",
content: function()
{
var elem = jQuery(this);
if (elem.is("[data-tooltip]"))
return this.getAttribute('data-tooltip') ;
},
track:true,
open: function(event,ui){
ui.tooltip.removeClass("ui-tooltip");
ui.tooltip.addClass("calendar_uitooltip");
}
});
ttp.tooltip("enable");
},
mousedown: function(){
jQuery(this).tooltip("disable");
}
});
//onClick Handler for calendar cells
jQuery("div.calendar_calAddEvent").click(function(ev)
{
//Click event handler for calendar cells
.on("click","div.calendar_calAddEvent",function(ev){
var timestamp = ev.target.getAttribute('data-date').split("|");
var owner = ev.target.getAttribute('id').split("_");
@ -458,8 +433,15 @@ app.classes.calendar = AppJS.extend(
}
that.egw.open(null, 'calendar', 'add', eventInfo , '_blank');
});
})
//Click event handler for calendar todos
.on("click", "a[data-todo]",function(ev){
var windowSize = ev.currentTarget.getAttribute('data-todo').split("|")[1];
var link = ev.currentTarget.getAttribute('href');
that.egw.open_link(link,'_blank',windowSize);
return false;
});
},
/**