|
148 | 148 | this.preview.container = this.preview;
|
149 | 149 |
|
150 | 150 | this.mdeditor.on('click', '.grav-mdeditor-button-code, .grav-mdeditor-button-preview', function(e) {
|
151 |
| - var task = 'task' + GravAdmin.config.param_sep; |
152 |
| - e.preventDefault(); |
153 |
| - |
154 |
| - if ($this.mdeditor.attr('data-mode') == 'tab') { |
155 |
| - if ($(this).hasClass('grav-mdeditor-button-preview')) { |
156 |
| - GravAjax({ |
157 |
| - dataType: 'JSON', |
158 |
| - url: $this.element.data('grav-urlpreview') + '/' + task + 'processmarkdown', |
159 |
| - method: 'post', |
160 |
| - data: $this.element.parents('form').serialize(), |
161 |
| - toastErrors: true, |
162 |
| - success: function (response) { |
163 |
| - $this.preview.container.html(response.message); |
164 |
| - } |
165 |
| - }); |
166 |
| - } |
| 151 | + var task = 'task' + GravAdmin.config.param_sep; |
| 152 | + e.preventDefault(); |
| 153 | + |
| 154 | + if ($this.mdeditor.attr('data-mode') == 'tab') { |
| 155 | + if ($(this).hasClass('grav-mdeditor-button-preview')) { |
| 156 | + GravAjax({ |
| 157 | + dataType: 'JSON', |
| 158 | + url: $this.element.data('grav-urlpreview') + '/' + task + 'processmarkdown', |
| 159 | + method: 'post', |
| 160 | + data: $this.element.parents('form').serialize(), |
| 161 | + toastErrors: true, |
| 162 | + success: function (response) { |
| 163 | + $this.preview.container.html(response.message); |
| 164 | + } |
| 165 | + }); |
| 166 | + } |
| 167 | + |
| 168 | + $this.mdeditor.find('.grav-mdeditor-button-code, .grav-mdeditor-button-preview').removeClass('mdeditor-active').filter(this).addClass('mdeditor-active'); |
167 | 169 |
|
168 |
| - $this.mdeditor.find('.grav-mdeditor-button-code, .grav-mdeditor-button-preview').removeClass('mdeditor-active').filter(this).addClass('mdeditor-active'); |
| 170 | + $this.activetab = $(this).hasClass('grav-mdeditor-button-code') ? 'code' : 'preview'; |
| 171 | + $this.mdeditor.attr('data-active-tab', $this.activetab); |
| 172 | + $this.editor.refresh(); |
169 | 173 |
|
170 |
| - $this.activetab = $(this).hasClass('grav-mdeditor-button-code') ? 'code' : 'preview'; |
171 |
| - $this.mdeditor.attr('data-active-tab', $this.activetab); |
172 |
| - $this.editor.refresh(); |
| 174 | + if ($this.activetab == 'preview') { |
| 175 | + $('.grav-mdeditor-toolbar').hide(); |
| 176 | + } else { |
| 177 | + $('.grav-mdeditor-toolbar').show(); |
173 | 178 | }
|
174 |
| - }); |
| 179 | + } |
| 180 | + }); |
175 | 181 |
|
176 | 182 | this.mdeditor.on('click', 'a[data-mdeditor-button]', function() {
|
177 | 183 |
|
|
0 commit comments