-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1204 from openeuropa/update-EPIC-EWPP-2575
EWPP-2575: Update Calendar item epic branch.
- Loading branch information
Showing
25 changed files
with
1,106 additions
and
397 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/** | ||
* @file | ||
* Plugin for adding sorting of table. | ||
*/ | ||
|
||
(function ($, CKEDITOR) { | ||
"use strict"; | ||
|
||
CKEDITOR.plugins.add('table_sort', { | ||
afterInit: function afterInit (editor) { | ||
CKEDITOR.on('dialogDefinition', function(event) { | ||
const dialog_name = event.data.name; | ||
const sort_attribute = 'data-sortable'; | ||
|
||
if (dialog_name !== 'cellProperties') { | ||
return; | ||
} | ||
|
||
const dialog_definition = event.data.definition; | ||
const info_tab = dialog_definition.getContents('info'); | ||
const langCell = event.editor.lang.table.cell; | ||
// Avoid multiple selectbox adding. | ||
if (!info_tab.get('columnSortable')) { | ||
info_tab.add({ | ||
type: 'select', | ||
label: 'Sortable', | ||
id: 'columnSortable', | ||
requiredContent: 'th[' + sort_attribute + ']', | ||
items: [ | ||
[langCell.yes, 'yes'], | ||
[langCell.no, 'no'], | ||
], | ||
|
||
/** | ||
* @param {CKEDITOR.dom.element[]} selectedCells | ||
*/ | ||
setup: function (selectedCells) { | ||
// Disable the element if any of the selected cells is not a header cell. | ||
for (let i = 0; i < selectedCells.length; i++) { | ||
if (selectedCells[i].getName() !== 'th') { | ||
this.disable(); | ||
this.setValue(null); | ||
return; | ||
} | ||
} | ||
|
||
// This method receives an array of selected cells. | ||
// We use the value of the first one as driver for the remaining cells. | ||
// @see setupCells() in /plugins/tabletools/dialogs/tableCell.js | ||
let value = selectedCells[0].hasAttribute(sort_attribute); | ||
|
||
for (let i = 1; i < selectedCells.length; i++) { | ||
if (selectedCells[i].hasAttribute(sort_attribute) !== value) { | ||
// If any of the cells has a different sortable value, set the value | ||
// to undetermined. | ||
value = null; | ||
break; | ||
} | ||
} | ||
|
||
// Convert the value to the matching option. | ||
if (value !== null) { | ||
value = value ? 'yes' : 'no'; | ||
} | ||
|
||
this.setValue(value); | ||
|
||
// The only way to have an empty select value in Firefox is | ||
// to set a negative selectedIndex. | ||
if (value === null && CKEDITOR.env.gecko) { | ||
this.getInputElement().$.selectedIndex = -1; | ||
} | ||
}, | ||
|
||
/** | ||
* @param {CKEDITOR.dom.element} selectedCell | ||
*/ | ||
commit: function (selectedCell) { | ||
const value = this.getValue(); | ||
|
||
// Handle only supported values. | ||
if (value === 'yes') { | ||
selectedCell.setAttribute(sort_attribute, true); | ||
} else if (value === 'no') { | ||
selectedCell.removeAttribute(sort_attribute); | ||
} | ||
} | ||
}); | ||
} | ||
}); | ||
} | ||
}); | ||
|
||
})(jQuery, CKEDITOR); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* @file | ||
* Plugin for adding zebra striping of table. | ||
*/ | ||
|
||
(function ($, CKEDITOR) { | ||
"use strict"; | ||
|
||
CKEDITOR.plugins.add('table_zebra_striping', { | ||
afterInit: function afterInit (editor) { | ||
CKEDITOR.on('dialogDefinition', function(event) { | ||
const dialog_name = event.data.name; | ||
|
||
if (dialog_name !== 'table' && dialog_name !== 'tableProperties') { | ||
return; | ||
} | ||
|
||
const dialog_definition = event.data.definition; | ||
const info_tab = dialog_definition.getContents('info'); | ||
const zebra_attribute = 'data-striped'; | ||
// Avoid multiple checkbox adding. | ||
if (!info_tab.get('zebraStriping')) { | ||
info_tab.add({ | ||
type: 'checkbox', | ||
label: event.editor.config.zebra_striping__checkboxLabel, | ||
id: 'zebraStriping', | ||
labelStyle: 'display: inline;', | ||
requiredContent: 'table[' + zebra_attribute + ']', | ||
setup: function (selectedTable) { | ||
this.setValue(selectedTable.getAttribute(zebra_attribute)); | ||
}, | ||
commit: function (data, selectedTable) { | ||
if (this.getValue()) { | ||
selectedTable.setAttribute(zebra_attribute, true); | ||
} else { | ||
selectedTable.removeAttribute(zebra_attribute); | ||
} | ||
} | ||
}); | ||
} | ||
}); | ||
} | ||
}); | ||
|
||
})(jQuery, CKEDITOR); |
70 changes: 70 additions & 0 deletions
70
modules/oe_theme_helper/src/Plugin/CKEditorPlugin/TableSort.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Drupal\oe_theme_helper\Plugin\CKEditorPlugin; | ||
|
||
use Drupal\ckeditor\CKEditorPluginBase; | ||
use Drupal\ckeditor\CKEditorPluginContextualInterface; | ||
use Drupal\editor\Entity\Editor; | ||
|
||
/** | ||
* Defines the "table_sort" with altering Table plugins. | ||
* | ||
* @CKEditorPlugin( | ||
* id = "table_sort", | ||
* label = @Translation("Table sort") | ||
* ) | ||
*/ | ||
class TableSort extends CKEditorPluginBase implements CKEditorPluginContextualInterface { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getFile() { | ||
return $this->getModulePath('oe_theme_helper') . '/js/table_sort.js'; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getConfig(Editor $editor) { | ||
return []; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getButtons() { | ||
return []; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function isEnabled(Editor $editor) { | ||
if (!$editor->hasAssociatedFilterFormat()) { | ||
return FALSE; | ||
} | ||
|
||
// "Sortable" option should be available only when the ECL table | ||
// filter is enabled and the table button is present in the WYSIWYG toolbar. | ||
$enabled = FALSE; | ||
$format = $editor->getFilterFormat(); | ||
if ($format->filters('filter_ecl_table')->status) { | ||
$settings = $editor->getSettings(); | ||
foreach ($settings['toolbar']['rows'] as $row) { | ||
foreach ($row as $group) { | ||
foreach ($group['items'] as $button) { | ||
if ($button === 'Table') { | ||
$enabled = TRUE; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
return $enabled; | ||
} | ||
|
||
} |
72 changes: 72 additions & 0 deletions
72
modules/oe_theme_helper/src/Plugin/CKEditorPlugin/TableZebraStriping.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Drupal\oe_theme_helper\Plugin\CKEditorPlugin; | ||
|
||
use Drupal\ckeditor\CKEditorPluginBase; | ||
use Drupal\ckeditor\CKEditorPluginContextualInterface; | ||
use Drupal\editor\Entity\Editor; | ||
|
||
/** | ||
* Defines the "table_zebra_striping" with altering Table plugins. | ||
* | ||
* @CKEditorPlugin( | ||
* id = "table_zebra_striping", | ||
* label = @Translation("Zebra striping") | ||
* ) | ||
*/ | ||
class TableZebraStriping extends CKEditorPluginBase implements CKEditorPluginContextualInterface { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getFile() { | ||
return $this->getModulePath('oe_theme_helper') . '/js/table_zebra_striping.js'; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getConfig(Editor $editor) { | ||
return [ | ||
'zebra_striping__checkboxLabel' => $this->t('Zebra striping'), | ||
]; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getButtons() { | ||
return []; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function isEnabled(Editor $editor) { | ||
if (!$editor->hasAssociatedFilterFormat()) { | ||
return FALSE; | ||
} | ||
|
||
// "Zebra striping" option should be available only when the ECL table | ||
// filter is enabled and the table button is present in the WYSIWYG toolbar. | ||
$enabled = FALSE; | ||
$format = $editor->getFilterFormat(); | ||
if ($format->filters('filter_ecl_table')->status) { | ||
$settings = $editor->getSettings(); | ||
foreach ($settings['toolbar']['rows'] as $row) { | ||
foreach ($row as $group) { | ||
foreach ($group['items'] as $button) { | ||
if ($button === 'Table') { | ||
$enabled = TRUE; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
return $enabled; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.