1 | dotclear.postExpander = function(line) { |
---|
2 | var td = line.firstChild; |
---|
3 | |
---|
4 | var img = document.createElement('img'); |
---|
5 | img.src = dotclear.img_plus_src; |
---|
6 | img.alt = dotclear.img_plus_alt; |
---|
7 | img.className = 'expand'; |
---|
8 | $(img).css('cursor','pointer'); |
---|
9 | img.line = line; |
---|
10 | img.onclick = function() { dotclear.viewPostContent(this,this.line); }; |
---|
11 | |
---|
12 | td.insertBefore(img,td.firstChild); |
---|
13 | }; |
---|
14 | |
---|
15 | dotclear.postsExpander = function(line,lines) { |
---|
16 | var td = line.firstChild; |
---|
17 | |
---|
18 | var img = document.createElement('img'); |
---|
19 | img.src = dotclear.img_plus_src; |
---|
20 | img.alt = dotclear.img_plus_alt; |
---|
21 | img.className = 'expand'; |
---|
22 | $(img).css('cursor','pointer'); |
---|
23 | img.lines = lines; |
---|
24 | img.onclick = function() { dotclear.viewPostsContent(this,this.lines); }; |
---|
25 | |
---|
26 | td.insertBefore(img,td.firstChild); |
---|
27 | }; |
---|
28 | |
---|
29 | dotclear.viewPostsContent = function(img,lines) { |
---|
30 | lines.each(function() { |
---|
31 | var td = this.firstChild; |
---|
32 | td.firstChild.click(); |
---|
33 | }); |
---|
34 | |
---|
35 | if (img.alt == dotclear.img_plus_alt) { |
---|
36 | img.src = dotclear.img_minus_src; |
---|
37 | img.alt = dotclear.img_minus_alt; |
---|
38 | } else { |
---|
39 | img.src = dotclear.img_plus_src; |
---|
40 | img.alt = dotclear.img_plus_alt; |
---|
41 | } |
---|
42 | }; |
---|
43 | |
---|
44 | dotclear.viewPostContent = function(img,line) { |
---|
45 | var postId = line.id.substr(1); |
---|
46 | var tr = document.getElementById('pe'+postId); |
---|
47 | |
---|
48 | if (!tr) { |
---|
49 | tr = document.createElement('tr'); |
---|
50 | tr.id = 'pe'+postId; |
---|
51 | var td = document.createElement('td'); |
---|
52 | td.colSpan = 8; |
---|
53 | td.className = 'expand'; |
---|
54 | tr.appendChild(td); |
---|
55 | |
---|
56 | img.src = dotclear.img_minus_src; |
---|
57 | img.alt = dotclear.img_minus_alt; |
---|
58 | |
---|
59 | // Get post content |
---|
60 | $.get('services.php',{f:'getPostById', id: postId, post_type: ''},function(data) { |
---|
61 | var rsp = $(data).children('rsp')[0]; |
---|
62 | |
---|
63 | if (rsp.attributes[0].value == 'ok') { |
---|
64 | var post = $(rsp).find('post_display_content').text(); |
---|
65 | var post_excerpt = $(rsp).find('post_display_excerpt').text(); |
---|
66 | var res = ''; |
---|
67 | |
---|
68 | if (post) { |
---|
69 | if (post_excerpt) { |
---|
70 | res += post_excerpt + '<hr />'; |
---|
71 | } |
---|
72 | res += post; |
---|
73 | $(td).append(res); |
---|
74 | } |
---|
75 | } else { |
---|
76 | alert($(rsp).find('message').text()); |
---|
77 | } |
---|
78 | }); |
---|
79 | |
---|
80 | $(line).toggleClass('expand'); |
---|
81 | line.parentNode.insertBefore(tr,line.nextSibling); |
---|
82 | } |
---|
83 | else if (tr.style.display == 'none') |
---|
84 | { |
---|
85 | $(tr).toggle(); |
---|
86 | $(line).toggleClass('expand'); |
---|
87 | img.src = dotclear.img_minus_src; |
---|
88 | img.alt = dotclear.img_minus_alt; |
---|
89 | } |
---|
90 | else |
---|
91 | { |
---|
92 | $(tr).toggle(); |
---|
93 | $(line).toggleClass('expand'); |
---|
94 | img.src = dotclear.img_plus_src; |
---|
95 | img.alt = dotclear.img_plus_alt; |
---|
96 | } |
---|
97 | }; |
---|
98 | |
---|
99 | $(function() { |
---|
100 | |
---|
101 | $('#form-entries tr.line').prepend('<td></td>'); |
---|
102 | $('#form-entries tr:not(.line) th:first').attr('colspan',4); |
---|
103 | $('#form-entries tr:not(.line)').each(function() { |
---|
104 | dotclear.postsExpander(this,$('#form-entries tr.line')); |
---|
105 | }); |
---|
106 | $('#form-entries tr.line').each(function() { |
---|
107 | dotclear.postExpander(this); |
---|
108 | }); |
---|
109 | $('.checkboxes-helpers').each(function() { |
---|
110 | p = $('<p></p>'); |
---|
111 | $(this).prepend(p); |
---|
112 | dotclear.checkboxesHelpers(p); |
---|
113 | }); |
---|
114 | $('#form-entries td input[type=checkbox]').enableShiftClick(); |
---|
115 | |
---|
116 | $("#pageslist").sortable({ |
---|
117 | cursor:'move', |
---|
118 | start: function( event, ui ) { |
---|
119 | // todo refermer les post ouverts |
---|
120 | }, |
---|
121 | stop: function( event, ui ) { |
---|
122 | $("#pageslist tr td input.position").each(function(i) { |
---|
123 | $(this).val(i+1); |
---|
124 | }); |
---|
125 | } |
---|
126 | }); |
---|
127 | $("#pageslist tr").hover(function () { |
---|
128 | $(this).css({'cursor':'move'}); |
---|
129 | }, function () { |
---|
130 | $(this).css({'cursor':'auto'}); |
---|
131 | }); |
---|
132 | $("#pageslist tr td input.position").hide(); |
---|
133 | $("#pageslist tr td.handle").addClass('handler'); |
---|
134 | }); |
---|