From b0d32b7a258a35ff1cc68b5a88f377c3643ec979 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 28 Sep 2012 16:11:57 +0530 Subject: [PATCH] form toolbar ui fixes and added themes --- .../page/profile_settings/profile_settings.js | 13 ++++- .../page/profile_settings/profile_settings.py | 4 ++ public/build.json | 14 +++--- {startup => public}/js/feature_setup.js | 0 {startup => public}/js/modules.js | 0 {startup => public/js}/startup.css | 0 {startup => public/js}/startup.js | 49 ++++++++++++++++++- public/js/themes.js | 41 ++++++++++++++++ {startup => public}/js/toolbar.js | 0 9 files changed, 112 insertions(+), 9 deletions(-) rename {startup => public}/js/feature_setup.js (100%) rename {startup => public}/js/modules.js (100%) rename {startup => public/js}/startup.css (100%) rename {startup => public/js}/startup.js (86%) create mode 100644 public/js/themes.js rename {startup => public}/js/toolbar.js (100%) diff --git a/home/page/profile_settings/profile_settings.js b/home/page/profile_settings/profile_settings.js index e9cd81f0f30..a0bb49ad097 100644 --- a/home/page/profile_settings/profile_settings.js +++ b/home/page/profile_settings/profile_settings.js @@ -27,7 +27,18 @@ MyProfile = function(wrapper) { this.wrapper.appframe = new wn.ui.AppFrame($(this.wrapper).find('.layout-appframe'), 'Profile Settings'); this.wrapper.appframe.add_button('Change Password', this.change_password); this.wrapper.appframe.add_button('Change Background', this.change_background); - + this.wrapper.appframe.add_label("Set Theme:"); + this.wrapper.appframe.add_select("Theme", + ["Default", "Desert", "Sky", "Tropic", "Snow", "Sun"]).change(function() { + erpnext.set_theme($(this).val().toLowerCase()); + }).change(function() { + wn.call({ + module: "home", + page: "profile_settings", + method: "set_user_theme", + args: {theme: $(this).val() } + }) + }); this.tab = make_table($a($(this.wrapper).find('.layout-main').get(0), 'div', '', {marginTop:'19px'}), 1, 2, '90%', ['50%', '50%'], {padding:'11px'}) this.img = $a($td(this.tab, 0, 0), 'img', '', {width: '120px', maxHeight:'200px'}); diff --git a/home/page/profile_settings/profile_settings.py b/home/page/profile_settings/profile_settings.py index 0de424f4682..4aed1cea55a 100644 --- a/home/page/profile_settings/profile_settings.py +++ b/home/page/profile_settings/profile_settings.py @@ -110,3 +110,7 @@ def set_user_background(): webnotes.conn.set_value('Profile', user, 'background_image', fid) return fid + +@webnotes.whitelist() +def set_user_theme(): + webnotes.conn.set_default("theme", webnotes.form_dict.theme, webnotes.session.user) diff --git a/public/build.json b/public/build.json index 8764beccac3..7ff8ac0c9d3 100644 --- a/public/build.json +++ b/public/build.json @@ -1,20 +1,20 @@ { "public/css/all-web.css": [ - "app/startup/startup.css", + "app/public/js/startup.css", "app/website/css/website.css" ], "public/css/all-app.css": [ - "app/startup/startup.css" + "app/public/js/startup.css" ], "public/js/all-web.js": [ - "app/startup/startup.js", + "app/public/js/startup.js", "app/public/js/conf.js" ], "public/js/all-app.js": [ - "app/startup/startup.js", - "app/startup/js/modules.js", - "app/startup/js/toolbar.js", - "app/startup/js/feature_setup.js", + "app/public/js/startup.js", + "app/public/js/modules.js", + "app/public/js/toolbar.js", + "app/public/js/feature_setup.js", "app/public/js/conf.js" ], } \ No newline at end of file diff --git a/startup/js/feature_setup.js b/public/js/feature_setup.js similarity index 100% rename from startup/js/feature_setup.js rename to public/js/feature_setup.js diff --git a/startup/js/modules.js b/public/js/modules.js similarity index 100% rename from startup/js/modules.js rename to public/js/modules.js diff --git a/startup/startup.css b/public/js/startup.css similarity index 100% rename from startup/startup.css rename to public/js/startup.css diff --git a/startup/startup.js b/public/js/startup.js similarity index 86% rename from startup/startup.js rename to public/js/startup.js index 73938db2801..0b43183758e 100644 --- a/startup/startup.js +++ b/public/js/startup.js @@ -58,6 +58,9 @@ erpnext.startup.start = function() { if(wn.boot.user_background) { erpnext.set_user_background(wn.boot.user_background); } + if(wn.boot.profile.defaults.theme) { + erpnext.set_theme(wn.boot.profile.defaults.theme[0].toLowerCase()); + } // always allow apps wn.boot.profile.allow_modules = wn.boot.profile.allow_modules.concat( @@ -205,4 +208,48 @@ Mousetrap.bind(["command+s", "ctrl+s"], function() { if(cur_frm) cur_frm.save(); return false; -}); \ No newline at end of file +}); + +// theme setter + +erpnext.themes = { + metal: { + sidebar: "#f2f2f2", + titlebar: "#dfdfdf", + toolbar: "#e9e9e9" + }, + desert: { + sidebar: "#FFFDF7", + titlebar: "#DAD4C2", + toolbar: "#FAF6E9" + }, + tropic: { + sidebar: "#FAFFF7", + toolbar: "#EEFAE9", + titlebar: "#D7ECD1" + }, + sky: { + sidebar: "#F7FFFE", + toolbar: "#E9F9FA", + titlebar: "#D7F5F7" + }, + snow: { + sidebar: "#fff", + titlebar: "#fff", + toolbar: "#fff" + }, + sun: { + sidebar: "#FFFFEF", + titlebar: "lightYellow", + toolbar: "#FFFDCA" + } +} + +erpnext.set_theme = function(theme) { + wn.dom.set_style(repl(".layout-wrapper-background { \ + background-color: %(sidebar)s !important; }\ + .appframe-toolbar { \ + background-color: %(toolbar)s !important; }\ + .appframe-titlebar { \ + background-color: %(titlebar)s !important; }", erpnext.themes[theme])); +} \ No newline at end of file diff --git a/public/js/themes.js b/public/js/themes.js new file mode 100644 index 00000000000..a60d3cf6c7e --- /dev/null +++ b/public/js/themes.js @@ -0,0 +1,41 @@ +erpnext.themes = { + metal: { + sidebar: "#f2f2f2", + titlebar: "#dfdfdf", + toolbar: "#e9e9e9" + }, + desert: { + sidebar: "#FFFDF7", + titlebar: "#DAD4C2", + toolbar: "#FAF6E9" + }, + tropic: { + sidebar: "#FAFFF7", + toolbar: "#EEFAE9", + titlebar: "#D7ECD1" + }, + sky: { + sidebar: "#F7FFFE", + toolbar: "#E9F9FA", + titlebar: "#D7F5F7" + }, + snow: { + sidebar: "#fff", + titlebar: "#fff", + toolbar: "#fff" + }, + sun: { + sidebar: "#FFFFEF", + titlebar: "lightYellow", + toolbar: "#FFFDCA" + } +} + +erpnext.set_theme = function(theme) { + wn.dom.set_style(repl(".layout-wrapper-background { \ + background-color: %(sidebar)s !important; }\ + .appframe-toolbar { \ + background-color: %(toolbar)s !important; }\ + .appframe-titlebar { \ + background-color: %(titlebar)s !important; }", erpnext.themes[theme])); +} \ No newline at end of file diff --git a/startup/js/toolbar.js b/public/js/toolbar.js similarity index 100% rename from startup/js/toolbar.js rename to public/js/toolbar.js