$(function(){ var agenda = new WebvalueAgenda(); agenda.init(); }); var WebvalueAgenda = function(){}; WebvalueAgenda.prototype = { hovering : false, init: function() { var self = this; var agendaId = $("#agenda > .id").html(); try{ agendaRefresh(); } catch(e){} $("#agenda .previous, #agenda .next").mousedown(function(e){ e.preventDefault(); }); $("#agenda .top .previous span, #agenda .bottom .previous span").click(function(){ var $this = $(this); var month = $this.parent().parent().parent().find(".current_month").html(); $.ajax({ url : '/frontend/components/agenda/action.php', type : 'post', data : { action : 'prev', month : month, id : agendaId }, success : function(result) { $("#agenda").html(result); self.init(); } }); }); $("#agenda .top .next span, #agenda .bottom .next span").click(function(){ var $this = $(this); var month = $this.parent().parent().parent().find(".current_month").html(); $.ajax({ url : '/frontend/components/agenda/action.php', type : 'post', data : { action : 'next', month : month, id : agendaId }, success : function(result) { $("#agenda").html(result); self.init(); } }); }); $("#agenda .event").click(function() { var $this = $(this); var $sRes = $("#searchresults"); self.createResultDiv(); setTimeout(function(){ $.ajax({ url : '/frontend/components/agenda/action.php', type : 'post', data : { action : 'showevent', id : $this.find('.id').html() }, success : function(result) { var offset = $this.offset(); var width = $this.outerWidth(); var height = $this.outerHeight(); var left = (offset.left + width); var blockHeight = $("#event_block").outerHeight() / 2; $("#event_block").css({left:left + 0, top:offset.top + (height/2) - blockHeight}); $("#event_block").html(result); try{ agendaClick(); } catch(e){} $("#event_block").fadeIn(150); $("#event_block").find(".result").hover(function(){ $("#event_block .selected").removeClass("selected"); $(this).addClass("selected"); }, function(){ $(this).removeClass("selected"); }); } }); },100); }); }, createResultDiv: function(ob) { $('body').append('
'); var $search = $("#event_block"); var self = this; $search.hover(function(){ self.hovering = true; }, function(){ self.hovering = false; }); $(window).click(function(){ if(self.hovering == false){ $search.fadeOut(150); } }); $search.find(".close").live("click",function(){ $search.fadeOut(150); }); } }