Last active
June 7, 2016 20:25
-
-
Save alexgleason/f720466452c8fb3fa7d8ce3fac2531eb to your computer and use it in GitHub Desktop.
Hallo Wagtail inline only
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
(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); |
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
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