83 lines
2.2 KiB
JavaScript
83 lines
2.2 KiB
JavaScript
$(function() {
|
|
$(".post_preview").click(function(){
|
|
$("#main-wrap").after("<span id='show_preview'></span>");
|
|
|
|
var preview_url = $(this).attr('url');
|
|
|
|
for ( instance in CKEDITOR.instances )
|
|
CKEDITOR.instances[instance].updateElement();
|
|
|
|
var formData;
|
|
if(typeof(FormData) == "function"){
|
|
formData = new FormData( $('form.previewable')[0] );
|
|
}else{
|
|
formData = $('form.previewable').serialize()
|
|
}
|
|
|
|
$.ajax({
|
|
type: "post",
|
|
url: preview_url,
|
|
data : formData,
|
|
processData: false,
|
|
contentType: false
|
|
}).done(function(data){
|
|
$('#show_preview').html(data);
|
|
$('#show_preview .modal').modal()
|
|
$('#show_preview .modal').height(($(window).height() * 0.7));
|
|
});
|
|
});
|
|
$(".preview_trigger").click(function(){
|
|
$("#main-wrap").after("<span id='show_preview'></span>");
|
|
$.ajax({
|
|
type: 'PUT',
|
|
url: $(this).attr("href"),
|
|
data: $(this).parents("form").serialize(),
|
|
success: function (msg) {
|
|
$('#show_preview .modal').modal();
|
|
$('#show_preview .modal').height(function() {
|
|
return $(window).height() * 0.7;
|
|
});
|
|
},
|
|
error: function(){
|
|
alert("ERROR");
|
|
}
|
|
});
|
|
return false;
|
|
});
|
|
// $('#main-wrap').on(clickEvent, '.post_preview, .preview_trigger', function(e) {
|
|
// $("#main-wrap").after("<span id='show_preview'></span>");
|
|
// if($(this).hasClass('post_preview')) {
|
|
// var attrs = e.target.attributes;
|
|
// var url = attrs['url'];
|
|
// $("form.previewable").ajaxSubmit({
|
|
// beforeSubmit: function(a,f,o){
|
|
// o.dataType = 'script';
|
|
// o.url = url.nodeValue;
|
|
// o.type = 'post';
|
|
// },success: function(msg) {
|
|
// $('#show_preview .modal').modal()
|
|
// $('#show_preview .modal').height(function() {
|
|
// return $(window).height() * 0.7;
|
|
// });
|
|
// }
|
|
|
|
// });
|
|
// } else if($(this).hasClass('preview_trigger')) {
|
|
// $.ajax({
|
|
// type: 'PUT',
|
|
// url: $(this).attr("href"),
|
|
// data: $(this).parents("form").serialize(),
|
|
// success: function (msg) {
|
|
// $('#show_preview .modal').modal();
|
|
// $('#show_preview .modal').height(function() {
|
|
// return $(window).height() * 0.7;
|
|
// });
|
|
// },
|
|
// error: function(){
|
|
// alert("ERROR");
|
|
// }
|
|
// });
|
|
// return false;
|
|
// }
|
|
// });
|
|
}); |