Dotclear

Changeset 3768:42e99b4be675 for admin/js


Ignore:
Timestamp:
07/06/18 16:37:54 (7 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Switch from img to input for expanding/hiding various contents (posts, module details, …)

Location:
admin/js
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • admin/js/_blog_theme.js

    r3706 r3768  
    88    $(this).after( 
    99      $(bar).toggleWithLegend($(this).parent().children('.toggle-bloc'), { 
    10         img_on_src: dotclear.img_plus_theme_src, 
     10        img_on_txt: dotclear.img_plus_theme_txt, 
    1111        img_on_alt: dotclear.img_plus_theme_alt, 
    12         img_off_src: dotclear.img_minus_theme_src, 
     12        img_off_txt: dotclear.img_minus_theme_txt, 
    1313        img_off_alt: dotclear.img_minus_theme_alt, 
    1414        legend_click: true 
    1515      })); 
    1616    $(this).children('img').click(function() { 
     17      // Click on theme thumbnail 
    1718      $(this).parent().parent().children('.bloc-toggler').click(); 
    1819    }); 
     
    4344    $('input[type=submit]', this).click(function() { 
    4445      var keyword = $(this).attr('name'); 
     46      if (!keyword) { 
     47        return true; 
     48      } 
    4549      var maction = keyword.match(rxActionType); 
    4650      var action = maction[0]; 
  • admin/js/_plugins.js

    r3762 r3768  
    66  $('table.modules.expandable tr.line').each(function() { 
    77    $('td.module-name, th.module-name', this).toggleWithLegend($(this).next('.module-more'), { 
    8       img_on_src: dotclear.img_plus_src, 
     8      img_on_txt: dotclear.img_plus_txt, 
    99      img_on_alt: dotclear.img_plus_alt, 
    10       img_off_src: dotclear.img_minus_src, 
     10      img_off_txt: dotclear.img_minus_txt, 
    1111      img_off_alt: dotclear.img_minus_alt, 
    1212      legend_click: true 
     
    2828    $('input[type=submit]', this).click(function() { 
    2929      var keyword = $(this).attr('name'); 
     30      if (!keyword) { 
     31        return true; 
     32      } 
    3033      var maction = keyword.match(rxActionType); 
    3134      var action = maction[0]; 
  • admin/js/common.js

    r3706 r3768  
    6969jQuery.fn.toggleWithLegend = function(target, s) { 
    7070  var defaults = { 
    71     img_on_src: dotclear.img_plus_src, 
     71    img_on_txt: dotclear.img_plus_txt, 
    7272    img_on_alt: dotclear.img_plus_alt, 
    73     img_off_src: dotclear.img_minus_src, 
     73    img_off_txt: dotclear.img_minus_txt, 
    7474    img_off_alt: dotclear.img_minus_alt, 
    7575    unfolded_sections: dotclear.unfolded_sections, 
     
    9696    speed = speed || 0; 
    9797    if (p.hide) { 
    98       $(i).get(0).src = p.img_on_src; 
    99       $(i).get(0).alt = p.img_on_alt; 
     98      $(i).get(0).value = p.img_on_txt; 
     99      $(i).get(0).setAttribute('aria-label', p.img_on_alt); 
    100100      target.addClass('hide'); 
    101101    } else { 
    102       $(i).get(0).src = p.img_off_src; 
    103       $(i).get(0).alt = p.img_off_alt; 
     102      $(i).get(0).value = p.img_off_txt; 
     103      $(i).get(0).setAttribute('aria-label', p.img_off_alt); 
    104104      target.removeClass('hide'); 
    105105      if (p.fn) { 
     
    122122  }; 
    123123  return this.each(function() { 
    124     var i = document.createElement('img'); 
    125     i.src = p.img_off_src; 
    126     i.alt = p.img_off_alt; 
    127     var a = document.createElement('a'); 
    128     a.href = '#'; 
    129     $(a).append(i); 
    130     $(a).css({ 
    131       border: 'none', 
    132       outline: 'none' 
    133     }); 
    134     var ctarget = p.legend_click ? this : a; 
     124    var b = document.createElement('input'); 
     125    b.setAttribute('type', 'submit'); 
     126    b.className = 'details-cmd'; 
     127    b.value = p.img_on_txt; 
     128    b.setAttribute('aria-label', p.img_off_alt); 
     129 
     130    var ctarget = p.legend_click ? this : b; 
    135131    $(ctarget).css('cursor', 'pointer'); 
    136132    if (p.legend_click) { 
    137133      $(ctarget).find('label').css('cursor', 'pointer'); 
    138134    } 
    139     $(ctarget).click(function() { 
     135    $(ctarget).click(function(e) { 
    140136      if (p.user_pref && set_user_pref) { 
    141137        if (p.hide ^ p.reverse_user_pref) { 
     
    158154        }); 
    159155      } 
    160       toggle(i, p.speed); 
     156      toggle(b, p.speed); 
     157      e.preventDefault(); 
    161158      return false; 
    162159    }); 
    163     toggle($(i).get(0)); 
    164     $(this).prepend(' ').prepend(a); 
     160    toggle($(b).get(0)); 
     161    $(this).prepend(b); 
    165162  }); 
    166163}; 
     
    180177  }; 
    181178  var singleExpander = function singleExpander(line) { 
    182     $('<input type="image" src="' + dotclear.img_plus_src + '" alt="' + dotclear.img_plus_alt + '"/>').click(function(e) { 
     179    $('<input class="details-cmd" type="submit" value="' + dotclear.img_plus_txt + '" aria-label="' + dotclear.img_plus_alt + '"/>').click(function(e) { 
    183180      toggleArrow(this); 
    184181      $.expandContent.options.callback.call(this, line); 
     
    187184  }; 
    188185  var multipleExpander = function multipleExpander(line, lines) { 
    189     $('<input type="image" src="' + dotclear.img_plus_src + '" alt="' + dotclear.img_plus_alt + '"/>').click(function(e) { 
     186    $('<input class="details-cmd" type="submit" value="' + dotclear.img_plus_txt + '" aria-label="' + dotclear.img_plus_alt + '"/>').click(function(e) { 
    190187      var that = this; 
    191188      var action = toggleArrow(this); 
     
    200197    action = action || ''; 
    201198    if (action == '') { 
    202       if (button.alt == dotclear.img_plus_alt) { 
     199      if (button.getAttribute('aria-label') == dotclear.img_plus_alt) { 
    203200        action = 'open'; 
    204201      } else { 
     
    207204    } 
    208205    if (action == 'open') { 
    209       button.src = dotclear.img_minus_src; 
    210       button.alt = dotclear.img_minus_alt; 
    211     } else { 
    212       button.src = dotclear.img_plus_src; 
    213       button.alt = dotclear.img_plus_alt; 
     206      button.value = dotclear.img_minus_txt; 
     207      button.setAttribute('aria-label', dotclear.img_minus_alt); 
     208    } else { 
     209      button.value = dotclear.img_plus_txt; 
     210      button.setAttribute('aria-label', dotclear.img_plus_alt); 
    214211    } 
    215212    return action; 
     
    221218  } 
    222219  var p = { 
    223     img_on_src: dotclear.img_plus_src, 
     220    img_on_txt: dotclear.img_plus_txt, 
    224221    img_on_alt: dotclear.img_plus_alt, 
    225     img_off_src: dotclear.img_minus_src, 
     222    img_off_txt: dotclear.img_minus_txt, 
    226223    img_off_alt: dotclear.img_minus_alt 
    227224  }; 
     
    247244  }; 
    248245  var textToggler = function(o) { 
    249     var i = $('<img src="' + p.img_on_src + '" alt="' + p.img_on_alt + '" />'); 
     246    var b = $('<input class="details-cmd" type="submit" value="' + p.img_on_txt + '" aria-label="' + p.img_on_alt + '"/>'); 
    250247    o.css('cursor', 'pointer'); 
    251248    var hide = true; 
    252     o.prepend(' ').prepend(i); 
     249    o.prepend(' ').prepend(b); 
    253250    o.click(function() { 
    254251      $(this).nextAll().each(function() { 
     
    261258      }); 
    262259      hide = !hide; 
    263       var img = $(this).find('img'); 
     260      var img = $(this).find('input.details-cmd'); 
    264261      if (!hide) { 
    265         img.attr('src', p.img_off_src); 
    266       } else { 
    267         img.attr('src', p.img_on_src); 
     262        img.attr('value', p.img_off_txt); 
     263        img.attr('aria-label', p.img_off_alt); 
     264      } else { 
     265        img.attr('value', p.img_on_txt); 
     266        img.attr('aria-label', p.img_on_alt); 
    268267      } 
    269268    }); 
     
    278277  var img = $('<p id="help-button"><span><a href="">' + dotclear.msg.help + '</a></span></p>'); 
    279278  var select = $(); 
    280   img.click(function() { 
     279  img.click(function(e) { 
    281280    return toggle(); 
     281    e.preventDefault(); 
    282282  }); 
    283283  $('#content').append(img); 
Note: See TracChangeset for help on using the changeset viewer.

Sites map