")
@@ -71,35 +74,83 @@ wn.views.moduleview.ModuleView = Class.extend({
},
add_section: function(section) {
section._title = wn._(section.title);
- var list_group = $('
"').appendTo(section.right
- ? $(this.wrapper).find(".side-section")
- : $(this.wrapper).find(".main-section"));
+ if(section.top) {
+ var list_group = $('
')
+ .appendTo($(this.wrapper).find(".module-top"));
+ } else {
+ var list_group = $('
\
+ - \
+
'
+ + wn._(section.title) +'
\
+ \
+
"').appendTo(section.right
+ ? $(this.wrapper).find(".side-section")
+ : $(this.wrapper).find(".main-section"));
+ }
section.list_group = list_group;
},
add_item: function(item, section) {
if(!item.description) item.description = "";
if(item.count==null) item.count = "";
+ if(section.top) {
+ var $parent = $(repl('
', {doctype:item.doctype}))
+ .appendTo(section.list_group)
+ .find(".alert");
+ this.top_item_total[item.doctype] = 0;
+ } else {
+ var $parent = $('
').appendTo(section.list_group);
+ }
- $(repl('\
- %(link)s"
- + (item.description
+ + ((item.description && !section.top)
? " %(description)s"
: "")
+ ((section.right || !item.doctype)
? ''
- : '\
- ')
- + "", item))
- .appendTo(section.list_group);
+ : '
'), item))
+ .appendTo($parent);
+
+ if(!section.top) {
+ $('
').appendTo($parent);
+ }
+ },
+ set_top_item_count: function(doctype, count, open_count) {
+ var me = this;
+ if(this.top_item_total[doctype]!=null) {
+
+ if(count!=null)
+ this.top_item_total[doctype] = count;
+ if(open_count!=null)
+ this.top_item_open[doctype] = open_count;
+
+ var maxtop = Math.max.apply(this, values(this.top_item_total));
+
+ $.each(this.top_item_total, function(doctype, item_count) {
+ $(me.wrapper).find(".module-item-progress[data-doctype='"+ doctype +"']")
+ .find(".module-item-progress-total")
+ .css("width", cint(flt(item_count)/maxtop*100) + "%")
+ })
+
+ $.each(this.top_item_open, function(doctype, item_count) {
+ $(me.wrapper).find(".module-item-progress[data-doctype='"+ doctype +"']")
+ .find(".module-item-progress-open")
+ .css("width", cint(flt(item_count)/me.top_item_total[doctype]*100) + "%")
+ })
+ }
},
render_static: function() {
// render sections
@@ -177,8 +228,9 @@ wn.views.moduleview.ModuleView = Class.extend({
$.each(r.message.item_count, function(doctype, count) {
$(me.wrapper).find("[data-doctype-count='"+doctype+"']")
.html(count)
- .addClass("badge badge-count")
+ .addClass("badge badge-count pull-right")
.css({cursor:"pointer"});
+ me.set_top_item_count(doctype, count)
})
}
@@ -194,12 +246,13 @@ wn.views.moduleview.ModuleView = Class.extend({
if(wn.boot.notification_info.open_count_doctype) {
$.each(wn.boot.notification_info.open_count_doctype, function(doctype, count) {
if(in_list(me.doctypes, doctype)) {
+ me.set_top_item_count(doctype, null, count);
$('
')
.css({
"cursor": "pointer",
"margin-right": "0px"
})
- .addClass("badge badge-important")
+ .addClass("badge badge-important pull-right")
.html(count)
.attr("data-doctype", doctype)
.insertAfter($(me.wrapper)
diff --git a/public/js/wn/views/pageview.js b/public/js/wn/views/pageview.js
index 71f14bf0a2..a7da3ccb21 100644
--- a/public/js/wn/views/pageview.js
+++ b/public/js/wn/views/pageview.js
@@ -81,14 +81,10 @@ wn.views.Page = Class.extend({
},
trigger: function(eventname) {
var me = this;
- try {
- if(pscript[eventname+'_'+this.name]) {
- pscript[eventname+'_'+this.name](me.wrapper);
- } else if(me.wrapper[eventname]) {
- me.wrapper[eventname](me.wrapper);
- }
- } catch(e) {
- console.log(e);
+ if(pscript[eventname+'_'+this.name]) {
+ pscript[eventname+'_'+this.name](me.wrapper);
+ } else if(me.wrapper[eventname]) {
+ me.wrapper[eventname](me.wrapper);
}
}
})