menu shows, time to code js to it
[redakcja.git] / redakcja / static / js / catalogue / book_list.js
1 (function($) {
2     $(function() {
3         // clicking on book checks chunks, too
4         $("input[name=select_book]").change(function(ev) {
5             $book = $(this);
6             $book.closest("table").find("input[name=select_chunk][data-book-id=" + $book.val() + "]").attr("checked", $book.is(':checked'));
7             });
8
9         // initialize context menu
10
11         var get_ids = function() {
12             return $.map($("input[name=select_chunk]:checked"), function(ele, idx) {
13                 return ele.value;
14                 }).join();
15         };
16
17         var set_stage = function(key, opt) {
18             var stage = $("select[name=stage] option[value!=]").eq(key).val();
19             $.post($('input[name=chunk_mass_edit_url]').val(),
20                    {
21                        ids: get_ids(),
22                        stage: stage,
23                    },
24                    function(data, status) {
25                        location.reload(true);
26                    }
27                   );
28         };
29
30         $.contextMenu({
31             selector: '#file-list',
32             items: {
33                 "stage": { 
34                     name: "Set stage",
35                     items: $.map($("select[name=stage] option[value!=]"),
36                                  function(ele, idx) {
37                                      return { 
38                                          name: $(ele).text(),
39                                          callback: set_stage,
40                                      };
41                                  }),
42                 },
43 /*              "user": { 
44                     name: "Set user",
45
46                           },
47                 "status": { 
48                     name: "Set status",
49                     items: 
50                           },*/
51
52             },
53         });
54         
55     });
56 })(jQuery);