2012-09-18 11:00:21 +01:00
|
|
|
$(document).ready(function() {
|
|
|
|
var preview_url = $('#preview_url').val();
|
|
|
|
$('#md_tabs.nav.nav-tabs').each(function(i) { $(this).find('a:first').tab('show') });
|
|
|
|
|
2012-10-04 19:40:12 +01:00
|
|
|
$(document).on('shown','#md_tabs a[data-toggle="tab"]', function (e) {
|
2012-09-18 11:00:21 +01:00
|
|
|
if(e.relatedTarget) { var hash = e.relatedTarget.hash; }
|
|
|
|
else { var hash = e.currentTarget.hash; }
|
|
|
|
var el = $(hash+'_input');
|
|
|
|
var el_dup = $(hash+'_input_dup');
|
|
|
|
var preview = $(e.target.hash+' > .formatted.cm-s-default');
|
|
|
|
if(el.val() != el_dup.val() || preview.val() === '') {
|
|
|
|
el_dup.val(el.val());
|
|
|
|
$.ajax({
|
|
|
|
type: 'POST',
|
|
|
|
url: preview_url,
|
|
|
|
data: el_dup.serialize(),
|
|
|
|
success: function(data){
|
2012-09-21 11:31:55 +01:00
|
|
|
preview.html(data).find('code').each(function (code) { CodeMirrorRun(this); })
|
2012-09-25 10:47:12 +01:00
|
|
|
}
|
|
|
|
});
|
2012-09-18 11:00:21 +01:00
|
|
|
};
|
|
|
|
});
|
|
|
|
});
|