From 03259071cd6995af90ca418212f0fe9b66aff687 Mon Sep 17 00:00:00 2001 From: Noah Manger Date: Mon, 9 Jan 2017 23:23:23 -0800 Subject: [PATCH 1/6] Adding sans-serif editor button --- fec/fec/static/js/hallo-sans-serif.js | 46 +++++++++++++++++++++++++++ fec/fec/wagtail_hooks.py | 3 ++ 2 files changed, 49 insertions(+) create mode 100644 fec/fec/static/js/hallo-sans-serif.js diff --git a/fec/fec/static/js/hallo-sans-serif.js b/fec/fec/static/js/hallo-sans-serif.js new file mode 100644 index 0000000000..f1969b19d0 --- /dev/null +++ b/fec/fec/static/js/hallo-sans-serif.js @@ -0,0 +1,46 @@ +(function() { + (function($) { + return $.widget('IKS.sansSerifButton', { + options: { + uuid: '', + editable: null + }, + populateToolbar: function(toolbar) { + var button, + widget = this; + + var checkClass = function() { + var node = widget.options.editable.getSelection().commonAncestorContainer; + var parent = $(node).parents('span').get(0); + if (parent) { + return parent.classList.contains('t-sans'); + } else { + return false; + } + }; + + button = $(''); + button.hallobutton({ + uuid: this.options.uuid, + editable: this.options.editable, + label: 'Sans-serif link', + icon: 'icon-edit', + command: null, + queryState: function(e) { + // Show the active state if it has the t-sans class already + return button.hallobutton('checked', checkClass()); + } + }); + + toolbar.append(button); + + button.on('click', function() { + // Get the selected node, find it's parent element and wrap it in a t-sans span + var node = widget.options.editable.getSelection().commonAncestorContainer; + var parent = $(node).parents('a').get(0); + $(parent).wrap(''); + }); + } + }); + })(jQuery); +}).call(this); diff --git a/fec/fec/wagtail_hooks.py b/fec/fec/wagtail_hooks.py index 37b98bbcd8..33d8049add 100644 --- a/fec/fec/wagtail_hooks.py +++ b/fec/fec/wagtail_hooks.py @@ -24,6 +24,7 @@ def whitelister_element_rules(): 'li': allow_without_attributes, 'ol': allow_without_attributes, 'p': allow_without_attributes, + 'span': attribute_rule({'class': True}), 'strong': allow_without_attributes, 'sub': allow_without_attributes, 'sup': allow_without_attributes, @@ -37,6 +38,7 @@ def editor_js(): + @@ -44,6 +46,7 @@ def editor_js(): ''') From fee00c75deb6d8e1187cf33606f7ec37193f40b1 Mon Sep 17 00:00:00 2001 From: Noah Manger Date: Mon, 9 Jan 2017 23:23:30 -0800 Subject: [PATCH 2/6] Removing unused method --- fec/fec/static/js/hallo-edit-html.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/fec/fec/static/js/hallo-edit-html.js b/fec/fec/static/js/hallo-edit-html.js index 2647dfc436..0a6d406cd2 100644 --- a/fec/fec/static/js/hallo-edit-html.js +++ b/fec/fec/static/js/hallo-edit-html.js @@ -12,13 +12,6 @@ populateToolbar: function(toolbar) { var button, widget; - var getEnclosing = function(tag) { - var node; - - node = widget.options.editable.getSelection().commonAncestorContainer; - return $(node).parents(tag).get(0); - }; - widget = this; button = $(''); From b3cddb2224f3139655139aff0b7e185f2d75c56c Mon Sep 17 00:00:00 2001 From: Noah Manger Date: Mon, 9 Jan 2017 23:23:44 -0800 Subject: [PATCH 3/6] Adding style for t-sans in editor --- fec/fec/static/css/customize-editor.css | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fec/fec/static/css/customize-editor.css b/fec/fec/static/css/customize-editor.css index 5ab625e4c6..597c65a00d 100644 --- a/fec/fec/static/css/customize-editor.css +++ b/fec/fec/static/css/customize-editor.css @@ -6,6 +6,14 @@ li.sequence-member .struct-block .sequence-container { width: 83%; } +li.sequence-member .struct-block .sequence-container .field-content { + width: 100%; +} + li.sequence-member .sequence-member-inner .sequence-type-list .sequence-container-inner { width: 100%; } + +.t-sans { + font-family: sans-serif; +} From e80189b94db7ca82579bfa98269833c80c05eb9b Mon Sep 17 00:00:00 2001 From: Noah Manger Date: Tue, 10 Jan 2017 20:35:33 -0800 Subject: [PATCH 4/6] Removing unnecessary whitelist declarations --- fec/fec/wagtail_hooks.py | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/fec/fec/wagtail_hooks.py b/fec/fec/wagtail_hooks.py index 33d8049add..525da5ec38 100644 --- a/fec/fec/wagtail_hooks.py +++ b/fec/fec/wagtail_hooks.py @@ -5,30 +5,7 @@ @hooks.register('construct_whitelister_element_rules') def whitelister_element_rules(): return { - # Commenting out disallowed tags so its easier to remember & revert - 'a': attribute_rule({'href': check_url}), - 'b': allow_without_attributes, - # 'br': allow_without_attributes, - # 'div': allow_without_attributes, - 'em': allow_without_attributes, - 'h1': allow_without_attributes, - 'h2': allow_without_attributes, - 'h3': allow_without_attributes, - 'h4': allow_without_attributes, - 'h5': allow_without_attributes, - 'h6': allow_without_attributes, - 'hr': allow_without_attributes, - 'i': allow_without_attributes, - 'img': attribute_rule({'src': check_url, 'width': True, 'height': True, - 'alt': True}), - 'li': allow_without_attributes, - 'ol': allow_without_attributes, - 'p': allow_without_attributes, 'span': attribute_rule({'class': True}), - 'strong': allow_without_attributes, - 'sub': allow_without_attributes, - 'sup': allow_without_attributes, - 'ul': allow_without_attributes, } @hooks.register('insert_editor_js') From 71fa14b59b2c151a0c21682deffcd608c9b47fa0 Mon Sep 17 00:00:00 2001 From: Noah Manger Date: Tue, 10 Jan 2017 20:35:42 -0800 Subject: [PATCH 5/6] Saving modification --- fec/fec/static/js/hallo-sans-serif.js | 1 + 1 file changed, 1 insertion(+) diff --git a/fec/fec/static/js/hallo-sans-serif.js b/fec/fec/static/js/hallo-sans-serif.js index f1969b19d0..da60ee9e6d 100644 --- a/fec/fec/static/js/hallo-sans-serif.js +++ b/fec/fec/static/js/hallo-sans-serif.js @@ -39,6 +39,7 @@ var node = widget.options.editable.getSelection().commonAncestorContainer; var parent = $(node).parents('a').get(0); $(parent).wrap(''); + widget.options.editable.setModified(); }); } }); From 6c1e3d4ee5a287685a2f2b0965279a70609e0d14 Mon Sep 17 00:00:00 2001 From: Noah Manger Date: Tue, 10 Jan 2017 20:46:57 -0800 Subject: [PATCH 6/6] Adding page link block --- fec/home/blocks.py | 1 + fec/home/templates/blocks/page-links.html | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 fec/home/templates/blocks/page-links.html diff --git a/fec/home/blocks.py b/fec/home/blocks.py index 9e5d7e1053..69a4039e5a 100644 --- a/fec/home/blocks.py +++ b/fec/home/blocks.py @@ -92,6 +92,7 @@ class ResourceBlock(blocks.StructBlock): ('contact_info', ContactInfoBlock()), ('internal_button', InternalButtonBlock()), ('external_button', ExternalButtonBlock()), + ('page', blocks.PageChooserBlock(template='blocks/page-links.html')), ('document_list', blocks.ListBlock(FeedDocumentBlock(), template='blocks/document-list.html', icon='doc-empty')) ]) diff --git a/fec/home/templates/blocks/page-links.html b/fec/home/templates/blocks/page-links.html new file mode 100644 index 0000000000..a9ebed1977 --- /dev/null +++ b/fec/home/templates/blocks/page-links.html @@ -0,0 +1,5 @@ +{% load wagtailcore_tags %} + +

+ {{ self }} » +