wn.ui.AppFrame = Class.extend({ init: function(parent, title, module) { this.set_document_title = true; this.buttons = {}; this.$w = $('
').appendTo(parent); this.$titlebar = $('
\
\ \ \ \ \ ×\
').appendTo(this.$w); this.$w.find('.close').click(function() { window.history.back(); }) if(title) this.title(title); if(module) this.set_marker(module); }, title: function(txt) { this.set_title(txt); }, set_title: function(txt) { if(this.set_document_title) document.title = txt; this.$titlebar.find(".appframe-title").html(txt); }, set_marker: function(module) { var color = wn.get_module_color(module); this.$titlebar.find(".appframe-marker") .css({ "background-color": color }); }, add_tab: function(tab_name, opacity, click) { var span = $('') .html(tab_name).insertAfter(this.$titlebar.find(".close")); opacity && span.css("opacity", opacity); click && span.click(click); return span }, add_module_tab: function(module) { this.add_tab(''+' ' + wn._(module) + "", 0.7, function() { wn.set_route(erpnext.modules[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'); }, add_label: function(label) { return $(""+label+" ").appendTo(this.toolbar); }, add_select: function(label, options) { this.add_toolbar(); return $("") .appendTo(this.toolbar); }, add_date: function(label, date) { this.add_toolbar(); return $("").datepicker({ dateFormat: sys_defaults.date_format.replace("yyyy", "yy"), changeYear: true, }).val(dateutil.str_to_user(date) || "").appendTo(this.toolbar); }, add_ripped_paper_effect: function(wrapper) { if(!wrapper) var wrapper = wn.container.page; var layout_main = $(wrapper).find('.layout-main'); if(!layout_main.length) { layout_main = $(wrapper).find('.layout-main-section'); } layout_main.css({"padding-top":"25px"}); $('
') .prependTo(layout_main) .css({"width": $(layout_main).width()}); } }); // parent, title, single_column // standard page with appframe wn.ui.make_app_page = function(opts) { if(opts.single_column) { $(opts.parent).html('
\
\
\
'); } else { $(opts.parent).html('
\
\
\
\
\
'); } opts.parent.appframe = new wn.ui.AppFrame($(opts.parent).find('.layout-appframe')); if(opts.set_document_title!==undefined) opts.parent.appframe.set_document_title = opts.set_document_title; if(opts.title) opts.parent.appframe.title(opts.title); if(opts.module) opts.parent.appframe.set_marker(opts.module); }