/
simplemde_init.js
42 lines (34 loc) · 991 Bytes
/
simplemde_init.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
* Init for Processwire
* These items could be added if fullscreen or sidebyside would work on PW
* Note that fullscreen mode is not working right on Reno theme
*/
var initSimpleMDE = function() {
var thisID = $(this).attr('id');
var visible = $(this).is(":visible");
console.log($(this));
if(visible) {
var simplemde = new SimpleMDE({
element: document.getElementById(thisID),
toolbar: ["bold", "italic", "heading", "|",
"quote", "unordered-list", "ordered-list", "|",
"link", "image", "|",
"preview", "side-by-side", "fullscreen", "|",
"table", "horizontal-rule", "code", "|",
"guide"
],
spellChecker: false,
promptURLs: true,
});
$(this).data('simplemde', simplemde);
}
}
/**
* Init the field on page load
*/
$(window).load(function(){
$('#Inputfield_description').each(initSimpleMDE);
});
$(document).on('wiretabclick reloaded opened', function() {
$('#Inputfield_description').each(initSimpleMDE);
});