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 *')) { |
||||
//event.stopPropagation();
|
var button = event.target; |
||||
var button = event.target; |
while (button && button.tagName && button.tagName !== 'TD') { |
||||
while (button && button.tagName && button.tagName !== 'TD') { |
button = button.parentElement; |
||||
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( |
_post( |
||||
document.getElementById('workshop-table-form'), |
document.getElementById('workshop-table-form'), |
||||
{ |
{ |
||||
block: block, |
block: block, |
||||
day: day, |
day: day, |
||||
location: location, |
location: location, |
||||
button: 'get-workshop-list' |
division: division, |
||||
}, |
button: 'get-workshop-list' |
||||
function (response) { |
}, |
||||
var table = document.getElementById('table'); |
function (response) { |
||||
table.innerHTML = response; |
var table = document.getElementById('table'); |
||||
table.classList.remove('loading'); |
table.innerHTML = response; |
||||
forEachElement('tr.selectable', function(row) { |
table.classList.remove('loading'); |
||||
row.addEventListener('click', function(event) { |
forEachElement('tr.selectable', function(row) { |
||||
var schedule = document.getElementById('schedule-preview'); |
row.addEventListener('click', function(event) { |
||||
schedule.classList.add('requesting'); |
var schedule = document.getElementById('schedule-preview'); |
||||
closeWorkshopSelector(); |
schedule.classList.add('requesting'); |
||||
var form = document.getElementById('workshop-table-form'); |
closeWorkshopSelector(); |
||||
_post( |
var form = document.getElementById('workshop-table-form'); |
||||
form, |
_post( |
||||
{ |
form, |
||||
workshop: row.getAttribute('data-workshop'), |
{ |
||||
block: block, |
workshop: row.getAttribute('data-workshop'), |
||||
day: day, |
block: block, |
||||
location: form.querySelector('#event_location').value, |
day: day, |
||||
button: 'set-workshop' |
location: form.querySelector('#event_location').value, |
||||
}, |
button: 'set-workshop' |
||||
updateSchedule |
}, |
||||
); |
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