Update Bootstrap to v4.1, fix chosen.js and pagedown on multiple sites
This commit is contained in:
2131
app/assets/javascripts/pagedown/markdown.editor.js.erb
Normal file
2131
app/assets/javascripts/pagedown/markdown.editor.js.erb
Normal file
File diff suppressed because it is too large
Load Diff
43
app/assets/javascripts/pagedown/pagedown.js.erb
Normal file
43
app/assets/javascripts/pagedown/pagedown.js.erb
Normal file
@@ -0,0 +1,43 @@
|
||||
//= require markdown.converter
|
||||
// markdown.editor is slightly adjusted to work with Bootstrap 4.
|
||||
// Taken from https://github.com/hughevans/pagedown-bootstrap-rails, V2.1.4
|
||||
//= require markdown.editor
|
||||
//= require markdown.sanitizer
|
||||
//= require markdown.extra
|
||||
|
||||
renderPagedown = function() {
|
||||
$(".wmd-output").each(function (i) {
|
||||
const converter = new Markdown.Converter();
|
||||
const content = $(this).html();
|
||||
return $(this).html(converter.makeHtml(content));
|
||||
})
|
||||
};
|
||||
|
||||
createPagedownEditor = function( selector, context ) {
|
||||
if (context == null) { context = 'body'; }
|
||||
return $(selector, context).each(function(i, input) {
|
||||
if ($(input).data('is_rendered')) {
|
||||
return;
|
||||
}
|
||||
const attr = $(input).attr('id').split('wmd-input')[1];
|
||||
const converter = new Markdown.Converter();
|
||||
Markdown.Extra.init(converter);
|
||||
const help = {
|
||||
handler() {
|
||||
window.open('http://daringfireball.net/projects/markdown/syntax');
|
||||
return false;
|
||||
},
|
||||
title: "<%= I18n.t('components.markdown_editor.help', default: 'Markdown Editing Help') %>"
|
||||
};
|
||||
|
||||
const editor = new Markdown.Editor(converter, attr, help);
|
||||
editor.run();
|
||||
$('[data-toggle="tooltip"]').tooltip();
|
||||
return $(input).data('is_rendered', true);
|
||||
});
|
||||
};
|
||||
|
||||
$(document).on('turbolinks:load', function() {
|
||||
renderPagedown();
|
||||
return createPagedownEditor('.wmd-input');
|
||||
});
|
Reference in New Issue
Block a user