Dotclear


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
  • admin/js/_comments.js

    r2527 r2531  
    1 dotclear.commentExpander = 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.viewCommentContent(line); 
    6                e.preventDefault(); 
    7           }) 
    8           .prependTo($(line).children().get(0)); // first td 
    9 }; 
    10  
    11 dotclear.commentsExpander = 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.viewCommentContent(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.viewCommentContent = function(line,action) { 
     2     var action = action || 'toggle'; 
    473     var commentId = $(line).attr('id').substr(1);      
    484     var tr = document.getElementById('ce'+commentId); 
    49       
    50      if (!tr) { 
     5 
     6     if ( !tr && ( action == 'toggle' || action == 'open' ) ) { 
    517          tr = document.createElement('tr'); 
    528          tr.id = 'ce'+commentId; 
     
    8541          line.parentNode.insertBefore(tr,line.nextSibling); 
    8642     } 
    87      else if (tr.style.display == 'none') 
     43     else if (tr && tr.style.display == 'none' && ( action == 'toggle' || action == 'open' ) ) 
    8844     { 
    89           $(tr).toggle(); 
    90           $(line).toggleClass('expand'); 
     45          $(tr).css('display', 'table-row'); 
     46          $(line).addClass('expand'); 
    9147     } 
    92      else 
     48     else if (tr && tr.style.display != 'none' && ( action == 'toggle' || action == 'close' ) ) 
    9349     { 
    94           $(tr).toggle(); 
    95           $(line).toggleClass('expand'); 
     50          $(tr).css('display', 'none'); 
     51          $(line).removeClass('expand'); 
    9652     } 
    9753}; 
    9854 
    9955$(function() { 
    100      $('#form-comments tr:not(.line)').each(function() { 
    101           dotclear.commentsExpander(this,$('#form-comments tr.line')); 
    102      }); 
    103      $('#form-comments tr.line').each(function() { 
    104           dotclear.commentExpander(this); 
     56     $.expandContent({ 
     57          line:$('#form-comments tr:not(.line)'), 
     58          lines:$('#form-comments tr.line'), 
     59          callback:dotclear.viewCommentContent 
    10560     }); 
    10661     $('.checkboxes-helpers').each(function() { 
Note: See TracChangeset for help on using the changeset viewer.

Sites map