1
|
(function($) {
|
2
|
$(function() {
|
3
|
$('.stats').click(function() {
|
4
|
var url = 'form/' + this.id + '/';
|
5
|
$('#ajax-dlg').load(url,
|
6
|
function () {
|
7
|
$(this).dialog({title: 'Choix des parametres', width: '700px',
|
8
|
buttons: [ { text: "Fermer",
|
9
|
click: function() { $(this).dialog("close"); } },
|
10
|
{ text: "Extraire",
|
11
|
click: function() { $("#ajax-dlg form").submit(); $(this).dialog("close"); } }]});
|
12
|
var deck = $('#id_participants_on_deck');
|
13
|
$(deck).bind('added', function() {
|
14
|
var added = $(deck).find('div:last');
|
15
|
var t = added.attr('id').indexOf('_group:');
|
16
|
if ( t == -1) return;
|
17
|
var query = added.attr('id').substr(t+1);
|
18
|
|
19
|
/* remove group element and fake id */
|
20
|
added.remove();
|
21
|
var val = $('#id_participants').val();
|
22
|
$('#id_participants').val(val.substr(0, val.substr(0, val.length-1).lastIndexOf('|')+1));
|
23
|
|
24
|
/* add all workers */
|
25
|
var receive_result = $('#id_participants_text').autocomplete('option', 'select');
|
26
|
$.getJSON($('#id_participants_text').autocomplete('option', 'source') + '?term=' + query,
|
27
|
function(data) {
|
28
|
$.each(data, function(key, val) {
|
29
|
if (key==0) return; /* ignore first element as it's the group itself */
|
30
|
var ui = Object();
|
31
|
ui.item = val;
|
32
|
receive_result(null, ui);
|
33
|
});
|
34
|
});
|
35
|
});
|
36
|
});
|
37
|
return false;
|
38
|
});
|
39
|
});
|
40
|
})(window.jQuery)
|