From 625df9094f5eec9f4f7dc2bc8bda659939c555dd Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Fri, 6 Apr 2012 17:24:39 +0800 Subject: [PATCH] theme changes --- app/assets/javascripts/orbitdesktop.js | 22 ++++++++++++---------- app/controllers/desktop_controller.rb | 3 ++- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/app/assets/javascripts/orbitdesktop.js b/app/assets/javascripts/orbitdesktop.js index 5d5fd81a..cb4c46e4 100755 --- a/app/assets/javascripts/orbitdesktop.js +++ b/app/assets/javascripts/orbitdesktop.js @@ -16,16 +16,18 @@ var orbitDesktop = function(dom){ var theme = o.theme; $.getJSON("/desktop/get_desktop_settings",{id:o.desktopId},function(desktopSettings){ if(desktopSettings){ - theme = desktopSettings.theme - } + theme = desktopSettings.theme; + o.theme = theme; + loadTheme(); + }else{loadTheme();} }) - - $.getJSON("/"+o.themefolder+"/"+theme+"/settings/"+theme+".json",function(ts){ - o.themesettings = eval(ts); - $('head').append( $('').attr('href', "/"+o.themefolder+"/"+theme+"/css/"+ts.css)); - $(document).ready(function(){o.loadWallpaper();o.bindDesktopEvents();o.loadIconCache();o.initializeDesktop();}); - }) - + var loadTheme = function(){ + $.getJSON("/"+o.themefolder+"/"+theme+"/settings/"+theme+".json",function(ts){ + o.themesettings = eval(ts); + $('head').append( $('').attr('href', "/"+o.themefolder+"/"+theme+"/css/"+ts.css)); + $(document).ready(function(){o.loadWallpaper();o.bindDesktopEvents();o.loadIconCache();o.initializeDesktop();}); + }) + } }; this.changeTheme = function(theme){ o.theme = theme; @@ -150,7 +152,7 @@ var orbitDesktop = function(dom){ }; this.tempFunc = function(){ //o.notify("This is test notification!!","alert",2) - $.post("/desktop/save_desktop_settings",{"theme":$("#change_theme").val()},function(){ + $.post("/desktop/save_desktop_settings",{"id":o.desktopId,"theme":$("#change_theme").val()},function(){ o.notify("Settings Saved!!","success"); }) } diff --git a/app/controllers/desktop_controller.rb b/app/controllers/desktop_controller.rb index a7ff8545..37cbb90e 100644 --- a/app/controllers/desktop_controller.rb +++ b/app/controllers/desktop_controller.rb @@ -19,7 +19,8 @@ class DesktopController< ApplicationController end def save_desktop_settings - Desktop.update_attributes(:theme => params["theme"]) + @desktop = Desktop.find(params["id"]) + @desktop.update_attributes(:theme => params["theme"]) a = Array.new a << {"success"=>"true"} render :json=>a.to_json