Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #99 from EightMedia/master
Fix django-tinymce on admin inlnes for Django >= 1.6
- Loading branch information
Showing
6 changed files
with
98 additions
and
50 deletions.
There are no files selected for viewing
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
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
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
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
(function ($) { | ||
function initTinyMCE($e) { | ||
if ($e.parents('.empty-form').length == 0) { // Don't do empty inlines | ||
var mce_conf = $.parseJSON($e.attr('data-mce-conf')); | ||
var id = $e.attr('id'); | ||
if ('elements' in mce_conf && mce_conf['mode'] == 'exact') { | ||
mce_conf['elements'] = id; | ||
} | ||
if ($e.attr('data-mce-gz-conf')) { | ||
tinyMCE_GZ.init($.parseJSON($e.attr('data-mce-gz-conf'))); | ||
} | ||
if (!tinyMCE.editors[id]) { | ||
tinyMCE.init(mce_conf); | ||
} | ||
} | ||
} | ||
|
||
$(function () { | ||
// initialize the TinyMCE editors on load | ||
$('.tinymce').each(function () { | ||
initTinyMCE($(this)); | ||
}); | ||
|
||
// initialize the TinyMCE editor after adding an inline | ||
// XXX: We don't use jQuery's click event as it won't work in Django 1.4 | ||
document.body.addEventListener("click", function(ev) { | ||
if(!ev.target.parentNode || ev.target.parentNode.className.indexOf("add-row") === -1) { | ||
return; | ||
} | ||
var $addRow = $(ev.target.parentNode); | ||
setTimeout(function() { // We have to wait until the inline is added | ||
$('textarea.tinymce', $addRow.parent()).each(function () { | ||
initTinyMCE($(this)); | ||
}); | ||
}, 0); | ||
}, true); | ||
}); | ||
}(django.jQuery)); |
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