orbit-basic/app/assets/javascripts/desktop/journal_pages.js.erb

399 lines
16 KiB
Plaintext
Raw Normal View History

2012-11-21 07:35:23 +00:00
orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // this init journal papers
this.initializeJournalPapers.formCallback = function(data){
2012-11-22 08:34:20 +00:00
if(data.success){
2012-11-21 07:35:23 +00:00
o.notify(data.msg,"success");
o.sub_menu_item($("div[content-type=menu] a").eq(0));
}else{
o.notify(data.msg,"alert");
}
}
this.initializeJournalPapers.list = function(){ // to open list part in journal papers page
var journalData;
var bindHandlers = function(){ // to bind handlers for list page
o.simple_drop_down();
o.tinyscrollbar_ext({
main: '.tinycanvas',
fill: '.list_t'
})
$("#journal_selection_options a").click(function(){
switch($(this).attr("href")){
case "all":
$(".list_item_action > .icon-check-empty").switchClass("icon-check-empty","icon-check",0);
break;
case "none":
$(".list_item_action > .icon-check").switchClass("icon-check","icon-check-empty",0);
break;
}
return false;
})
$("#journal_view_selection a").click(function(){
switch($(this).attr("href")){
case "journal":
journalview();
break;
case "keywords":
keywordsview();
break;
case "title":
titleview();
break;
case "abstract":
abstractview();
break;
case "file":
fileview();
break;
}
return false;
})
2012-11-23 05:22:01 +00:00
$("div[container=true]").unbind(".edit").on("click.edit",".journal_paper_edit",function(){
2012-11-21 07:35:23 +00:00
$.ajax({
url : $(this).attr("href"),
type : "get",
success : function(data){
var prev_data = $("div[container=true]").html();
$("div[container=true]").html(data);
o.tinyscrollbar_ext({
main: '.tinycanvas',
fill: '.s_grid_con'
})
2012-11-21 07:35:23 +00:00
$(".bt-cancel").click(function(){
$("div[container=true]").html(prev_data);
2012-12-06 07:44:16 +00:00
o.tinyscrollbar_ext({
main: '.tinycanvas',
fill: '.list_t'
})
2012-11-21 07:35:23 +00:00
})
}
})
return false;
})
2012-11-23 05:22:01 +00:00
$("div[container=true]").unbind(".delete").on("click.delete",".journal_paper_delete",function(){
2012-11-23 02:46:42 +00:00
var delurl = $(this).attr("href");
var parent = $(this).parent();
o.confirm({
buttons : ["Yes","No"],
highlighted : 2,
message : "Are you sure, you want to delete this paper?"
},function(value){
if(value){
$.ajax({
url : delurl,
type : "DELETE",
2012-11-23 05:22:01 +00:00
success : function(data){
if(data.success){
parent.hide("slide",function(){parent.remove();});
o.notify(data.msg,"success");
}
2012-11-23 02:46:42 +00:00
}
})
}
})
return false;
})
2012-11-21 07:35:23 +00:00
}
var bindSecondaryHandlers = function(){
$("#journal_p div#paper_list a.icon-check-empty").click(function(){
if($(this).hasClass("icon-check-empty")){
$(this).switchClass("icon-check-empty","icon-check",0);
} else if($(this) .hasClass("icon-check")) {
$(this).switchClass("icon-check","icon-check-empty",0);
} else if($(this).hasClass("icon-star")){
$(this).removeClass("icon-star").addClass("icon-star-empty");
} else if($(this).hasClass("icon-star-empty")){
$(this).removeClass("icon-star-empty").addClass("icon-star");
}
return false;
})
}
var journalview = function(){
$("#journal_p div#paper_list div.overview").empty();
var column = $('<div class="g_col list_t"><ul></ul></div>'),
counter = 1,
li;
$.each(journalData,function(i,journal){
$.each(journal.papers,function(j,paper){
2012-12-05 19:42:20 +00:00
li = $('<li class="list_t_item"><div class="list_item_action"><a href="" class="icon-check-empty"></a><a href="" class="icon-star-empty"></a></div><div class="list_t_title">'+journal.title+'</div><div class="list_t_des">'+paper.title+'</div><div class="list_item_function"><a class="journal_paper_edit admbg2 admtxt" href="'+paper.url_edit+'">Edit</a> <a class="journal_paper_delete admbg2 admtxt" href="'+paper.url_delete+'">Delete</a></div></li>');
2012-11-21 07:35:23 +00:00
column.find("ul").append(li);
if(counter%5==0){
$("#journal_p div#paper_list div.overview").append(column);
column = $('<div class="g_col list_t"><ul></ul></div>');
}
counter++;
})
})
$("#journal_p div#paper_list div.overview").append(column);
bindSecondaryHandlers();
}
var fileview = function(){
$("#journal_p div#paper_list div.overview").empty();
var column = $('<div class="g_col list_t"><ul></ul></div>'),
counter = 1,
li = null;
$.each(journalData,function(i,journal){
$.each(journal.papers,function(j,paper){
li = null;
2012-12-06 03:43:40 +00:00
li = $('<li class="list_t_item file_view"></li>');
li.append('<div class="list_item_action"><a href="" class="icon-check-empty"></a><a href="" class="icon-star-empty"></a></div><div class="list_t_title">'+journal.title+'</div><div class="list_t_des"></div>');
var file_list = li.find('.list_t_des');
2012-11-21 07:35:23 +00:00
$.each(paper.files,function(k,file){
var thistitle = file.title;
2012-12-06 03:43:40 +00:00
thistitle = ( thistitle.length > 8 )? thistitle.substring(0,8)+'...' : thistitle;
if(!file.title){
thistitle = "Untitled File";
}
var img = $('<a class="file" href="'+file.url+'" target="_blank" ><img src="'+file.icon+'" /><span class="filetitle">'+thistitle+'</span></a>');
file_list.append(img);
2012-11-21 07:35:23 +00:00
})
2012-12-05 19:42:20 +00:00
li.append('<div class="list_item_function"><a class="journal_paper_edit admbg2 admtxt" href="'+paper.url_edit+'">Edit</a> <a class="journal_paper_delete admbg2 admtxt" href="'+paper.url_delete+'">Delete</a></div>');
2012-11-21 07:35:23 +00:00
column.find("ul").append(li);
2012-12-06 03:43:40 +00:00
if(counter%3==0){
2012-11-21 07:35:23 +00:00
$("#journal_p div#paper_list div.overview").append(column);
column = $('<div class="g_col list_t"><ul></ul></div>');
}
counter++;
})
})
$("#journal_p div#paper_list div.overview").append(column);
bindSecondaryHandlers();
}
var keywordsview = function(){
$("#journal_p div#paper_list div.overview").empty();
var column = $('<div class="g_col list_t"><ul></ul></div>'),
counter = 1,
li;
$.each(journalData,function(i,journal){
$.each(journal.papers,function(j,paper){
2012-12-05 19:42:20 +00:00
li = $('<li class="list_t_item"><div class="list_item_action"><a href="" class="icon-check-empty"></a><a href="" class="icon-star-empty"></a></div><div class="list_t_title">'+paper.title+'</div><div class="list_t_des">'+paper.keywords+'</div><div class="list_item_function"><a class="journal_paper_edit admbg2 admtxt" href="'+paper.url_edit+'">Edit</a> <a class="journal_paper_delete admbg2 admtxt" href="'+paper.url_delete+'">Delete</a></div></li>');
2012-11-21 07:35:23 +00:00
column.find("ul").append(li);
if(counter%5==0){
$("#journal_p div#paper_list div.overview").append(column);
column = $('<div class="g_col list_t"><ul></ul></div>');
}
counter++;
})
})
$("#journal_p div#paper_list div.overview").append(column);
bindSecondaryHandlers();
}
var titleview = function(){
$("#journal_p div#paper_list div.overview").empty();
var column = $('<div class="g_col list_t"><ul></ul></div>'),
counter = 1,
li;
$.each(journalData,function(i,journal){
$.each(journal.papers,function(j,paper){
2012-12-05 19:42:20 +00:00
li = $('<li class="list_t_item"><div class="list_item_action"><a href="" class="icon-check-empty"></a><a href="" class="icon-star-empty"></a></div><div class="list_t_title">'+paper.title+'</div><div class="list_item_function"><a class="journal_paper_edit admbg2 admtxt" href="'+paper.url_edit+'">Edit</a> <a class="journal_paper_delete admbg2 admtxt" href="'+paper.url_delete+'">Delete</a></div></li>');
2012-11-21 07:35:23 +00:00
column.find("ul").append(li);
if(counter%5==0){
$("#journal_p div#paper_list div.overview").append(column);
column = $('<div class="g_col list_t"><ul></ul></div>');
}
counter++;
})
})
$("#journal_p div#paper_list div.overview").append(column);
bindSecondaryHandlers();
}
var abstractview = function(){
$("#journal_p div#paper_list div.overview").empty();
var column = $('<div class="g_col list_t"><ul></ul></div>'),
li;
$.each(journalData,function(i,journal){
$.each(journal.papers,function(j,paper){
2012-12-05 19:42:20 +00:00
li = $('<li class="list_t_item" style="height:auto;"><div class="list_item_action"><a href="" class="icon-check-empty"></a><a href="" class="icon-star-empty"></a></div><div class="list_t_title">'+paper.title+'</div><div class="list_t_des">'+paper.abstract+'</div><div class="list_item_function"><a class="journal_paper_edit admbg2 admtxt" href="'+paper.url_edit+'">Edit</a> <a class="journal_paper_delete admbg2 admtxt" href="'+paper.url_delete+'">Delete</a></div></li>');
2012-11-21 07:35:23 +00:00
column.find("ul").append(li);
$("#journal_p div#paper_list div.overview").append(column);
column = $('<div class="g_col list_t"><ul></ul></div>');
})
})
$("#journal_p div#paper_list div.overview").append(column);
bindSecondaryHandlers();
}
var getData = function(){
$.getJSON("/desktop/journal_pages/get_journals_json",function(journals){
journalData = eval(journals);
journalview();
bindHandlers();
})
}
getData();
}
this.initializeJournalPapers.addpaper = function(){ // to open add pages in journal papers page
var bindHandlers = function(){ // to bind handlers for add page
o.simple_drop_down();
o.tinyscrollbar_ext({
main: '.tinycanvas',
fill: '.s_grid_con'
})
}
bindHandlers();
}
this.initializeJournalPapers.journal = function(){ // to open add pages in journal papers page
var bindHandlers = function(){ // to bind handlers for add page
o.simple_drop_down();
o.tinyscrollbar_ext({
main: '.tinycanvas',
2012-12-05 08:10:15 +00:00
fill: '.g_col'
})
}
bindHandlers();
}
2012-11-21 09:11:18 +00:00
this.initializeJournalPapers.coAuthorformCallback = function(data){
2012-11-21 07:35:23 +00:00
if(data.success){
o.notify(data.msg,"success");
o.sub_menu_item($("div[content-type=menu] a").eq(0));
}else{
o.notify(data.msg,"alert");
}
}
this.initializeJournalPapers.coauthor = function(){ // to open add pages in coauthor page
2012-11-21 07:35:23 +00:00
var bindHandlers = function(){ // to bind handlers for add page
o.simple_drop_down();
o.tinyscrollbar_ext({
main: '.tinycanvas',
2012-12-05 09:51:36 +00:00
fill: '.g_col'
2012-11-21 07:35:23 +00:00
})
2012-12-05 09:09:17 +00:00
$("div[container=true]").unbind(".editcoauthor").on("click.editcoauthor", "a.bt-edit", function(){
2012-12-03 04:23:56 +00:00
$.ajax({
url : $(this).attr("href"),
type : "get",
success : function(data){
var prev_data = $("div[container=true]").html();
$("div[container=true]").html(data);
o.tinyscrollbar_ext({
main: '.tinycanvas',
fill: '.s_grid_con'
})
$(".bt-cancel").click(function(){
$("div[container=true]").html(prev_data);
2012-12-06 07:44:16 +00:00
o.tinyscrollbar_ext({
main: '.tinycanvas',
fill: '.g_col'
})
2012-12-03 04:23:56 +00:00
})
}
})
return false;
})
2012-12-05 10:58:43 +00:00
$("div[container=true]").unbind(".editype").on("click.edittype", "a.bt-edit-type", function(){
var parent = $(this).parent().parent();
2012-12-05 22:12:25 +00:00
parent.find('.list_item_function').hide();
2012-12-05 10:58:43 +00:00
$.ajax({
url : $(this).attr("href"),
type : "get",
success : function(data){
2012-12-05 22:12:25 +00:00
var prev_data = parent.find(".form_space").html();
parent.find(".form_space").html(data);
2012-12-05 10:58:43 +00:00
$(".bt-cancel-type").click(function(){
2012-12-05 22:12:25 +00:00
parent.find(".form_space").html(prev_data);
parent.find('.list_item_function').show();
});
2012-12-05 10:58:43 +00:00
}
})
return false;
})
2012-12-03 07:44:26 +00:00
$("div[container=true]").unbind(".delete").on("click.delete","a.bt-delete",function(){
2012-12-05 09:09:17 +00:00
2012-12-03 04:23:56 +00:00
var delurl = $(this).attr("href");
var parent = $(this).parent().parent();
o.confirm({
buttons : ["Yes","No"],
highlighted : 2,
message : "Are you sure, you want to delete this author?"
},function(value){
if(value){
$.ajax({
url : delurl,
type : "DELETE",
success : function(data){
if(data.success){
parent.hide("slide",function(){parent.remove();});
o.notify(data.msg,"success");
}
}
})
}
})
return false;
2012-12-03 04:47:05 +00:00
})
2012-12-03 09:52:05 +00:00
$("div[container=true]").unbind(".new_type").on("click.new_type","a.bt-new-type",function(){
2012-12-03 04:47:05 +00:00
$.ajax({
url : $(this).attr("href"),
type : "get",
success : function(data){
var prev_data = $("div[container=true]").html();
$("div[container=true]").html(data);
o.tinyscrollbar_ext({
main: '.tinycanvas',
fill: '.s_grid_con'
})
$(".bt-cancel").click(function(){
$("div[container=true]").html(prev_data);
2012-12-06 07:44:16 +00:00
o.tinyscrollbar_ext({
main: '.tinycanvas',
fill: '.g_col'
})
2012-12-03 04:47:05 +00:00
})
}
})
return false;
})
2012-12-03 09:52:05 +00:00
$("div[container=true]").unbind(".bt-co-author").on("click.bt-co-author","a.bt-co-author",function(){
2012-12-03 06:54:52 +00:00
$.ajax({
url : $(this).attr("href"),
type : "get",
success : function(data){
var prev_data = $("div[container=true]").html();
$("div[container=true]").html(data);
o.tinyscrollbar_ext({
main: '.tinycanvas',
fill: '.s_grid_con'
})
$(".bt-cancel").click(function(){
$("div[container=true]").html(prev_data);
2012-12-06 07:44:16 +00:00
o.tinyscrollbar_ext({
main: '.tinycanvas',
fill: '.g_col'
})
2012-12-03 06:54:52 +00:00
})
}
})
return false;
})
2012-11-21 07:35:23 +00:00
}
2012-12-03 04:47:05 +00:00
bindHandlers();
}
2012-12-03 06:54:52 +00:00
this.initializeJournalPapers.coauthorRelationForm = function(data){
if(data.success){
o.notify(data.msg,"success");
2012-12-05 22:12:25 +00:00
$("#co_author_relation_table").html(data.newvalue);
2012-12-03 06:54:52 +00:00
}else{
o.notify(data.msg,"alert");
}
}
2012-12-05 10:58:43 +00:00
this.initializeJournalPapers.coauthorRelationEditForm = function(data){
if(data.success){
o.notify(data.msg,"success");
2012-12-05 22:12:25 +00:00
$("#co_author_relation_table").html(data.newvalue);
2012-12-05 10:58:43 +00:00
}else{
o.notify(data.msg,"alert");
}
}
2012-12-03 04:47:05 +00:00
};