// Copyright 2013 Web Notes Technologies Pvt Ltd
// License: MIT. See license.txt
// wn._("Form")
wn.ui.AppFrame = Class.extend({
init: function(parent, title, module) {
this.set_document_title = true;
this.buttons = {};
this.$w = $('
").css({
"border-top": "7px solid " + module_info.color
});
// this.$w.find(".title-area").css({
// "border-left": "5px solid " + module_info.color
// })
}
},
set_views_for: function(doctype, active_view) {
this.doctype = doctype;
var me = this;
var views = [{
icon: "icon-file-alt",
route: "",
type: "form",
set_route: function() {
if(wn.views.formview[me.doctype]) {
wn.set_route("Form", me.doctype, wn.views.formview[me.doctype].frm.docname);
} else {
new_doc(doctype);
}
}
}];
if(!locals.DocType[doctype].issingle) {
views.push({
icon: "icon-list",
route: "List/" + doctype,
type: "list"
});
}
if(locals.DocType[doctype].__calendar_js) {
views.push({
icon: "icon-calendar",
route: "Calendar/" + doctype,
type: "calendar"
});
}
if(wn.model.can_get_report(doctype)) {
views.push({
icon: "icon-table",
route: "Report2/" + doctype,
type: "report"
});
}
this.set_views(views, active_view);
},
set_views: function(views, active_view) {
var me = this;
$right = this.$w.find(".appframe-right .btn-group");
$.each(views, function(i, e) {
var btn = $(repl('
', e))
.click(e.set_route || function() {
window.location.hash = "#" + $(this).attr("data-route");
})
.css({
width: "39px"
})
.attr("title", wn._(toTitle(e.type)))
.appendTo($right);
if(e.type==active_view) {
btn.addClass("btn-inverse");
}
});
},
add_help_button: function(txt) {
$('
')
.data('help-text', txt)
.click(function() { msgprint($(this).data('help-text'), 'Help'); })
.appendTo(this.toolbar);
},
clear_buttons: function() {
this.toolbar && this.toolbar.empty().toggle(false);
$(".custom-menu").remove();
},
add_button: function(label, click, icon, title_toolbar) {
!title_toolbar && this.toolbar.toggle(true);
args = { label: label, icon:'' };
if(icon) {
args.icon = '
';
}
this.buttons[label] = $(repl('
', args))
.appendTo(title_toolbar ? this.$w.find(".title-button-area") : this.toolbar)
.click(click);
return this.buttons[label];
},
get_menu: function(label) {
return $("#navbar-" + label.toLowerCase());
},
add_menu_divider: function(menu) {
menu = typeof menu == "string" ?
this.get_menu(menu) : menu;
$('').appendTo(menu);
},
add_dropdown_button: function(parent, label, click, icon) {
var menu = this.get_menu(parent);
if(menu.find("li:not(.custom-menu)").length && !menu.find(".divider").length) {
this.add_menu_divider(menu);
}
return $('')
.appendTo(menu)
.find("a")
.click(function() {
click();
});
},
add_label: function(label) {
return $("
"+label+" ")
.appendTo($("
").appendTo(this.toolbar));
},
add_select: function(label, options) {
this.add_toolbar();
return $("