Dotclear

Changeset 4007:d08f9c5e38db for admin/js


Ignore:
Timestamp:
07/11/19 15:15:52 (6 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Responsive tables (not yet applied for plugins), thanks Adrian Roselli for code (js/css)  http://adrianroselli.com/2018/02/tables-css-display-properties-and-aria.html

Location:
admin/js
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • admin/js/_blogs.js

    r3880 r4007  
    88  $('#form-blogs td input[type=checkbox]').enableShiftClick(); 
    99  dotclear.condSubmit('#form-blogs td input[type=checkbox]', '#form-blogs #do-action'); 
     10  dotclear.responsiveCellHeaders(document.querySelector('#form-blogs table'), '#form-blogs table', 1); 
    1011  $('#form-blogs').submit(function() { 
    1112    const action = $(this).find('select[name="action"]').val(); 
  • admin/js/_comments.js

    r3880 r4007  
    5454  dotclear.commentsActionsHelper(); 
    5555  dotclear.condSubmit('#form-comments td input[type=checkbox]', '#form-comments #do-action'); 
     56  dotclear.responsiveCellHeaders(document.querySelector('#form-comments table'), '#form-comments table', 1); 
    5657  $('form input[type=submit][name=delete_all_spam]').click(function() { 
    5758    return window.confirm(dotclear.msg.confirm_spam_delete); 
  • admin/js/_posts_list.js

    r3880 r4007  
    5555  dotclear.condSubmit('#form-entries td input[type=checkbox]', '#form-entries #do-action'); 
    5656  dotclear.postsActionsHelper(); 
     57  dotclear.responsiveCellHeaders(document.querySelector('#form-entries table'), '#form-entries table', 1); 
    5758}); 
  • admin/js/_users.js

    r3880 r4007  
    77  }); 
    88  dotclear.condSubmit('#form-users input[type="checkbox"]', '#form-users #do-action'); 
     9  dotclear.responsiveCellHeaders(document.querySelector('#form-users table'), '#form-users table', 1); 
    910  $('#form-users').submit(function() { 
    1011    const action = $(this).find('select[name="action"]').val(); 
  • admin/js/common.js

    r3930 r4007  
    460460      window.open($(this).attr('href')); 
    461461    }); 
     462  }, 
     463 
     464  /** 
     465   * Add headers on each cells (responsive tables) 
     466   * 
     467   * @param      DOM elt   table         The table 
     468   * @param      string    selector      The selector 
     469   * @param      number    [offset=0]    The offset = number of firsts columns to ignore 
     470   * @param      boolean   [thead=false] True if titles are in thead rather than in the first tr of the body 
     471   */ 
     472  responsiveCellHeaders: function(table, selector, offset = 0, thead = false) { 
     473    try { 
     474      let THarray = []; 
     475      const ths = table.getElementsByTagName("th"); 
     476      for (let i = 0; i < ths.length; i++) { 
     477        for (let colspan = ths[i].colSpan; colspan > 0; colspan--) { 
     478          THarray.push(ths[i].innerText.replace('►', '')); 
     479        } 
     480      } 
     481      let styleElm = document.createElement("style"); 
     482      let styleSheet; 
     483      document.head.appendChild(styleElm); 
     484      styleSheet = styleElm.sheet; 
     485      for (let i = offset; i < THarray.length; i++) { 
     486        styleSheet.insertRule( 
     487          selector + " td:nth-child(" + (i + 1) + ')::before {content:"' + THarray[i] + ' ";}', 
     488          styleSheet.cssRules.length 
     489        ); 
     490      } 
     491      table.className += (table.className !== '' ? ' ' : '') + 'rch' + (thead ? ' rch-thead' : ''); 
     492    } catch (e) { 
     493      console.log("responsiveCellHeaders(): " + e); 
     494    } 
    462495  }, 
    463496 
Note: See TracChangeset for help on using the changeset viewer.

Sites map