From b571373c8ff022d5d054e66547dee2a77404bfa2 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Wed, 21 Nov 2012 15:35:23 +0800 Subject: [PATCH] new file created for journal pages --- app/assets/javascripts/desktop.js | 3 +- .../javascripts/desktop/journal_pages.js.erb | 233 +++++++++++++++++ app/assets/javascripts/orbitdesktop.js | 234 +----------------- 3 files changed, 236 insertions(+), 234 deletions(-) diff --git a/app/assets/javascripts/desktop.js b/app/assets/javascripts/desktop.js index 37c654c7..de5f7f71 100644 --- a/app/assets/javascripts/desktop.js +++ b/app/assets/javascripts/desktop.js @@ -13,4 +13,5 @@ //= require bootstrap //= require orbitdesktopAPI //= require orbitTimeline -//= require orbitdesktop \ No newline at end of file +//= require orbitdesktop +//= require desktop/journal_pages \ No newline at end of file diff --git a/app/assets/javascripts/desktop/journal_pages.js.erb b/app/assets/javascripts/desktop/journal_pages.js.erb index e69de29b..4720686c 100644 --- a/app/assets/javascripts/desktop/journal_pages.js.erb +++ b/app/assets/javascripts/desktop/journal_pages.js.erb @@ -0,0 +1,233 @@ +orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // this init journal papers + this.initializeJournalPapers.formCallback = function(data){ + 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.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; + }) + + $("div[container=true]").on("click",".journal_paper_edit",function(){ + $.ajax({ + url : $(this).attr("href"), + type : "get", + success : function(data){ + var prev_data = $("div[container=true]").html(); + $("div[container=true]").html(data); + $(".bt-cancel").click(function(){ + $("div[container=true]").html(prev_data); + }) + } + }) + return false; + }) + + } + + 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 = $('
'), + counter = 1, + li; + $.each(journalData,function(i,journal){ + $.each(journal.papers,function(j,paper){ + li = $('
  • '+journal.title+'
    '+paper.title+'
    Edit
  • '); + column.find("ul").append(li); + if(counter%5==0){ + $("#journal_p div#paper_list div.overview").append(column); + column = $('
    '); + } + counter++; + }) + }) + $("#journal_p div#paper_list div.overview").append(column); + bindSecondaryHandlers(); + } + var fileview = function(){ + $("#journal_p div#paper_list div.overview").empty(); + var column = $('
    '), + counter = 1, + li = null; + $.each(journalData,function(i,journal){ + $.each(journal.papers,function(j,paper){ + li = null; + li = $('
  • '); + li.append('
    '+journal.title+'
    '); + $.each(paper.files,function(k,file){ + var thistitle = file.title; + if(!file.title) + thistitle = "Untitled File"; + var img = $('
    '+thistitle+'
    '); + li.append(img); + }) + li.append('Edit'); + column.find("ul").append(li); + if(counter%5==0){ + $("#journal_p div#paper_list div.overview").append(column); + column = $('
    '); + } + counter++; + }) + }) + $("#journal_p div#paper_list div.overview").append(column); + bindSecondaryHandlers(); + } + var keywordsview = function(){ + $("#journal_p div#paper_list div.overview").empty(); + var column = $('
    '), + counter = 1, + li; + $.each(journalData,function(i,journal){ + $.each(journal.papers,function(j,paper){ + li = $('
  • '+paper.title+'
    '+paper.keywords+'
    Edit
  • '); + column.find("ul").append(li); + if(counter%5==0){ + $("#journal_p div#paper_list div.overview").append(column); + column = $('
    '); + } + counter++; + }) + }) + $("#journal_p div#paper_list div.overview").append(column); + bindSecondaryHandlers(); + } + + var titleview = function(){ + $("#journal_p div#paper_list div.overview").empty(); + var column = $('
    '), + counter = 1, + li; + $.each(journalData,function(i,journal){ + $.each(journal.papers,function(j,paper){ + li = $('
  • '+paper.title+'
    Edit
  • '); + column.find("ul").append(li); + if(counter%5==0){ + $("#journal_p div#paper_list div.overview").append(column); + column = $('
    '); + } + counter++; + }) + }) + $("#journal_p div#paper_list div.overview").append(column); + bindSecondaryHandlers(); + } + + var abstractview = function(){ + $("#journal_p div#paper_list div.overview").empty(); + var column = $('
    '), + li; + $.each(journalData,function(i,journal){ + $.each(journal.papers,function(j,paper){ + li = $('
  • '+paper.title+'
    '+paper.abstract+'
    Edit
  • '); + column.find("ul").append(li); + $("#journal_p div#paper_list div.overview").append(column); + column = $('
    '); + }) + }) + $("#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.coAuthorformCallback = function(ruse){ + this.initializeJournalPapers.formCallback = function(data){ + 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 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(); + } + + + }; \ No newline at end of file diff --git a/app/assets/javascripts/orbitdesktop.js b/app/assets/javascripts/orbitdesktop.js index 834e1931..bebaa016 100755 --- a/app/assets/javascripts/orbitdesktop.js +++ b/app/assets/javascripts/orbitdesktop.js @@ -825,239 +825,7 @@ var orbitDesktop = function(dom){ timeline.initialize(); }; - this.initializeJournalPapers = function(target,url,cache){ // this init journal papers - this.initializeJournalPapers.formCallback = function(data){ - 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.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; - }) - - $("div[container=true]").on("click",".journal_paper_edit",function(){ - $.ajax({ - url : $(this).attr("href"), - type : "get", - success : function(data){ - var prev_data = $("div[container=true]").html(); - $("div[container=true]").html(data); - $(".bt-cancel").click(function(){ - $("div[container=true]").html(prev_data); - }) - } - }) - return false; - }) - - } - - 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 = $('
    '), - counter = 1, - li; - $.each(journalData,function(i,journal){ - $.each(journal.papers,function(j,paper){ - li = $('
  • '+journal.title+'
    '+paper.title+'
    Edit
  • '); - column.find("ul").append(li); - if(counter%5==0){ - $("#journal_p div#paper_list div.overview").append(column); - column = $('
    '); - } - counter++; - }) - }) - $("#journal_p div#paper_list div.overview").append(column); - bindSecondaryHandlers(); - } - var fileview = function(){ - $("#journal_p div#paper_list div.overview").empty(); - var column = $('
    '), - counter = 1, - li = null; - $.each(journalData,function(i,journal){ - $.each(journal.papers,function(j,paper){ - li = null; - li = $('
  • '); - li.append('
    '+journal.title+'
    '); - $.each(paper.files,function(k,file){ - var thistitle = file.title; - if(!file.title) - thistitle = "Untitled File"; - var img = $('
    '+thistitle+'
    '); - li.append(img); - }) - li.append('Edit'); - column.find("ul").append(li); - if(counter%5==0){ - $("#journal_p div#paper_list div.overview").append(column); - column = $('
    '); - } - counter++; - }) - }) - $("#journal_p div#paper_list div.overview").append(column); - bindSecondaryHandlers(); - } - var keywordsview = function(){ - $("#journal_p div#paper_list div.overview").empty(); - var column = $('
    '), - counter = 1, - li; - $.each(journalData,function(i,journal){ - $.each(journal.papers,function(j,paper){ - li = $('
  • '+paper.title+'
    '+paper.keywords+'
    Edit
  • '); - column.find("ul").append(li); - if(counter%5==0){ - $("#journal_p div#paper_list div.overview").append(column); - column = $('
    '); - } - counter++; - }) - }) - $("#journal_p div#paper_list div.overview").append(column); - bindSecondaryHandlers(); - } - - var titleview = function(){ - $("#journal_p div#paper_list div.overview").empty(); - var column = $('
    '), - counter = 1, - li; - $.each(journalData,function(i,journal){ - $.each(journal.papers,function(j,paper){ - li = $('
  • '+paper.title+'
    Edit
  • '); - column.find("ul").append(li); - if(counter%5==0){ - $("#journal_p div#paper_list div.overview").append(column); - column = $('
    '); - } - counter++; - }) - }) - $("#journal_p div#paper_list div.overview").append(column); - bindSecondaryHandlers(); - } - - var abstractview = function(){ - $("#journal_p div#paper_list div.overview").empty(); - var column = $('
    '), - li; - $.each(journalData,function(i,journal){ - $.each(journal.papers,function(j,paper){ - li = $('
  • '+paper.title+'
    '+paper.abstract+'
    Edit
  • '); - column.find("ul").append(li); - $("#journal_p div#paper_list div.overview").append(column); - column = $('
    '); - }) - }) - $("#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.coAuthorformCallback = function(ruse){ - this.initializeJournalPapers.formCallback = function(data){ - 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 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.initializeAppstore = function(target,url,cache){