Dotclear


Ignore:
Timestamp:
11/08/13 16:54:05 (12 years ago)
Author:
Nicolas <nikrou77@…>
Branch:
2.6
Message:

Fix a11y when expanding content in lists views (entries, comments, pages)
Closes #1848
Need refactoring and tests !

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/pages/list.js

    r2058 r2527  
    11dotclear.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; 
    10      img.onclick = function() { dotclear.viewPostContent(this,this.line); }; 
    11       
    12      td.insertBefore(img,td.firstChild); 
     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 
    139}; 
    1410 
    1511dotclear.postsExpander = function(line,lines) { 
    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'); 
    23      img.lines = lines; 
    24      img.onclick = function() { dotclear.viewPostsContent(this,this.lines); }; 
    25  
    26      td.insertBefore(img,td.firstChild); 
     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 
    2722}; 
    2823 
    29 dotclear.viewPostsContent = function(img,lines) { 
    30       
    31      action = 'toggle'; 
     24dotclear.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     } 
    3234 
    33      if (img.alt == dotclear.img_plus_alt) { 
     35     if (action=='open') { 
    3436          img.src = dotclear.img_minus_src; 
    3537          img.alt = dotclear.img_minus_alt; 
    36           action = 'open'; 
    3738     } else { 
    3839          img.src = dotclear.img_plus_src; 
    3940          img.alt = dotclear.img_plus_alt; 
    40           action = 'close'; 
    4141     } 
    42       
    43      lines.each(function() { 
    44           var td = this.firstChild; 
    45           dotclear.viewPostContent(td.firstChild,td.firstChild.line,action); 
    46      }); 
    47 }; 
    4842 
    49 dotclear.viewPostContent = function(img,line,action) { 
    50       
     43     return action; 
     44} 
     45 
     46dotclear.viewPostContent = function(line,action) { 
    5147     var action = action || 'toggle'; 
    52      var postId = line.id.substr(1); 
     48     var postId = $(line).attr('id').substr(1); 
    5349     var tr = document.getElementById('pe'+postId); 
    5450      
     
    6056          td.className = 'expand'; 
    6157          tr.appendChild(td); 
    62            
    63           img.src = dotclear.img_minus_src; 
    64           img.alt = dotclear.img_minus_alt; 
    6558           
    6659          // Get post content 
     
    9285          $(tr).css('display', 'table-row'); 
    9386          $(line).addClass('expand'); 
    94           img.src = dotclear.img_minus_src; 
    95           img.alt = dotclear.img_minus_alt; 
    9687     } 
    9788     else if (tr && tr.style.display != 'none' && ( action == 'toggle' || action == 'close' ) ) 
     
    9990          $(tr).css('display', 'none'); 
    10091          $(line).removeClass('expand'); 
    101           img.src = dotclear.img_plus_src; 
    102           img.alt = dotclear.img_plus_alt; 
    10392     } 
    10493      
     
    10695     if( parentTable.find('tr.expand').length == parentTable.find('tr.line').length ) { 
    10796          img = parentTable.find('tr:not(.line) th:first img'); 
    108           img.attr('src',dotclear.img_minus_src); 
    109           img.attr('alt',dotclear.img_minus_alt); 
    11097     } 
    11198      
    11299     if( parentTable.find('tr.expand').length == 0 ) { 
    113100          img = parentTable.find('tr:not(.line) th:first img'); 
    114           img.attr('src',dotclear.img_plus_src); 
    115           img.attr('alt',dotclear.img_plus_alt); 
    116101     } 
    117102      
Note: See TracChangeset for help on using the changeset viewer.

Sites map