Dotclear

source: plugins/pages/list.js @ 3182:adf3c934173f

Revision 3182:adf3c934173f, 3.4 KB checked in by franck <carnet.franck.paul@…>, 10 years ago (diff)

Disable submit button unless at least one item selected whenever is possible, closes #1600

Line 
1dotclear.viewPostContent = function(line,action) {
2     var action = action || 'toggle';
3     if ($(line).attr('id') == undefined) { return; }
4
5     var postId = $(line).attr('id').substr(1);
6     var tr = document.getElementById('pe'+postId);
7
8     if ( !tr && ( action == 'toggle' || action == 'open' ) ) {
9          tr = document.createElement('tr');
10          tr.id = 'pe'+postId;
11          var td = document.createElement('td');
12          td.colSpan = 8;
13          td.className = 'expand';
14          tr.appendChild(td);
15
16          // Get post content
17          $.get('services.php',{f:'getPostById', id: postId, post_type: ''},function(data) {
18               var rsp = $(data).children('rsp')[0];
19
20               if (rsp.attributes[0].value == 'ok') {
21                    var post = $(rsp).find('post_display_content').text();
22                    var post_excerpt = $(rsp).find('post_display_excerpt').text();
23                    var res = '';
24
25                    if (post) {
26                         if (post_excerpt) {
27                              res += post_excerpt + '<hr />';
28                         }
29                         res += post;
30                         $(td).append(res);
31                    }
32               } else {
33                    alert($(rsp).find('message').text());
34               }
35          });
36
37          $(line).addClass('expand');
38          line.parentNode.insertBefore(tr,line.nextSibling);
39     }
40     else if (tr && tr.style.display == 'none' && ( action == 'toggle' || action == 'open' ) )
41     {
42          $(tr).css('display', 'table-row');
43          $(line).addClass('expand');
44     }
45     else if (tr && tr.style.display != 'none' && ( action == 'toggle' || action == 'close' ) )
46     {
47          $(tr).css('display', 'none');
48          $(line).removeClass('expand');
49     }
50};
51
52$(function() {
53     $('#pageslist tr.line').prepend('<td class="expander"></td>');
54     $('#form-entries tr:not(.line) th:first').attr('colspan',4);
55     $.expandContent({
56          line:$('#form-entries tr:not(.line)'),
57          lines:$('#form-entries tr.line'),
58          callback:dotclear.viewPostContent
59     });
60     $('.checkboxes-helpers').each(function() {
61          p = $('<p></p>');
62          $(this).prepend(p);
63          dotclear.checkboxesHelpers(p,undefined,'#pageslist td input[type=checkbox]','#form-entries #do-action');
64     });
65     $('#pageslist td input[type=checkbox]').enableShiftClick();
66     dotclear.condSubmit('#pageslist td input[type=checkbox]','#form-entries #do-action');
67
68     $("#pageslist tr.line td:not(.expander)").mousedown(function(){
69          $('#pageslist tr.line').each(function() {
70               var td = this.firstChild;
71               dotclear.viewPostContent(td.firstChild,td.firstChild.line,'close');
72          });
73          $('#pageslist tr:not(.line)').remove();
74     });
75
76     $("#pageslist").sortable({
77          cursor:'move',
78          stop: function( event, ui ) {
79               $("#pageslist tr td input.position").each(function(i) {
80                    $(this).val(i+1);
81               });
82          }
83     });
84     $("#pageslist tr").hover(function () {
85          $(this).css({'cursor':'move'});
86     }, function () {
87          $(this).css({'cursor':'auto'});
88     });
89     $("#pageslist tr td input.position").hide();
90     $("#pageslist tr td.handle").addClass('handler');
91
92     $("form input[type=submit]").click(function() {
93          $("input[type=submit]", $(this).parents("form")).removeAttr("clicked");
94          $(this).attr("clicked", "true");
95     })
96
97     $('#form-entries').submit(function() {
98          var action = $(this).find('select[name="action"]').val();
99          var checked = false;
100          if ($("input[name=reorder][clicked=true]").val()) {
101               return true;
102          }
103          $(this).find('input[name="entries[]"]').each(function() {
104               if (this.checked) {
105                    checked = true;
106               }
107          });
108
109          if (!checked) { return false; }
110
111          if (action == 'delete') {
112               return window.confirm(dotclear.msg.confirm_delete_posts.replace('%s',$('input[name="entries[]"]:checked').size()));
113          }
114
115          return true;
116     });
117});
Note: See TracBrowser for help on using the repository browser.

Sites map