Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/link-block #728

Merged
merged 6 commits into from
Jan 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions fec/fec/static/css/customize-editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it not get this class from fec-style?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This stylesheet is loaded by the admin interface, which doesn't load fec-style. I added this as a one-off style so that you can know that the button works.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha!

}
7 changes: 0 additions & 7 deletions fec/fec/static/js/hallo-edit-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noting that this is removed because it wasn't actually being used.


button = $('<span></span>');
Expand Down
47 changes: 47 additions & 0 deletions fec/fec/static/js/hallo-sans-serif.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
(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 = $('<span></span>');
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('<span class="t-sans"></span>');
widget.options.editable.setModified();
});
}
});
})(jQuery);
}).call(this);
26 changes: 3 additions & 23 deletions fec/fec/wagtail_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +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,
'strong': allow_without_attributes,
'sub': allow_without_attributes,
'sup': allow_without_attributes,
'ul': allow_without_attributes,
'span': attribute_rule({'class': True}),
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I learned that these rules are the default ones, so we don't need to include them... just the ones that we want to add.


@hooks.register('insert_editor_js')
Expand All @@ -37,13 +15,15 @@ def editor_js():
<script src="/static/js/vendor/rangy-core.js"></script>
<script src="/static/js/vendor/rangy-selectionsaverestore.js"></script>
<script src="/static/js/hallo-edit-html.js"></script>
<script src="/static/js/hallo-sans-serif.js"></script>
<script src="/static/js/customize-editor.js"></script>
<script src="/static/js-beautify/js/lib/beautify-html.js"></script>
<script src="/static/ace-builds/src-noconflict/ace.js"></script>
<script src="/static/ace-builds/src-noconflict/mode-html.js"></script>
<script>
registerHalloPlugin('editHtmlButton');
registerHalloPlugin('hallocleanhtml');
registerHalloPlugin('sansSerifButton');
</script>
''')

Expand Down
1 change: 1 addition & 0 deletions fec/home/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
])

Expand Down
5 changes: 5 additions & 0 deletions fec/home/templates/blocks/page-links.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% load wagtailcore_tags %}

<p class="usa-width-one-half">
<a class="t-sans" href="{{ self.url }}">{{ self }} &raquo;</a>
</p>