Dotclear

Changeset 2531:2daf216ff255 for plugins


Ignore:
Timestamp:
11/09/13 11:40:06 (12 years ago)
Author:
Nicolas <nikrou77@…>
Branch:
2.6
Message:

Refactoring of expandContent for list (entries, comments, trackback).
Addresses #1848

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/pages/list.js

    r2527 r2531  
    1 dotclear.postExpander = function(line) { 
    2      $('<a href="#"><img src="'+dotclear.img_plus_src+'" alt="'+dotclear.img_plus_alt+'"/></a>') 
    3           .click(function(e) { 
    4                dotclear.toggleArrow(this); 
    5                dotclear.viewPostContent(line); 
    6                e.preventDefault(); 
    7           }) 
    8           .prependTo($(line).children().get(0)); // first td 
    9 }; 
    10  
    11 dotclear.postsExpander = function(line,lines) { 
    12      $('<a href="#"><img src="'+dotclear.img_plus_src+'" alt="'+dotclear.img_plus_alt+'"/></a>') 
    13           .click(function(e) { 
    14                dotclear.toggleArrow(this); 
    15                lines.each(function() { 
    16                     var action = dotclear.toggleArrow(this.firstChild.firstChild); 
    17                     dotclear.viewPostContent(this,action); 
    18                }); 
    19                e.preventDefault(); 
    20           }) 
    21           .prependTo($(line).children().get(0)); // first td 
    22 }; 
    23  
    24 dotclear.toggleArrow = function(link,action) { 
    25      action = action || ''; 
    26      var img = $(link).children().get(0); 
    27      if (action=='') { 
    28           if (img.alt==dotclear.img_plus_alt) { 
    29                action = 'open'; 
    30           } else { 
    31                action = 'close'; 
    32           } 
    33      } 
    34  
    35      if (action=='open') { 
    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      return action; 
    44 } 
    45  
    461dotclear.viewPostContent = function(line,action) { 
    472     var action = action || 'toggle'; 
     
    9146          $(line).removeClass('expand'); 
    9247     } 
    93       
    94      parentTable = $(line).parents('table'); 
    95      if( parentTable.find('tr.expand').length == parentTable.find('tr.line').length ) { 
    96           img = parentTable.find('tr:not(.line) th:first img'); 
    97      } 
    98       
    99      if( parentTable.find('tr.expand').length == 0 ) { 
    100           img = parentTable.find('tr:not(.line) th:first img'); 
    101      } 
    102       
    10348}; 
    10449 
    10550$(function() { 
    106  
    10751     $('#pageslist tr.line').prepend('<td class="expander"></td>'); 
    10852     $('#form-entries tr:not(.line) th:first').attr('colspan',4); 
    109      $('#form-entries tr:not(.line)').each(function() { 
    110           dotclear.postsExpander(this,$('#form-entries tr.line')); 
    111      }); 
    112      $('#pageslist tr.line').each(function() { 
    113           dotclear.postExpander(this); 
     53     $.expandContent({ 
     54          line:$('#form-entries tr:not(.line)'), 
     55          lines:$('#form-entries tr.line'), 
     56          callback:dotclear.viewPostContent 
    11457     }); 
    11558     $('.checkboxes-helpers').each(function() { 
Note: See TracChangeset for help on using the changeset viewer.

Sites map