Godwin
7 years ago
13 changed files with 614 additions and 280 deletions
After Width: | Height: | Size: 377 B |
@ -1,114 +1,114 @@ |
|||||
(function() { |
(function() { |
||||
function closeWorkshopSelector() { |
function closeWorkshopSelector() { |
||||
document.getElementById('workshop-selector').classList.remove('open'); |
document.getElementById('workshop-selector').classList.remove('open'); |
||||
document.body.classList.remove('modal-open'); |
document.body.classList.remove('modal-open'); |
||||
} |
} |
||||
document.getElementById('workshop-selector').addEventListener('click', function(event) { |
document.getElementById('workshop-selector').addEventListener('click', function(event) { |
||||
if (event.target.id == 'workshop-selector') { |
if (event.target.id == 'workshop-selector') { |
||||
closeWorkshopSelector(); |
closeWorkshopSelector(); |
||||
} |
} |
||||
}); |
}); |
||||
function _post(form, params, f) { |
function _post(form, params, f) { |
||||
var request = new XMLHttpRequest(); |
var request = new XMLHttpRequest(); |
||||
request.onreadystatechange = function() { |
request.onreadystatechange = function() { |
||||
if (request.readyState == 4) { |
if (request.readyState == 4) { |
||||
if (request.status == 200) { |
if (request.status == 200) { |
||||
f(request.responseText); |
f(request.responseText); |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
request.open('POST', form.getAttribute('action'), true); |
request.open('POST', form.getAttribute('action'), true); |
||||
request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); |
request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); |
||||
params['authenticity_token'] = form.querySelector('[name="authenticity_token"]').value; |
params['authenticity_token'] = form.querySelector('[name="authenticity_token"]').value; |
||||
var data = []; |
var data = []; |
||||
for (var key in params) { |
for (var key in params) { |
||||
data.push(key + '=' + params[key]); |
data.push(key + '=' + params[key]); |
||||
} |
} |
||||
request.send(data.join('&')); |
request.send(data.join('&')); |
||||
} |
} |
||||
function selectorMatches(el, selector) { |
function selectorMatches(el, selector) { |
||||
var p = Element.prototype; |
var p = Element.prototype; |
||||
var f = p.matches || p.webkitMatchesSelector || p.mozMatchesSelector || p.msMatchesSelector || function(s) { |
var f = p.matches || p.webkitMatchesSelector || p.mozMatchesSelector || p.msMatchesSelector || function(s) { |
||||
return [].indexOf.call(document.querySelectorAll(s), this) !== -1; |
return [].indexOf.call(document.querySelectorAll(s), this) !== -1; |
||||
}; |
}; |
||||
return f.call(el, selector); |
return f.call(el, selector); |
||||
} |
} |
||||
function updateSchedule(html) { |
function updateSchedule(html) { |
||||
var schedule = document.getElementById('schedule-preview'); |
var schedule = document.getElementById('schedule-preview'); |
||||
var s = document.createElement('div'); |
var s = document.createElement('div'); |
||||
s.innerHTML = html; |
s.innerHTML = html; |
||||
schedule.innerHTML = s.children[0].innerHTML; |
schedule.innerHTML = s.children[0].innerHTML; |
||||
schedule.classList.remove('requesting'); |
schedule.classList.remove('requesting'); |
||||
} |
} |
||||
|
|
||||
document.body.addEventListener('submit', function (event) { |
document.body.addEventListener('submit', function (event) { |
||||
if (event.target.classList.contains('deschedule-workshop')) { |
if (event.target.classList.contains('deschedule-workshop')) { |
||||
event.preventDefault(); |
event.preventDefault(); |
||||
var schedule = document.getElementById('schedule-preview'); |
var schedule = document.getElementById('schedule-preview'); |
||||
var form = event.target; |
var form = event.target; |
||||
schedule.classList.add('requesting'); |
schedule.classList.add('requesting'); |
||||
_post( |
_post( |
||||
form, |
form, |
||||
{ |
{ |
||||
id: form.querySelector('[name="id"]').value, |
id: form.querySelector('[name="id"]').value, |
||||
button: 'deschedule_workshop' |
button: 'deschedule_workshop' |
||||
}, |
}, |
||||
updateSchedule |
updateSchedule |
||||
); |
); |
||||
} |
} |
||||
}); |
}); |
||||
document.body.addEventListener('click', function (event) { |
document.body.addEventListener('click', function (event) { |
||||
//console.log(event.target);
|
|
||||
|
if (selectorMatches(event.target, 'td.workshop.open, td.workshop.open *')) { |
||||
if (selectorMatches(event.target, 'td.workshop.open, td.workshop.open *')) { |
var button = event.target; |
||||
//event.stopPropagation();
|
while (button && button.tagName && button.tagName !== 'TD') { |
||||
var button = event.target; |
button = button.parentElement; |
||||
while (button && button.tagName && button.tagName !== 'TD') { |
} |
||||
button = button.parentElement; |
|
||||
} |
|
||||
|
|
||||
document.getElementById('workshop-selector').classList.add('open'); |
document.getElementById('workshop-selector').classList.add('open'); |
||||
var table = document.getElementById('table'); |
var table = document.getElementById('table'); |
||||
table.classList.add('loading'); |
table.classList.add('loading'); |
||||
document.body.classList.add('modal-open'); |
document.body.classList.add('modal-open'); |
||||
|
|
||||
var block = button.getAttribute('data-block'); |
var block = button.getAttribute('data-block'); |
||||
var day = button.getAttribute('data-day'); |
var day = button.getAttribute('data-day'); |
||||
var location = button.getAttribute('data-location'); |
var location = button.getAttribute('data-location'); |
||||
|
var division = button.getAttribute('data-division'); |
||||
_post( |
|
||||
document.getElementById('workshop-table-form'), |
_post( |
||||
{ |
document.getElementById('workshop-table-form'), |
||||
block: block, |
{ |
||||
day: day, |
block: block, |
||||
location: location, |
day: day, |
||||
button: 'get-workshop-list' |
location: location, |
||||
}, |
division: division, |
||||
function (response) { |
button: 'get-workshop-list' |
||||
var table = document.getElementById('table'); |
}, |
||||
table.innerHTML = response; |
function (response) { |
||||
table.classList.remove('loading'); |
var table = document.getElementById('table'); |
||||
forEachElement('tr.selectable', function(row) { |
table.innerHTML = response; |
||||
row.addEventListener('click', function(event) { |
table.classList.remove('loading'); |
||||
var schedule = document.getElementById('schedule-preview'); |
forEachElement('tr.selectable', function(row) { |
||||
schedule.classList.add('requesting'); |
row.addEventListener('click', function(event) { |
||||
closeWorkshopSelector(); |
var schedule = document.getElementById('schedule-preview'); |
||||
var form = document.getElementById('workshop-table-form'); |
schedule.classList.add('requesting'); |
||||
_post( |
closeWorkshopSelector(); |
||||
form, |
var form = document.getElementById('workshop-table-form'); |
||||
{ |
_post( |
||||
workshop: row.getAttribute('data-workshop'), |
form, |
||||
block: block, |
{ |
||||
day: day, |
workshop: row.getAttribute('data-workshop'), |
||||
location: form.querySelector('#event_location').value, |
block: block, |
||||
button: 'set-workshop' |
day: day, |
||||
}, |
location: form.querySelector('#event_location').value, |
||||
updateSchedule |
button: 'set-workshop' |
||||
); |
}, |
||||
}); |
updateSchedule |
||||
}, table); |
); |
||||
} |
}); |
||||
); |
}, table); |
||||
} |
} |
||||
}, true); |
); |
||||
|
} |
||||
|
}, true); |
||||
})(); |
})(); |
||||
|
@ -0,0 +1,12 @@ |
|||||
|
- add_inline_script :registrations |
||||
|
= columns(medium: 12) do |
||||
|
.goes-fullscreen#registrations-table |
||||
|
.flex-column |
||||
|
= searchfield :search, nil, big: true, stretch: true |
||||
|
%a.button{data: { expands: 'registrations-table' }}='expand' |
||||
|
%a.button.delete{data: { contracts: 'registrations-table' }}='close' |
||||
|
.table-scroller#registrations |
||||
|
= html_table(@excel_data, workshops_table_options) |
||||
|
= columns(medium: 12) do |
||||
|
.actions.center |
||||
|
= link_to (_'links.download.Excel'), administration_step_path(@this_conference.slug, :workshops, format: :xlsx), class: [:button, :download] |
Loading…
Reference in new issue