1 | /* |
---|
2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
3 | # |
---|
4 | # This file is part of Dotclear 2. |
---|
5 | # |
---|
6 | # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear |
---|
7 | # Licensed under the GPL version 2.0 license. |
---|
8 | # See LICENSE file or |
---|
9 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
10 | # |
---|
11 | # -- END LICENSE BLOCK ----------------------------------------- |
---|
12 | */ |
---|
13 | |
---|
14 | dotclear.postExpander = function(line) { |
---|
15 | var title = $(line).find('.widget-name'); |
---|
16 | title.find('.form-note').remove(); |
---|
17 | order = title.find('input[name*=order]'); |
---|
18 | link = $('<a href="#" alt="expand" class="aexpand"/>').append(title.text()); |
---|
19 | rem = title.find('input[name*=_rem]'); |
---|
20 | br = title.find('br'); |
---|
21 | title.empty().append(order).append(link).append(rem).append(br); |
---|
22 | |
---|
23 | var img = document.createElement('img'); |
---|
24 | img.src = dotclear.img_plus_src; |
---|
25 | img.alt = dotclear.img_plus_alt; |
---|
26 | img.className = 'expand'; |
---|
27 | $(img).css('cursor','pointer'); |
---|
28 | img.onclick = function() { dotclear.viewPostContent($(this).parents('li')); }; |
---|
29 | link.click(function(e) { |
---|
30 | e.preventDefault(); |
---|
31 | dotclear.viewPostContent($(this).parents('li')); |
---|
32 | }); |
---|
33 | |
---|
34 | title.prepend(img); |
---|
35 | }; |
---|
36 | |
---|
37 | dotclear.viewPostContent = function(line,action) { |
---|
38 | var action = action || 'toogle'; |
---|
39 | var img = line.find('.expand'); |
---|
40 | var isopen = img.attr('alt') == dotclear.img_plus_alt; |
---|
41 | |
---|
42 | if( action == 'close' || ( action == 'toogle' && !isopen ) ) { |
---|
43 | line.find('.widgetSettings').hide(); |
---|
44 | img.attr('src', dotclear.img_plus_src); |
---|
45 | img.attr('alt', dotclear.img_plus_alt); |
---|
46 | } else if ( action == 'open' || ( action == 'toogle' && isopen ) ) { |
---|
47 | line.find('.widgetSettings').show(); |
---|
48 | img.attr('src', dotclear.img_minus_src); |
---|
49 | img.attr('alt', dotclear.img_minus_alt); |
---|
50 | } |
---|
51 | |
---|
52 | }; |
---|
53 | |
---|
54 | $(function() { |
---|
55 | // reset |
---|
56 | $('input[name="wreset"]').click(function() { |
---|
57 | return window.confirm(dotclear.msg.confirm_widgets_reset); |
---|
58 | }); |
---|
59 | |
---|
60 | // plier/déplier |
---|
61 | $('#dndnav > li, #dndextra > li, #dndcustom > li').each(function() { |
---|
62 | dotclear.postExpander(this); |
---|
63 | dotclear.viewPostContent($(this), 'close'); |
---|
64 | }); |
---|
65 | |
---|
66 | // remove |
---|
67 | $('input[name*=rem]').change(function () { |
---|
68 | if ($(this).attr("checked")) { |
---|
69 | $(this).parents('li').remove(); |
---|
70 | } |
---|
71 | }); |
---|
72 | |
---|
73 | }); |
---|