Guest User

Untitled

a guest
Nov 21st, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.12 KB | None | 0 0
  1. window.addEvent('domready', function(){
  2.  
  3. /**
  4. * Add tooltips to calendar links
  5. */
  6. $$('#calendar table tbody td').each(function(cell){
  7. var link = cell.getElement('a');
  8. if(link){
  9. var details = JSON.decode(cell.getElement('input[name=details]').value);
  10. link.tooltipTitle = new Date().parse(details.date).format('%d/%m/%Y');
  11. link.tooltipText = '';
  12. switch(link.rel){
  13.  
  14. case 'registration_future':
  15. if(details.comment){
  16. link.tooltipText += details.comment + '.<br /><br />';
  17. }
  18. if(details.morning_full || details.afternoon_full){
  19. link.tooltipText += details.morning_full? 'Voormiddag: volzet <br />' : 'Voormiddag: er zijn nog vrije plaatsen.<br />';
  20. link.tooltipText += details.afternoon_full? 'Namiddag: volzet <br />' : 'Namiddag: er zijn nog vrije plaatsen.<br />';
  21. }else{
  22. link.tooltipText += 'Er zijn nog voldoende plaatsen vrij.<br />';
  23. }
  24. link.tooltipText += '<br />Klik voor meer details';
  25. break;
  26.  
  27. case 'registration_past':
  28. link.tooltipText += 'Er is op deze dag geen inschrijving (meer) mogelijk.';
  29. break;
  30.  
  31. case 'closed':
  32. link.tooltipText += details.comment || 'Er is op deze dag geen inschrijving mogelijk.';
  33. break;
  34.  
  35. case 'undefined':
  36. link.tooltipText += 'Er is op deze dag (nog) geen inschrijving mogelijk.';
  37. break;
  38. }
  39. }
  40. });
  41.  
  42. new Tips($$('#calendar table tbody a'), {
  43. title: function(link){ return link.tooltipTitle; },
  44. text: function(link){ return link.tooltipText; },
  45. className: 'tooltip'
  46. });
  47.  
  48. /**
  49. * Handle delete link in registrations overview
  50. */
  51. $$('div.registrations table a.delete').each(function(link){
  52. link.addEvent('click', function(){
  53.  
  54. // Define post parameters
  55. var postData = {
  56. registrations: this.rel.split('|')
  57. };
  58.  
  59. // Delete row
  60. deleteItem.request({
  61. url: '/inschrijven/deletesessionregistrations',
  62. message: 'Ben je zeker dat je deze inschrijving wil verwijderen?',
  63. postData: postData,
  64. successCallback: function(response){
  65. this.getParent('tr').highlight();
  66. if(this.getParent('tbody').getElements('tr').length == 1){
  67. this.getParent('div.registrations').destroy();
  68. }else{
  69. this.getParent('tr').destroy.delay(400, this.getParent('tr'));
  70. }
  71. }.bind(this),
  72. errorCallback: function(response){
  73. alert(response.message)
  74. }
  75. })
  76. });
  77. });
  78.  
  79. /**
  80. * Show registration popup OR registration list when clicking on available day
  81. */
  82. $$('td.available a').each(function(link){
  83. link.addEvent('click', function(){
  84.  
  85. // Get cell
  86. var cell = link.getParent('td');
  87.  
  88. // Get day details
  89. var dayDetails = JSON.decode(cell.getElement('input[name=details]').value);
  90.  
  91. // Show popup overlay
  92. popupOverlay.fadeIn(900);
  93.  
  94. // Determine which popup to show
  95. if(cell.hasClass('confirmed') || cell.hasClass('editable')){
  96. registrationListPopup.show(dayDetails);
  97. }else{
  98. registrationPopup.show(dayDetails);
  99. }
  100. })
  101. });
  102.  
  103. /**
  104. * Show registration list when clicking on unavailable but confirmed day
  105. */
  106. $$('td.closed.confirmed a').each(function(link){
  107. link.addEvent('click', function(){
  108.  
  109. // Get cell
  110. var cell = link.getParent('td');
  111.  
  112. // Get day details
  113. var dayDetails = JSON.decode(cell.getElement('input[name=details]').value);
  114.  
  115. // Show popup overlay
  116. popupOverlay.fadeIn(900);
  117.  
  118. // Determine which popup to show
  119. registrationListPopup.show(dayDetails);
  120. })
  121. });
  122.  
  123. /**
  124. * Hide popup overlay on registration popup close
  125. */
  126. registrationPopup.closeButton.addEvent('click', function(){
  127. popupOverlay.fadeOut();
  128. });
  129.  
  130. /**
  131. * Hide popup overlay on registrationlist popup close
  132. */
  133. registrationListPopup.closeButton.addEvent('click', function(){
  134. popupOverlay.fadeOut();
  135. });
  136.  
  137. /**
  138. * Show registration popup on registrationlist submit click
  139. */
  140. registrationListPopup.newRegistrationButton.addEvent('click', function(){
  141. registrationListPopup.hide();
  142. registrationPopup.show(registrationListPopup.dayDetails);
  143. });
  144.  
  145. /**
  146. * Move popup overlay to back on reservation popup close
  147. */
  148. reservationPopup.closeButton.addEvent('click', function(){
  149. popupOverlay.setZIndex(900);
  150. });
  151.  
  152. /**
  153. * Handle click on registration popup submit button
  154. */
  155. registrationPopup.submitButton.addEvent('click', function(){
  156. registrationPopup.submit({
  157. url: '/inschrijven/addregistration',
  158. successCallback: function(response){
  159. location.reload(true);
  160. },
  161. errorCallback: function(response){
  162. alert(response.message);
  163. if(response.reload){
  164. location.reload(true);
  165. }
  166. }
  167. });
  168. });
  169.  
  170. /**
  171. * Handle click on reservation popup submit button
  172. */
  173. reservationPopup.submitButton.addEvent('click', function(){
  174. reservationPopup.submit({
  175. url: '/inschrijven/addreservation',
  176. successCallback: function(response){
  177. reservationPopup.hide();
  178. popupOverlay.setZIndex(900);
  179. },
  180. errorCallback: function(response){
  181. alert(response.message);
  182. }
  183. });
  184. });
  185.  
  186. /**
  187. * Handle click on registration popup reservation link
  188. */
  189. registrationPopup.reservationLink.addEvent('click', function(){
  190. popupOverlay.setZIndex(950);
  191. reservationPopup.show(registrationPopup.dayDetails.id);
  192. });
  193.  
  194.  
  195. var showDialog = true;
  196. /**
  197. * Warn for unchecked agreement checkbox on confirmation of registrations
  198. */
  199. if($('registrations_confirm')){
  200. $('registrations_confirm').onsubmit = function(){
  201. if(!$('registrations_confirm').getElement('input[name=agreement]').checked){
  202. alert('Om inschrijvingen te bewaren dient u akkoord te gaan met ons huishoudelijk reglement');
  203. return false;
  204. }
  205. }
  206. }
  207.  
  208. /*function showDialog(booler) {
  209.  
  210. }
  211.  
  212.  
  213. var btnInschrijving = document.getElementById('btn_bevestig_inschrijving');
  214. if (btnInschrijving) {
  215. btnInschrijving.onclick = function () {
  216. console.log("clicked set true");
  217. showDialog = false;
  218. }
  219. }
  220.  
  221. window.onbeforeunload = function (evt) {
  222. console.log(evt);
  223. var message = 'U hebt uw inschrijving nog niet bevestigd. Bent u zeker dat u deze pagina wil verlaten? Uw wijzigingen worden niet opgeslagen.';
  224. if (typeof evt == 'undefined') {
  225.  
  226. evt = window.event;
  227.  
  228. }
  229. if (evt ) {
  230. if (document.getElementsByClassName('registrations').length > 0 && showDialog == true) {
  231. evt.returnValue = message;
  232. }
  233. }
  234. console.log('clicked : ' + showDialog);
  235. if (document.getElementsByClassName('registrations').length > 0 && showDialog == true) {
  236. return message;
  237. }
  238.  
  239. showDialog = false;
  240. console.log('clicked 2 : ' + showDialog);
  241. }*/
  242.  
  243. hostname = new RegExp(location.host);
  244. // Act on each link
  245. $$('a').each(function(){
  246.  
  247. // Store current link's url
  248. var url = $(this).attr("href");
  249.  
  250. // Test if current host (domain) is in it
  251. if(hostname.test(url)){
  252. // If it's local...
  253. $(this).addClass('local');
  254. }
  255. else if(url.slice(0, 1) == "#"){
  256. // It's an anchor link
  257. $(this).addClass('anchor');
  258. }
  259. else {
  260. // a link that does not contain the current host
  261. $(this).addClass('external');
  262. }
  263. });
  264.  
  265. });
Add Comment
Please, Sign In to add comment