From 48323ac1afb8faf42a0ecfc1bf36f7f0e5721817 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Thu, 12 Apr 2012 14:44:08 +0800 Subject: [PATCH] lot of changes in fetching --- app/assets/images/icons/dailyenglish.png | Bin 0 -> 900 bytes app/assets/images/icons/quotes.png | Bin 0 -> 1122 bytes app/assets/javascripts/orbitdesktop.js | 66 +++++++++++++++---- app/controllers/desktop_controller.rb | 42 ++++++++---- app/views/desktop/app_manager.html.erb | 6 +- app/views/desktop/sections.html.erb | 12 ++-- app/views/desktop/settings/sections.html.erb | 2 +- config/routes.rb | 1 + 8 files changed, 96 insertions(+), 33 deletions(-) create mode 100644 app/assets/images/icons/dailyenglish.png create mode 100644 app/assets/images/icons/quotes.png diff --git a/app/assets/images/icons/dailyenglish.png b/app/assets/images/icons/dailyenglish.png new file mode 100644 index 0000000000000000000000000000000000000000..c820bd610cccf964eebaa25beee18ae5cb0d7a29 GIT binary patch literal 900 zcmV-~1AF|5P)V>IRB3Hx05CK!F)=SOGMHQ4%K!iZ z+DSw~RA_-7yn8dw8n2e#O~Tp=zO;{D75Z#^{33+4v4m^dq(I~?z085pjGMIP{OV4D#D10deV zEc!YNFnsDGBHl|B*r~BWUeRm7#r*aG6Cxhvn8uC9Zb=*X$60`|C8a3cOe2h18{jn- zveqVeOQ5js_)cNpIUG!B-3b)d9p5QzsWi$It8IpRECJ1BqycIQOL(#Qi>8Mi?th_* zq?V>hEls=Xqr8Ue&DnBMN)Kh-u5*Fg^j1mXc8y}Wa+LnuV_qrS61v_@5gD6Q>YrMi zA-Sl&-jv3drymz+q@5b&@53(p){(@m<=Xv=3K;$k^na)AP$vKbgeE zHBhsFrYan_-A~~PMsM>$_{Mn2`Dv2#?)KSIc&4yhYza<@2U^bCR^2#U_?^D--Lvs2 zBI9@O0;z==k_+myz_Xy0T9|P+J>87&qOE7iLtfTL5~7?uyxjeHulMQ5_+-iHSr#sX zr~i@%RfX%CN-NxMK;h5LDB6gKPu*s{>sL{N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&68$4KSrp1^;NpF1d5w!0Be?0QdCIw>Rif1VPW2f om=59}7^C5HA2t2I!>{7~140V}-Ime%=l}o!07*qoM6N<$f_9h*x&QzG literal 0 HcmV?d00001 diff --git a/app/assets/javascripts/orbitdesktop.js b/app/assets/javascripts/orbitdesktop.js index fa032ffd..7179cad6 100755 --- a/app/assets/javascripts/orbitdesktop.js +++ b/app/assets/javascripts/orbitdesktop.js @@ -12,6 +12,7 @@ var orbitDesktop = function(dom){ this.currentface = "home"; this.desktopData = {"home":"","settings":"","work":"","favorite":"","apps_manager":"","sections":""}; this.tp = ""; + this.sectionList; this.initialize = function(){ var theme = o.theme; $.getJSON("/desktop/get_desktop_settings",{id:o.desktopId},function(desktopSettings){ @@ -112,7 +113,7 @@ var orbitDesktop = function(dom){ $(".group").each(function(){groupWrapperWidth+=$(this).width();}) groupWrapperWidth+=200; groupWrapperHeight = $(".group").height() + 20; - groupWrapperHeight = (groupWrapperHeight > ($(window).height()-extraspace))? $(window).height()-extraspace:groupWrapperHeight; + // groupWrapperHeight = (groupWrapperHeight > ($(window).height()-extraspace))? $(window).height()-extraspace:groupWrapperHeight; $("#group_wrapper").css("width",groupWrapperWidth); $(".grp").sortable({ @@ -172,7 +173,7 @@ var orbitDesktop = function(dom){ var tilecolor = tilecolors[Math.floor(Math.random()*tilecolors.length)]; var op = opacity[Math.floor(Math.random()*opacity.length)]; if(tile.data_category == "app") - $li = $('
  • '+tile.title+'

  • '); + $li = $('
  • '+tile.title+'

  • '); else $li = $('
  • '+tile.title+'

    test content
  • '); $group.find("ul").append($li); @@ -185,6 +186,7 @@ var orbitDesktop = function(dom){ } var loadSectionList = function(){ $.getJSON("/desktop/getsectionlist",{desktopid:o.desktopId},function(sectionlist){ + o.sectionList = eval(sectionlist); $.each(sectionlist,function(i,section){ var tempstyle=""; if(i==0){ @@ -266,9 +268,22 @@ var orbitDesktop = function(dom){ }) $('.tinycanvas').tinyscrollbar({ axis: 'x'}); } + var loadApps = function(){ + $.getJSON("/desktop/getapplist",{desktopid:o.desktopId},function(appss){ + $.each(appss,function(i,apps){ + $.each(apps,function(i,app){ + var $div; + $div = $('

    '+app.title+'

    '); + $("#app_list").append($div); + }) + }) + + bindHandlers(); + }) + } if(!o.desktopData[o.currentface]){ $(o.contentHolder).empty().load("/desktop/"+target,function(){ - bindHandlers(); + loadApps(); }); }else{ $(o.contentHolder).html(o.desktopData[o.currentface]); @@ -313,17 +328,45 @@ var orbitDesktop = function(dom){ if( !$sdm.children('.sdm_o') ){ return; } else { - $sdm.hover(function(){ - $(this).addClass('thmc2'); - }, function(){ - $(this).removeClass('thmc2'); - }); + $sdm.hover(function(){$(this).addClass('thmc2');}, function(){$(this).removeClass('thmc2');}); } }; - + var loadApps = function(){ + $.getJSON("/desktop/getapplist",{desktopid:o.desktopId},function(appss){ + var $group,$lii,$li; + var z=0; + for(section in o.sectionList){ + $group = $('
      '); + for(x=0;x<4;x++){ + if(x==0){ + $li = $('
    • '+o.sectionList[z].name+'
    • '); + $group.find("ul.section_grp").append($li); + } + if(z!=x){ + $lii = $(''); + $group.find("ul.section_grp").append($lii); + } + } + z++; + $("div#group_wrapper").append($group); + } + $.each(appss,function(i,apps){ + var y=0; + $.each(apps,function(i,app){ + var $div; + $div = $('

      '+app.title+'

      '); + $("#app_list").append($div); + }) + y++; + }) + + + bindHandlers(); + }) + } if(!o.desktopData[o.currentface]){ $(o.contentHolder).empty().load("/desktop/"+target,function(){ - bindHandlers(); + loadApps(); }); }else{ $(o.contentHolder).html(o.desktopData[o.currentface]); @@ -405,7 +448,7 @@ var orbitDesktop = function(dom){ $(o.contentHolder).empty().load("/desktop/"+target,function(){ bindHandlers(); - sections(); + themes(); }); }; this.loadWallpaper = function(wallpaper){ @@ -447,6 +490,7 @@ orbitDesktop.prototype.themefolder = "themes"; orbitDesktop.prototype.widgetfolder = "desktop_widgets"; orbitDesktop.prototype.desktopId = "1"; orbitDesktop.prototype.notifyImgPath = "temp"; +orbitDesktop.prototype.iconPath = "/assets/icons/"; var uselessfunction = function(){ $.post("/desktop/temp_func",{sectionid:"4f83e7bbbd98eb041600001d"}); diff --git a/app/controllers/desktop_controller.rb b/app/controllers/desktop_controller.rb index d426b4da..ca776043 100644 --- a/app/controllers/desktop_controller.rb +++ b/app/controllers/desktop_controller.rb @@ -1,6 +1,9 @@ class DesktopController< ApplicationController layout 'desktop' before_filter :authenticate_user! + + #to load pages... + def index @desktop = current_user.desktop @section = @desktop.sections.first @@ -18,6 +21,19 @@ class DesktopController< ApplicationController def sections render :layout => false end + def settings + render :layout => false + end + + def settingthemes + render "desktop/settings/themes", :layout => false + end + + def settingsections + render "desktop/settings/sections", :layout => false + end + + #ajax data load.... def save_desktop_settings @desktop = Desktop.find(params["id"]) @@ -32,18 +48,6 @@ class DesktopController< ApplicationController render :json => @desktop.to_json end - def settings - render :layout => false - end - - def settingthemes - render "desktop/settings/themes", :layout => false - end - - def settingsections - render "desktop/settings/sections", :layout => false - end - def getgroups @section = Section.find(params["sectionid"]) @groups = @section.groups @@ -76,4 +80,18 @@ class DesktopController< ApplicationController b << {"success"=>"true"} render :json=>b.to_json end + + def getapplist + @desktop = Desktop.find(params["desktopid"]) + @sections = @desktop.sections + a = Array.new + @sections.each do |section| + @groups = section.groups + @groups.each do |group| + @tiles = group.tiles.where(:data_category.all => ["app"]) + a << @tiles + end + end + render :json=>a.to_json + end end \ No newline at end of file diff --git a/app/views/desktop/app_manager.html.erb b/app/views/desktop/app_manager.html.erb index fdbe9236..682ef540 100755 --- a/app/views/desktop/app_manager.html.erb +++ b/app/views/desktop/app_manager.html.erb @@ -19,8 +19,8 @@
      -