This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
orbit-4-1/app/assets/javascripts/member-selection.js

49 lines
1.3 KiB
JavaScript
Raw Permalink Normal View History

$(document).ready(function() {
$(".select_user_modal").on('click', function(){
var ids = [];
var users = $('.selected_user');
users.each(function(i) {
ids.push(users.eq(i).attr('id'));
});
$("#main-wrap").after("<span id='select_user'></span>");
$.ajax({
type: 'GET',
url: $(this).attr("rel"),
dataType: 'script',
data: {ids: ids},
success: function (msg) {
$("#member-filter").modal('show'); },
error: function(){
// TODO: i18n in javascript
alert("ERROR");
}
});
return false;
});
$("#remove_users").on('click', function(){
var ids = [];
var users = $('.selected_user input[type="checkbox"]:checked');
users.each(function(i) {
ids.push(users.eq(i).parent().attr('id'));
});
if (users.size() > 0) {
// TODO: i18n in javascript
if (confirm('Are you sure you want to delete this?')) {
$.ajax({
type: 'DELETE',
url: $(this).attr("rel"),
dataType: 'script',
data: {ids: ids},
error: function(){
// TODO: i18n in javascript
alert("ERROR");
}
});
}
}
else {
// TODO: i18n in javascript
alert('You did not select anything to delete')
}
});
});