wn.ui.AppFrame = Class.extend({ init: function(parent, title, module) { this.set_document_title = true; this.buttons = {}; this.$w = $('
').prependTo(parent); this.$titlebar = $(' ').appendTo(this.$w); this.$w.find('.close').click(function() { window.history.back(); }) if(title) this.set_title(title); }, title: function(txt) { this.set_title(txt); }, set_title: function(txt, full_text) { if(this.set_document_title) document.title = txt; this.$titlebar.find(".appframe-title").html(txt) .attr("title", full_text || txt); }, clear_breadcrumbs: function() { this.$w.find(".appframe-breadcrumb").empty(); }, add_breadcrumb: function(icon, link, title) { if(link) { $(repl("\ ", { icon: icon, link: link, title: title })).appendTo(this.$w.find(".appframe-breadcrumb")); } else { $(repl("", { icon: icon, })).appendTo(this.$w.find(".appframe-breadcrumb")); } }, add_home_breadcrumb: function() { this.add_breadcrumb("icon-home", wn.home_page, "Home"); }, add_list_breadcrumb: function(doctype) { this.add_breadcrumb("icon-list", "List/" + encodeURIComponent(doctype), doctype + " List"); }, add_module_breadcrumb: function(module) { var module_info = wn.modules[module]; if(module_info) { this.add_breadcrumb(module_info.icon, module_info.link, module_info.label || module); } }, add_button: function(label, click, icon) { this.add_toolbar(); args = { label: label, icon:'' }; if(icon) { args.icon = ''; } this.buttons[label] = $(repl('', args)) .click(click) .appendTo(this.toolbar); return this.buttons[label]; }, add_help_button: function(txt) { this.add_toolbar(); $('') .data('help-text', txt) .click(function() { msgprint($(this).data('help-text'), 'Help'); }) .appendTo(this.toolbar); }, clear_buttons: function() { this.toolbar && this.toolbar.empty(); }, add_toolbar: function() { if(!this.toolbar) this.$w.append(' '); this.toolbar = this.$w.find('.appframe-toolbar .btn-group'); }, add_label: function(label) { return $(""+label+" ").appendTo(this.toolbar.parent()); }, add_select: function(label, options) { this.add_toolbar(); return $("