// requires // menu.js // search.js // datatype.js // dom.js var about_dialog; function WNToolbar(parent) { var me = this; this.setup = function() { this.wrapper = $a(parent, 'div', '', {color:'#FFF', padding:'2px 0px' }); set_gradient(this.wrapper, '#444', '#000'); this.table_wrapper = $a(this.wrapper, 'div', '', {marginLeft:'4px', padding:'2px'}); this.body_tab = make_table(this.table_wrapper, 1, 3, '100%', ['0%','64%','36%'],{verticalAlign:'middle'}); this.menu = new MenuToolbar($td(this.body_tab,0,1)); this.setup_home(); this.setup_new(); this.setup_search(); this.setup_recent(); if(in_list(user_roles, 'Administrator')) this.setup_options(); this.setup_help(); this.setup_report_builder(); this.setup_logout(); } // Options // ---------------------------------------------------------------------------------------- this.setup_options = function() { var tm = this.menu.add_top_menu('Pages', function() { }, "sprite-pages"); var fn = function() { if(this.dt=='Page') loadpage(this.dn); else loaddoc(this.dt, this.dn); mclose(); } // add start items profile.start_items.sort(function(a,b){return (a[4]-b[4])}); for(var i=0;i< profile.start_items.length;i++) { var d = profile.start_items[i]; var mi = this.menu.add_item('Pages',d[1], fn); mi.dt = d[0]; mi.dn = d[5]?d[5]:d[1]; } } // Home // ---------------------------------------------------------------------------------------- this.setup_home = function() { me.menu.add_top_menu('Home', function() { loadpage(home_page); }, "sprite-home"); } // Recent // ---------------------------------------------------------------------------------------- this.setup_recent = function() { this.rdocs = me.menu.add_top_menu('Recent', function() { }, "sprite-recent"); this.rdocs.items = {}; var fn = function() { // recent is only for forms loaddoc(this.dt, this.dn); mclose(); } // add to recent this.rdocs.add = function(dt, dn, on_top) { var has_parent = false; if(locals[dt] && locals[dt][dn] && locals[dt][dn].parent) has_parent = true; if(!in_list(['Start Page','ToDo Item','Event','Search Criteria'], dt) && !has_parent) { // if there in list, only bring it to top if(this.items[dt+'-'+dn]) { var mi = this.items[dt+'-'+dn]; mi.bring_to_top(); return; } var tdn = dn; var rec_label = '' +'' +'' +'
'+tdn+''+get_doctype_label(dt)+'
'; var mi = me.menu.add_item('Recent',rec_label,fn, on_top); mi.dt = dt; mi.dn = dn; this.items[dt+'-'+dn] = mi; if(pscript.on_recent_update)pscript.on_recent_update(); } } // remove from recent this.rdocs.remove = function(dt, dn) { var it = me.rdocs.items[dt+'-'+dn]; if(it)$dh(it); if(pscript.on_recent_update)pscript.on_recent_update(); } this.rename_notify = function(dt, old, name) { me.rdocs.remove(dt, old); me.rdocs.add(dt, name, 1); } rename_observers.push(this); // add menu items try{ var rlist = JSON.parse(profile.recent); } catch(e) { return; /*old style-do nothing*/ } var m = rlist.length; if(m>15)m=15; for (var i=0;iProfile'; $td(t,0,4).innerHTML = 'Logout'; this.menu_table_right = t; $y($td(t,0,5), {width:'18px'}); this.spinner = $a($td(t,0,5),'img','',{display:'none'}); this.spinner.src = 'images/ui/spinner.gif'; } this.download_backup = function() { $c('webnotes.utils.backups.get_backup',{},function(r,rt) {}); } this.setup(); } var get_help = function() { msgprint('Help not implemented'); } var get_feedback = function() { // dialog var d = new Dialog(640, 320, "Please give your feedback"); d.make_body( [['Text','Feedback'] ,['Button','Send', function() { $c_obj('Feedback Control', 'get_feedback', d.widgets['Feedback'].value, function(r,rt) { d.hide(); if(r.message) msgprint(r.message); }) } ]] ); d.show(); // send to Feedback Control }