Dotclear

Changeset 2527:52b330f07bd8


Ignore:
Timestamp:
11/08/13 16:54:05 (10 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 !

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • admin/js/_comments.js

    r2526 r2527  
    11dotclear.commentExpander = function(line) { 
    22     $('<a href="#"><img src="'+dotclear.img_plus_src+'" alt="'+dotclear.img_plus_alt+'"/></a>') 
    3           .click(function() { 
     3          .click(function(e) { 
    44               dotclear.toggleArrow(this); 
    55               dotclear.viewCommentContent(line); 
     6               e.preventDefault(); 
    67          }) 
    78          .prependTo($(line).children().get(0)); // first td 
     
    1011dotclear.commentsExpander = function(line,lines) { 
    1112     $('<a href="#"><img src="'+dotclear.img_plus_src+'" alt="'+dotclear.img_plus_alt+'"/></a>') 
    12           .click(function() { 
     13          .click(function(e) { 
    1314               dotclear.toggleArrow(this); 
    1415               lines.each(function() { 
     
    1617                    dotclear.viewCommentContent(this,action); 
    1718               }); 
     19               e.preventDefault(); 
    1820          }) 
    1921          .prependTo($(line).children().get(0)); // first td 
  • admin/js/_post.js

    r2109 r2527  
    11dotclear.commentExpander = 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.viewCommentContent(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.viewCommentContent(line); 
     6               e.preventDefault(); 
     7          }) 
     8          .prependTo($(line).children().get(0)); // first td 
    139}; 
    1410 
    15 dotclear.viewCommentContent = function(img,line) { 
    16      var commentId = line.id.substr(1); 
    17  
     11dotclear.toggleArrow = function(link,action) { 
     12     action = action || ''; 
     13     var img = $(link).children().get(0); 
     14     if (action=='') { 
     15          if (img.alt==dotclear.img_plus_alt) { 
     16               action = 'open'; 
     17          } else { 
     18               action = 'close'; 
     19          } 
     20     } 
     21 
     22     if (action=='open') { 
     23          img.src = dotclear.img_minus_src; 
     24          img.alt = dotclear.img_minus_alt; 
     25     } else { 
     26          img.src = dotclear.img_plus_src; 
     27          img.alt = dotclear.img_plus_alt; 
     28     } 
     29 
     30     return action; 
     31} 
     32 
     33dotclear.viewCommentContent = function(line,action) { 
     34     var commentId = $(line).attr('id').substr(1); 
    1835     var tr = document.getElementById('ce'+commentId); 
    1936 
     
    2542          td.className = 'expand'; 
    2643          tr.appendChild(td); 
    27  
    28           img.src = dotclear.img_minus_src; 
    29           img.alt = dotclear.img_minus_alt; 
    3044 
    3145          // Get comment content 
     
    6074          $(tr).toggle(); 
    6175          $(line).toggleClass('expand'); 
    62           img.src = dotclear.img_minus_src; 
    63           img.alt = dotclear.img_minus_alt; 
    6476     } 
    6577     else 
     
    6779          $(tr).toggle(); 
    6880          $(line).toggleClass('expand'); 
    69           img.src = dotclear.img_plus_src; 
    70           img.alt = dotclear.img_plus_alt; 
    7181     } 
    7282}; 
  • admin/js/_posts_list.js

    r2526 r2527  
    11dotclear.postExpander = function(line) { 
    22     $('<a href="#"><img src="'+dotclear.img_plus_src+'" alt="'+dotclear.img_plus_alt+'"/></a>') 
    3           .click(function() { 
     3          .click(function(e) { 
    44               dotclear.toggleArrow(this); 
    55               dotclear.viewPostContent(line); 
     6               e.preventDefault(); 
    67          }) 
    78          .prependTo($(line).children().get(0)); // first td 
     
    1011dotclear.postsExpander = function(line,lines) { 
    1112     $('<a href="#"><img src="'+dotclear.img_plus_src+'" alt="'+dotclear.img_plus_alt+'"/></a>') 
    12           .click(function() { 
     13          .click(function(e) { 
    1314               dotclear.toggleArrow(this); 
    1415               lines.each(function() { 
     
    1617                    dotclear.viewPostContent(this,action); 
    1718               }); 
     19               e.preventDefault(); 
    1820          }) 
    1921          .prependTo($(line).children().get(0)); // first td 
  • 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