function dialogDone(dialog, form, controls) { var sub = $('#popdone', controls); $("form:not(#dialog)").append(''); $("form:not(#dialog)").append(""); $(":input", $(form)).each(function(){ $(this).css('visibility','hidden'); $("form:not(#dialog)").append($(this)); }); $(form).remove(); $("form:not(#dialog)").submit(); return false; } function dialogCancelled(dialog, form, controls) { var sub = $('#popcancel', controls).attr('name'); pObj = new Object(); pObj[sub] = "submit"; pObj["reqMethod"] = "ajax"; // should be "none" for no output, but that doesn't seem to work.... $.post(document.location.pathname,pObj, function(data, status) { if(status!='success') { alert("An error occurred."); } else { $(dialog).dialog("destroy").remove(); } }); } function handleReturn(dialog, data) { // grab the form from the returned data var form = $("form",data); // remove (but keep) the controls controls = $(".controls",$(form)).remove(); //alert($(controls).html()); $(dialog).dialog('option', 'buttons', { "Ok" : function() { dialogDone(dialog,form, controls); }, "Cancel" : function () { dialogCancelled(dialog, form, controls);} }) $(dialog).bind('dialogclose', function(event, ui) { dialogCancelled(dialog, form, controls); }); // dialog-ify $(dialog).html(form); // handle the submit somehow $("input[type='submit']",$(form)).click(function() { $(dialog).dialog("disable"); $(this).closest("form").append(""); var query = $(this).closest("form").serialize(); $.get(document.location.pathname+"?"+query,null, function(data) { handleReturn(dialog,data); }); return false; }); $(dialog).dialog("enable"); } $(document).ready(function() { // font size thingie var org = 0.75; var cur = 0.75; var size = parseFloat($.cookie('fontsize')); if(size) { cur = size; $('body').css('font-size', cur+'em'); $('input').css('font-size', '1em'); $('textarea').css('font-size', '1em'); } $('a#abigger').bind('click', function() { cur = cur*1.1; $('body').css('font-size', cur+'em'); $('input').css('font-size', '1em'); $('textarea').css('font-size', '1em'); $.cookie('fontsize',cur, { path: '/' }); }); $('a#asmaller').bind('click', function() { cur = cur*0.9; $('body').css('font-size', cur+'em'); $('input').css('font-size', '1em'); $('textarea').css('font-size', '1em'); $.cookie('fontsize',cur, { path: '/' }); }); $('a#areset').bind('click', function() { $('body').css('font-size', org+'em'); $('input').css('font-size', '1em'); $('textarea').css('font-size', '1em'); cur = org; $.cookie('fontsize',cur, { path: '/' }); }); // scroll stuff $(window).scrollTop(scroll); // special case form zoekforms... $("input:#zoeksubmit").mouseup(function () { $("form:#zoekform").submit(); return false; }); $("input:#zoeksubmit").mouseup(function () { $("form:#zoekform").submit(); return false; }); $("form:#zoekform").submit(function () { $("input:#zoeksubmit").attr('disabled','disabled'); //$("form:#zoekform").submit(); return true; }); $("input:#zoeksubmit").mouseover(function () { $(this).attr("src",$(this).attr("src").replace("but-type1.png","but-type1-hover.png")); }); $("input:#zoeksubmit").mouseout(function () { $(this).attr("src",$(this).attr("src").replace("but-type1-hover.png","but-type1.png")); }); //$("form:not(.noscroll)").submit(function () { $("form:not(.noscroll)").live('submit',(function () { $("form").append(''); })); $("a.scroll").live('click',(function () { h = $(this).attr("href"); sep = "&"; if(h.indexOf('?')==-1) sep = "?"; $(this).attr("href",h+sep+"scroll="+$(window).scrollTop()); })); // external links $("a.new").click(function () { window.open($(this).attr("href"));return false; }); // login $("input#i_username").focus(function () { if($(this).attr('value')=='Username') $(this).attr('value',''); if($("input#i_password").attr('value')=='Password') $("input#i_password").attr('value',''); }); $("input#i_password").focus(function () { if($(this).attr('value')=='Password') $(this).attr('value',''); if($("input#i_username").attr('value')=='Username') $("input#i_username").attr('value',''); }); $("input.popbutton").click(function() { // setup the dialog var dialog = $("
Please wait...
").append("form"); $(dialog).dialog({ resizable: false, modal: true, minWidth: 300, minHeight: 300, closeOnEscape: true }); $(dialog).dialog("disable"); // post it, and get the return value var name = $(this).attr('name'); pObj = new Object(); pObj[name] = "select"; $.post(document.location.pathname,pObj, function(data) { handleReturn(dialog, data); }); return false; }); $("#newsnext, #newsprev").live('click', function() { var url = $(this).attr('href'); var shift = 256; if($(this).attr('id')=='newsprev') shift=-shift; $.get(url, function(data) { $("#newswrap").css({overflow: 'hidden', position: 'relative'}); $("#newswrap").wrapInner('
'); $("#wrap").css('position','relative').animate({left: (0-shift)+'px'},200,function() { $(this).css({left:(0+shift)+'px'}) $(this).empty().append($("#newswrap", $(data)).children()); $(this).animate({left: '0'}) }); }); return false; }); $("#agendanext, #agendaprev, #agendacurr").live('click', function() { var shift = 456; if($(this).attr('id')=='agendaprev') shift=-shift; var name = $(this).attr('name'); // create post arr = new Object; arr[name] = name; $.post(document.location.pathname,arr, function(data) { $("#agendaleft").css({overflow: 'hidden', position: 'absolute'}); $("#agendaleft").wrapInner('
'); $("#wrap").css('position','relative').animate({left: (0-shift)+'px'},200,function() { $(this).css({left:(0+shift)+'px'}) $(this).empty().append($("#agendaleft", $(data)).children()); $(this).animate({left: '0'}); }); }); return false; }); //$(".hcaro-controls input[type='image']").live('click', function() { $(".hitem").delegate(".hcaro-controls input[type='image']",'click', function() { // fix container height var hwrap = $(".hcarowrap",$(this).closest('.hitem')); if($("*:animated",hwrap).length!=0) return false; hwrap.css('position','relative'); hwrap.css('overflow','hidden'); hwrap.css('height',hwrap.height()+'px'); var name = $(this).attr('name'); var id = $(this).closest('form').attr('id'); var shift = hwrap.height(); var dir = 'down'; if($(this).hasClass('up')) { dir = 'up'; } $("ul.hcaro",$("#"+id).parent()).css('position','relative'); // create post arr = new Object; arr[name] = name; $.post(document.location.pathname,arr, function(data) { clone = $("ul.hcaro",$("#"+id).parent()).clone().empty().addClass('clone').append( $("ul.hcaro",$("#"+id,$(data)).parent()).children() ); $("ul.hcaro",$("#"+id).parent()).addClass('orig'); if($("div.wrap",$("#"+id).parent()).length==0) { $("ul.hcaro",$("#"+id).parent()).wrap("
"); } // if shift == negative, append, else prepend var moveTo = 0; if(dir=='up') { $("div.wrap",$("#"+id).parent()).css({top: (0-shift)+'px'}) $("div.wrap",$("#"+id).parent()).prepend(clone); moveTo = 0; } else { $("div.wrap",$("#"+id).parent()).append(clone); moveTo = -shift; } //$("div.wrap",$("#"+id).parent()).animate({top: (0-shift)+'px'},300, function() { $("div.wrap",$("#"+id).parent()).animate({top: moveTo+'px'},300, function() { $("#"+id).replaceWith($("#"+id, $(data))); // replace form $("ul.hcaro.orig",$("#"+id).parent()).remove(); $("ul.hcaro.clone",$("#"+id).parent()).removeClass('clone'); $("div.wrap",$("#"+id).parent()).css({top:'0px'}); }); }); return false; }); //$(".poll input[type='submit']").live('click', function() { $(".poll").delegate("input[type='submit']","click" , function() { // fix container height var hitem = $(this).closest('.hitem'); if($("*:animated",hitem).length!=0) return false; hitem.css('position','relative'); hitem.css('overflow','hidden'); hitem.css('height',hitem.height()+'px'); var name = $(this).attr('name'); var value = $(this).attr('value'); var id = $(this).closest('form').attr('id'); // create post arr = $(this).closest('form').serialize()+"&"+name+"="+value; $.post(document.location.pathname, arr, function(data) { var hpoll = $(".hpoll",$("#"+id)); hpoll.css('position','relative'); hpoll.css('top','0px'); var h = hpoll.height(); var xpoll = hpoll.clone().empty().addClass("xpoll").append( $(".hpoll",$("#"+id, $(data))).children()); xpoll.css('position','relative'); xpoll.height(h); xpoll.css('top',(-h+'px')); xpoll.appendTo(hpoll.parent()); xpoll.fadeIn(200); hpoll.fadeOut(200, function() { xpoll.css('top','0px'); hpoll.remove(); }); }); return false; }); // build the carousel $('ul#leestafel').carousel(); // accordion for uitgave/auteur $("div.acco .accowrap").hide(); //$("div.acco .accowrap:first").show(); $("div.acco h3").click( function() { if(":hidden",$(this)) { $("div.acco .accowrap").slideUp(250); $("div.acco h3 a").removeClass("select"); $(this).next().slideDown(250); $("a",$(this)).addClass('select'); } return false; }); }); // // create closure // (function($) { // // plugin definition // $.fn.carousel = function(settings) { // build main options before element iteration var settings = $.extend( {}, $.fn.carousel.defaults, settings); // iterate and reformat each matched element return this.each(function() { $this = $(this); var total = $this.width(); var zero = total/2; var avail = total-0.65*settings.itemwidth; var step = 2*Math.PI/settings.numseats; var items = Array(); var seats = Array(); var oOff; var liIdx; if($(settings.container,$this).length==0) return; var t = 0; $(settings.container,$this).each(function() { var item = new Object(); item.jqNode = $(this).clone(); $(this).remove(); item.itemNode = $('.item:eq(0)', item.jqNode).clone(); item.itemNode.css({width: '100%', height: '100%'}); $('img',item.itemNode).css({width: '100%', height: '100%'}); item.subNode = $('.sub:eq(0)', item.jqNode).clone(); item.index = t++; items.push(item); }); // items now contains all elements that should be on the carousel createSeats(); // attach the navigation arrows arrRight = $(""); arrLeft = $(""); var from = {}; var to = {}; $("#hometafel .left").append(arrLeft).hover( function() { $('img',$(this)).attr('src','/data/stdimg/caro-prev-hover.png'); var curr = seats[0].data('angle')+Math.PI/2; to = { rot: curr+6*Math.PI }; from = { rot: curr}; $(from).animate(to, { duration: 60000, easing: 'linear', step: function() { rotate(this.rot); } }); }, function() { $('img',$(this)).attr('src','/data/stdimg/caro-prev.png'); $(from).stop(); } ); $("#hometafel .right").append(arrRight).hover( function() { $('img',$(this)).attr('src','/data/stdimg/caro-next-hover.png'); var curr = seats[0].data('angle')+Math.PI/2; to = { rot: curr-6*Math.PI }; from = { rot: curr}; $(from).animate(to, { duration: 60000, easing: 'linear', step: function() { rotate(this.rot); } }); }, function() { $('img',$(this)).attr('src','/data/stdimg/caro-next.png'); $(from).stop(); } ); function createSeats() { for(t=0;t").appendTo($this); seat.data('index',t); seat.data('angle', t*step - Math.PI/2); seat.css('position','absolute'); positionSeat(seat); // fill seat seat.append(items[t % items.length].itemNode.clone()); seat.data('item',items[t % items.length]); seat.hoverIntent( function() { liIdx = $(this).data('index'); idx = seats[liIdx].data('item').index; $('#sub').empty().append(items[idx].subNode.children().clone()); }, function() { $('#sub').empty(); } ); seat.mousedown(function(event) { event.preventDefault(); var date = new Date(); var time = date.getTime(); // correct for offset within object tmp = $(this).offset(); oOff = (event.pageX - tmp.left)-settings.itemwidth/2; liIdx = $(this).data('index'); $(document).mouseup( function(event) { event.preventDefault(); $("#leestafel").unbind('mousemove'); date = new Date(); if(date.getTime() - time <250) { window.location.href = $("a",$("#leestafel li:eq("+liIdx+")")).attr('href'); } return false; }); $("#leestafel").mousemove(function(event) { event.preventDefault(); mOff = $(this).offset(); mOff = mOff.left; var pos = event.pageX - mOff - zero -oOff ; if(Math.abs(pos) > (avail)/2 ) { // clicked outside (?) } else { // correct for width of object var fact = total/avail; var rel = Math.asin((pos*fact)/zero); visible = settings.numseats /2 + 1; rotate(rel-(liIdx-(visible-1)/2)*step); } }); }); seats.push(seat); } } function rotate(rot) { for(t=0;t 0.60) { // this seat is (or will be) visible // if it's currently hidden, this will be a signal // to prepare attach it's content. if(seat.is(':hidden')) { tmp = seat.offset(); // are we appearing on the left, or on the right side ? var index = seat.data('index'); var itemindex; var asked; if(pos < zero) { // left, so ask one index higer index++; if(index==settings.numseats) index=0; asked=index; itemindex = seats[index].data('item').index; itemindex--; if(itemindex<0) itemindex+=items.length; } else { // right, so ask one index lower index--; if(index<0) index+=settings.numseats; asked = index; itemindex = seats[index].data('item').index; itemindex++; if(itemindex==items.length) itemindex=0; } // update seat //seat.empty().append('

'+seat.data('index')+'

').append(items[itemindex].jqNode.clone()); seat.empty().append(items[itemindex].itemNode.clone()); seat.data('item',items[itemindex]); } seat.show(); $("a",seat).click(function() {return false; }); if(scale<0.85) { seat.css('opacity',(scale-0.6)/0.25); } else { seat.css('opacity',1); } seat.width(settings.itemwidth*scale); seat.height(settings.itemheight*scale); seat.css('z-index',Math.floor(scale*100)); seat.css('left',Math.floor(pos-seat.width()/2)+"px"); seat.css('bottom',"0"); } else { seat.hide(); } } }); }; // // plugin defaults // $.fn.carousel.defaults = { numseats : 14, // how many seats on the carousel itemwidth : 125, // width of items in seat, used for offsetting positions itemheight : 200, // height of items in seat container : 'li' }; // //end of closure // })(jQuery);