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() { |
Rushabh Mehta | 9d1faea | 2012-10-02 14:56:41 +0530 | [diff] [blame] | 21 | $.each(wn.module_css_classes, function(i, v) { |
| 22 | v.name = i; |
Anand Doshi | eaaf651 | 2012-02-24 15:29:07 +0530 | [diff] [blame] | 23 | $(repl(erpnext.desktop.gradient, v)).appendTo('head'); |
| 24 | }); |
| 25 | } |
| 26 | |
| 27 | erpnext.desktop.render = function() { |
Rushabh Mehta | a38bbe2 | 2012-02-29 10:55:43 +0530 | [diff] [blame] | 28 | var icons = { |
Rushabh Mehta | 9d1faea | 2012-10-02 14:56:41 +0530 | [diff] [blame] | 29 | 'Accounts': { sprite: 'account', label: 'Accounts'}, |
| 30 | 'Selling': { sprite: 'selling', label: 'Selling'}, |
| 31 | 'Stock': { sprite: 'stock', label: 'Stock'}, |
| 32 | 'Buying': { sprite: 'buying', label: 'Buying'}, |
| 33 | 'Support': { sprite: 'support', label: 'Support'}, |
| 34 | 'HR': { sprite: 'hr', label: 'Human<br />Resources'}, |
| 35 | 'Projects': { sprite: 'project', label: 'Projects'}, |
| 36 | 'Production': { sprite: 'production', label: 'Production'}, |
| 37 | 'Website': { sprite: 'website', label: 'Website'}, |
| 38 | 'Activity': { sprite: 'feed', label: 'Activity'}, |
| 39 | 'Setup': { sprite: 'setting', label: 'Setup'}, |
Rushabh Mehta | 9d1faea | 2012-10-02 14:56:41 +0530 | [diff] [blame] | 40 | 'To Do': { sprite: 'todo', label: 'To Do'}, |
| 41 | 'Messages': { sprite: 'messages', label: 'Messages'}, |
| 42 | 'Calendar': { sprite: 'calendar', label: 'Calendar'}, |
| 43 | 'Knowledge Base': { sprite: 'kb', label: 'Knowledge<br />Base'} |
Rushabh Mehta | a38bbe2 | 2012-02-29 10:55:43 +0530 | [diff] [blame] | 44 | } |
Anand Doshi | eaaf651 | 2012-02-24 15:29:07 +0530 | [diff] [blame] | 45 | |
Rushabh Mehta | a38bbe2 | 2012-02-29 10:55:43 +0530 | [diff] [blame] | 46 | var add_icon = function(m) { |
| 47 | var icon = icons[m]; |
| 48 | icon.link = erpnext.modules[m]; |
Rushabh Mehta | 9d1faea | 2012-10-02 14:56:41 +0530 | [diff] [blame] | 49 | icon.gradient = wn.module_css_map[m]; |
| 50 | |
Rushabh Mehta | 17da764 | 2012-02-28 18:56:56 +0530 | [diff] [blame] | 51 | $('#icon-grid').append(repl('\ |
Rushabh Mehta | a38bbe2 | 2012-02-29 10:55:43 +0530 | [diff] [blame] | 52 | <div id="%(sprite)s" class="case-wrapper"><a href="#!%(link)s">\ |
Anand Doshi | eaaf651 | 2012-02-24 15:29:07 +0530 | [diff] [blame] | 53 | <div class="case-border case-%(gradient)s">\ |
| 54 | <div class="sprite-image sprite-%(sprite)s"></div>\ |
| 55 | </div></a>\ |
| 56 | <div class="case-label">%(label)s</div>\ |
Rushabh Mehta | a38bbe2 | 2012-02-29 10:55:43 +0530 | [diff] [blame] | 57 | </div>', icon)); |
Rushabh Mehta | 17da764 | 2012-02-28 18:56:56 +0530 | [diff] [blame] | 58 | } |
| 59 | |
Rushabh Mehta | 17da764 | 2012-02-28 18:56:56 +0530 | [diff] [blame] | 60 | // setup |
Rushabh Mehta | a38bbe2 | 2012-02-29 10:55:43 +0530 | [diff] [blame] | 61 | for(var i in wn.boot.modules_list) { |
| 62 | var m = wn.boot.modules_list[i]; |
Rushabh Mehta | 86945fe | 2012-11-15 16:58:27 +0530 | [diff] [blame] | 63 | if(!in_list(['Setup', 'Core'], m) && wn.boot.profile.allow_modules.indexOf(m)!=-1) |
Rushabh Mehta | a38bbe2 | 2012-02-29 10:55:43 +0530 | [diff] [blame] | 64 | add_icon(m); |
| 65 | } |
| 66 | |
Rushabh Mehta | 428929b | 2012-03-01 11:24:45 +0530 | [diff] [blame] | 67 | |
Rushabh Mehta | 17da764 | 2012-02-28 18:56:56 +0530 | [diff] [blame] | 68 | if(user_roles.indexOf('System Manager')!=-1) |
Rushabh Mehta | a38bbe2 | 2012-02-29 10:55:43 +0530 | [diff] [blame] | 69 | add_icon('Setup') |
Rushabh Mehta | 17da764 | 2012-02-28 18:56:56 +0530 | [diff] [blame] | 70 | |
| 71 | // apps |
Anand Doshi | db62876 | 2012-02-24 17:56:00 +0530 | [diff] [blame] | 72 | erpnext.desktop.show_pending_notifications(); |
| 73 | |
| 74 | } |
| 75 | |
| 76 | erpnext.desktop.show_pending_notifications = function() { |
Anand Doshi | 7854f81 | 2012-03-14 12:01:13 +0530 | [diff] [blame] | 77 | var add_circle = function(str_module, id, title) { |
| 78 | var module = $('#'+str_module); |
| 79 | module.find('a:first').append( |
| 80 | repl('<div id="%(id)s" class="circle" title="%(title)s" style="display: None">\ |
| 81 | <span class="circle-text"></span>\ |
| 82 | </div>', {id: id, title: title})); |
| 83 | |
| 84 | var case_border = module.find('.case-border'); |
| 85 | var circle = module.find('.circle'); |
| 86 | |
| 87 | var add_hover_and_click = function(primary, secondary, hover_class, click_class) { |
| 88 | primary |
| 89 | .hover( |
| 90 | function() { secondary.addClass(hover_class); }, |
| 91 | function() { secondary.removeClass(hover_class); }) |
| 92 | .mousedown(function() { secondary.addClass(click_class); }) |
| 93 | .mouseup(function() { secondary.removeClass(click_class); }) |
| 94 | .focusin(function() { $(this).mousedown(); }) |
| 95 | .focusout(function() { $(this).mouseup(); }) |
| 96 | } |
| 97 | |
| 98 | add_hover_and_click(case_border, circle, 'hover-effect', 'circle-click'); |
| 99 | add_hover_and_click(circle, case_border, 'hover-effect', 'case-border-click'); |
| 100 | |
| 101 | } |
| 102 | |
| 103 | add_circle('messages', 'unread_messages', 'Unread Messages'); |
| 104 | add_circle('support', 'open_support_tickets', 'Open Support Tickets'); |
| 105 | add_circle('todo', 'things_todo', 'Things To Do'); |
| 106 | add_circle('calendar', 'todays_events', 'Todays Events'); |
Rushabh Mehta | 07c94ce | 2012-06-04 12:57:23 +0530 | [diff] [blame] | 107 | add_circle('project', 'open_tasks', 'Open Tasks'); |
Rushabh Mehta | c7dbe29 | 2012-08-07 12:12:55 +0530 | [diff] [blame] | 108 | add_circle('kb', 'unanswered_questions', 'Unanswered Questions'); |
Anand Doshi | 7854f81 | 2012-03-14 12:01:13 +0530 | [diff] [blame] | 109 | |
Rushabh Mehta | 3948927 | 2012-05-03 10:44:44 +0530 | [diff] [blame] | 110 | erpnext.update_messages(); |
Anand Doshi | db62876 | 2012-02-24 17:56:00 +0530 | [diff] [blame] | 111 | |
Anand Doshi | eaaf651 | 2012-02-24 15:29:07 +0530 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | pscript.onload_desktop = function() { |
| 115 | // load desktop |
| 116 | erpnext.desktop.refresh(); |
| 117 | } |
| 118 | |