/* * lib/js/lib/history/history.min.js */ /* * jQuery hashchange event - v1.3 - 7/21/2010 * http://benalman.com/projects/jquery-hashchange-plugin/ * * Copyright (c) 2010 "Cowboy" Ben Alman * Dual licensed under the MIT and GPL licenses. * http://benalman.com/about/license/ */ (function($,e,b){var c="hashchange",h=document,f,g=$.event.special,i=h.documentMode,d="on"+c in e&&(i===b||i>7);function a(j){j=j||location.href;return"#"+j.replace(/^[^#]*#?(.*)$/,"$1")}$.fn[c]=function(j){return j?this.bind(c,j):this.trigger(c)};$.fn[c].delay=50;g[c]=$.extend(g[c],{setup:function(){if(d){return false}$(f.start)},teardown:function(){if(d){return false}$(f.stop)}});f=(function(){var j={},p,m=a(),k=function(q){return q},l=k,o=k;j.start=function(){p||n()};j.stop=function(){p&&clearTimeout(p);p=b};function n(){var r=a(),q=o(m);if(r!==m){l(m=r,q);$(e).trigger(c)}else{if(q!==m){location.href=location.href.replace(/#.*/,"")+q}}p=setTimeout(n,$.fn[c].delay)}$.browser.msie&&!d&&(function(){var q,r;j.start=function(){if(!q){r=$.fn[c].src;r=r&&r+a();q=$('';var div=$a(parent,'div');div.innerHTML='
';var ul_form=div.childNodes[0];var f_list=[];var inp_fdata=$a_input($a(ul_form,'span'),'file',{name:'filedata'},{marginLeft:'7px'});if(!('cmd'in args)){var inp=$a_input($a(ul_form,'span'),'hidden',{name:'cmd'});inp.value='uploadfile';} var inp=$a_input($a(ul_form,'span'),'hidden',{name:'uploader_id'});inp.value=id;var inp=$a_input($a(ul_form,'span'),'submit',null,{marginLeft:'7px'});inp.value='Upload';$y(inp,{width:'80px'});for(var key in args){var inp=$a_input($a(ul_form,'span'),'hidden',{name:key});inp.value=args[key];} uploaders[id]=this;} function upload_callback(id,fid){uploaders[id].callback(fid);} /* * lib/js/legacy/webpage/page.js */ function Page(page_name,content){var me=this;this.name=page_name;this.trigger=function(event){try{if(pscript[event+'_'+this.name]) pscript[event+'_'+this.name](me.wrapper);if(me.wrapper[event]){me.wrapper[event](me.wrapper);}}catch(e){console.log(e);}} this.page_show=function(){set_title(me.doc.title?me.doc.title:me.name);if(!me.onload_complete){me.trigger('onload');me.onload_complete=true;} me.trigger('onshow');cur_frm=null;} this.wrapper=wn.container.add_page(page_name,this.page_show);this.cont=this.wrapper if(content) this.wrapper.innerHTML=content;return this;} function render_page(page_name,menuitem){if(!page_name)return;if((!locals['Page'])||(!locals['Page'][page_name])){loadpage('_home');return;} var pdoc=locals['Page'][page_name];if(pdoc.style)set_style(pdoc.style) var p=new Page(page_name,pdoc._Page__content?pdoc._Page__content:pdoc.content);var script=pdoc.__script?pdoc.__script:pdoc.script;p.doc=pdoc;if(script){eval(script);} wn.container.change_to(page_name);return p;} function refresh_page(page_name){var fn=function(r,rt){render_page(page_name)} $c('webnotes.widgets.page.getpage',{'name':page_name},fn);} /* * lib/js/legacy/wn/page_layout.js */ wn.PageLayout=function(args){$.extend(this,args) this.wrapper=$a(this.parent,'div','layout-wrapper layout-wrapper-background');this.main=$a(this.wrapper,'div','layout-main-section');this.sidebar_area=$a(this.wrapper,'div','layout-side-section');$a(this.wrapper,'div','',{clear:'both'});this.head=$a(this.main,'div');this.toolbar_area=$a(this.main,'div');this.body=$a(this.main,'div');this.footer=$a(this.main,'div');if(this.heading){this.page_head=new PageHeader(this.head,this.heading);}} /* * lib/js/legacy/wn/widgets/footer.js */ wn.widgets.Footer=function(args){$.extend(this,args);this.make=function(){this.wrapper=$a(this.parent,'div','std-footer');this.table=make_table(this.wrapper,1,this.columns,[],{width:100/this.columns+'%'});this.render_items();} this.render_items=function(){for(var i=0;i0){for(pl in perm) perm[pl][WRITE]=0;} return perm;} LocalDB.create=function(doctype,n){if(!n)n=LocalDB.get_localname(doctype);var doc=LocalDB.add(doctype,n) doc.__islocal=1;doc.owner=user;LocalDB.set_default_values(doc);return n;} LocalDB.delete_record=function(dt,dn){var d=locals[dt][dn];if(!d.__islocal) d.__oldparent=d.parent;d.parent='old_parent:'+d.parent;d.docstatus=2;d.__deleted=1;} LocalDB.get_default_value=function(fn,ft,df){if(df=='_Login'||df=='__user') return user;else if(df=='_Full Name') return user_fullname;else if(ft=='Date'&&(df=='Today'||df=='__today')){return get_today();} else if(df) return df;else if(user_defaults[fn]) return user_defaults[fn][0];else if(sys_defaults[fn]) return sys_defaults[fn];} LocalDB.add_child=function(doc,childtype,parentfield){var n=LocalDB.create(childtype);var d=locals[childtype][n];d.parent=doc.name;d.parentfield=parentfield;d.parenttype=doc.doctype;return d;} LocalDB.no_copy_list=['amended_from','amendment_date','cancel_reason'];LocalDB.copy=function(dt,dn,from_amend){var newdoc=LocalDB.create(dt);for(var key in locals[dt][dn]){if(key!=='name'&&key.substr(0,2)!='__'){locals[dt][newdoc][key]=locals[dt][dn][key];} var df=get_field(dt,key);if(df&&((!from_amend&&cint(df.no_copy)==1)||in_list(LocalDB.no_copy_list,df.fieldname))){locals[dt][newdoc][key]='';}} return locals[dt][newdoc];} function make_doclist(dt,dn,deleted){var dl=[];dl[0]=locals[dt][dn];for(var ndt in locals){if(locals[ndt]){for(var ndn in locals[ndt]){var doc=locals[ndt][ndn];if(doc&&doc.parenttype==dt&&(doc.parent==dn||(deleted&&doc.__oldparent==dn))){dl[dl.length]=doc;}}}} return dl;} var Meta={};var local_dt={};Meta.make_local_dt=function(dt,dn){var dl=make_doclist('DocType',dt);if(!local_dt[dt])local_dt[dt]={};if(!local_dt[dt][dn])local_dt[dt][dn]={};for(var i=0;i1)return true;var fl=fields_list[dt];if(!fl)return true;var all_clear=true;var errfld=[];for(var i=0;iMandatory fields required in '+ (doc.parenttype?(fields[doc.parenttype][doc.parentfield].label+' (Table)'):get_doctype_label(doc.doctype))+':\n'+errfld.join('\n'));return all_clear;} /* * lib/js/legacy/app.js */ var popup_cont;var session={};if(!wn)var wn={};function startup(){popup_cont=$a(document.getElementsByTagName('body')[0],'div');var setup_globals=function(r){wn.boot=r;profile=r.profile;user=r.profile.name;user_fullname=wn.user_info(user).fullname;user_defaults=profile.defaults;user_roles=profile.roles;user_email=profile.email;home_page=r.home_page;_p.letter_heads=r.letter_heads;sys_defaults=r.sysdefaults;session.rt=profile.can_read;if(r.ipinfo)session.ipinfo=r.ipinfo;session.dt_labels=r.dt_labels;session.rev_dt_labels={} if(r.dt_labels){for(key in r.dt_labels)session.rev_dt_labels[r.dt_labels[key]]=key;} wn.control_panel=r.control_panel;} var setup_viewport=function(){wn.container=new wn.views.Container();if(user=='Guest') user_defaults.hide_webnotes_toolbar=1;if(!cint(user_defaults.hide_webnotes_toolbar)||user=='Administrator'){wn.container.wntoolbar=new wn.ui.toolbar.Toolbar();} $(document).trigger('startup');try{if(wn.control_panel.custom_startup_code) eval(wn.control_panel.custom_startup_code);}catch(e){errprint(e);} var t=to_open();if(t){window.location.hash=t;}else if(home_page){loadpage(home_page);} wn.route();$dh('startup_div');$ds('body_div');} var callback=function(r,rt){if(r.exc)console.log(r.exc);setup_globals(r);setup_viewport();} if(wn.boot){LocalDB.sync(wn.boot.docs);callback(wn.boot,'');if(wn.boot.error_messages) console.log(wn.boot.error_messages) if(wn.boot.server_messages) msgprint(wn.boot.server_messages);}else{if($i('startup_div')) $c('startup',{},callback,null,1);}} function to_open(){if(get_url_arg('page')) return get_url_arg('page');var h=location.hash;if(h){return h.substr(1);}} function logout(){$c('logout',args={},function(r,rt){if(r.exc){msgprint(r.exc);return;} redirect_to_login();});} function redirect_to_login(){if(login_file) window.location.href=login_file;else{window.location.reload();}} _p.def_print_style_body="html, body, div, span, td { font-family: Arial, Helvetica; font-size: 12px; }"+"\npre { margin:0; padding:0;}" _p.def_print_style_other="\n.simpletable, .noborder { border-collapse: collapse; margin-bottom: 10px;}" +"\n.simpletable td {border: 1pt solid #000; vertical-align: top; padding: 2px; }" +"\n.noborder td { vertical-align: top; }" _p.go=function(html){var d=document.createElement('div') d.innerHTML=html $(d).printElement();} _p.preview=function(html){var w=window.open('');w.document.write(html) w.document.close();} var resize_observers=[] function set_resize_observer(fn){if(resize_observers.indexOf(fn)==-1)resize_observers.push(fn);} window.onresize=function(){return;var ht=get_window_height();for(var i=0;ierpnext\ ').hover(function(){$(this).find('.icon-home').addClass('navbar-icon-home-hover');},function(){$(this).find('.icon-home').removeClass('navbar-icon-home-hover');});}) /* * erpnext/startup/startup.js */ var current_module;var is_system_manager=0;wn.provide('erpnext.startup');erpnext.modules={'Selling':'selling-home','Accounts':'accounts-home','Stock':'stock-home','Buying':'buying-home','Support':'support-home','Projects':'projects-home','Production':'production-home','Website':'website-home','HR':'hr-home','Setup':'Setup','Activity':'activity','To Do':'todo','Calendar':'calendar','Messages':'messages','Knowledge Base':'questions','Dashboard':'dashboard'} erpnext.startup.set_globals=function(){pscript.is_erpnext_saas=cint(wn.control_panel.sync_with_gateway) if(inList(user_roles,'System Manager'))is_system_manager=1;} erpnext.startup.start=function(){$('#startup_div').html('Starting up...').toggle(true);erpnext.startup.set_globals();if(wn.boot.user_background){erpnext.set_user_background(wn.boot.user_background);} if(user=='Guest'){if(wn.boot.custom_css){set_style(wn.boot.custom_css);} if(wn.boot.website_settings.title_prefix){wn.title_prefix=wn.boot.website_settings.title_prefix;}}else{wn.boot.profile.allow_modules=wn.boot.profile.allow_modules.concat(['To Do','Knowledge Base','Calendar','Activity','Messages']) if(user_roles.indexOf('Accounts Manager')!=-1){wn.boot.profile.allow_modules.push('Dashboard');} erpnext.toolbar.setup();erpnext.startup.set_periodic_updates();if(in_list(user_roles,'System Manager')&&(wn.boot.setup_complete=='No')){wn.require("erpnext/startup/js/complete_setup.js");erpnext.complete_setup();}} $('#startup_div').toggle(false);} show_chart_browser=function(nm,chart_type){var call_back=function(){if(nm=='Sales Browser'){var sb_obj=new SalesBrowser();sb_obj.set_val(chart_type);} else if(nm=='Accounts Browser') pscript.make_chart(chart_type);} loadpage(nm,call_back);} var update_messages=function(reset){if(inList(['Guest'],user)||!wn.session_alive){return;} if(!reset){$c_page('home','event_updates','get_global_status_messages',null,function(r,rt){if(!r.exc){wn.container.wntoolbar.set_new_comments(r.message.unread_messages);var show_in_circle=function(parent_id,msg){var parent=$('#'+parent_id);if(parent){if(msg){parent.find('span:first').text(msg);parent.toggle(true);}else{parent.toggle(false);}}} show_in_circle('unread_messages',r.message.unread_messages.length);show_in_circle('open_support_tickets',r.message.open_support_tickets);show_in_circle('things_todo',r.message.things_todo);show_in_circle('todays_events',r.message.todays_events);}else{clearInterval(wn.updates.id);}});}else{wn.container.wntoolbar.set_new_comments(0);$('#unread_messages').toggle(false);}} erpnext.startup.set_periodic_updates=function(){wn.updates={};if(wn.updates.id){clearInterval(wn.updates.id);} wn.updates.id=setInterval(update_messages,60000);} erpnext.set_user_background=function(src){set_style(repl('body { background: url("files/%(src)s") repeat;}',{src:src}))} $(document).bind('startup',function(){erpnext.startup.start();}); /* * erpnext/website/js/topbar.js */ wn.provide('erpnext.navbar');erpnext.navbar.Navbar=Class.extend({init:function(){this.make();$('.brand').html(wn.boot.website_settings.brand_html);this.make_items();$('.dropdown-toggle').dropdown();},make:function(){$('header').append('');$('.brand').attr('href','#!'+(wn.boot.website_settings.home_page||'Login Page'))},make_items:function(){var items=wn.boot.website_menus;for(var i=0;i\ %(label)s',item))}} for(var i=0;i').click(function(){return false;});$parent_li.append('');} item.route=item.url||item.custom_page;$parent_li.find('.dropdown-menu').append(repl('
  • \ %(label)s
  • ',item))}}}});erpnext.Footer=Class.extend({init:function(){$('footer').html(repl('',wn.boot.website_settings));this.make_items();},make_items:function(){var items=wn.boot.website_menus for(var i=0;i%(label)s',item))}}}});$(document).bind('startup',function(){erpnext.navbar.navbar=new erpnext.navbar.Navbar();})