| 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 | title.empty().append(order).append(link); |
|---|
| 20 | |
|---|
| 21 | var img = document.createElement('img'); |
|---|
| 22 | img.src = dotclear.img_plus_src; |
|---|
| 23 | img.alt = dotclear.img_plus_alt; |
|---|
| 24 | img.className = 'expand'; |
|---|
| 25 | $(img).css('cursor','pointer'); |
|---|
| 26 | img.onclick = function() { dotclear.viewPostContent($(this).parents('li')); }; |
|---|
| 27 | link.click(function(e) { |
|---|
| 28 | e.preventDefault(); |
|---|
| 29 | dotclear.viewPostContent($(this).parents('li')); |
|---|
| 30 | }); |
|---|
| 31 | |
|---|
| 32 | title.prepend(img); |
|---|
| 33 | }; |
|---|
| 34 | |
|---|
| 35 | dotclear.viewPostContent = function(line,action) { |
|---|
| 36 | var action = action || 'toogle'; |
|---|
| 37 | var img = line.find('.expand'); |
|---|
| 38 | var isopen = img.attr('alt') == dotclear.img_plus_alt; |
|---|
| 39 | |
|---|
| 40 | if( action == 'close' || ( action == 'toogle' && !isopen ) ) { |
|---|
| 41 | line.find('.widgetSettings').hide(); |
|---|
| 42 | img.attr('src', dotclear.img_plus_src); |
|---|
| 43 | img.attr('alt', dotclear.img_plus_alt); |
|---|
| 44 | } else if ( action == 'open' || ( action == 'toogle' && isopen ) ) { |
|---|
| 45 | line.find('.widgetSettings').show(); |
|---|
| 46 | img.attr('src', dotclear.img_minus_src); |
|---|
| 47 | img.attr('alt', dotclear.img_minus_alt); |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | }; |
|---|
| 51 | |
|---|
| 52 | $(function() { |
|---|
| 53 | // reset |
|---|
| 54 | $('input[name="wreset"]').click(function() { |
|---|
| 55 | return window.confirm(dotclear.msg.confirm_widgets_reset); |
|---|
| 56 | }); |
|---|
| 57 | |
|---|
| 58 | // plier/déplier |
|---|
| 59 | $('#dndnav > li, #dndextra > li, #dndcustom > li').each(function() { |
|---|
| 60 | dotclear.postExpander(this); |
|---|
| 61 | dotclear.viewPostContent($(this), 'close'); |
|---|
| 62 | }); |
|---|
| 63 | |
|---|
| 64 | // remove |
|---|
| 65 | $('input[name*=rem]').change(function () { |
|---|
| 66 | if ($(this).attr("checked")) { |
|---|
| 67 | $(this).parents('li').remove(); |
|---|
| 68 | } |
|---|
| 69 | }); |
|---|
| 70 | |
|---|
| 71 | }); |
|---|