2012-04-17 03:34:25 +00:00
|
|
|
//Preview need a link in form as Ex and a corresponding PUT action in controller
|
|
|
|
//Ex preview trigger:
|
|
|
|
// <%= link_to "NewPreview", realtime_preview_admin_ad_banner_path(ad_banner_tab) , :class=>'preview_trigger'%>
|
|
|
|
|
|
|
|
$(document).ready(function() {
|
2012-09-07 09:55:59 +00:00
|
|
|
// $(".post_preview").click(function(e){
|
|
|
|
// $("#main-wrap").after("<span id='show_preview'></span>");
|
|
|
|
// e.preventDefault();
|
|
|
|
// var form = $(this).parents("form").first()
|
|
|
|
// //var cont = form["content"].value;
|
|
|
|
// // $.ajax({
|
|
|
|
// // type: 'POST',
|
|
|
|
// // url: $(this).attr("href")+'?preview=true',
|
|
|
|
// // data: form.serialize(),
|
|
|
|
// // dataType: "script",
|
|
|
|
// // success: function (msg) {
|
|
|
|
// // $("#"+start_modal_with_id).modal('show'); },
|
|
|
|
// // error: function(){
|
|
|
|
// // alert("ERROR");
|
|
|
|
// // }
|
|
|
|
// // });
|
|
|
|
// url = "/panel/news/back_end/news_bulletins/preview?preview=true"
|
|
|
|
// // alert(url)
|
|
|
|
// form.attr("action",url);
|
|
|
|
// form.submit();
|
|
|
|
// //return false;
|
|
|
|
// });
|
|
|
|
$("button.post_preview").click(function(){
|
2012-10-01 09:21:23 +00:00
|
|
|
var btn = document.getElementById("button_for_preview");
|
|
|
|
var attrs = btn.attributes;
|
|
|
|
var url = attrs['url'];
|
|
|
|
// url = url.replace("url=","");
|
2012-09-07 09:55:59 +00:00
|
|
|
$("form.nccu_ajax_form").ajaxSubmit({
|
|
|
|
beforeSubmit: function(a,f,o){
|
|
|
|
$("#main-wrap").after("<span id='show_preview'></span>");
|
|
|
|
o.dataType = 'script';
|
2012-10-01 09:21:23 +00:00
|
|
|
o.url = url.nodeValue;
|
2012-09-10 03:53:59 +00:00
|
|
|
o.type = 'post';
|
2012-10-01 09:56:55 +00:00
|
|
|
},success: function(msg) { console.log(msg); }
|
2012-10-01 09:48:51 +00:00
|
|
|
|
2012-09-07 09:55:59 +00:00
|
|
|
});
|
|
|
|
})
|
|
|
|
// $("form.nccu_ajax_form").ajaxForm({
|
|
|
|
// beforeSubmit: function(a,f,o) {
|
|
|
|
// // if(clicked_what.hasClass("post_preview")){
|
|
|
|
// // $("#main-wrap").after("<span id='show_preview'></span>");
|
|
|
|
// // o.dataType = 'script';
|
|
|
|
// // o.url = clicked_what.attr("url");
|
|
|
|
// // }
|
|
|
|
// },
|
|
|
|
// success: function(data) {
|
|
|
|
// // if(!clicked_what.hasClass("post_preview")){
|
|
|
|
// // window.location = data.redirect_url;
|
|
|
|
// // }
|
|
|
|
// }
|
|
|
|
// })
|
2012-09-04 01:24:12 +00:00
|
|
|
|
2012-04-17 03:34:25 +00:00
|
|
|
$("a.preview_trigger").click(function(){
|
2012-04-25 09:08:51 +00:00
|
|
|
$("#main-wrap").after("<span id='show_preview'></span>");
|
2012-04-17 03:34:25 +00:00
|
|
|
$.ajax({
|
2012-04-23 09:03:55 +00:00
|
|
|
type: 'PUT',
|
2012-04-17 03:34:25 +00:00
|
|
|
url:$(this).attr("href"),
|
2012-04-23 09:03:55 +00:00
|
|
|
data:$(this).parents("form").serialize(),
|
|
|
|
success: function (msg) {
|
|
|
|
$("#"+start_modal_with_id).modal('show'); },
|
|
|
|
error: function(){
|
|
|
|
alert("ERROR");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return false;
|
|
|
|
});
|
2012-04-17 03:34:25 +00:00
|
|
|
});
|