3 // clicking on book checks chunks, too
4 $("input[name=select_book]").change(function(ev) {
6 $book.closest("table").find("input[name=select_chunk][data-book-id=" + $book.val() + "]").attr("checked", $book.is(':checked'));
9 // initialize context menu
11 var get_ids = function() {
12 return $.map($("input[name=select_chunk]:checked"), function(ele, idx) {
15 $.map($("input[name=select_book][data-chunk-id!=]:checked"), function(ele, idx) {
16 return $(ele).attr("data-chunk-id");
21 var set_field = function(key, ops) {
27 if (key == "publish" || key == "unpublish") {
30 var kp = key.split('_');
32 var idx = parseInt(kp[1]);
34 var target_field = field;
35 if (field == 'other-user')
36 target_field = 'user';
38 fds[target_field] = $("select[name="+field+"] option[value!=]").eq(idx).val();
40 /* fill in the form */
41 $("#chunk_mass_edit [name=ids]").val(get_ids());
43 $("#chunk_mass_edit [name="+fn+"]").val(fds[fn]);
46 $.post($("#chunk_mass_edit").attr("action"),
47 $("#chunk_mass_edit").serialize(),
48 function(data, status) {
49 location.reload(true);
57 var get_items = function(field) {
59 $.each($("select[name="+field+"] option[value!=]"),
61 d[field+"_"+idx] = { name: $(ele).text() };
68 selector: '#file-list',
71 name: $("label[for=mass_edit_stage]").text(),
72 items: get_items("stage"),
76 name: $("label[for=mass_edit_user]").text(),
78 var active_users = get_items("user");
79 active_users['other'] = {
80 name: $("label[for=mass_edit_other]").text(),
81 items: get_items("other-user"),
88 name: $("label[for=mass_edit_publish]").text(),
92 name: $("label[for=mass_edit_unpublish]").text(),