Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- window.addEvent('domready', function(){
- /**
- * Add tooltips to calendar links
- */
- $$('#calendar table tbody td').each(function(cell){
- var link = cell.getElement('a');
- if(link){
- var details = JSON.decode(cell.getElement('input[name=details]').value);
- link.tooltipTitle = new Date().parse(details.date).format('%d/%m/%Y');
- link.tooltipText = '';
- switch(link.rel){
- case 'registration_future':
- if(details.comment){
- link.tooltipText += details.comment + '.<br /><br />';
- }
- if(details.morning_full || details.afternoon_full){
- link.tooltipText += details.morning_full? 'Voormiddag: volzet <br />' : 'Voormiddag: er zijn nog vrije plaatsen.<br />';
- link.tooltipText += details.afternoon_full? 'Namiddag: volzet <br />' : 'Namiddag: er zijn nog vrije plaatsen.<br />';
- }else{
- link.tooltipText += 'Er zijn nog voldoende plaatsen vrij.<br />';
- }
- link.tooltipText += '<br />Klik voor meer details';
- break;
- case 'registration_past':
- link.tooltipText += 'Er is op deze dag geen inschrijving (meer) mogelijk.';
- break;
- case 'closed':
- link.tooltipText += details.comment || 'Er is op deze dag geen inschrijving mogelijk.';
- break;
- case 'undefined':
- link.tooltipText += 'Er is op deze dag (nog) geen inschrijving mogelijk.';
- break;
- }
- }
- });
- new Tips($$('#calendar table tbody a'), {
- title: function(link){ return link.tooltipTitle; },
- text: function(link){ return link.tooltipText; },
- className: 'tooltip'
- });
- /**
- * Handle delete link in registrations overview
- */
- $$('div.registrations table a.delete').each(function(link){
- link.addEvent('click', function(){
- // Define post parameters
- var postData = {
- registrations: this.rel.split('|')
- };
- // Delete row
- deleteItem.request({
- url: '/inschrijven/deletesessionregistrations',
- message: 'Ben je zeker dat je deze inschrijving wil verwijderen?',
- postData: postData,
- successCallback: function(response){
- this.getParent('tr').highlight();
- if(this.getParent('tbody').getElements('tr').length == 1){
- this.getParent('div.registrations').destroy();
- }else{
- this.getParent('tr').destroy.delay(400, this.getParent('tr'));
- }
- }.bind(this),
- errorCallback: function(response){
- alert(response.message)
- }
- })
- });
- });
- /**
- * Show registration popup OR registration list when clicking on available day
- */
- $$('td.available a').each(function(link){
- link.addEvent('click', function(){
- // Get cell
- var cell = link.getParent('td');
- // Get day details
- var dayDetails = JSON.decode(cell.getElement('input[name=details]').value);
- // Show popup overlay
- popupOverlay.fadeIn(900);
- // Determine which popup to show
- if(cell.hasClass('confirmed') || cell.hasClass('editable')){
- registrationListPopup.show(dayDetails);
- }else{
- registrationPopup.show(dayDetails);
- }
- })
- });
- /**
- * Show registration list when clicking on unavailable but confirmed day
- */
- $$('td.closed.confirmed a').each(function(link){
- link.addEvent('click', function(){
- // Get cell
- var cell = link.getParent('td');
- // Get day details
- var dayDetails = JSON.decode(cell.getElement('input[name=details]').value);
- // Show popup overlay
- popupOverlay.fadeIn(900);
- // Determine which popup to show
- registrationListPopup.show(dayDetails);
- })
- });
- /**
- * Hide popup overlay on registration popup close
- */
- registrationPopup.closeButton.addEvent('click', function(){
- popupOverlay.fadeOut();
- });
- /**
- * Hide popup overlay on registrationlist popup close
- */
- registrationListPopup.closeButton.addEvent('click', function(){
- popupOverlay.fadeOut();
- });
- /**
- * Show registration popup on registrationlist submit click
- */
- registrationListPopup.newRegistrationButton.addEvent('click', function(){
- registrationListPopup.hide();
- registrationPopup.show(registrationListPopup.dayDetails);
- });
- /**
- * Move popup overlay to back on reservation popup close
- */
- reservationPopup.closeButton.addEvent('click', function(){
- popupOverlay.setZIndex(900);
- });
- /**
- * Handle click on registration popup submit button
- */
- registrationPopup.submitButton.addEvent('click', function(){
- registrationPopup.submit({
- url: '/inschrijven/addregistration',
- successCallback: function(response){
- location.reload(true);
- },
- errorCallback: function(response){
- alert(response.message);
- if(response.reload){
- location.reload(true);
- }
- }
- });
- });
- /**
- * Handle click on reservation popup submit button
- */
- reservationPopup.submitButton.addEvent('click', function(){
- reservationPopup.submit({
- url: '/inschrijven/addreservation',
- successCallback: function(response){
- reservationPopup.hide();
- popupOverlay.setZIndex(900);
- },
- errorCallback: function(response){
- alert(response.message);
- }
- });
- });
- /**
- * Handle click on registration popup reservation link
- */
- registrationPopup.reservationLink.addEvent('click', function(){
- popupOverlay.setZIndex(950);
- reservationPopup.show(registrationPopup.dayDetails.id);
- });
- var showDialog = true;
- /**
- * Warn for unchecked agreement checkbox on confirmation of registrations
- */
- if($('registrations_confirm')){
- $('registrations_confirm').onsubmit = function(){
- if(!$('registrations_confirm').getElement('input[name=agreement]').checked){
- alert('Om inschrijvingen te bewaren dient u akkoord te gaan met ons huishoudelijk reglement');
- return false;
- }
- }
- }
- /*function showDialog(booler) {
- }
- var btnInschrijving = document.getElementById('btn_bevestig_inschrijving');
- if (btnInschrijving) {
- btnInschrijving.onclick = function () {
- console.log("clicked set true");
- showDialog = false;
- }
- }
- window.onbeforeunload = function (evt) {
- console.log(evt);
- var message = 'U hebt uw inschrijving nog niet bevestigd. Bent u zeker dat u deze pagina wil verlaten? Uw wijzigingen worden niet opgeslagen.';
- if (typeof evt == 'undefined') {
- evt = window.event;
- }
- if (evt ) {
- if (document.getElementsByClassName('registrations').length > 0 && showDialog == true) {
- evt.returnValue = message;
- }
- }
- console.log('clicked : ' + showDialog);
- if (document.getElementsByClassName('registrations').length > 0 && showDialog == true) {
- return message;
- }
- showDialog = false;
- console.log('clicked 2 : ' + showDialog);
- }*/
- hostname = new RegExp(location.host);
- // Act on each link
- $$('a').each(function(){
- // Store current link's url
- var url = $(this).attr("href");
- // Test if current host (domain) is in it
- if(hostname.test(url)){
- // If it's local...
- $(this).addClass('local');
- }
- else if(url.slice(0, 1) == "#"){
- // It's an anchor link
- $(this).addClass('anchor');
- }
- else {
- // a link that does not contain the current host
- $(this).addClass('external');
- }
- });
- });
Add Comment
Please, Sign In to add comment