Skip to content
This repository has been archived by the owner on Nov 30, 2023. It is now read-only.

Commit

Permalink
Removed the modules submodule and added them correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-sparks committed Nov 9, 2017
1 parent 85321f2 commit 362db0d
Show file tree
Hide file tree
Showing 108 changed files with 7,277 additions and 1 deletion.
1 change: 0 additions & 1 deletion modules
Submodule modules deleted from 6c27b0
7 changes: 7 additions & 0 deletions modules/admin_ui_toggle/admin_ui_toggle.info.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: Admin UI Toggle
type: module
description: 'Provides the Admin UI Toggle block'
package: Sector
core: 8.x
dependencies:
- block
11 changes: 11 additions & 0 deletions modules/admin_ui_toggle/admin_ui_toggle.libraries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
admin-ui-toggle:
version: VERSION
css:
component:
css/admin-ui-toggle.css: {}
js:
js/admin_ui_toggle.js: {}
dependencies:
- core/jquery
- core/jquery.once
- core/drupal
11 changes: 11 additions & 0 deletions modules/admin_ui_toggle/admin_ui_toggle.module
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

/**
* Implements hook_theme().
*/
function admin_ui_toggle_theme($existing, $type, $theme, $path) {
return [
'admin_ui_toggle' => [
],
];
}
40 changes: 40 additions & 0 deletions modules/admin_ui_toggle/css/admin-ui-toggle.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
body.admin-ui-hide {padding-top:0px!important;}
.admin-ui-hide #toolbar-bar {display:none!important;}
.admin-ui-hide .contextual-links-wrapper {display:none!important;}
.admin-ui-hide .tabs--primary {display:none!important;}
.admin-ui-hide .alert {display:none!important;}
html body.admin-ui-hide.toolbar-bar {margin-top: 0!important;}
.admin-ui-toggle p {
margin:0;padding:0;
}
.block-admin-ui-toggle {
display: flex;
}
.admin-ui-toggle button {
position: fixed;
top:0;
right:150px;
border: none;
outline:none;
z-index: 9999;
}
.admin-ui-toggle button:before {
content: 'Hide menu';
font-size: 12px;
line-height: 1;
}
.admin-ui-toggle.ui-is-hidden button:before {
content: 'Show menu';
}
.admin-ui-toggle button .fa-toggle-off {
display: none;
}
.admin-ui-toggle button .fa-toggle-on {
display: block;
}
.admin-ui-hide .admin-ui-toggle button .fa-toggle-off {
display: block;
}
.admin-ui-hide .admin-ui-toggle button .fa-toggle-on {
display: none;
}
18 changes: 18 additions & 0 deletions modules/admin_ui_toggle/js/admin_ui_toggle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
(function ($, Drupal) {

'use strict';

Drupal.behaviors.admin_ui_toggle = {
attach: function (context, settings) {
$("button",".admin-ui-toggle").on('click', function(evt){
$("body").toggleClass("admin-ui-hide");
if ($("body").hasClass('admin-ui-hide')) {
$('.admin-ui-toggle').addClass('ui-is-hidden');
} else {
$('.admin-ui-toggle').removeClass('ui-is-hidden');
}
evt.preventDefault();
});
}
};
})(jQuery, Drupal);
32 changes: 32 additions & 0 deletions modules/admin_ui_toggle/src/Plugin/Block/AdminUiToggle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Drupal\admin_ui_toggle\Plugin\Block;

use Drupal\Core\Block\BlockBase;

/**
* Provides the admin ui toggle block.
*
* @Block(
* id = "admin_ui_toggle",
* admin_label = @Translation("Sector blocks - Admin UI toggle"),
* )
*/
class AdminUiToggle extends BlockBase {

/**
* {@inheritdoc}
*/
public function build() {
$items = array();

return array(
'#theme' => 'admin_ui_toggle',
'#attached' => [
'library' => [
'admin_ui_toggle/admin-ui-toggle'
],
],
);
}
}
7 changes: 7 additions & 0 deletions modules/admin_ui_toggle/templates/admin-ui-toggle.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% block content %}
<div class="admin-ui-toggle">
<p>
<button></button>
</p>
</div>
{% endblock %}
13 changes: 13 additions & 0 deletions modules/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "sparksi/sector_modules",
"description": "Project-specific modules for the Sector D8 project",
"type": "drupal-custom-module",
"license": "GPL-2.0+",
"minimum-stability": "dev",
"authors": [
{
"name": "Sparks Interactive",
"role": "Development"
}
]
}
9 changes: 9 additions & 0 deletions modules/plain_text/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Plain text module

Probably needs a better name..

This module creates a checkbox at at /admin/config/content/formats/manage/{format}.
If this checkbox is ticked then all text pasted in the ckeditor using this text
format will have all formatting stripped.

This retains the integrity of the Paste from word toolbar button.
52 changes: 52 additions & 0 deletions modules/plain_text/js/plain_text.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* @file
*
* JS file for making sure that intercepts paste events from Ctrl/CMd+V and
* right click and strips the formatting from them using proper Jquery
* functions.
*
* @ignore
*/

(function ($, Drupal, drupalSettings, _) {

'use strict';

Drupal.ckeditor = Drupal.ckeditor || {};

Drupal.behaviors.plaintext = {
attach: function () {
// Checks if the CKEDITOR currently exists
if (typeof CKEDITOR !== 'undefined') {
CKEDITOR.on('instanceReady', function (i) {
// Gets the editor instance.
var editor = i.editor;
// The paste from word dialog shows up by default on any paste event.
// We don't want that, so this disables it.
editor.config.pasteFromWordPromptCleanup = false;
// Paste event.
editor.on('paste', function (e) {
// Checks if the PlainText config is true, if its false, don't apply
// the processing to the text.
if(editor.config.PlainText === true) {
console.log(e);
console.log(editor);
// Paste events that aren't the pastefromword paste dialog creates
// this $ object inside the editor. We check if it exists.
//
// If it exists it means the paste should be stripped.
if (e.data.dataTransfer.$) {
// Not 100% sure if this is needed. Will test.
e.data.type = 'text';

var text = '';
// Strip the tags using the jQuery.text function.
e.data.dataValue = jQuery(e.data.dataValue).text();
}
}
});
});
}
}
}
})(jQuery, Drupal, drupalSettings, _);
5 changes: 5 additions & 0 deletions modules/plain_text/plain_text.info.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: Plain Text
type: module
description: 'Plain text plugin for ckeditor'
package: Sector
core: 8.x
7 changes: 7 additions & 0 deletions modules/plain_text/plain_text.libraries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
plain-text:
version: VERSION
js:
js/plain_text.js: {}
dependencies:
- core/jquery
- core/drupal
26 changes: 26 additions & 0 deletions modules/plain_text/plain_text.module
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

/**
* Implements hook_page_attachments().
*/
function plain_text_page_attachments(array &$attachments) {
// Attach the library.
$attachments['#attached']['library'][] = 'plain_text/plain-text';
}

//TODO: MAKE THIS AND THE JS NICER

function plain_text_editor_js_settings_alter(array &$settings) {
// Get all active formats.
$filters_list = filter_formats();

// For every text format, check if the Enable plain text filter is enabled,
// if it is, set the variable so it can be used later in the JS.
foreach (array_keys($settings['editor']['formats']) as $text_format_id) {
$format_filter = $filters_list[$text_format_id]->filters()->getAll();
$format_filter_config = $format_filter['plain_text_filter']->getConfiguration();
if($format_filter_config['status']) {
$settings['editor']['formats'][$text_format_id]['editorSettings']['PlainText'] = TRUE;
}
}
}
24 changes: 24 additions & 0 deletions modules/plain_text/src/Plugin/Filter/PlainTextFilter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace Drupal\plain_text\Plugin\Filter;

use Drupal\filter\Plugin\FilterBase;
use Drupal\filter\FilterProcessResult;

/**
* @Filter(
* id = "plain_text_filter",
* title = @Translation("Enforce plain text paste"),
* description = @Translation("If enabled, all text pasted directly into the CKEditor will be stripped of all tags and pasted as plain text."),
* type = Drupal\filter\Plugin\FilterInterface::TYPE_HTML_RESTRICTOR,
* )
*/
class PlainTextFilter extends FilterBase {

public function process($text, $langcode) {
// The text is processed using the JS that is loaded if this filter is
// enabled. Thus we only need to return the same text sent to this function.
$result = new FilterProcessResult($text);
return $result;
}
}
6 changes: 6 additions & 0 deletions modules/sector_blocks/sector_blocks.info.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: Sector blocks
description: Provides custom blocks for Sector
package: Sector

type: module
core: 8.x
17 changes: 17 additions & 0 deletions modules/sector_blocks/sector_blocks.module
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

/**
* Implements hook_theme().
*/
function sector_blocks_theme($existing, $type, $theme, $path) {
return [
'responsive_menu_control_block' => [
],
'search_desktop_fly_out_control_block' => [
],
'search_api_box' => [
],
'search_api_box_mobile' => [
],
];
}
25 changes: 25 additions & 0 deletions modules/sector_blocks/src/Plugin/Block/ResponsiveMenuControls.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace Drupal\sector_blocks\Plugin\Block;

use Drupal\Core\Block\BlockBase;

/**
* Provides the responsive menu controls block.
*
* @Block(
* id = "responsive_menu_controls",
* admin_label = @Translation("Sector blocks - Responsive menu controls"),
* )
*/
class ResponsiveMenuControls extends BlockBase {
/**
* {@inheritdoc}
*/
public function build() {
$build = [];
$build['#theme'] = 'responsive_menu_control_block';

return $build;
}
}
25 changes: 25 additions & 0 deletions modules/sector_blocks/src/Plugin/Block/SearchApiBox.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace Drupal\sector_blocks\Plugin\Block;

use Drupal\Core\Block\BlockBase;

/**
* Provides the search api box block. Replicates the default search block design.
*
* @Block(
* id = "search_api_box",
* admin_label = @Translation("Sector blocks - Search API block"),
* )
*/
class SearchApiBox extends BlockBase {
/**
* {@inheritdoc}
*/
public function build() {
$build = [];
$build['#theme'] = 'search_api_box';

return $build;
}
}
26 changes: 26 additions & 0 deletions modules/sector_blocks/src/Plugin/Block/SearchApiBoxMobile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Drupal\sector_blocks\Plugin\Block;

use Drupal\Core\Block\BlockBase;

/**
* Provides the search api box block. Replicates the default search block design.
* Mobile version.
*
* @Block(
* id = "search_api_box_mobile",
* admin_label = @Translation("Sector blocks - Search API block (mobile)"),
* )
*/
class SearchApiBoxMobile extends BlockBase {
/**
* {@inheritdoc}
*/
public function build() {
$build = [];
$build['#theme'] = 'search_api_box_mobile';

return $build;
}
}
Loading

0 comments on commit 362db0d

Please sign in to comment.