diff --git a/frappe/build.py b/frappe/build.py
index fb057934b0..b7c56356d2 100644
--- a/frappe/build.py
+++ b/frappe/build.py
@@ -11,11 +11,11 @@ Build the `public` folders and setup languages
import os, sys, frappe, json, shutil
from cssmin import cssmin
-def bundle(no_compress, make_copy=False):
+def bundle(no_compress, make_copy=False, verbose=False):
"""concat / minify js files"""
# build js files
make_asset_dirs(make_copy=make_copy)
- build(no_compress)
+ build(no_compress, verbose)
def watch(no_compress):
"""watch and rebuild if necessary"""
@@ -49,11 +49,11 @@ def make_asset_dirs(make_copy=False):
else:
os.symlink(os.path.abspath(source), target)
-def build(no_compress=False):
+def build(no_compress=False, verbose=False):
assets_path = os.path.join(frappe.local.sites_path, "assets")
for target, sources in get_build_maps().iteritems():
- pack(os.path.join(assets_path, target), sources, no_compress)
+ pack(os.path.join(assets_path, target), sources, no_compress, verbose)
shutil.copy(os.path.join(os.path.dirname(os.path.abspath(frappe.__file__)), 'data', 'languages.txt'), frappe.local.sites_path)
# reset_app_html()
@@ -89,7 +89,7 @@ def get_build_maps():
timestamps = {}
-def pack(target, sources, no_compress):
+def pack(target, sources, no_compress, verbose):
from cStringIO import StringIO
outtype, outtxt = target.split(".")[-1], ''
@@ -109,7 +109,11 @@ def pack(target, sources, no_compress):
if outtype=="js" and extn=="js" and (not no_compress) and suffix!="concat" and (".min." not in f):
tmpin, tmpout = StringIO(data.encode('utf-8')), StringIO()
jsm.minify(tmpin, tmpout)
- outtxt += unicode(tmpout.getvalue() or '', 'utf-8').strip('\n') + ';'
+ minified = tmpout.getvalue()
+ outtxt += unicode(minified or '', 'utf-8').strip('\n') + ';'
+
+ if verbose:
+ print "{0}: {1}k".format(f, int(len(minified) / 1024))
elif outtype=="js" and extn=="html":
# add to frappe.templates
content = data.replace("\n", " ").replace("'", "\'")
diff --git a/frappe/cli.py b/frappe/cli.py
index ce4ebef3c2..73d8113dda 100755
--- a/frappe/cli.py
+++ b/frappe/cli.py
@@ -464,10 +464,10 @@ def reload_doc(module, doctype, docname, force=False):
frappe.destroy()
@cmd
-def build(make_copy=False):
+def build(make_copy=False, verbose=False):
import frappe.build
import frappe
- frappe.build.bundle(False, make_copy=make_copy)
+ frappe.build.bundle(False, make_copy=make_copy, verbose=verbose)
@cmd
def watch():
diff --git a/frappe/public/build.json b/frappe/public/build.json
index d0294f896a..3fdab1d5c5 100644
--- a/frappe/public/build.json
+++ b/frappe/public/build.json
@@ -74,7 +74,6 @@
"public/js/legacy/datatype.js",
"public/js/legacy/dom.js",
"public/js/legacy/handler.js",
- "public/js/legacy/printElement.js",
"public/js/legacy/loaders.js",
"public/js/frappe/ui/appframe.js",
@@ -120,8 +119,6 @@
"public/js/frappe/views/test_runner.js",
"public/js/frappe/form/formatters.js",
- "public/js/legacy/layout.js",
-
"public/js/frappe/ui/toolbar/selector_dialog.js",
"public/js/frappe/ui/toolbar/new.js",
"public/js/frappe/ui/toolbar/search.js",
@@ -133,7 +130,6 @@
"public/js/frappe/ui/editor.js",
"public/js/legacy/form.js",
- "public/js/legacy/print_format.js",
"public/js/legacy/clientscriptAPI.js",
"public/js/frappe/form/toolbar.js",
@@ -150,8 +146,12 @@
"public/js/frappe/form/linked_with.js",
"public/js/frappe/form/workflow.js",
"public/js/frappe/form/assign_to.js",
- "public/js/frappe/form/print.js",
- "public/js/frappe/print/print_table.js"
+ "public/js/frappe/form/print.js"
+ ],
+ "js/print_format_v3.min.js": [
+ "public/js/legacy/layout.js",
+ "public/js/legacy/print_table.js",
+ "public/js/legacy/print_format.js"
],
"js/slickgrid.min.js": [
"public/js/lib/slickgrid/jquery.event.drag.js",
diff --git a/frappe/public/js/frappe/form/print.js b/frappe/public/js/frappe/form/print.js
index 863e043601..f23e072592 100644
--- a/frappe/public/js/frappe/form/print.js
+++ b/frappe/public/js/frappe/form/print.js
@@ -103,6 +103,7 @@ frappe.ui.form.PrintPreview = Class.extend({
},
preview_old_style: function() {
var me = this;
+ frappe.require("/assets/js/print_format_v3.min.js");
_p.build(me.print_sel.val(), function(html) {
me.wrapper.find(".print-format").html('
'
+__("Warning: This Print Format is in old style and cannot be generated via the API.")
@@ -111,10 +112,12 @@ frappe.ui.form.PrintPreview = Class.extend({
}, !this.with_letterhead(), true, true);
},
print_old_style: function() {
+ frappe.require("/assets/js/print_format_v3.min.js");
_p.build(this.print_sel.val(), _p.go,
!this.with_letterhead());
},
new_page_preview_old_style: function() {
+ frappe.require("/assets/js/print_format_v3.min.js");
_p.build(this.print_sel.val(), _p.preview,
!this.with_letterhead());
},
diff --git a/frappe/public/js/legacy/printElement.js b/frappe/public/js/legacy/printElement.js
deleted file mode 100644
index f38b7547a2..0000000000
--- a/frappe/public/js/legacy/printElement.js
+++ /dev/null
@@ -1,133 +0,0 @@
-///
-/*
-* Print Element Plugin 1.2
-*
-* Copyright (c) 2010 Erik Zaadi
-*
-* Inspired by PrintArea (http://plugins.jquery.com/project/PrintArea) and
-* http://stackoverflow.com/questions/472951/how-do-i-print-an-iframe-from-javascript-in-safari-chrome
-*
-* Home Page : http://projects.erikzaadi/jQueryPlugins/jQuery.printElement
-* Issues (bug reporting) : http://github.com/erikzaadi/jQueryPlugins/issues/labels/printElement
-* jQuery plugin page : http://plugins.jquery.com/project/printElement
-*
-* Thanks to David B (http://github.com/ungenio) and icgJohn (http://www.blogger.com/profile/11881116857076484100)
-* For their great contributions!
-*
-* Dual licensed under the MIT and GPL licenses:
-* http://www.opensource.org/licenses/mit-license.php
-* http://www.gnu.org/licenses/gpl.html
-*
-* Note, Iframe Printing is not supported in Opera and Chrome 3.0, a popup window will be shown instead
-*/
-; (function (window, undefined) {
- var document = window["document"];
- var $ = window["jQuery"];
- $.fn["printElement"] = function (options) {
- var mainOptions = $.extend({}, $.fn["printElement"]["defaults"], options);
- //Remove previously printed iframe if exists
- $("[id^='printElement_']").remove();
-
- return this.each(function () {
- //Support Metadata Plug-in if available
- var opts = $.meta ? $.extend({}, mainOptions, $(this).data()) : mainOptions;
- _printElement($(this), opts);
- });
- };
- $.fn["printElement"]["defaults"] = {
- "printMode": 'iframe', //Usage : iframe / popup
- "pageTitle": '', //Print Page Title
- "overrideElementCSS": null,
- /* Can be one of the following 3 options:
-* 1 : boolean (pass true for stripping all css linked)
-* 2 : array of $.fn.printElement.cssElement (s)
-* 3 : array of strings with paths to alternate css files (optimized for print)
-*/
- "printBodyOptions": {
- "styleToAdd": 'padding:10px;margin:10px;', //style attributes to add to the body of print document
- "classNameToAdd": '' //css class to add to the body of print document
- },
- "leaveOpen": false, // in case of popup, leave the print page open or not
- "iframeElementOptions": {
- "styleToAdd": 'border:none;position:absolute;width:0px;height:0px;bottom:0px;left:0px;', //style attributes to add to the iframe element
- "classNameToAdd": '' //css class to add to the iframe element
- }
- };
- $.fn["printElement"]["cssElement"] = {
- "href": '',
- "media": ''
- };
- function _printElement(element, opts) {
- //Create markup to be printed
- var html = _getMarkup(element, opts);
-
- var popupOrIframe = null;
- var documentToWriteTo = null;
- if (opts["printMode"].toLowerCase() == 'popup') {
- popupOrIframe = window.open('about:blank', 'printElementWindow', 'width=650,height=440,scrollbars=yes');
- documentToWriteTo = popupOrIframe.document;
- }
- else {
- //The random ID is to overcome a safari bug http://www.cjboco.com.sharedcopy.com/post.cfm/442dc92cd1c0ca10a5c35210b8166882.html
- var printElementID = "printElement_" + (Math.round(Math.random() * 99999)).toString();
- //Native creation of the element is faster..
- var iframe = document.createElement('IFRAME');
- $(iframe).attr({
- style: opts["iframeElementOptions"]["styleToAdd"],
- id: printElementID,
- className: opts["iframeElementOptions"]["classNameToAdd"],
- frameBorder: 0,
- scrolling: 'no',
- src: 'about:blank'
- });
- document.body.appendChild(iframe);
- documentToWriteTo = (iframe.contentWindow || iframe.contentDocument);
- if (documentToWriteTo.document)
- documentToWriteTo = documentToWriteTo.document;
- iframe = document.frames ? document.frames[printElementID] : document.getElementById(printElementID);
- popupOrIframe = iframe.contentWindow || iframe;
- }
- focus();
- documentToWriteTo.open();
- documentToWriteTo.write(html);
- documentToWriteTo.close();
- _callPrint(popupOrIframe);
- };
-
- function _callPrint(element) {
- if (element && element["printPage"])
- element["printPage"]();
- else
- setTimeout(function () {
- _callPrint(element);
- }, 50);
- }
-
- function _getElementHTMLIncludingFormElements(element) {
- var $element = $(element);
- var elementHtml = $('
').append($element.clone()).html();
- return elementHtml;
- }
-
- function _getBaseHref() {
- var port = (window.location.port) ? ':' + window.location.port : '';
- return window.location.protocol + '//' + window.location.hostname + port + window.location.pathname;
- }
-
- function _getMarkup(element, opts) {
- var $element = $(element);
- var elementHtml = _getElementHTMLIncludingFormElements(element);
-
- var html = new Array();
- html.push('
' + opts["pageTitle"] + '');
- //Ensure that relative links work
- html.push('
');
- html.push('');
- html.push('
' + elementHtml + '
');
- html.push('');
- html.push('');
-
- return html.join('');
- };
-})(window);
\ No newline at end of file
diff --git a/frappe/public/js/frappe/print/print_table.js b/frappe/public/js/legacy/print_table.js
similarity index 94%
rename from frappe/public/js/frappe/print/print_table.js
rename to frappe/public/js/legacy/print_table.js
index ccc88c3b47..d6d7d0578c 100644
--- a/frappe/public/js/frappe/print/print_table.js
+++ b/frappe/public/js/legacy/print_table.js
@@ -1,16 +1,4 @@
-// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
-// MIT License. See license.txt
-
-frappe.provide("frappe.print");
-
-// opts:
-// doctype (parent)
-// docname
-// tabletype
-// fieldname
-// show_all = false;
-
-frappe.print.Table = Class.extend({
+frappe.printTable = Class.extend({
init: function(opts) {
$.extend(this, opts);
if(!this.columns)
@@ -205,7 +193,7 @@ frappe.print.Table = Class.extend({
})
function print_table(dt, dn, fieldname, tabletype, cols, head_labels, widths, condition, cssClass, modifier) {
- return new frappe.print.Table({
+ return new frappe.printTable({
doctype: dt,
docname: dn,
fieldname: fieldname,