diff --git a/config.json b/config.json index b8305673adf4..a8c9a76b1883 100644 --- a/config.json +++ b/config.json @@ -1,6 +1,6 @@ { "base_template": "lib/website/templates/base.html", - "framework_version": "3.13.0", + "framework_version": "3.13.1", "modules": { "Calendar": { "color": "#2980b9", diff --git a/public/js/legacy/print_format.js b/public/js/legacy/print_format.js index bbc7c011d5d5..0891ae37ab69 100644 --- a/public/js/legacy/print_format.js +++ b/public/js/legacy/print_format.js @@ -1,5 +1,5 @@ // Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -// MIT License. See license.txt +// MIT License. See license.txt // default print style _p.def_print_style_body = "html, body, div, span, td, p { \ @@ -46,11 +46,11 @@ _p.preview = function(html) { $.extend(_p, { show_dialog: function() { if(!_p.dialog) { - _p.make_dialog(); + _p.make_dialog(); } _p.dialog.show(); }, - + make_dialog: function() { // Prepare Dialog Box Layout var dialog = new wn.ui.Dialog({ @@ -64,7 +64,7 @@ $.extend(_p, {

'}, ] }); - + dialog.$wrapper.find(".btn-print").click(function() { var args = dialog.get_values(); _p.build( @@ -82,21 +82,21 @@ $.extend(_p, { args.no_letterhead // no_letterhead ); }); - + dialog.onshow = function() { var $print = dialog.fields_dict.print_format.$input; $print.empty().add_options(cur_frm.print_formats); - + if(cur_frm.$print_view_select && cur_frm.$print_view_select.val()) $print.val(cur_frm.$print_view_select.val()); } - + _p.dialog = dialog; }, - + // Define formats dict formats: {}, - + /* args dict can contain: + fmtname --> print format name + onload @@ -107,19 +107,19 @@ $.extend(_p, { if(!fmtname) { fmtname= "Standard"; } - + args = { fmtname: fmtname, onload: onload, no_letterhead: no_letterhead, only_body: only_body }; - + if(!cur_frm) { alert('No Document Selected'); return; } - + // Get current doc (record) var doc = locals[cur_frm.doctype][cur_frm.docname]; if(args.fmtname == 'Standard') { @@ -146,35 +146,35 @@ $.extend(_p, { no_letterhead: args.no_letterhead, no_heading: no_heading, only_body: args.only_body - })); + })); } }, - + render: function(args) { var container = document.createElement('div'); var stat = ''; - + if(!args.no_heading) { // if draft/archived, show draft/archived banner - stat += _p.show_draft(args); + stat += _p.show_draft(args); stat += _p.show_archived(args); stat += _p.show_cancelled(args); } - + // Append args.body's content as a child of container container.innerHTML = args.body; - + // Show letterhead? _p.show_letterhead(container, args); - + _p.run_embedded_js(container, args.doc); var style = _p.consolidate_css(container, args); - + _p.render_header_on_break(container, args); - + return _p.render_final(style, stat, container, args); }, - + head_banner_format: function() { return "\ @@ -192,11 +192,11 @@ $.extend(_p, { }, /* - Check if doc's status is not submitted (docstatus == 0) + Check if doc's status is not submitted (docstatus == 0) and submission is pending - + Display draft in header if true - */ + */ show_draft: function(args) { var is_doctype_submittable = 0; var plist = locals['DocPerm']; @@ -217,10 +217,10 @@ $.extend(_p, { return ""; } }, - - + + /* - Check if doc is archived + Check if doc is archived Display archived in header if true */ show_archived: function(args) { @@ -231,7 +231,7 @@ $.extend(_p, { return archived; } else { return ""; - } + } }, @@ -247,7 +247,7 @@ $.extend(_p, { return cancelled; } else { return ""; - } + } }, @@ -269,11 +269,11 @@ $.extend(_p, { } style_list = container.getElementsByTagName('style'); } - + // Concatenate all styles style_concat = (args.only_body ? '' : _p.def_print_style_body) + _p.def_print_style_other + args.style + body_style; - + return style_concat; }, @@ -290,7 +290,7 @@ $.extend(_p, { } } }, - + add_span: function(html) { var tags = ["]>", "]>", "]>", "]>", "]>"]; var match = false; @@ -299,25 +299,25 @@ $.extend(_p, { match = true; } } - + if(!match) { html = "" + html + ""; } - + return html; }, - - + + // Attach letterhead at top of container - show_letterhead: function(container, args) { + show_letterhead: function(container, args) { if(!args.no_letterhead) { - container.innerHTML = '
' - + _p.get_letter_head() + '
' + container.innerHTML = '
' + + _p.get_letter_head() + '
' + container.innerHTML; } }, - - + + render_header_on_break: function(container, args) { var page_set = container.getElementsByClassName('page-settings'); if(page_set.length) { @@ -331,8 +331,8 @@ $.extend(_p, { } } }, - - + + // called by _p.render for final render of print render_final: function(style, stat, container, args) { if(!args.only_body) { @@ -357,13 +357,13 @@ $.extend(_p, { + container.innerHTML + '' + footer; - - + + // replace relative links by absolute links var prefix = window.location.href.split("app.html")[0] // find unique matches var matches = $.unique(finished.match(/src=['"]([^'"]*)['"]/g) || []); - + $.each(matches, function(i, v) { if(v.substr(0,4)=="src=") { var v = v.substr(5, v.length-6); @@ -371,11 +371,11 @@ $.extend(_p, { finished = finished.split(v).join(prefix + v); } }); - + return finished; }, - - + + // fetches letter head from current doc or control panel get_letter_head: function() { var cp = wn.control_panel; @@ -387,7 +387,7 @@ $.extend(_p, { } return lh; }, - + // common print style setting print_style: "\ .datalabelcell { \ @@ -410,7 +410,7 @@ $.extend(_p, { font-weight: bold; \ margin: 8px 0px; \ }", - + print_std: function(no_letterhead, no_heading) { // Get doctype, docname, layout for a doctype var docname = cur_frm.docname; @@ -426,10 +426,10 @@ $.extend(_p, { // Heading var h1_style = { fontSize: '22px', - marginBottom: '8px' + marginBottom: '8px' } var h1 = $a(me.layout.cur_row.header, 'h1', '', h1_style); - + // Get print heading if (cur_frm.pformat[docname]) { // first check in cur_frm.pformat @@ -446,7 +446,7 @@ $.extend(_p, { // if not, just have doctype has heading h1.innerHTML = val ? val : wn._(doctype); } - + var h2_style = { fontSize: '16px', color: '#888', @@ -457,16 +457,16 @@ $.extend(_p, { } var h2 = $a(me.layout.cur_row.header, 'div', '', h2_style); h2.innerHTML = docname; - - if(cur_frm.state_fieldname) { + + if(cur_frm.state_fieldname && !cur_frm.fields_dict[cur_frm.state_fieldname].print_hide) { $a(h2, 'br'); - var span = $a(h2, 'span', '', - {padding: "3px", color: "#fff", backgroundColor: "#777", + var span = $a(h2, 'span', '', + {padding: "3px", color: "#fff", backgroundColor: "#777", display:"inline-block"}); span.innerHTML = cur_frm.doc[cur_frm.state_fieldname]; } }, - + build_data: function(data, doctype, docname) { // Start with a row and a cell in that row if(data[0] && data[0].fieldtype != "Section Break") { @@ -475,47 +475,47 @@ $.extend(_p, { me.layout.addcell(); } } - + $.extend(this, { generate_custom_html: function(field, doctype, docname) { var container = $a(me.layout.cur_cell, 'div'); - container.innerHTML = cur_frm.pformat[field.fieldname](locals[doctype][docname]); + container.innerHTML = cur_frm.pformat[field.fieldname](locals[doctype][docname]); }, - + render_normal: function(field, data, i) { switch(field.fieldtype) { case 'Section Break': me.layout.addrow(); - + // Add column if no column break after this field if(data[i+1] && data[i+1].fieldtype != 'Column Break') { me.layout.addcell(); } break; - + case 'Column Break': - me.layout.addcell(field.width, field.label); + me.layout.addcell(field.width, field.label); break; - + case 'Table': var table = print_table( doctype, // dt docname, // dn field.fieldname, - field.options, // tabletype + field.options, // tabletype null, // cols null, // head_labels null, // widths null); // condition me.layout = _p.print_std_add_table(table, me.layout, me.pf_list, doctype, no_letterhead); break; - + case 'HTML': var div = $a(me.layout.cur_cell, 'div'); div.innerHTML = field.options; break; - + case 'Code': var div = $a(me.layout.cur_cell, 'div'); var val = _f.get_value(doctype, docname, @@ -524,22 +524,22 @@ $.extend(_p, { ':
' + (val ? val : '') +
 									'
'; break; - + case 'Text Editor': var div = $a(me.layout.cur_cell, 'div'); var val = _f.get_value(doctype, docname, field.fieldname); div.innerHTML = val ? val : ''; break; - + default: // Add Cell Data _p.print_std_add_field(doctype, docname, field, me.layout); break; } - } + } }); - + // Then build each field for(var i = 0; i < data.length; i++) { var fieldname = data[i].fieldname ? data[i].fieldname : @@ -554,11 +554,11 @@ $.extend(_p, { // Do the normal rendering this.render_normal(field, data, i); } - } + } } me.layout.close_borders(); }, - + build_html: function() { var html = ''; for(var i = 0; i < me.pf_list.length; i++) { @@ -574,7 +574,7 @@ $.extend(_p, { return html; } }); - + if(!no_heading) { this.build_head(data, doctype, docname); } @@ -584,18 +584,18 @@ $.extend(_p, { var html = this.build_html(); return html; }, - + add_layout: function(doctype) { var layout = new Layout(); layout.addrow(); - + if(locals['DocType'][doctype].print_outline == 'Yes') { layout.with_border = 1 } - - return layout; + + return layout; }, - + print_std_add_table: function(t, layout, pf_list, dt, no_letterhead) { if(t.appendChild) { // If only one table is passed @@ -604,57 +604,57 @@ $.extend(_p, { page_break = '\n\
'; - + // If a list of tables is passed for(var i = 0; i < t.length-1; i++) { // add to current page layout.cur_cell.appendChild(t[i]); layout.close_borders(); - + pf_list.push(page_break); - + // Create new page layout = _p.add_layout(dt, no_letterhead); pf_list.push(layout); - + layout.addrow(); layout.addcell(); - + var div = $a(layout.cur_cell, 'div'); div.innerHTML = 'Continued from previous page...'; div.style.padding = '4px'; } - + // Append last table layout.cur_cell.appendChild(t[t.length-1]); } return layout; }, - + print_std_add_field: function(dt, dn, f, layout) { var val = _f.get_value(dt, dn, f.fieldname); if(f.fieldtype!='Button') { if(val || in_list(['Float', 'Int', 'Currency'], f.fieldtype)) { // If value or a numeric type then proceed - + // Add field table row = _p.field_tab(layout.cur_cell); - + // Add label row.cells[0].innerHTML = wn._(f.label ? f.label : f.fieldname); row.cells[1].innerHTML = wn.format(val, f, {for_print: true}); - + // left align currency in normal display if(f.fieldtype == 'Currency') { $y(row.cells[1], { textAlign: 'left' }); } - + } } }, - + field_tab: function(layout_cell) { - var tab = $a(layout_cell, 'table', '', {width:'100%'}); + var tab = $a(layout_cell, 'table', '', {width:'100%'}); var row = tab.insertRow(0); _p.row = row; // Don't know this line's purpose row.insertCell(0); @@ -664,4 +664,4 @@ $.extend(_p, { row.cells[1].className = 'datainputcell'; return row; } -}); \ No newline at end of file +});