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() {
$("li#wwli").css("cursor","pointer");
$("li#wwli").click(function() {
document.location.href = $("a:first",$(this)).attr('href');
});
$("li#wwli").hover(
function() {
if($(this).text().indexOf("leeg") == -1) {
$("img:first", $(this)).attr('src','/data/stdimg/but-type6-hover.png');
}
},
function() {
$("img:first", $(this)).attr('src','/data/stdimg/but-type6.png');
}
);
// 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: '/' });
});
chopText();
// 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 = 456;
if($(this).attr('id')=='newsprev') shift=-shift;
$.get(url, function(data) {
var obj = "#newsleft";
if(!$(obj).length) obj = "#actieleft";
$(obj).css({overflow: 'hidden', position: 'relative'});
$(obj).wrapInner('');
$("#wrap").css('position','relative').animate({left: (0-shift)+'px'},200,function() {
$(this).css({left:(0+shift)+'px'})
$(this).empty().append($(obj, $(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'});
});
chopText($(".choptext",$("#"+id).parent()));
});
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($("div.accowrap:hidden",$(this).parent()).length) {
$("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"+settings.container+">").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);
function doView(id) {
viewerPages = new Array();
$("body").css({overflow: "hidden"});
$.modal("", { minWidth:600, minHeight: 300,
onClose: function(dialog) {
$("body").css({overflow: "auto"});
$.modal.close();
},
onShow: function(dialog) {
$.get("?action=uitgave.loadViewer&id="+id, function(viewerhtml) {
dialog.data.append($(".viewtop",viewerhtml));
dialog.data.append($(".viewpager",viewerhtml));
dialog.data.append($(".viewcontent",viewerhtml));
h = dialog.data.height()-$(".viewtop").height()-32; // 12px padding + 2px correction
//window.location.hash="";
$(".viewcontent").height(h);
st = $(".viewcontent").offset();
$(".viewcontent div").each(function() {
viewerPages.push($(this));
off = $(this).offset();
$(this).data("top",(off.top-st.top));
$(this).data("src",$("a", $(this)).remove().attr("href"));
});
viewerPages[0].html("
");
$(".viewpager ul li:eq(0)").addClass('select');
$(".viewcontent").scroll(function() {
st = $(this).scrollTop();
arr = $(this).data("top");
t = 0;
while(t");
viewerPages[t-1].data("loaded",1);
}
if(t");
viewerPages[t].data("loaded",1);
}
});
});
}
});
}
function OldchopText(selector, reference) {
var width = $(reference).width();
$(selector).each(function() {
var text = $(this).text();
if($(this).width() > width && text.length >= 1) {
var limit = 0;
do {
limit++;
text = text.substring(0,text.length - 1);
$(this).text(text+"…");
} while($(this).width() > width && limit < 100);
}
});
}
function chopText(obj) {
var whitespace = /^\s*$/;
var includeWhiteSpaceNodes = false;
var textNodes = [];
function getTextNodes(node) {
if(node.nodeType == 3) {
if(includeWhiteSpaceNodes || !whitespace.test(node.nodeValue)) {
textNodes.push(node.parentNode);
}
} else {
for(var i=0,len=node.childNodes.length;i w && text.length >= 1) {
var limit = 0;
do {
limit++;
text = text.substring(0,text.length - 1);
obj.text(text+"…");
} while(obj.width() > w && limit < 100);
}
}
var sel;
if(obj) {
sel = obj;
} else {
sel = $(".choptext");
}
sel.each(function() {
textNodes = [];
getTextNodes($(this).get(0));
for(var i=0,len=textNodes.length;i= 31 )
return;
return day_diff == 0 && (
diff < 60 && "zojuist" ||
diff < 120 && "1 minuut geleden" ||
diff < 3600 && Math.floor( diff / 60 ) + " minuten geleden" ||
diff < 7200 && "1 uur geleden" ||
diff < 86400 && Math.floor( diff / 3600 ) + " uur geleden") ||
day_diff == 1 && "gisteren" ||
day_diff < 7 && day_diff + " dagen geleden" ||
day_diff < 31 && Math.ceil( day_diff / 7 ) + " weken geleden";
}
function get_Twitter(context, name) {
$.getJSON("http://api.twitter.com/1/statuses/user_timeline.json?screen_name="+encodeURIComponent(name)+"&trim_user=1&count=12&callback=?", function(data) {
has = false;
if(data && data[0]['text']) {
context.replaceWith(""+data[0]['text']+" "+prettyDate(data[0]['created_at']));
has = true;
}
if(!has) context.replaceWith("Geen bericht gevonden. ");
});
}
function get_Hyves(context, name) {
$.getJSON("http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20xml%20where%20url%3D%22"+encodeURIComponent(name)+"%22&format=json&callback=?", function(data) {
has = false;
if (data.query.results.rss) {
t = data.query.results.rss.channel.item[0];
if(t.title) {
context.replaceWith(""+t.description+" "+prettyDate(t.pubDate));
has = true;
}
}
if(!has) context.replaceWith("Geen bericht gevonden. ");
});
}
function get_Facebook(context, name) {
url = "http://www.facebook.com/feeds/page.php?id=181658135284&format=rss20";
//alert("http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20xml%20where%20url%3D%22"+encodeURIComponent(url)+"%22&format=json");
$.getJSON("http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20xml%20where%20url%3D%22"+encodeURIComponent(url)+"%22&format=json&callback=?", function(data) {
has = false;
//alert(data);
if (data.query.results.rss) {
t = data.query.results.rss.channel.item[0];
//alert(t.title)
if(t.title) {
context.replaceWith(""+t.title+" "+prettyDate(t.pubDate));
has = true;
}
}
if(!has) context.replaceWith("Geen bericht gevonden. ");
});
}
function gogo() {
var imgwidth = $('img.actiepageimg').outerWidth(true);
var width = $('h1.cufactie').width() - imgwidth;
var totalWidth = $('h1.cufactie').width();
// once the available width is known, clear the padding on the image
// the pixels thus saved are needed for some discrepancies in the set
// width in the headings.
// ADD : can't do that, the margin is needed for when the bodytext is alongside
// the image
//$('img.actiepageimg').css('padding-right','0');
$('h1.cufactie').wrap('');
$('h1.cufactie span').each(function() {
$(this).wrap("");
$(this).css('white-space','nowrap');
base = parseFloat($(this).css('font-size'));
base*= (width / ($(this).width()));
$(this).css('font-size', base+'px');
//Cufon.replace('h1.cufactie', { fontFamily: 'Hoefler' });
//Cufon.replace('h1.cufactie', { fontFamily: 'Futura' });
Cufon.refresh('h1.cufactie');
base = parseInt($(this).css('letter-spacing'));
diff = width - $(this).width();
numletters = $(this).text().length;
corr = diff/numletters;
step = Math.abs(corr/5);
$(this).css('letter-spacing', corr+'px');
// while( ($(this).width() != w) && (t<20)) {
// fact = step;
// if($(this).width() > w) {
// fact = -step;
// }
// base+=fact;
// $(this).css('letter-spacing', base+'px');
// t++;
// console.log(t+ " "+fact+" "+w+ " "+$(this).width());
// }
//Cufon.replace('h1.cufactie', { fontFamily: 'Futura' });
});
};