<commit_before>package com.helger.photon.uictrls.datatables.plugins;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import com.helger.commons.ValueEnforcer;
import com.helger.commons.state.ETriState;
import com.helger.html.hc.IHCConversionSettingsToNode;
import com.helger.html.jscode.IJSExpression;
import com.helger.html.jscode.JSAnonymousFunction;
import com.helger.html.jscode.JSArray;
import com.helger.html.jscode.JSAssocArray;
import com.helger.html.jscode.JSExpr;
import com.helger.photon.core.app.html.PhotonCSS;
import com.helger.photon.core.app.html.PhotonJS;
import com.helger.photon.uictrls.EUICtrlsCSSPathProvider;
import com.helger.photon.uictrls.EUICtrlsJSPathProvider;

public class DataTablesPluginResponsive extends AbstractDataTablesPlugin
{
  private List <DTPResponsiveBreakpoint> m_aBreakpoints;
  private ETriState m_eDetails = ETriState.UNDEFINED;
  /** function renderer( api, rowIdx ) */
  private JSAnonymousFunction m_aDetailsRenderer;
  private IJSExpression m_aDetailsTarget;
  private EDTPResponsiveType m_eDetailsType;

  public DataTablesPluginResponsive ()
  {
    super ("responsive");
  }

  @Nonnull
  public DataTablesPluginResponsive addBreakpoint (@Nonnull final DTPResponsiveBreakpoint aBreakpoint)
  {
    ValueEnforcer.notNull (aBreakpoint, "Breakpoint");
    if (m_aBreakpoints == null)
      m_aBreakpoints = new ArrayList <> ();
    m_aBreakpoints.add (aBreakpoint);
    return this;
  }

  @Nonnull
  public DataTablesPluginResponsive setDetails (@Nonnull final ETriState eDetails)
  {
    ValueEnforcer.notNull (eDetails, "Details");
    m_eDetails = eDetails;
    return this;
  }

  @Nonnull
  public DataTablesPluginResponsive setDetailsRenderer (@Nullable final JSAnonymousFunction aDetailsRenderer)
  {
    m_aDetailsRenderer = aDetailsRenderer;
    return this;
  }

  @Nonnull
  public DataTablesPluginResponsive setDetailsTarget (final int nDetailsTarget)
  {
    return setDetailsTarget (JSExpr.lit (nDetailsTarget));
  }

  @Nonnull
  public DataTablesPluginResponsive setDetailsTarget (final String sDetailsTarget)
  {
    return setDetailsTarget (JSExpr.lit (sDetailsTarget));
  }

  @Nonnull
  public DataTablesPluginResponsive setDetailsTarget (@Nullable final IJSExpression aDetailsTarget)
  {
    m_aDetailsTarget = aDetailsTarget;
    return this;
  }

  @Nonnull
  public DataTablesPluginResponsive setDetailsType (@Nullable final EDTPResponsiveType eDetailsType)
  {
    m_eDetailsType = eDetailsType;
    return this;
  }

  @Nullable
  public IJSExpression getInitParams ()
  {
    final JSAssocArray ret = new JSAssocArray ();<commit_msg>Added special handling for invisible columns<commit_after>package com.helger.photon.uictrls.datatables.plugins;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import com.helger.commons.ValueEnforcer;
import com.helger.commons.state.ETriState;
import com.helger.html.css.DefaultCSSClassProvider;
import com.helger.html.css.ICSSClassProvider;
import com.helger.html.hc.IHCConversionSettingsToNode;
import com.helger.html.jscode.IJSExpression;
import com.helger.html.jscode.JSAnonymousFunction;
import com.helger.html.jscode.JSArray;
import com.helger.html.jscode.JSAssocArray;
import com.helger.html.jscode.JSExpr;
import com.helger.photon.core.app.html.PhotonCSS;
import com.helger.photon.core.app.html.PhotonJS;
import com.helger.photon.uictrls.EUICtrlsCSSPathProvider;
import com.helger.photon.uictrls.EUICtrlsJSPathProvider;
import com.helger.photon.uictrls.datatables.DataTables;
import com.helger.photon.uictrls.datatables.column.DataTablesColumnDef;

public class DataTablesPluginResponsive extends AbstractDataTablesPlugin
{
  public static final ICSSClassProvider CSS_CLASS_ALL = DefaultCSSClassProvider.create ("all");
  public static final ICSSClassProvider CSS_CLASS_CONTROL = DefaultCSSClassProvider.create ("control");
  public static final ICSSClassProvider CSS_CLASS_NONE = DefaultCSSClassProvider.create ("none");
  public static final ICSSClassProvider CSS_CLASS_NEVER = DefaultCSSClassProvider.create ("never");

  private List <DTPResponsiveBreakpoint> m_aBreakpoints;
  private ETriState m_eDetails = ETriState.UNDEFINED;
  /** function renderer( api, rowIdx ) */
  private JSAnonymousFunction m_aDetailsRenderer;
  private IJSExpression m_aDetailsTarget;
  private EDTPResponsiveType m_eDetailsType;

  public DataTablesPluginResponsive ()
  {
    super ("responsive");
  }

  @Nonnull
  public DataTablesPluginResponsive addBreakpoint (@Nonnull final DTPResponsiveBreakpoint aBreakpoint)
  {
    ValueEnforcer.notNull (aBreakpoint, "Breakpoint");
    if (m_aBreakpoints == null)
      m_aBreakpoints = new ArrayList <> ();
    m_aBreakpoints.add (aBreakpoint);
    return this;
  }

  @Nonnull
  public DataTablesPluginResponsive setDetails (@Nonnull final ETriState eDetails)
  {
    ValueEnforcer.notNull (eDetails, "Details");
    m_eDetails = eDetails;
    return this;
  }

  @Nonnull
  public DataTablesPluginResponsive setDetailsRenderer (@Nullable final JSAnonymousFunction aDetailsRenderer)
  {
    m_aDetailsRenderer = aDetailsRenderer;
    return this;
  }

  @Nonnull
  public DataTablesPluginResponsive setDetailsTarget (final int nDetailsTarget)
  {
    return setDetailsTarget (JSExpr.lit (nDetailsTarget));
  }

  @Nonnull
  public DataTablesPluginResponsive setDetailsTarget (final String sDetailsTarget)
  {
    return setDetailsTarget (JSExpr.lit (sDetailsTarget));
  }

  @Nonnull
  public DataTablesPluginResponsive setDetailsTarget (@Nullable final IJSExpression aDetailsTarget)
  {
    m_aDetailsTarget = aDetailsTarget;
    return this;
  }

  @Nonnull
  public DataTablesPluginResponsive setDetailsType (@Nullable final EDTPResponsiveType eDetailsType)
  {
    m_eDetailsType = eDetailsType;
    return this;
  }

  @Override
  public void finalizeDataTablesSettings (@Nonnull final DataTables aDT)
  {
    // Source:
    // https://github.com/DataTables/Responsive/issues/8
    for (final DataTablesColumnDef aColumnDef : aDT.getAllColumns ())
      if (!aColumnDef.isVisible ())
        aColumnDef.addClass (CSS_CLASS_NEVER);
  }

  @Nullable
  public IJSExpression getInitParams ()
  {
    final JSAssocArray ret = new JSAssocArray ();
{'fraction_non_alphanumeric': 0.08042895442359249, 'fraction_numerical': 0.00015770383220312253, 'mean_word_length': 5.151309408341416, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5837361', 'n_tokens_mistral': 2025, 'n_tokens_neox': 1978, 'n_words': 394}