[0] | 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; |
---|
[1034] | 10 | img.onclick = function() { dotclear.viewPostContent(this,this.line); }; |
---|
[0] | 11 | |
---|
| 12 | td.insertBefore(img,td.firstChild); |
---|
| 13 | }; |
---|
| 14 | |
---|
[1034] | 15 | dotclear.postsExpander = function(line,lines) { |
---|
[1033] | 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'); |
---|
[1034] | 23 | img.lines = lines; |
---|
| 24 | img.onclick = function() { dotclear.viewPostsContent(this,this.lines); }; |
---|
[1033] | 25 | |
---|
| 26 | td.insertBefore(img,td.firstChild); |
---|
| 27 | }; |
---|
| 28 | |
---|
[1034] | 29 | dotclear.viewPostsContent = function(img,lines) { |
---|
| 30 | lines.each(function() { |
---|
[1033] | 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 | |
---|
[0] | 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() { |
---|
[995] | 100 | // Entry type switcher |
---|
| 101 | $('#type').change(function() { |
---|
| 102 | this.form.submit(); |
---|
| 103 | }); |
---|
| 104 | |
---|
[1033] | 105 | $('#form-entries tr:not(.line)').each(function() { |
---|
[1034] | 106 | dotclear.postsExpander(this,$('#form-entries tr.line')); |
---|
[1033] | 107 | }); |
---|
[0] | 108 | $('#form-entries tr.line').each(function() { |
---|
| 109 | dotclear.postExpander(this); |
---|
| 110 | }); |
---|
| 111 | $('.checkboxes-helpers').each(function() { |
---|
| 112 | dotclear.checkboxesHelpers(this); |
---|
| 113 | }); |
---|
| 114 | $('#form-entries td input[type=checkbox]').enableShiftClick(); |
---|
| 115 | dotclear.postsActionsHelper(); |
---|
| 116 | }); |
---|