Commit bc454427 authored by Mark Fullmer's avatar Mark Fullmer

Code syntax cleanup & default tablesaw type

parent 38aa2b4f
......@@ -749,4 +749,4 @@ a.tablesaw-btn {
opacity: .25;
cursor: default;
pointer-events: none;
}
\ No newline at end of file
}
......@@ -3,4 +3,4 @@ type: module
description: Make tables in WYSIWYG fields responsive
core: 8.x
package: Other
configure: responsive_tables_filter.settings
\ No newline at end of file
configure: responsive_tables_filter.settings
......@@ -3,4 +3,4 @@ responsive_tables_filter.admin:
parent: system.admin_config_content
description: Configure the Tablesaw responsive table behavior
route_name: responsive_tables_filter.settings
weight: 100
\ No newline at end of file
weight: 100
......@@ -4,4 +4,4 @@ responsive_tables_filter.settings:
_form: '\Drupal\responsive_tables_filter\Form\TablesawSettings'
_title: 'Responsive Tables'
requirements:
_permission: 'administer site configuration'
\ No newline at end of file
_permission: 'administer site configuration'
......@@ -51,7 +51,7 @@ class FilterResponsiveTablesFilter extends FilterBase {
$form['tablesaw_type'] = [
'#type' => 'select',
'#title' => $this->t('Default mode'),
'#default_value' => $this->settings['tablesaw_type'],
'#default_value' => $this->settings['tablesaw_type'] ?? 'stack',
'#description' => $this->t('This will apply by default to tables in WYSIWYGs, but can be overridden on an individual basis by adding the <code>class</code> "tablesaw-stack", "tablesaw-columntoggle", or "tablesaw-swipe" to the <code>table</code> tag. See documentation: https://github.com/filamentgroup/tablesaw'),
'#options' => self::$modes,
];
......@@ -90,7 +90,7 @@ class FilterResponsiveTablesFilter extends FilterBase {
// Find existing class attributes, if any, and append tablesaw class.
$existing_classes = $table->getAttribute('class');
if (strpos($existing_classes, 'no-tablesaw') === FALSE) {
$type = $this->settings['tablesaw_type'];
$type = $this->settings['tablesaw_type'] ?? 'stack';
// Allow for class-based override of default.
foreach (array_keys(self::$modes) as $mode) {
if (strpos($existing_classes, "tablesaw-" . $mode) !== FALSE) {
......
......@@ -23,7 +23,7 @@ class FilterProcessTest extends UnitTestCase {
*
* @var \Drupal\responsive_tables_filter\Plugin\Filter\FilterResponsiveTablesFilter
*/
protected $responsive_filter;
protected $responsiveFilter;
/**
* {@inheritdoc}
......@@ -36,13 +36,13 @@ class FilterProcessTest extends UnitTestCase {
'allowed_html' => '<a href> <p> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <br> <h3 id> <table class additional> <th> <tr> <td> <thead> <tbody> <tfoot>',
'filter_html_help' => 1,
'filter_html_nofollow' => 0,
'filter_responsive_tables_filter' => ["tablesaw_type" => "stack"]
'filter_responsive_tables_filter' => ["tablesaw_type" => "stack"],
];
$this->filter = new FilterHtml($configuration, 'filter_html', ['provider' => 'test']);
$this->filter->setStringTranslation($this->getStringTranslationStub());
// See Drupal\Core\Plugin\PluginBase.
$this->responsive_filter = new FilterResponsiveTablesFilter(array(), 'filter_responsive_tables_filter', ['provider' => 'test']);
$this->responsiveFilter = new FilterResponsiveTablesFilter([], 'filter_responsive_tables_filter', ['provider' => 'test']);
}
/**
......@@ -57,7 +57,7 @@ class FilterProcessTest extends UnitTestCase {
*/
public function testfilterAttributes($html, $expected) {
$html_filter = $this->filter->filterAttributes($html);
$result = $this->responsive_filter->runFilter($html_filter);
$result = $this->responsiveFilter->runFilter($html_filter);
$this->assertSame($expected, $result);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment