Anand Doshi | eaaf651 | 2012-02-24 15:29:07 +0530 | [diff] [blame] | 1 | wn.provide('erpnext.desktop'); |
| 2 | |
| 3 | erpnext.desktop.gradient = "<style>\ |
| 4 | .case-%(name)s {\ |
| 5 | background: %(start)s; /* Old browsers */\ |
Anand Doshi | 0e14096 | 2012-03-01 12:16:02 +0530 | [diff] [blame] | 6 | background: -moz-radial-gradient(center, ellipse cover, %(start)s 0%, %(middle)s 44%, %(end)s 100%); /* FF3.6+ */\ |
| 7 | background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%,%(start)s), color-stop(44%,%(middle)s), color-stop(100%,%(end)s)); /* Chrome,Safari4+ */\ |
| 8 | background: -webkit-radial-gradient(center, ellipse cover, %(start)s 0%,%(middle)s 44%,%(end)s 100%); /* Chrome10+,Safari5.1+ */\ |
| 9 | background: -o-radial-gradient(center, ellipse cover, %(start)s 0%,%(middle)s 44%,%(end)s 100%); /* Opera 12+ */\ |
| 10 | background: -ms-radial-gradient(center, ellipse cover, %(start)s 0%,%(middle)s 44%,%(end)s 100%); /* IE10+ */\ |
| 11 | background: radial-gradient(center, ellipse cover, %(start)s 0%,%(middle)s 44%,%(end)s 100%); /* W3C */\ |
Anand Doshi | eaaf651 | 2012-02-24 15:29:07 +0530 | [diff] [blame] | 12 | }\ |
| 13 | </style>" |
| 14 | |
| 15 | erpnext.desktop.refresh = function() { |
| 16 | erpnext.desktop.add_classes(); |
| 17 | erpnext.desktop.render(); |
| 18 | } |
| 19 | |
| 20 | erpnext.desktop.add_classes = function() { |
| 21 | var classes = [ |
Anand Doshi | db62876 | 2012-02-24 17:56:00 +0530 | [diff] [blame] | 22 | { name: 'red', start: '#A90329', middle: '#8F0222', end: '#6D0019' }, |
| 23 | { name: 'brown', start: '#723e02', middle: '#633501', end: '#4a2700' }, |
| 24 | { name: 'green', start: '#4b5602', middle: '#3f4901', end: '#313800' }, |
| 25 | { name: 'blue', start: '#026584', middle: '#025770', end: '#004256' }, |
| 26 | { name: 'yellow', start: '#be7902', middle: '#a66a02', end: '#865500' }, |
| 27 | { name: 'purple', start: '#4d017d', middle: '#410169', end: '#310050' }, |
| 28 | { name: 'ocean', start: '#02a47e', middle: '#018d6c', end: '#006a51' }, |
| 29 | { name: 'pink', start: '#a40281', middle: '#8d016e', end: '#6a0053' }, |
| 30 | { name: 'grey', start: '#545454', middle: '#484848', end: '#363636' }, |
| 31 | { name: 'dark-red', start: '#68021a', middle: '#590116', end: '#440010' }, |
| 32 | { name: 'leaf-green', start: '#b0a400', middle: '#968c00', end: '#726a00' }, |
| 33 | //{ name: 'dark-blue', start: '#023bae', middle: '#013295', end: '#002672' }, |
| 34 | { name: 'bright-green', start: '#03ad1f', middle: '#02941a', end: '#007213' }, |
| 35 | { name: 'bright-yellow', start: '#ffd65e', middle: '#febf04', end: '#ed9017' }, |
| 36 | { name: 'peacock', start: '#026584', middle: '#026584', end: '#322476' }, |
| 37 | { name: 'violet', start: '#50448e', middle: '#473b7f', end: '#3a3169' }, |
| 38 | { name: 'ultra-dark-green', start: '#014333', middle: '#01372b', end: '#002a20' }, |
Anand Doshi | eaaf651 | 2012-02-24 15:29:07 +0530 | [diff] [blame] | 39 | ]; |
| 40 | $.each(classes, function(i, v) { |
| 41 | $(repl(erpnext.desktop.gradient, v)).appendTo('head'); |
| 42 | }); |
| 43 | } |
| 44 | |
| 45 | erpnext.desktop.render = function() { |
Rushabh Mehta | a38bbe2 | 2012-02-29 10:55:43 +0530 | [diff] [blame] | 46 | var icons = { |
| 47 | 'Accounts': { gradient: 'blue', sprite: 'account', label: 'Accounts'}, |
| 48 | 'Selling': { gradient: 'green', sprite: 'selling', label: 'Selling'}, |
| 49 | 'Stock': { gradient: 'yellow', sprite: 'stock', label: 'Stock'}, |
| 50 | 'Buying': { gradient: 'red', sprite: 'buying', label: 'Buying'}, |
| 51 | 'Support': { gradient: 'purple', sprite: 'support', label: 'Support'}, |
| 52 | 'HR': { gradient: 'ocean', sprite: 'hr', label: 'Human<br />Resources'}, |
| 53 | 'Projects': { gradient: 'violet', sprite: 'project', label: 'Projects'}, |
| 54 | 'Production': { gradient: 'dark-red', sprite: 'production', label: 'Production'}, |
| 55 | 'Website': { gradient: 'leaf-green', sprite: 'website', label: 'Website'}, |
| 56 | 'Activity': { gradient: 'brown', sprite: 'feed', label: 'Activity'}, |
| 57 | 'Setup': { gradient: 'grey', sprite: 'setting', label: 'Setup'}, |
| 58 | 'Dashboard': { gradient: 'bright-green', sprite: 'dashboard', label: 'Dashboard'}, |
| 59 | 'To Do': { gradient: 'bright-yellow', sprite: 'todo', label: 'To Do'}, |
| 60 | 'Messages': { gradient: 'pink', sprite: 'messages', label: 'Messages'}, |
| 61 | 'Calendar': { gradient: 'peacock', sprite: 'calendar', label: 'Calendar'}, |
| 62 | 'Knowledge Base': { gradient: 'ultra-dark-green', sprite: 'kb', label: 'Knowledge<br />Base'} |
| 63 | } |
| 64 | |
Anand Doshi | eaaf651 | 2012-02-24 15:29:07 +0530 | [diff] [blame] | 65 | |
Rushabh Mehta | a38bbe2 | 2012-02-29 10:55:43 +0530 | [diff] [blame] | 66 | var add_icon = function(m) { |
| 67 | var icon = icons[m]; |
| 68 | icon.link = erpnext.modules[m]; |
Rushabh Mehta | 17da764 | 2012-02-28 18:56:56 +0530 | [diff] [blame] | 69 | $('#icon-grid').append(repl('\ |
Rushabh Mehta | a38bbe2 | 2012-02-29 10:55:43 +0530 | [diff] [blame] | 70 | <div id="%(sprite)s" class="case-wrapper"><a href="#!%(link)s">\ |
Anand Doshi | eaaf651 | 2012-02-24 15:29:07 +0530 | [diff] [blame] | 71 | <div class="case-border case-%(gradient)s">\ |
| 72 | <div class="sprite-image sprite-%(sprite)s"></div>\ |
| 73 | </div></a>\ |
| 74 | <div class="case-label">%(label)s</div>\ |
Rushabh Mehta | a38bbe2 | 2012-02-29 10:55:43 +0530 | [diff] [blame] | 75 | </div>', icon)); |
Rushabh Mehta | 17da764 | 2012-02-28 18:56:56 +0530 | [diff] [blame] | 76 | } |
| 77 | |
Rushabh Mehta | 17da764 | 2012-02-28 18:56:56 +0530 | [diff] [blame] | 78 | // setup |
Rushabh Mehta | a38bbe2 | 2012-02-29 10:55:43 +0530 | [diff] [blame] | 79 | |
| 80 | for(var i in wn.boot.modules_list) { |
| 81 | var m = wn.boot.modules_list[i]; |
Anand Doshi | 2d4139c | 2012-03-23 14:46:07 +0530 | [diff] [blame] | 82 | if(!in_list(['Setup', 'Dashboard'], m) && wn.boot.profile.allow_modules.indexOf(m)!=-1) |
Rushabh Mehta | a38bbe2 | 2012-02-29 10:55:43 +0530 | [diff] [blame] | 83 | add_icon(m); |
| 84 | } |
| 85 | |
Rushabh Mehta | 428929b | 2012-03-01 11:24:45 +0530 | [diff] [blame] | 86 | if(user_roles.indexOf('Accounts Manager')!=-1) |
| 87 | add_icon('Dashboard') |
| 88 | |
Rushabh Mehta | 17da764 | 2012-02-28 18:56:56 +0530 | [diff] [blame] | 89 | if(user_roles.indexOf('System Manager')!=-1) |
Rushabh Mehta | a38bbe2 | 2012-02-29 10:55:43 +0530 | [diff] [blame] | 90 | add_icon('Setup') |
Rushabh Mehta | 17da764 | 2012-02-28 18:56:56 +0530 | [diff] [blame] | 91 | |
| 92 | // apps |
Anand Doshi | db62876 | 2012-02-24 17:56:00 +0530 | [diff] [blame] | 93 | erpnext.desktop.show_pending_notifications(); |
| 94 | |
| 95 | } |
| 96 | |
| 97 | erpnext.desktop.show_pending_notifications = function() { |
Anand Doshi | 7854f81 | 2012-03-14 12:01:13 +0530 | [diff] [blame] | 98 | var add_circle = function(str_module, id, title) { |
| 99 | var module = $('#'+str_module); |
| 100 | module.find('a:first').append( |
| 101 | repl('<div id="%(id)s" class="circle" title="%(title)s" style="display: None">\ |
| 102 | <span class="circle-text"></span>\ |
| 103 | </div>', {id: id, title: title})); |
| 104 | |
| 105 | var case_border = module.find('.case-border'); |
| 106 | var circle = module.find('.circle'); |
| 107 | |
| 108 | var add_hover_and_click = function(primary, secondary, hover_class, click_class) { |
| 109 | primary |
| 110 | .hover( |
| 111 | function() { secondary.addClass(hover_class); }, |
| 112 | function() { secondary.removeClass(hover_class); }) |
| 113 | .mousedown(function() { secondary.addClass(click_class); }) |
| 114 | .mouseup(function() { secondary.removeClass(click_class); }) |
| 115 | .focusin(function() { $(this).mousedown(); }) |
| 116 | .focusout(function() { $(this).mouseup(); }) |
| 117 | } |
| 118 | |
| 119 | add_hover_and_click(case_border, circle, 'hover-effect', 'circle-click'); |
| 120 | add_hover_and_click(circle, case_border, 'hover-effect', 'case-border-click'); |
| 121 | |
| 122 | } |
| 123 | |
| 124 | add_circle('messages', 'unread_messages', 'Unread Messages'); |
| 125 | add_circle('support', 'open_support_tickets', 'Open Support Tickets'); |
| 126 | add_circle('todo', 'things_todo', 'Things To Do'); |
| 127 | add_circle('calendar', 'todays_events', 'Todays Events'); |
Rushabh Mehta | 07c94ce | 2012-06-04 12:57:23 +0530 | [diff] [blame] | 128 | add_circle('project', 'open_tasks', 'Open Tasks'); |
Rushabh Mehta | c7dbe29 | 2012-08-07 12:12:55 +0530 | [diff] [blame] | 129 | add_circle('kb', 'unanswered_questions', 'Unanswered Questions'); |
Anand Doshi | 7854f81 | 2012-03-14 12:01:13 +0530 | [diff] [blame] | 130 | |
Rushabh Mehta | 3948927 | 2012-05-03 10:44:44 +0530 | [diff] [blame] | 131 | erpnext.update_messages(); |
Anand Doshi | db62876 | 2012-02-24 17:56:00 +0530 | [diff] [blame] | 132 | |
Anand Doshi | eaaf651 | 2012-02-24 15:29:07 +0530 | [diff] [blame] | 133 | } |
| 134 | |
| 135 | pscript.onload_desktop = function() { |
| 136 | // load desktop |
| 137 | erpnext.desktop.refresh(); |
| 138 | } |
| 139 | |