Skip to content

Instantly share code, notes, and snippets.

@alexgleason
Last active June 7, 2016 20:25
Show Gist options
  • Save alexgleason/f720466452c8fb3fa7d8ce3fac2531eb to your computer and use it in GitHub Desktop.
Save alexgleason/f720466452c8fb3fa7d8ce3fac2531eb to your computer and use it in GitHub Desktop.
Hallo Wagtail inline only
(function() {
(function($) {
return $.widget('IKS.inlineonly', {
options: {
uuid: '',
editable: null,
buttonCssClass: null
},
populateToolbar: function(toolbar) {
var whitelist = [
'halloformat', 'hallowagtaillink', 'hallowagtaildoclink'
];
$(toolbar).children().filter(function() {
var className = this.className.split(/\s+/)[0];
return $.inArray(className, whitelist) == -1;
}).remove();
}
});
})(jQuery);
}).call(this);
from django.utils.html import format_html, format_html_join
from django.conf import settings
from wagtail.wagtailcore import hooks
@hooks.register('insert_editor_js')
def editor_js():
js_files = [
'js/hallowagtailinlineonly.js',
]
js_includes = format_html_join('\n', '<script src="{0}{1}"></script>',
((settings.STATIC_URL, filename) for filename in js_files)
)
return js_includes + format_html(
"""
<script>
registerHalloPlugin('inlineonly');
</script>
"""
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment