all-web smaller
This commit is contained in:
parent
a22fb20fbd
commit
4b6ee11503
7 changed files with 17 additions and 181 deletions
|
|
@ -1,5 +1,19 @@
|
|||
/* FORMS */
|
||||
|
||||
.breadcrumbs-area {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.breadcrumbs {
|
||||
background-color: #e8e8e8;
|
||||
padding: 3px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.breadcrumbs a {
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
div.form-section-head {
|
||||
margin: 11px 0px 3px 0px;
|
||||
border-top: 1px solid #ccc;
|
||||
|
|
|
|||
|
|
@ -264,86 +264,6 @@ function DocLink(p, doctype, name, onload) {
|
|||
}
|
||||
var doc_link = DocLink;
|
||||
|
||||
// in words
|
||||
|
||||
var known_numbers = {
|
||||
0: 'zero',
|
||||
1: 'one',
|
||||
2: 'two',
|
||||
3: 'three',
|
||||
4: 'four',
|
||||
5: 'five',
|
||||
6: 'six',
|
||||
7: 'seven',
|
||||
8: 'eight',
|
||||
9: 'nine',
|
||||
10: 'ten',
|
||||
11: 'eleven',
|
||||
12: 'twelve',
|
||||
13: 'thirteen',
|
||||
14: 'fourteen',
|
||||
15: 'fifteen',
|
||||
16: 'sixteen',
|
||||
17: 'seventeen',
|
||||
18: 'eighteen',
|
||||
19: 'nineteen',
|
||||
20: 'twenty',
|
||||
30: 'thirty',
|
||||
40: 'forty',
|
||||
50: 'fifty',
|
||||
60: 'sixty',
|
||||
70: 'seventy',
|
||||
80: 'eighty',
|
||||
90: 'ninety'
|
||||
}
|
||||
|
||||
function in_words(n) {
|
||||
var is_million = wn.control_panel.currency_format == 'Millions' ? 1 : 0;
|
||||
n=cint(n)
|
||||
if(known_numbers[n]) return known_numbers[n];
|
||||
var bestguess = n + '';
|
||||
var remainder = 0
|
||||
if(n<=20)
|
||||
alert('Error while converting to words');
|
||||
else if(n<100) {
|
||||
return in_words(Math.floor(n/10)*10) + '-' + in_words(n%10);
|
||||
} else if(n<1000) {
|
||||
bestguess= in_words(Math.floor(n/100)) + ' ' + 'hundred';
|
||||
remainder = n%100;
|
||||
} else if(!is_million) {
|
||||
if(n<100000) {
|
||||
bestguess= in_words(Math.floor(n/1000)) + ' ' + 'thousand';
|
||||
remainder = n%1000;
|
||||
} else if(n < 10000000) {
|
||||
bestguess= in_words(Math.floor(n/100000)) + ' ' + 'lakh';
|
||||
remainder = n%100000;
|
||||
} else {
|
||||
bestguess= in_words(Math.floor(n/10000000)) + ' ' + 'crore'
|
||||
remainder = n%10000000
|
||||
}
|
||||
} else {
|
||||
if(n<1000000) {
|
||||
bestguess= in_words(Math.floor(n/1000)) + ' ' + 'thousand';
|
||||
remainder = n%1000;
|
||||
} else if(n < 1000000000) {
|
||||
bestguess= in_words(Math.floor(n/1000000)) + ' ' + 'million';
|
||||
remainder = n%1000000;
|
||||
} else {
|
||||
bestguess= in_words(Math.floor(n/1000000000)) + ' ' + 'billion'
|
||||
remainder = n%1000000000
|
||||
}
|
||||
|
||||
}
|
||||
if(remainder) {
|
||||
if(remainder >= 100) comma = ','
|
||||
else comma = ''
|
||||
return bestguess + comma + ' ' + in_words(remainder);
|
||||
} else {
|
||||
return bestguess;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function roundNumber(num, dec) {
|
||||
var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -1,98 +0,0 @@
|
|||
// Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com)
|
||||
//
|
||||
// MIT License (MIT)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
// OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
// PAGE
|
||||
|
||||
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() {
|
||||
// default set_title
|
||||
set_title(me.doc.title ? me.doc.title : me.name);
|
||||
|
||||
if(!me.onload_complete) {
|
||||
me.trigger('onload');
|
||||
me.onload_complete = true;
|
||||
}
|
||||
me.trigger('onshow');
|
||||
|
||||
// clear cur_frm
|
||||
cur_frm = null;
|
||||
}
|
||||
|
||||
this.wrapper = wn.container.add_page(page_name, this.page_show);
|
||||
this.cont = this.wrapper // bc
|
||||
|
||||
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])) {
|
||||
// no page, go home
|
||||
loadpage('_home');
|
||||
return;
|
||||
}
|
||||
var pdoc = locals['Page'][page_name];
|
||||
|
||||
// style
|
||||
if(pdoc.style) set_style(pdoc.style)
|
||||
|
||||
// create page
|
||||
var p = new Page(page_name, pdoc._Page__content?pdoc._Page__content:pdoc.content);
|
||||
// script
|
||||
var script = pdoc.__script ? pdoc.__script : pdoc.script;
|
||||
p.doc = pdoc;
|
||||
|
||||
if(script) {
|
||||
eval(script);
|
||||
}
|
||||
|
||||
// change
|
||||
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);
|
||||
}
|
||||
|
|
@ -48,7 +48,7 @@ function PageHeader(parent, main_text, sub_text) {
|
|||
this.close_btn = $a(this.wrapper, 'a', 'close', {}, '×');
|
||||
this.close_btn.onclick = function() { window.history.back(); };
|
||||
|
||||
this.breadcrumbs = $a(this.wrapper, 'div');
|
||||
this.breadcrumbs = $a(this.wrapper, 'div', 'breadcrumbs-area');
|
||||
this.main_head = $a(this.wrapper, 'h1', '', def_ph_style.main_heading);
|
||||
this.sub_head = $a(this.wrapper, 'h4', '', def_ph_style.sub_heading);
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ _f.FrmHeader = function(parent, frm) {
|
|||
|
||||
this.page_head = new PageHeader(this.wrapper);
|
||||
wn.views.breadcrumbs(this.page_head.breadcrumbs, frm.meta.module, frm.meta.name);
|
||||
|
||||
|
||||
// doctype
|
||||
this.dt_area = $a(this.page_head.main_head, 'h1', '', {marginRight:'8px', display:'inline'})
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
wn.provide('wn.views');
|
||||
wn.views.breadcrumbs = function(parent, module, doctype, name) {
|
||||
var $bspan = $(repl('<span class="breadcrumbs">\
|
||||
<a href="#%(home_page)s"><i class="icon-home"></i></a></span>', {home_page: wn.boot.home_page}));
|
||||
<a href="#%(home_page)s">Home</a></span>', {home_page: wn.boot.home_page}));
|
||||
if(module) {
|
||||
$bspan.append(repl(' / <a href="#!%(module_small)s-home">%(module)s Home</a>',
|
||||
{module: module, module_small: module.toLowerCase() }))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue