Dotclear

Changeset 3842:d2616cbea480


Ignore:
Timestamp:
09/01/18 09:28:56 (7 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

button(type="button") is better than input(type="submit") for show/hide, show/close js button as the input may catch the enter key in form and the button not

Location:
admin
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • admin/js/common.js

    r3841 r3842  
    9595  var toggle = function(i, speed) { 
    9696    speed = speed || 0; 
     97    var b = $(i).get(0); 
    9798    if (p.hide) { 
    98       $(i).get(0).value = p.img_on_txt; 
    99       $(i).get(0).setAttribute('aria-label', p.img_on_alt); 
     99      b.firstChild.data = p.img_on_txt; 
     100      b.setAttribute('value', p.img_on_txt); 
     101      b.setAttribute('aria-label', p.img_on_alt); 
    100102      target.addClass('hide'); 
    101103    } else { 
    102       $(i).get(0).value = p.img_off_txt; 
    103       $(i).get(0).setAttribute('aria-label', p.img_off_alt); 
     104      b.firstChild.data = p.img_off_txt; 
     105      b.setAttribute('value', p.img_off_txt); 
     106      b.setAttribute('aria-label', p.img_off_alt); 
    104107      target.removeClass('hide'); 
    105108      if (p.fn) { 
     
    122125  }; 
    123126  return this.each(function() { 
    124     var b = document.createElement('input'); 
    125     b.setAttribute('type', 'submit'); 
     127    var b = document.createElement('button'); 
     128    b.setAttribute('type', 'button'); 
    126129    b.className = 'details-cmd'; 
    127130    b.value = p.img_on_txt; 
    128     b.setAttribute('aria-label', p.img_off_alt); 
     131    b.setAttribute('aria-label', p.img_on_alt); 
     132    var t = document.createTextNode(p.img_on_txt); 
     133    b.appendChild(t); 
    129134 
    130135    var ctarget = p.legend_click ? this : b; 
     
    166171  }; 
    167172  var singleExpander = function singleExpander(line, callback) { 
    168     $('<input class="details-cmd" type="submit" value="' + dotclear.img_plus_txt + '" aria-label="' + dotclear.img_plus_alt + '"/>').click(function(e) { 
     173    $('<button type="button" class="details-cmd" aria-label="' + dotclear.img_plus_alt + '">' + dotclear.img_plus_txt + '</button>').click(function (e) { 
    169174      toggleArrow(this); 
    170175      callback(line); 
     
    173178  }; 
    174179  var multipleExpander = function multipleExpander(line, lines, callback) { 
    175     $('<input class="details-cmd" type="submit" value="' + dotclear.img_plus_txt + '" aria-label="' + dotclear.img_plus_alt + '"/>').click(function(e) { 
     180    $('<button type="button" class="details-cmd" aria-label="' + dotclear.img_plus_alt + '">' + dotclear.img_plus_txt + '</button>').click(function (e) { 
    176181      var action = toggleArrow(this); 
    177182      lines.each(function() { 
     
    192197    } 
    193198    if (action == 'open') { 
    194       button.value = dotclear.img_minus_txt; 
     199      button.firstChild.data = dotclear.img_minus_txt; 
     200      button.setAttribute('value', dotclear.img_minus_txt); 
    195201      button.setAttribute('aria-label', dotclear.img_minus_alt); 
    196202    } else { 
    197       button.value = dotclear.img_plus_txt; 
     203      button.firstChild.data = dotclear.img_plus_txt; 
     204      button.setAttribute('value', dotclear.img_plus_txt); 
    198205      button.setAttribute('aria-label', dotclear.img_plus_alt); 
    199206    } 
     
    232239  }; 
    233240  var textToggler = function(o) { 
    234     var b = $('<input class="details-cmd" type="submit" value="' + p.img_on_txt + '" aria-label="' + p.img_on_alt + '"/>'); 
     241    var b = $('<button type="button" class="details-cmd" aria-label="' + p.img_on_alt + '">' + p.img_on_txt + '</button>'); 
    235242    o.css('cursor', 'pointer'); 
    236243    var hide = true; 
     
    246253      }); 
    247254      hide = !hide; 
    248       var img = $(this).find('input.details-cmd'); 
     255      var img = $(this).find('button.details-cmd'); 
    249256      if (!hide) { 
     257        img.html(p.img_off_txt); 
    250258        img.attr('value', p.img_off_txt); 
    251259        img.attr('aria-label', p.img_off_alt); 
    252260      } else { 
     261        img.html(p.img_on_txt); 
    253262        img.attr('value', p.img_on_txt); 
    254263        img.attr('aria-label', p.img_on_alt); 
  • admin/style/default-dark.css

    r3839 r3842  
    13411341  padding: 0; } 
    13421342 
    1343 input.details-cmd { 
     1343button.details-cmd { 
    13441344  font-size: 0.9em; 
    13451345  border: none; 
     
    13491349  color: currentColor; 
    13501350  background: transparent; } 
    1351   input.details-cmd:hover, input.details-cmd:focus { 
     1351  button.details-cmd:hover, button.details-cmd:focus { 
    13521352    background: transparent; 
    13531353    color: #bee74b; } 
     
    21032103    padding-bottom: 6px; 
    21042104    font-size: 1em; } 
    2105   #login-screen input.details-cmd { 
    2106     width: auto; 
    2107     margin: 0 5px 0 0; 
    2108     padding: 0; } 
    21092105  #login-screen #issue { 
    21102106    margin-left: 1.33em; 
  • admin/style/default.css

    r3839 r3842  
    13411341  padding: 0; } 
    13421342 
    1343 input.details-cmd { 
     1343button.details-cmd { 
    13441344  font-size: 0.9em; 
    13451345  border: none; 
     
    13491349  color: currentColor; 
    13501350  background: transparent; } 
    1351   input.details-cmd:hover, input.details-cmd:focus { 
     1351  button.details-cmd:hover, button.details-cmd:focus { 
    13521352    background: transparent; 
    13531353    color: #bee74b; } 
     
    21032103    padding-bottom: 6px; 
    21042104    font-size: 1em; } 
    2105   #login-screen input.details-cmd { 
    2106     width: auto; 
    2107     margin: 0 5px 0 0; 
    2108     padding: 0; } 
    21092105  #login-screen #issue { 
    21102106    margin-left: 1.33em; 
  • admin/style/scss/partials/_auth.scss

    r3770 r3842  
    5151          font-size: 1em; 
    5252     } 
    53   input.details-cmd { 
    54     width: auto; 
    55     margin: 0 5px 0 0; 
    56     padding: 0; 
    57   } 
    5853     #issue { 
    5954          margin-left: 1.33em; 
  • admin/style/scss/partials/_buttons.scss

    r3768 r3842  
    208208} 
    209209 
    210 input.details-cmd { 
     210button.details-cmd { 
    211211  font-size: 0.9em; 
    212212  border: none; 
Note: See TracChangeset for help on using the changeset viewer.

Sites map