4 // clicking on book checks chunks, too
5 $("input[name=select_book]").change(function(ev) {
7 $book.closest("table").find("input[name=select_chunk][data-book-id=" + $book.val() + "]").attr("checked", $book.is(':checked'));
10 // initialize context menu
12 var get_ids = function() {
13 return $.map($("input[name=select_chunk]:checked"), function(ele, idx) {
16 $.map($("input[name=select_book][data-chunk-id!=]:checked"), function(ele, idx) {
17 return $(ele).attr("data-chunk-id");
21 var get_callback = function(form_field_name) {
22 var $form = $("#chunk_mass_edit");
23 var $field = $("[name=" + form_field_name + "]", $form);
24 var $ids_field = $("[name=ids]").val(get_ids());
25 var usable_callback = function(value) {
27 $ids_field.val(get_ids());
28 $.post($form.attr("action"),
30 function(data, status) {
31 location.reload(true);
36 return usable_callback;
39 var get_items = function(field, callback) {
41 $.each($("select[name="+field+"] option[value!=]"),
43 d[field + "_" + idx] = {
45 callback: function() {callback($(ele).attr('value'));}
51 var user_callback = get_callback('user');
53 get_items("active-users", user_callback)
55 var current_user_items = user_items = {};
57 var more_label = $("label[for=mass_edit_more_users]").text();
58 for (user_table in users) {
59 for (user in users[user_table]) {
60 if (i && i % 20 == 0) {
62 current_user_items['more'] = {
66 current_user_items = more_items;
68 current_user_items[user] = users[user_table][user];
73 selector: '#file-list',
76 name: $("label[for=mass_edit_stage]").text(),
77 items: get_items("stage", get_callback('stage')),
81 name: $("label[for=mass_edit_user]").text(),
86 name: $("label[for=mass_edit_project]").text(),
87 items: get_items("project", get_callback('project')),