|
1 | 1 | /**
|
2 |
| - * Name : Martor v1.6.41 |
| 2 | + * Name : Martor v1.6.42 |
3 | 3 | * Created by : Agus Makmun (Summon Agus)
|
4 |
| - * Release date : 29-Mar-2024 |
| 4 | + * Release date : 30-Mar-2024 |
5 | 5 | * License : GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
|
6 | 6 | * Repository : https://github.com/agusmakmun/django-markdown-editor
|
| 7 | + * JS Minifier : https://jscompress.com |
7 | 8 | **/
|
8 | 9 |
|
9 | 10 | (function ($) {
|
|
147 | 148 | var currentTab = $('.tab-pane#nav-preview-' + field_name);
|
148 | 149 | var editorTabButton = $('.nav-link#nav-editor-tab-' + field_name);
|
149 | 150 | var previewTabButton = $('.nav-link#nav-preview-tab-' + field_name);
|
150 |
| - var toolbarButtons = $(this).closest('.tab-martor-menu').find('.martor-toolbar') |
| 151 | + var toolbarButtons = $(this).closest('.tab-martor-menu').find('.martor-toolbar'); |
151 | 152 |
|
152 | 153 | editorTabButton.click(function () {
|
153 | 154 | // show the `.martor-toolbar` for this current editor if under preview.
|
154 |
| - $(this).closest('.tab-martor-menu').find('.martor-toolbar').show(); |
| 155 | + toolbarButtons.show(); |
155 | 156 | });
|
156 | 157 | previewTabButton.click(function () {
|
157 |
| - $(this).closest('.tab-martor-menu').find('.martor-toolbar').hide(); |
| 158 | + toolbarButtons.hide(); |
158 | 159 | });
|
159 | 160 |
|
160 | 161 | var refreshPreview = function () {
|
|
207 | 208 | if (editorConfig.living !== 'true') {
|
208 | 209 | previewTabButton.click(function () {
|
209 | 210 | // hide the `.martor-toolbar` for this current editor if under preview.
|
210 |
| - $(this).closest('.tab-martor-menu').find('.martor-toolbar').hide(); |
| 211 | + toolbarButtons.hide(); |
211 | 212 | refreshPreview();
|
212 | 213 | });
|
213 | 214 | } else {
|
|
858 | 859 | });
|
859 | 860 |
|
860 | 861 | // Set initial value if has the content before.
|
861 |
| - if (textareaId.val() != '') { |
862 |
| - editor.setValue(textareaId.val(), -1); |
863 |
| - } |
| 862 | + editor.setValue(textareaId.val(), -1); |
864 | 863 | });// end each `mainMartor`
|
865 | 864 | };
|
866 | 865 |
|
|
870 | 869 |
|
871 | 870 | if ('django' in window && 'jQuery' in window.django)
|
872 | 871 | django.jQuery(document).on('formset:added', function (event) {
|
873 |
| - var row = $(event.target); |
874 |
| - row.find('.main-martor').each(function () { |
875 |
| - var id = row.attr('id'); |
876 |
| - id = id.substr(id.lastIndexOf('-') + 1); |
877 |
| - // Notice here we are using our jQuery instead of Django's. |
878 |
| - // This is because plugins are only loaded for ours. |
879 |
| - var fixed = $(this.outerHTML.replace(/__prefix__/g, id)); |
880 |
| - $(this).replaceWith(fixed); |
881 |
| - fixed.martor(); |
882 |
| - }); |
| 872 | + // add delay for formset to load |
| 873 | + setTimeout(function(){ |
| 874 | + var row = $(event.target); |
| 875 | + row.find('.main-martor').each(function () { |
| 876 | + var id = row.attr('id'); |
| 877 | + id = id.substr(id.lastIndexOf('-') + 1); |
| 878 | + // Notice here we are using our jQuery instead of Django's. |
| 879 | + // This is because plugins are only loaded for ours. |
| 880 | + var fixed = $(this.outerHTML.replace(/__prefix__/g, id)); |
| 881 | + $(this).replaceWith(fixed); |
| 882 | + fixed.martor(); |
| 883 | + }); |
| 884 | + }, 1000); |
883 | 885 | });
|
884 | 886 | })(jQuery);
|
0 commit comments