From 4aa155a44d09f5168bd1236001d9c80da4813eb4 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Tue, 26 Jun 2012 21:09:33 +0800 Subject: [PATCH] timeline updates major ones.. --- app/assets/javascripts/orbitTimeline.js | 79 +++++++++++-------- app/assets/javascripts/orbitdesktop.js | 4 - app/assets/javascripts/orbitdesktopAPI.js | 2 +- app/assets/stylesheets/desktopmain.css | 15 +++- app/assets/stylesheets/orbitTimeline.css | 11 ++- app/controllers/desktop_orbit_controller.rb | 13 +++ .../desktop_publications_controller.rb | 4 +- app/models/journal.rb | 2 +- app/views/desktop/orbit.html.erb | 4 +- config/routes.rb | 5 +- 10 files changed, 87 insertions(+), 52 deletions(-) diff --git a/app/assets/javascripts/orbitTimeline.js b/app/assets/javascripts/orbitTimeline.js index 4a6a7846..0fc48c78 100644 --- a/app/assets/javascripts/orbitTimeline.js +++ b/app/assets/javascripts/orbitTimeline.js @@ -8,61 +8,72 @@ var orbitTimeline = function(dom){ //this.marker = t.timelineHtml.find("#timline_marker"); this.scale = t.timelineHtml.find("#timeline_scale"); //this.container = t.timelineHtml.find("#t_container"); + this.events = new Array; + this.monthList = ["","January","February","March","April","May","June","July","August","September","October","November","December"]; this.initialize = function(){ t.dom.html(t.timelineHtml); $("div.scrollbar").hide(); - //var cursor = t.marker.draggable({containment:"parent","option":"cursorAt"}); - var timelineScale = t.constructTimeScale(); - $("#timeline_scale").html(timelineScale); - t.makeBubble("012012"); - t.makeBubble("012012"); - $("#test_bubble").click(function(){ - t.makeBubble("062012"); - }) - + t.constructTimeScale(function(timelineScale){ + $("#timeline_scale").html(timelineScale); + for(eve in t.events){ + + t.makeBubble(t.events[eve]); + } + }); } - this.constructTimeScale = function(){ - //$.getJSON("test.json",function(){ - var scale = $("
"); - scale.append($("
2013
January
June
2012
")); - scale.find(".scale_region").each(function(){ - var verticalchars = ""; - var txt = $(this).text(); - var margin = ($(this).width()-20)/2; - // for(c in txt){ - // if($(this).hasClass('month')){ - // verticalchars+=""+txt.charAt(c)+""; - // }else - // verticalchars+=""+txt.charAt(c)+""; - // } - //$(this).html(verticalchars); + this.constructTimeScale = function(callbackFn){ + var mon ="",year=""; + var scale = $("
"); + $.getJSON("desktop_orbit/getevents",{"event":"papers"},function(journals){ + $.each(journals,function(x,journal){ + $.each(journal.papers,function(i,paper){ + var dt = new Date(paper.created_at); + var cur_mon = paper.created_at.substr(5,2); + var cur_year = dt.getFullYear(); + var cdt = paper.created_at.substr(0,7).replace("-",""); + var bubbleData = {"fulldate" : t.monthList[parseInt(cur_mon)] +", " + dt.getDate() + ", " + cur_year,"title":paper.title,"jtitle":journal.title,"coauthors":paper.coauthors,"abstract":paper.abstract,"timestamp":cdt} + t.events.push(bubbleData); + if(cur_year != year){ + year = cur_year; + scale.append($("
"+(year+1)+"
")); + } + if(cur_mon != mon){ + mon = cur_mon; + scale.append($("
"+t.monthList[parseInt(mon)]+"
")) + } + }); }) - return scale; - //}) + scale.append($("
"+year+"
")); + if(typeof callbackFn == "function"){ + callbackFn.call(this,scale); + } + + }); } - this.makeBubble = function(timestamp){ - var totalul = $("#scale_wrapper").find("div[data-content="+timestamp+"] ul").length; - var targetul = $("#scale_wrapper div[data-content="+timestamp+"] div.bubble_list ul").eq(totalul-1); + this.makeBubble = function(bubbleData){ + var totalul = $("#scale_wrapper").find("div[data-content="+bubbleData.timestamp+"] ul").length; + var targetul = $("#scale_wrapper div[data-content="+bubbleData.timestamp+"] div.bubble_list ul").eq(totalul-1); if(totalul == 0){ var ul = $(""); - $("#scale_wrapper").find("div[data-content="+timestamp+"] div.bubble_list").append(ul); + $("#scale_wrapper").find("div[data-content="+bubbleData.timestamp+"] div.bubble_list").append(ul); targetul = ul; }else{ var totalli = targetul.find("li").length; if(totalli >= 5){ var ul = $(""); - $("#scale_wrapper").find("div[data-content="+timestamp+"] div.bubble_list").append(ul); + $("#scale_wrapper").find("div[data-content="+bubbleData.timestamp+"] div.bubble_list").append(ul); targetul = ul; } } - var bubble = $("
  • This is test bubble.
  • "); + var bt = (bubbleData.title.length > 70? bubbleData.title.substr(0,70) + "..." : bubbleData.title); + var bubble = $("
  • "+bt+" - "+bubbleData.fulldate+"
  • "); bubble.css("margin-left","25px"); targetul.prepend(bubble); - bubble.show("bounce",{},500); + bubble.show(); bubble.click(function(){ o.toolPopup({ parent: $(this), - html : "
    "+timestamp+"
    ", + html : "

    "+bubbleData.jtitle+"

    Co-Authors:

    "+bubbleData.coauthors+"

    Abstract:

    "+bubbleData.abstract+"
    ", height: "auto", width:"300px" }); diff --git a/app/assets/javascripts/orbitdesktop.js b/app/assets/javascripts/orbitdesktop.js index ceecc1e2..31f80074 100755 --- a/app/assets/javascripts/orbitdesktop.js +++ b/app/assets/javascripts/orbitdesktop.js @@ -112,9 +112,6 @@ var orbitDesktop = function(dom){ }); $("a#d_appstore").click(function(){ var target = $(this).attr("href"); - console.log(o.currenthtml); - console.log(target); - console.log(o.currentface); if(o.currenthtml!=target){ o.desktopData[o.currentface] = $(o.contentHolder).html(); $("#content").hide("drop",o.transitionTime,function(){ @@ -907,7 +904,6 @@ var orbitDesktop = function(dom){ this.initializeOrbitTimeline = function(target){ o.currenthtml = target; o.currentface = "orbit"; - console.log(o.currentface); var bindHandlers = function(){ var timeline = new orbitTimeline("timeline"); timeline.initialize(); diff --git a/app/assets/javascripts/orbitdesktopAPI.js b/app/assets/javascripts/orbitdesktopAPI.js index 8e84cbb7..a89e0230 100644 --- a/app/assets/javascripts/orbitdesktopAPI.js +++ b/app/assets/javascripts/orbitdesktopAPI.js @@ -173,7 +173,7 @@ var orbitDesktopAPI = function(){ settings.width = (!settings.width ? "150px" : settings.width); settings.html = (!settings.html ? "" : settings.html); var leftpos = settings.parent.width(); - var toolpopup = $("
    "+settings.html+"
    "); + var toolpopup = $("
    "+settings.html+"
    "); settings.parent.css("position","relative"); settings.parent.prepend(toolpopup); toolpopup.click(function(event){ diff --git a/app/assets/stylesheets/desktopmain.css b/app/assets/stylesheets/desktopmain.css index b4b741eb..23ce5029 100644 --- a/app/assets/stylesheets/desktopmain.css +++ b/app/assets/stylesheets/desktopmain.css @@ -724,6 +724,19 @@ a:focus { outline: none; } border-radius:5px; border-color:black; font-size:15px; - padding: 5px 0px 10px 0px; + padding: 10px; cursor: default; + background-color:#ccc; +} +.desktop_toolpopup span{ + margin:3px 0 3px 0; +} +.desktop_toolpopup h3{ + text-align: center; + font-weight:bolder; + margin-bottom:5px; +} +.desktop_toolpopup h2{ + font-weight:bolder; + margin-top:3px; } diff --git a/app/assets/stylesheets/orbitTimeline.css b/app/assets/stylesheets/orbitTimeline.css index aa06eb82..feb007a6 100644 --- a/app/assets/stylesheets/orbitTimeline.css +++ b/app/assets/stylesheets/orbitTimeline.css @@ -1,5 +1,5 @@ .t_scale{ - width:2000px; + min-width:2000px; height:516px; bottom:0; } @@ -43,16 +43,15 @@ cursor: pointer; width:300px; height:30px; - background:lightblue; border-style:solid; border-width:5px; float: left; border-radius:5px; margin-top: 10px; margin-bottom:10px; - font-size:20px; + font-size:15px; padding:5px; - text-align:center; + text-align:justify; display: none; } .month_heading{ @@ -63,4 +62,8 @@ .bubble_list ul{ width:350px; float:left; +} +.bubble_list ul li span.date{ + font-weight:bolder; + float:right; } \ No newline at end of file diff --git a/app/controllers/desktop_orbit_controller.rb b/app/controllers/desktop_orbit_controller.rb index 4bb57e68..0aaf3a6a 100644 --- a/app/controllers/desktop_orbit_controller.rb +++ b/app/controllers/desktop_orbit_controller.rb @@ -4,4 +4,17 @@ class DesktopOrbitController< ApplicationController render "desktop/orbit", :layout => false end + def getevents + @event = params["event"] + @data = Array.new + case @event + when "papers" + @journals = current_user.journals + @journals.each do |journal| + @data << {"title"=> journal.title,"papers"=> journal.papers} + end + end + render :json=>@data.to_json + end + end \ No newline at end of file diff --git a/app/controllers/desktop_publications_controller.rb b/app/controllers/desktop_publications_controller.rb index 0679daed..4f30ebde 100644 --- a/app/controllers/desktop_publications_controller.rb +++ b/app/controllers/desktop_publications_controller.rb @@ -12,14 +12,14 @@ class DesktopPublicationsController< ApplicationController end def create_journal - Journal.create(user_id: current_user.id, title: "2012, Material Chemistry and Physics Journal") + Journal.create(user_id: current_user.id, title: "2012, Javascript") b = Array.new b << {"success"=>"true"} render :json=>b.to_json end def getjournals - @journals = Journal.all + @journals = current_user.journals data = Array.new @journals.each do |journal| @papers = journal.papers.all diff --git a/app/models/journal.rb b/app/models/journal.rb index 4b4cb8df..88497f61 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -11,7 +11,7 @@ class Journal before_create :initialize_paper def initialize_paper - for i in 0..25 + for i in 0..5 self.papers.build end end diff --git a/app/views/desktop/orbit.html.erb b/app/views/desktop/orbit.html.erb index b1894981..b9a68912 100644 --- a/app/views/desktop/orbit.html.erb +++ b/app/views/desktop/orbit.html.erb @@ -15,9 +15,7 @@ - - - +
    diff --git a/config/routes.rb b/config/routes.rb index c6e5c009..850e3fa6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -168,8 +168,9 @@ Orbit::Application.routes.draw do match '/desktop_appstore/widgets_settings'=>'desktop_appstore#widgets_settings' match '/desktop_orbit/orbit' => 'desktop_orbit#orbit' - - + match '/desktop_orbit/getevents' => 'desktop_orbit#getevents' + #match '/desktop_orbit/getevents' => 'desktop_publications#create_journal' + match '/desktop/temp_func/'=>'desktop#temp_func' match '/panel/:app_name/front_end/:app_action/:id' => 'pages#show_from_link', :constraints => lambda { |request|