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); //$("form:not(.noscroll)").submit(function () { $("form:not(.noscroll)").submit(function () { $("form").append(''); }); $("a.scroll").click(function () { $(this).attr("href",$(this).attr("href")+"&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; }); $('.antwoord').each(function(){ $(this).hide() }); $('.vraag').click(function() { $(this).parent().toggleClass('liopen'); $(this).next().toggle(); }); });