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

73 lines
2.0 KiB
JavaScript
Raw Permalink 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>");
var preview_url = $(this).attr('url');
2012-10-01 09:48:51 +00:00
$("form.previewable").ajaxSubmit({
beforeSubmit: function(a,f,o){
o.dataType = 'script';
o.url = preview_url;
o.type = 'post';
},success: function(msg) {
$('#show_preview .modal').modal()
2013-11-06 08:31:27 +00:00
$('#show_preview .modal').height(function() {
return $(window).height() * 0.7;
2013-10-24 06:46:53 +00:00
});
}});
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;
// });
2013-11-06 08:31:27 +00:00
// }
// });
// } 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
// });
});