This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
orbit-4-1/app/assets/javascripts/lib/modal-preview.js

66 lines
1.8 KiB
JavaScript
Raw Normal View History

2013-10-24 06:46:53 +00:00
$(function() {
2013-11-06 08:31:27 +00:00
$(".post_preview").click(function(){
2013-10-24 06:46:53 +00:00
$("#main-wrap").after("<span id='show_preview'></span>");
2012-10-01 09:48:51 +00:00
2013-11-06 08:31:27 +00:00
$.post($(this).attr('url'), $(".previewable").serialize() ,function(data){
$('#show_preview .modal').modal();
$('#show_preview .modal').height(function() {
return $(window).height() * 0.7;
2013-10-24 06:46:53 +00:00
});
2013-11-06 08:31:27 +00:00
},'script');
2013-10-24 06:46:53 +00:00
});
2013-11-06 08:31:27 +00:00
$(".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) {
2013-10-24 06:46:53 +00:00
// $("#main-wrap").after("<span id='show_preview'></span>");
2013-11-06 08:31:27 +00:00
// 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");
2013-10-24 06:46:53 +00:00
// }
2013-11-06 08:31:27 +00:00
// });
// return false;
// }
2013-10-24 06:46:53 +00:00
// });
});