From e6ee4150c1b205280126b2359f7481de5ad4a445 Mon Sep 17 00:00:00 2001 From: sigitas Date: Mon, 13 Apr 2015 09:02:33 +0300 Subject: [PATCH] initial template --- bower.json | 2 +- public/css/built.css | 31 +- public/css/built.public.css | 31 +- public/js/built.js | 402 +++++++++++++++--------- public/js/pdf.pdfmake.js | 106 +++++++ public/js/script.js | 14 +- public/js/templates/clean.js | 73 +++++ resources/views/invoices/edit.blade.php | 6 +- resources/views/invoices/pdf.blade.php | 11 +- 9 files changed, 469 insertions(+), 207 deletions(-) create mode 100644 public/js/templates/clean.js diff --git a/bower.json b/bower.json index a6587cac4fff..2070837878c7 100644 --- a/bower.json +++ b/bower.json @@ -5,7 +5,7 @@ "jquery": "~1.11", "bootstrap": "~3.*", "jquery-ui": "~1.*", - "datatables": "~1.*", + "datatables": "1.10.5", "datatables-bootstrap3": "*", "knockout.js": "~3.*", "knockout-mapping": "*", diff --git a/public/css/built.css b/public/css/built.css index 2a5178f4a6fc..f3ee1192a763 100644 --- a/public/css/built.css +++ b/public/css/built.css @@ -37,34 +37,26 @@ table.dataTable tfoot td { padding: 10px 18px 6px 18px; border-top: 1px solid #111111; } -table.dataTable thead .sorting, table.dataTable thead .sorting_asc, -table.dataTable thead .sorting_desc { +table.dataTable thead .sorting_desc, +table.dataTable thead .sorting { cursor: pointer; *cursor: hand; } -table.dataTable thead .sorting, -table.dataTable thead .sorting_asc, -table.dataTable thead .sorting_desc, -table.dataTable thead .sorting_asc_disabled, -table.dataTable thead .sorting_desc_disabled { - background-repeat: no-repeat; - background-position: center right; -} table.dataTable thead .sorting { - background-image: url("../images/sort_both.png"); + background: url("../images/sort_both.png") no-repeat center right; } table.dataTable thead .sorting_asc { - background-image: url("../images/sort_asc.png"); + background: url("../images/sort_asc.png") no-repeat center right; } table.dataTable thead .sorting_desc { - background-image: url("../images/sort_desc.png"); + background: url("../images/sort_desc.png") no-repeat center right; } table.dataTable thead .sorting_asc_disabled { - background-image: url("../images/sort_asc_disabled.png"); + background: url("../images/sort_asc_disabled.png") no-repeat center right; } table.dataTable thead .sorting_desc_disabled { - background-image: url("../images/sort_desc_disabled.png"); + background: url("../images/sort_desc_disabled.png") no-repeat center right; } table.dataTable tbody tr { background-color: white; @@ -216,15 +208,15 @@ table.dataTable.nowrap th, table.dataTable.nowrap td { } table.dataTable.compact thead th, table.dataTable.compact thead td { - padding: 4px 17px 4px 4px; + padding: 5px 9px; } table.dataTable.compact tfoot th, table.dataTable.compact tfoot td { - padding: 4px; + padding: 5px 9px 3px 9px; } table.dataTable.compact tbody th, table.dataTable.compact tbody td { - padding: 4px; + padding: 4px 5px; } table.dataTable th.dt-left, table.dataTable td.dt-left { @@ -406,9 +398,6 @@ table.dataTable td { /* W3C */ box-shadow: inset 0 0 3px #111; } -.dataTables_wrapper .dataTables_paginate .ellipsis { - padding: 0 1em; -} .dataTables_wrapper .dataTables_processing { position: absolute; top: 50%; diff --git a/public/css/built.public.css b/public/css/built.public.css index 6fe6d83190ea..69a38fb189ad 100644 --- a/public/css/built.public.css +++ b/public/css/built.public.css @@ -37,34 +37,26 @@ table.dataTable tfoot td { padding: 10px 18px 6px 18px; border-top: 1px solid #111111; } -table.dataTable thead .sorting, table.dataTable thead .sorting_asc, -table.dataTable thead .sorting_desc { +table.dataTable thead .sorting_desc, +table.dataTable thead .sorting { cursor: pointer; *cursor: hand; } -table.dataTable thead .sorting, -table.dataTable thead .sorting_asc, -table.dataTable thead .sorting_desc, -table.dataTable thead .sorting_asc_disabled, -table.dataTable thead .sorting_desc_disabled { - background-repeat: no-repeat; - background-position: center right; -} table.dataTable thead .sorting { - background-image: url("../images/sort_both.png"); + background: url("../images/sort_both.png") no-repeat center right; } table.dataTable thead .sorting_asc { - background-image: url("../images/sort_asc.png"); + background: url("../images/sort_asc.png") no-repeat center right; } table.dataTable thead .sorting_desc { - background-image: url("../images/sort_desc.png"); + background: url("../images/sort_desc.png") no-repeat center right; } table.dataTable thead .sorting_asc_disabled { - background-image: url("../images/sort_asc_disabled.png"); + background: url("../images/sort_asc_disabled.png") no-repeat center right; } table.dataTable thead .sorting_desc_disabled { - background-image: url("../images/sort_desc_disabled.png"); + background: url("../images/sort_desc_disabled.png") no-repeat center right; } table.dataTable tbody tr { background-color: white; @@ -216,15 +208,15 @@ table.dataTable.nowrap th, table.dataTable.nowrap td { } table.dataTable.compact thead th, table.dataTable.compact thead td { - padding: 4px 17px 4px 4px; + padding: 5px 9px; } table.dataTable.compact tfoot th, table.dataTable.compact tfoot td { - padding: 4px; + padding: 5px 9px 3px 9px; } table.dataTable.compact tbody th, table.dataTable.compact tbody td { - padding: 4px; + padding: 4px 5px; } table.dataTable th.dt-left, table.dataTable td.dt-left { @@ -406,9 +398,6 @@ table.dataTable td { /* W3C */ box-shadow: inset 0 0 3px #111; } -.dataTables_wrapper .dataTables_paginate .ellipsis { - padding: 0 1em; -} .dataTables_wrapper .dataTables_processing { position: absolute; top: 50%; diff --git a/public/js/built.js b/public/js/built.js index c94563f39bce..b3f5d74d703e 100644 --- a/public/js/built.js +++ b/public/js/built.js @@ -10365,14 +10365,14 @@ this.tablist=this._getList().addClass("ui-tabs-nav ui-helper-reset ui-helper-cle */ if("undefined"==typeof jQuery)throw new Error("Bootstrap's JavaScript requires jQuery");+function(a){"use strict";var b=a.fn.jquery.split(" ")[0].split(".");if(b[0]<2&&b[1]<9||1==b[0]&&9==b[1]&&b[2]<1)throw new Error("Bootstrap's JavaScript requires jQuery version 1.9.1 or higher")}(jQuery),+function(a){"use strict";function b(){var a=document.createElement("bootstrap"),b={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var c in b)if(void 0!==a.style[c])return{end:b[c]};return!1}a.fn.emulateTransitionEnd=function(b){var c=!1,d=this;a(this).one("bsTransitionEnd",function(){c=!0});var e=function(){c||a(d).trigger(a.support.transition.end)};return setTimeout(e,b),this},a(function(){a.support.transition=b(),a.support.transition&&(a.event.special.bsTransitionEnd={bindType:a.support.transition.end,delegateType:a.support.transition.end,handle:function(b){return a(b.target).is(this)?b.handleObj.handler.apply(this,arguments):void 0}})})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var c=a(this),e=c.data("bs.alert");e||c.data("bs.alert",e=new d(this)),"string"==typeof b&&e[b].call(c)})}var c='[data-dismiss="alert"]',d=function(b){a(b).on("click",c,this.close)};d.VERSION="3.3.4",d.TRANSITION_DURATION=150,d.prototype.close=function(b){function c(){g.detach().trigger("closed.bs.alert").remove()}var e=a(this),f=e.attr("data-target");f||(f=e.attr("href"),f=f&&f.replace(/.*(?=#[^\s]*$)/,""));var g=a(f);b&&b.preventDefault(),g.length||(g=e.closest(".alert")),g.trigger(b=a.Event("close.bs.alert")),b.isDefaultPrevented()||(g.removeClass("in"),a.support.transition&&g.hasClass("fade")?g.one("bsTransitionEnd",c).emulateTransitionEnd(d.TRANSITION_DURATION):c())};var e=a.fn.alert;a.fn.alert=b,a.fn.alert.Constructor=d,a.fn.alert.noConflict=function(){return a.fn.alert=e,this},a(document).on("click.bs.alert.data-api",c,d.prototype.close)}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.button"),f="object"==typeof b&&b;e||d.data("bs.button",e=new c(this,f)),"toggle"==b?e.toggle():b&&e.setState(b)})}var c=function(b,d){this.$element=a(b),this.options=a.extend({},c.DEFAULTS,d),this.isLoading=!1};c.VERSION="3.3.4",c.DEFAULTS={loadingText:"loading..."},c.prototype.setState=function(b){var c="disabled",d=this.$element,e=d.is("input")?"val":"html",f=d.data();b+="Text",null==f.resetText&&d.data("resetText",d[e]()),setTimeout(a.proxy(function(){d[e](null==f[b]?this.options[b]:f[b]),"loadingText"==b?(this.isLoading=!0,d.addClass(c).attr(c,c)):this.isLoading&&(this.isLoading=!1,d.removeClass(c).removeAttr(c))},this),0)},c.prototype.toggle=function(){var a=!0,b=this.$element.closest('[data-toggle="buttons"]');if(b.length){var c=this.$element.find("input");"radio"==c.prop("type")&&(c.prop("checked")&&this.$element.hasClass("active")?a=!1:b.find(".active").removeClass("active")),a&&c.prop("checked",!this.$element.hasClass("active")).trigger("change")}else this.$element.attr("aria-pressed",!this.$element.hasClass("active"));a&&this.$element.toggleClass("active")};var d=a.fn.button;a.fn.button=b,a.fn.button.Constructor=c,a.fn.button.noConflict=function(){return a.fn.button=d,this},a(document).on("click.bs.button.data-api",'[data-toggle^="button"]',function(c){var d=a(c.target);d.hasClass("btn")||(d=d.closest(".btn")),b.call(d,"toggle"),c.preventDefault()}).on("focus.bs.button.data-api blur.bs.button.data-api",'[data-toggle^="button"]',function(b){a(b.target).closest(".btn").toggleClass("focus",/^focus(in)?$/.test(b.type))})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.carousel"),f=a.extend({},c.DEFAULTS,d.data(),"object"==typeof b&&b),g="string"==typeof b?b:f.slide;e||d.data("bs.carousel",e=new c(this,f)),"number"==typeof b?e.to(b):g?e[g]():f.interval&&e.pause().cycle()})}var c=function(b,c){this.$element=a(b),this.$indicators=this.$element.find(".carousel-indicators"),this.options=c,this.paused=null,this.sliding=null,this.interval=null,this.$active=null,this.$items=null,this.options.keyboard&&this.$element.on("keydown.bs.carousel",a.proxy(this.keydown,this)),"hover"==this.options.pause&&!("ontouchstart"in document.documentElement)&&this.$element.on("mouseenter.bs.carousel",a.proxy(this.pause,this)).on("mouseleave.bs.carousel",a.proxy(this.cycle,this))};c.VERSION="3.3.4",c.TRANSITION_DURATION=600,c.DEFAULTS={interval:5e3,pause:"hover",wrap:!0,keyboard:!0},c.prototype.keydown=function(a){if(!/input|textarea/i.test(a.target.tagName)){switch(a.which){case 37:this.prev();break;case 39:this.next();break;default:return}a.preventDefault()}},c.prototype.cycle=function(b){return b||(this.paused=!1),this.interval&&clearInterval(this.interval),this.options.interval&&!this.paused&&(this.interval=setInterval(a.proxy(this.next,this),this.options.interval)),this},c.prototype.getItemIndex=function(a){return this.$items=a.parent().children(".item"),this.$items.index(a||this.$active)},c.prototype.getItemForDirection=function(a,b){var c=this.getItemIndex(b),d="prev"==a&&0===c||"next"==a&&c==this.$items.length-1;if(d&&!this.options.wrap)return b;var e="prev"==a?-1:1,f=(c+e)%this.$items.length;return this.$items.eq(f)},c.prototype.to=function(a){var b=this,c=this.getItemIndex(this.$active=this.$element.find(".item.active"));return a>this.$items.length-1||0>a?void 0:this.sliding?this.$element.one("slid.bs.carousel",function(){b.to(a)}):c==a?this.pause().cycle():this.slide(a>c?"next":"prev",this.$items.eq(a))},c.prototype.pause=function(b){return b||(this.paused=!0),this.$element.find(".next, .prev").length&&a.support.transition&&(this.$element.trigger(a.support.transition.end),this.cycle(!0)),this.interval=clearInterval(this.interval),this},c.prototype.next=function(){return this.sliding?void 0:this.slide("next")},c.prototype.prev=function(){return this.sliding?void 0:this.slide("prev")},c.prototype.slide=function(b,d){var e=this.$element.find(".item.active"),f=d||this.getItemForDirection(b,e),g=this.interval,h="next"==b?"left":"right",i=this;if(f.hasClass("active"))return this.sliding=!1;var j=f[0],k=a.Event("slide.bs.carousel",{relatedTarget:j,direction:h});if(this.$element.trigger(k),!k.isDefaultPrevented()){if(this.sliding=!0,g&&this.pause(),this.$indicators.length){this.$indicators.find(".active").removeClass("active");var l=a(this.$indicators.children()[this.getItemIndex(f)]);l&&l.addClass("active")}var m=a.Event("slid.bs.carousel",{relatedTarget:j,direction:h});return a.support.transition&&this.$element.hasClass("slide")?(f.addClass(b),f[0].offsetWidth,e.addClass(h),f.addClass(h),e.one("bsTransitionEnd",function(){f.removeClass([b,h].join(" ")).addClass("active"),e.removeClass(["active",h].join(" ")),i.sliding=!1,setTimeout(function(){i.$element.trigger(m)},0)}).emulateTransitionEnd(c.TRANSITION_DURATION)):(e.removeClass("active"),f.addClass("active"),this.sliding=!1,this.$element.trigger(m)),g&&this.cycle(),this}};var d=a.fn.carousel;a.fn.carousel=b,a.fn.carousel.Constructor=c,a.fn.carousel.noConflict=function(){return a.fn.carousel=d,this};var e=function(c){var d,e=a(this),f=a(e.attr("data-target")||(d=e.attr("href"))&&d.replace(/.*(?=#[^\s]+$)/,""));if(f.hasClass("carousel")){var g=a.extend({},f.data(),e.data()),h=e.attr("data-slide-to");h&&(g.interval=!1),b.call(f,g),h&&f.data("bs.carousel").to(h),c.preventDefault()}};a(document).on("click.bs.carousel.data-api","[data-slide]",e).on("click.bs.carousel.data-api","[data-slide-to]",e),a(window).on("load",function(){a('[data-ride="carousel"]').each(function(){var c=a(this);b.call(c,c.data())})})}(jQuery),+function(a){"use strict";function b(b){var c,d=b.attr("data-target")||(c=b.attr("href"))&&c.replace(/.*(?=#[^\s]+$)/,"");return a(d)}function c(b){return this.each(function(){var c=a(this),e=c.data("bs.collapse"),f=a.extend({},d.DEFAULTS,c.data(),"object"==typeof b&&b);!e&&f.toggle&&/show|hide/.test(b)&&(f.toggle=!1),e||c.data("bs.collapse",e=new d(this,f)),"string"==typeof b&&e[b]()})}var d=function(b,c){this.$element=a(b),this.options=a.extend({},d.DEFAULTS,c),this.$trigger=a('[data-toggle="collapse"][href="#'+b.id+'"],[data-toggle="collapse"][data-target="#'+b.id+'"]'),this.transitioning=null,this.options.parent?this.$parent=this.getParent():this.addAriaAndCollapsedClass(this.$element,this.$trigger),this.options.toggle&&this.toggle()};d.VERSION="3.3.4",d.TRANSITION_DURATION=350,d.DEFAULTS={toggle:!0},d.prototype.dimension=function(){var a=this.$element.hasClass("width");return a?"width":"height"},d.prototype.show=function(){if(!this.transitioning&&!this.$element.hasClass("in")){var b,e=this.$parent&&this.$parent.children(".panel").children(".in, .collapsing");if(!(e&&e.length&&(b=e.data("bs.collapse"),b&&b.transitioning))){var f=a.Event("show.bs.collapse");if(this.$element.trigger(f),!f.isDefaultPrevented()){e&&e.length&&(c.call(e,"hide"),b||e.data("bs.collapse",null));var g=this.dimension();this.$element.removeClass("collapse").addClass("collapsing")[g](0).attr("aria-expanded",!0),this.$trigger.removeClass("collapsed").attr("aria-expanded",!0),this.transitioning=1;var h=function(){this.$element.removeClass("collapsing").addClass("collapse in")[g](""),this.transitioning=0,this.$element.trigger("shown.bs.collapse")};if(!a.support.transition)return h.call(this);var i=a.camelCase(["scroll",g].join("-"));this.$element.one("bsTransitionEnd",a.proxy(h,this)).emulateTransitionEnd(d.TRANSITION_DURATION)[g](this.$element[0][i])}}}},d.prototype.hide=function(){if(!this.transitioning&&this.$element.hasClass("in")){var b=a.Event("hide.bs.collapse");if(this.$element.trigger(b),!b.isDefaultPrevented()){var c=this.dimension();this.$element[c](this.$element[c]())[0].offsetHeight,this.$element.addClass("collapsing").removeClass("collapse in").attr("aria-expanded",!1),this.$trigger.addClass("collapsed").attr("aria-expanded",!1),this.transitioning=1;var e=function(){this.transitioning=0,this.$element.removeClass("collapsing").addClass("collapse").trigger("hidden.bs.collapse")};return a.support.transition?void this.$element[c](0).one("bsTransitionEnd",a.proxy(e,this)).emulateTransitionEnd(d.TRANSITION_DURATION):e.call(this)}}},d.prototype.toggle=function(){this[this.$element.hasClass("in")?"hide":"show"]()},d.prototype.getParent=function(){return a(this.options.parent).find('[data-toggle="collapse"][data-parent="'+this.options.parent+'"]').each(a.proxy(function(c,d){var e=a(d);this.addAriaAndCollapsedClass(b(e),e)},this)).end()},d.prototype.addAriaAndCollapsedClass=function(a,b){var c=a.hasClass("in");a.attr("aria-expanded",c),b.toggleClass("collapsed",!c).attr("aria-expanded",c)};var e=a.fn.collapse;a.fn.collapse=c,a.fn.collapse.Constructor=d,a.fn.collapse.noConflict=function(){return a.fn.collapse=e,this},a(document).on("click.bs.collapse.data-api",'[data-toggle="collapse"]',function(d){var e=a(this);e.attr("data-target")||d.preventDefault();var f=b(e),g=f.data("bs.collapse"),h=g?"toggle":e.data();c.call(f,h)})}(jQuery),+function(a){"use strict";function b(b){b&&3===b.which||(a(e).remove(),a(f).each(function(){var d=a(this),e=c(d),f={relatedTarget:this};e.hasClass("open")&&(e.trigger(b=a.Event("hide.bs.dropdown",f)),b.isDefaultPrevented()||(d.attr("aria-expanded","false"),e.removeClass("open").trigger("hidden.bs.dropdown",f)))}))}function c(b){var c=b.attr("data-target");c||(c=b.attr("href"),c=c&&/#[A-Za-z]/.test(c)&&c.replace(/.*(?=#[^\s]*$)/,""));var d=c&&a(c);return d&&d.length?d:b.parent()}function d(b){return this.each(function(){var c=a(this),d=c.data("bs.dropdown");d||c.data("bs.dropdown",d=new g(this)),"string"==typeof b&&d[b].call(c)})}var e=".dropdown-backdrop",f='[data-toggle="dropdown"]',g=function(b){a(b).on("click.bs.dropdown",this.toggle)};g.VERSION="3.3.4",g.prototype.toggle=function(d){var e=a(this);if(!e.is(".disabled, :disabled")){var f=c(e),g=f.hasClass("open");if(b(),!g){"ontouchstart"in document.documentElement&&!f.closest(".navbar-nav").length&&a('',trigger:"hover focus",title:"",delay:0,html:!1,container:!1,viewport:{selector:"body",padding:0}},c.prototype.init=function(b,c,d){if(this.enabled=!0,this.type=b,this.$element=a(c),this.options=this.getOptions(d),this.$viewport=this.options.viewport&&a(this.options.viewport.selector||this.options.viewport),this.$element[0]instanceof document.constructor&&!this.options.selector)throw new Error("`selector` option must be specified when initializing "+this.type+" on the window.document object!");for(var e=this.options.trigger.split(" "),f=e.length;f--;){var g=e[f];if("click"==g)this.$element.on("click."+this.type,this.options.selector,a.proxy(this.toggle,this));else if("manual"!=g){var h="hover"==g?"mouseenter":"focusin",i="hover"==g?"mouseleave":"focusout";this.$element.on(h+"."+this.type,this.options.selector,a.proxy(this.enter,this)),this.$element.on(i+"."+this.type,this.options.selector,a.proxy(this.leave,this))}}this.options.selector?this._options=a.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},c.prototype.getDefaults=function(){return c.DEFAULTS},c.prototype.getOptions=function(b){return b=a.extend({},this.getDefaults(),this.$element.data(),b),b.delay&&"number"==typeof b.delay&&(b.delay={show:b.delay,hide:b.delay}),b},c.prototype.getDelegateOptions=function(){var b={},c=this.getDefaults();return this._options&&a.each(this._options,function(a,d){c[a]!=d&&(b[a]=d)}),b},c.prototype.enter=function(b){var c=b instanceof this.constructor?b:a(b.currentTarget).data("bs."+this.type);return c&&c.$tip&&c.$tip.is(":visible")?void(c.hoverState="in"):(c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c)),clearTimeout(c.timeout),c.hoverState="in",c.options.delay&&c.options.delay.show?void(c.timeout=setTimeout(function(){"in"==c.hoverState&&c.show()},c.options.delay.show)):c.show())},c.prototype.leave=function(b){var c=b instanceof this.constructor?b:a(b.currentTarget).data("bs."+this.type);return c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c)),clearTimeout(c.timeout),c.hoverState="out",c.options.delay&&c.options.delay.hide?void(c.timeout=setTimeout(function(){"out"==c.hoverState&&c.hide()},c.options.delay.hide)):c.hide()},c.prototype.show=function(){var b=a.Event("show.bs."+this.type);if(this.hasContent()&&this.enabled){this.$element.trigger(b);var d=a.contains(this.$element[0].ownerDocument.documentElement,this.$element[0]);if(b.isDefaultPrevented()||!d)return;var e=this,f=this.tip(),g=this.getUID(this.type);this.setContent(),f.attr("id",g),this.$element.attr("aria-describedby",g),this.options.animation&&f.addClass("fade");var h="function"==typeof this.options.placement?this.options.placement.call(this,f[0],this.$element[0]):this.options.placement,i=/\s?auto?\s?/i,j=i.test(h);j&&(h=h.replace(i,"")||"top"),f.detach().css({top:0,left:0,display:"block"}).addClass(h).data("bs."+this.type,this),this.options.container?f.appendTo(this.options.container):f.insertAfter(this.$element);var k=this.getPosition(),l=f[0].offsetWidth,m=f[0].offsetHeight;if(j){var n=h,o=this.options.container?a(this.options.container):this.$element.parent(),p=this.getPosition(o);h="bottom"==h&&k.bottom+m>p.bottom?"top":"top"==h&&k.top-mp.width?"left":"left"==h&&k.left-lg.top+g.height&&(e.top=g.top+g.height-i)}else{var j=b.left-f,k=b.left+f+c;jg.width&&(e.left=g.left+g.width-k)}return e},c.prototype.getTitle=function(){var a,b=this.$element,c=this.options;return a=b.attr("data-original-title")||("function"==typeof c.title?c.title.call(b[0]):c.title)},c.prototype.getUID=function(a){do a+=~~(1e6*Math.random());while(document.getElementById(a));return a},c.prototype.tip=function(){return this.$tip=this.$tip||a(this.options.template)},c.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".tooltip-arrow")},c.prototype.enable=function(){this.enabled=!0},c.prototype.disable=function(){this.enabled=!1},c.prototype.toggleEnabled=function(){this.enabled=!this.enabled},c.prototype.toggle=function(b){var c=this;b&&(c=a(b.currentTarget).data("bs."+this.type),c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c))),c.tip().hasClass("in")?c.leave(c):c.enter(c)},c.prototype.destroy=function(){var a=this;clearTimeout(this.timeout),this.hide(function(){a.$element.off("."+a.type).removeData("bs."+a.type)})};var d=a.fn.tooltip;a.fn.tooltip=b,a.fn.tooltip.Constructor=c,a.fn.tooltip.noConflict=function(){return a.fn.tooltip=d,this}}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.popover"),f="object"==typeof b&&b;(e||!/destroy|hide/.test(b))&&(e||d.data("bs.popover",e=new c(this,f)),"string"==typeof b&&e[b]())})}var c=function(a,b){this.init("popover",a,b)};if(!a.fn.tooltip)throw new Error("Popover requires tooltip.js");c.VERSION="3.3.4",c.DEFAULTS=a.extend({},a.fn.tooltip.Constructor.DEFAULTS,{placement:"right",trigger:"click",content:"",template:''}),c.prototype=a.extend({},a.fn.tooltip.Constructor.prototype),c.prototype.constructor=c,c.prototype.getDefaults=function(){return c.DEFAULTS},c.prototype.setContent=function(){var a=this.tip(),b=this.getTitle(),c=this.getContent();a.find(".popover-title")[this.options.html?"html":"text"](b),a.find(".popover-content").children().detach().end()[this.options.html?"string"==typeof c?"html":"append":"text"](c),a.removeClass("fade top bottom left right in"),a.find(".popover-title").html()||a.find(".popover-title").hide()},c.prototype.hasContent=function(){return this.getTitle()||this.getContent()},c.prototype.getContent=function(){var a=this.$element,b=this.options;return a.attr("data-content")||("function"==typeof b.content?b.content.call(a[0]):b.content)},c.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".arrow")};var d=a.fn.popover;a.fn.popover=b,a.fn.popover.Constructor=c,a.fn.popover.noConflict=function(){return a.fn.popover=d,this}}(jQuery),+function(a){"use strict";function b(c,d){this.$body=a(document.body),this.$scrollElement=a(a(c).is(document.body)?window:c),this.options=a.extend({},b.DEFAULTS,d),this.selector=(this.options.target||"")+" .nav li > a",this.offsets=[],this.targets=[],this.activeTarget=null,this.scrollHeight=0,this.$scrollElement.on("scroll.bs.scrollspy",a.proxy(this.process,this)),this.refresh(),this.process()}function c(c){return this.each(function(){var d=a(this),e=d.data("bs.scrollspy"),f="object"==typeof c&&c;e||d.data("bs.scrollspy",e=new b(this,f)),"string"==typeof c&&e[c]()})}b.VERSION="3.3.4",b.DEFAULTS={offset:10},b.prototype.getScrollHeight=function(){return this.$scrollElement[0].scrollHeight||Math.max(this.$body[0].scrollHeight,document.documentElement.scrollHeight)},b.prototype.refresh=function(){var b=this,c="offset",d=0;this.offsets=[],this.targets=[],this.scrollHeight=this.getScrollHeight(),a.isWindow(this.$scrollElement[0])||(c="position",d=this.$scrollElement.scrollTop()),this.$body.find(this.selector).map(function(){var b=a(this),e=b.data("target")||b.attr("href"),f=/^#./.test(e)&&a(e);return f&&f.length&&f.is(":visible")&&[[f[c]().top+d,e]]||null}).sort(function(a,b){return a[0]-b[0]}).each(function(){b.offsets.push(this[0]),b.targets.push(this[1])})},b.prototype.process=function(){var a,b=this.$scrollElement.scrollTop()+this.options.offset,c=this.getScrollHeight(),d=this.options.offset+c-this.$scrollElement.height(),e=this.offsets,f=this.targets,g=this.activeTarget;if(this.scrollHeight!=c&&this.refresh(),b>=d)return g!=(a=f[f.length-1])&&this.activate(a);if(g&&b=e[a]&&(void 0===e[a+1]||b .dropdown-menu > .active").removeClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!1),b.addClass("active").find('[data-toggle="tab"]').attr("aria-expanded",!0),h?(b[0].offsetWidth,b.addClass("in")):b.removeClass("fade"),b.parent(".dropdown-menu").length&&b.closest("li.dropdown").addClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!0),e&&e()}var g=d.find("> .active"),h=e&&a.support.transition&&(g.length&&g.hasClass("fade")||!!d.find("> .fade").length);g.length&&h?g.one("bsTransitionEnd",f).emulateTransitionEnd(c.TRANSITION_DURATION):f(),g.removeClass("in")};var d=a.fn.tab;a.fn.tab=b,a.fn.tab.Constructor=c,a.fn.tab.noConflict=function(){return a.fn.tab=d,this};var e=function(c){c.preventDefault(),b.call(a(this),"show")};a(document).on("click.bs.tab.data-api",'[data-toggle="tab"]',e).on("click.bs.tab.data-api",'[data-toggle="pill"]',e)}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.affix"),f="object"==typeof b&&b;e||d.data("bs.affix",e=new c(this,f)),"string"==typeof b&&e[b]()})}var c=function(b,d){this.options=a.extend({},c.DEFAULTS,d),this.$target=a(this.options.target).on("scroll.bs.affix.data-api",a.proxy(this.checkPosition,this)).on("click.bs.affix.data-api",a.proxy(this.checkPositionWithEventLoop,this)),this.$element=a(b),this.affixed=null,this.unpin=null,this.pinnedOffset=null,this.checkPosition()};c.VERSION="3.3.4",c.RESET="affix affix-top affix-bottom",c.DEFAULTS={offset:0,target:window},c.prototype.getState=function(a,b,c,d){var e=this.$target.scrollTop(),f=this.$element.offset(),g=this.$target.height();if(null!=c&&"top"==this.affixed)return c>e?"top":!1;if("bottom"==this.affixed)return null!=c?e+this.unpin<=f.top?!1:"bottom":a-d>=e+g?!1:"bottom";var h=null==this.affixed,i=h?e:f.top,j=h?g:b;return null!=c&&c>=e?"top":null!=d&&i+j>=a-d?"bottom":!1},c.prototype.getPinnedOffset=function(){if(this.pinnedOffset)return this.pinnedOffset;this.$element.removeClass(c.RESET).addClass("affix");var a=this.$target.scrollTop(),b=this.$element.offset();return this.pinnedOffset=b.top-a},c.prototype.checkPositionWithEventLoop=function(){setTimeout(a.proxy(this.checkPosition,this),1)},c.prototype.checkPosition=function(){if(this.$element.is(":visible")){var b=this.$element.height(),d=this.options.offset,e=d.top,f=d.bottom,g=a(document.body).height();"object"!=typeof d&&(f=e=d),"function"==typeof e&&(e=d.top(this.$element)),"function"==typeof f&&(f=d.bottom(this.$element));var h=this.getState(g,b,e,f);if(this.affixed!=h){null!=this.unpin&&this.$element.css("top","");var i="affix"+(h?"-"+h:""),j=a.Event(i+".bs.affix");if(this.$element.trigger(j),j.isDefaultPrevented())return;this.affixed=h,this.unpin="bottom"==h?this.getPinnedOffset():null,this.$element.removeClass(c.RESET).addClass(i).trigger(i.replace("affix","affixed")+".bs.affix")}"bottom"==h&&this.$element.offset({top:g-b-f})}};var d=a.fn.affix;a.fn.affix=b,a.fn.affix.Constructor=c,a.fn.affix.noConflict=function(){return a.fn.affix=d,this},a(window).on("load",function(){a('[data-spy="affix"]').each(function(){var c=a(this),d=c.data();d.offset=d.offset||{},null!=d.offsetBottom&&(d.offset.bottom=d.offsetBottom),null!=d.offsetTop&&(d.offset.top=d.offsetTop),b.call(c,d)})})}(jQuery); -/*! DataTables 1.10.6 +/*! DataTables 1.10.5 * ©2008-2014 SpryMedia Ltd - datatables.net/license */ /** * @summary DataTables * @description Paginate, search and order HTML tables - * @version 1.10.6 + * @version 1.10.5 * @file jquery.dataTables.js * @author SpryMedia Ltd (www.sprymedia.co.uk) * @contact www.sprymedia.co.uk/contact @@ -10478,17 +10478,9 @@ var e=c.find(".active:last a"),f=a.Event("hide.bs.tab",{relatedTarget:b[0]}),g=a // Escape regular expression special characters var _re_escape_regex = new RegExp( '(\\' + [ '/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\', '$', '^', '-' ].join('|\\') + ')', 'g' ); - // http://en.wikipedia.org/wiki/Foreign_exchange_market - // - \u20BD - Russian ruble. - // - \u20a9 - South Korean Won - // - \u20BA - Turkish Lira - // - \u20B9 - Indian Rupee - // - R - Brazil (R$) and South Africa - // - fr - Swiss Franc - // - kr - Swedish krona, Norwegian krone and Danish krone - // - \u2009 is thin space and \u202F is narrow no-break space, both used in many - // standards as thousands separators. - var _re_formatted_numeric = /[',$£€¥%\u2009\u202F\u20BD\u20a9\u20BArfk]/gi; + // U+2009 is thin space and U+202F is narrow no-break space, both used in many + // standards as thousands separators + var _re_formatted_numeric = /[',$£€¥%\u2009\u202F]/g; var _empty = function ( d ) { @@ -10517,13 +10509,6 @@ var e=c.find(".active:last a"),f=a.Event("hide.bs.tab",{relatedTarget:b[0]}),g=a var _isNumber = function ( d, decimalPoint, formatted ) { var strType = typeof d === 'string'; - // If empty return immediately so there must be a number if it is a - // formatted string (this stops the string "k", or "kr", etc being detected - // as a formatted number for currency - if ( _empty( d ) ) { - return true; - } - if ( decimalPoint && strType ) { d = _numToDecimal( d, decimalPoint ); } @@ -10532,7 +10517,7 @@ var e=c.find(".active:last a"),f=a.Event("hide.bs.tab",{relatedTarget:b[0]}),g=a d = d.replace( _re_formatted_numeric, '' ); } - return !isNaN( parseFloat(d) ) && isFinite( d ); + return _empty( d ) || (!isNaN( parseFloat(d) ) && isFinite( d )); }; @@ -10860,12 +10845,6 @@ var e=c.find(".active:last a"),f=a.Event("hide.bs.tab",{relatedTarget:b[0]}),g=a _fnCompatMap( init, 'orderData', 'aDataSort' ); _fnCompatMap( init, 'orderSequence', 'asSorting' ); _fnCompatMap( init, 'orderDataType', 'sortDataType' ); - - // orderData can be given as an integer - var dataSort = init.aDataSort; - if ( dataSort && ! $.isArray( dataSort ) ) { - init.aDataSort = [ dataSort ]; - } } @@ -10916,7 +10895,7 @@ var e=c.find(".active:last a"),f=a.Event("hide.bs.tab",{relatedTarget:b[0]}),g=a // In rtl text layout, some browsers (most, but not all) will place the // scrollbar on the left, rather than the right. - browser.bScrollbarLeft = Math.round( test.offset().left ) !== 1; + browser.bScrollbarLeft = test.offset().left !== 1; n.remove(); } @@ -11046,7 +11025,7 @@ var e=c.find(".active:last a"),f=a.Event("hide.bs.tab",{relatedTarget:b[0]}),g=a /* iDataSort to be applied (backwards compatibility), but aDataSort will take * priority if defined */ - if ( oOptions.iDataSort !== undefined ) + if ( typeof oOptions.iDataSort === 'number' ) { oCol.aDataSort = [ oOptions.iDataSort ]; } @@ -12759,6 +12738,8 @@ var e=c.find(".active:last a"),f=a.Event("hide.bs.tab",{relatedTarget:b[0]}),g=a return aReturn; } + + /** * Create an Ajax call based on the table's settings, taking into account that * parameters can have multiple forms, and backwards compatibility. @@ -12801,18 +12782,14 @@ var e=c.find(".active:last a"),f=a.Event("hide.bs.tab",{relatedTarget:b[0]}),g=a var ajaxData; var ajax = oSettings.ajax; var instance = oSettings.oInstance; - var callback = function ( json ) { - _fnCallbackFire( oSettings, null, 'xhr', [oSettings, json] ); - fn( json ); - }; if ( $.isPlainObject( ajax ) && ajax.data ) { ajaxData = ajax.data; var newData = $.isFunction( ajaxData ) ? - ajaxData( data, oSettings ) : // fn can manipulate data or return - ajaxData; // an object object or array to merge + ajaxData( data ) : // fn can manipulate data or return an object + ajaxData; // object or array to merge // If the function returned something, use that alone data = $.isFunction( ajaxData ) && newData ? @@ -12833,7 +12810,8 @@ var e=c.find(".active:last a"),f=a.Event("hide.bs.tab",{relatedTarget:b[0]}),g=a } oSettings.json = json; - callback( json ); + _fnCallbackFire( oSettings, null, 'xhr', [oSettings, json] ); + fn( json ); }, "dataType": "json", "cache": false, @@ -12866,7 +12844,7 @@ var e=c.find(".active:last a"),f=a.Event("hide.bs.tab",{relatedTarget:b[0]}),g=a $.map( data, function (val, key) { // Need to convert back to 1.9 trad format return { name: key, value: val }; } ), - callback, + fn, oSettings ); } @@ -12880,7 +12858,7 @@ var e=c.find(".active:last a"),f=a.Event("hide.bs.tab",{relatedTarget:b[0]}),g=a else if ( $.isFunction( ajax ) ) { // Is a function - let the caller define what needs to be done - oSettings.jqXHR = ajax.call( instance, data, callback, oSettings ); + oSettings.jqXHR = ajax.call( instance, data, fn, oSettings ); } else { @@ -13046,7 +13024,6 @@ var e=c.find(".active:last a"),f=a.Event("hide.bs.tab",{relatedTarget:b[0]}),g=a return json[old] !== undefined ? json[old] : json[modern]; }; - var data = _fnAjaxDataSrc( settings, json ); var draw = compat( 'sEcho', 'draw' ); var recordsTotal = compat( 'iTotalRecords', 'recordsTotal' ); var recordsFiltered = compat( 'iTotalDisplayRecords', 'recordsFiltered' ); @@ -13063,6 +13040,7 @@ var e=c.find(".active:last a"),f=a.Event("hide.bs.tab",{relatedTarget:b[0]}),g=a settings._iRecordsTotal = parseInt(recordsTotal, 10); settings._iRecordsDisplay = parseInt(recordsFiltered, 10); + var data = _fnAjaxDataSrc( settings, json ); for ( var i=0, ien=data.length ; i').css( { + width: '100%', + height: 200, + padding: 0 + } )[0]; - if ( width === undefined ) { - var sizer = $('

').css( { + var outer = $('

') + .css( { position: 'absolute', top: 0, left: 0, - width: '100%', + width: 200, height: 150, padding: 0, - overflow: 'scroll', + overflow: 'hidden', visibility: 'hidden' } ) - .appendTo('body'); + .append( inner ) + .appendTo( 'body' ); - width = sizer[0].offsetWidth - sizer[0].clientWidth; - DataTable.__scrollbarWidth = width; + var w1 = inner.offsetWidth; + outer.css( 'overflow', 'scroll' ); + var w2 = inner.offsetWidth; - sizer.remove(); + if ( w1 === w2 ) { + w2 = outer[0].clientWidth; + } + + outer.remove(); + + DataTable.__scrollbarWidth = w1 - w2; } - return width; + return DataTable.__scrollbarWidth; } @@ -15101,10 +15088,6 @@ var e=c.find(".active:last a"),f=a.Event("hide.bs.tab",{relatedTarget:b[0]}),g=a // Yes, modify the sort nextSortIdx = next( sorting[sortIdx], true ); - if ( nextSortIdx === null && sorting.length === 1 ) { - nextSortIdx = 0; // can't remove sorting completely - } - if ( nextSortIdx === null ) { sorting.splice( sortIdx, 1 ); } @@ -15339,43 +15322,31 @@ var e=c.find(".active:last a"),f=a.Event("hide.bs.tab",{relatedTarget:b[0]}),g=a // Restore key features - todo - for 1.11 this needs to be done by // subscribed events - if ( state.start !== undefined ) { - settings._iDisplayStart = state.start; - settings.iInitDisplayStart = state.start; - } - if ( state.length !== undefined ) { - settings._iDisplayLength = state.length; - } + settings._iDisplayStart = state.start; + settings.iInitDisplayStart = state.start; + settings._iDisplayLength = state.length; + settings.aaSorting = []; // Order - if ( state.order !== undefined ) { - settings.aaSorting = []; - $.each( state.order, function ( i, col ) { - settings.aaSorting.push( col[0] >= columns.length ? - [ 0, col[1] ] : - col - ); - } ); - } + $.each( state.order, function ( i, col ) { + settings.aaSorting.push( col[0] >= columns.length ? + [ 0, col[1] ] : + col + ); + } ); // Search - if ( state.search !== undefined ) { - $.extend( settings.oPreviousSearch, _fnSearchToHung( state.search ) ); - } + $.extend( settings.oPreviousSearch, _fnSearchToHung( state.search ) ); // Columns for ( i=0, ien=state.columns.length ; i…'); + container.append(''); break; case 'first': @@ -24907,10 +24899,6 @@ var e=c.find(".active:last a"),f=a.Event("hide.bs.tab",{relatedTarget:b[0]}),g=a number: function ( thousands, decimal, precision, prefix ) { return { display: function ( d ) { - if ( typeof d !== 'number' && typeof d !== 'string' ) { - return d; - } - var negative = d < 0 ? '-' : ''; d = Math.abs( parseFloat( d ) ); @@ -31833,17 +31821,23 @@ var isIE = /*@cc_on!@*/false || !!document.documentMode; // At least IE6 var invoiceOld; -function generatePDF(invoice, javascript, force) { +function generatePDF(invoice, javascript, force, cb) { invoice = calculateAmounts(invoice); var a = copyInvoice(invoice); var b = copyInvoice(invoiceOld); if (!force && _.isEqual(a, b)) { return; } + pdfmakeMarker = "//pdfmake"; invoiceOld = invoice; report_id = invoice.invoice_design_id; - doc = GetPdf(invoice, javascript); - return doc; + if(true || javascript.slice(0, pdfmakeMarker.length) === pdfmakeMarker) { + GetPdfMake(invoice, javascript, cb); + //doc.getDataUrl(cb); + } else { + doc = GetPdf(invoice, javascript); + cb( doc.output("datauristring")); + } } function copyInvoice(orig) { @@ -32622,7 +32616,7 @@ function concatStrings() { concatStr += ' '; } } - return data.length ? concatStr : false; + return data.length ? concatStr : ""; } function displayGrid(doc, invoice, data, x, y, layout, options) { @@ -33346,5 +33340,111 @@ function roundToTwo(num, toString) { function truncate(str, length) { return (str && str.length > length) ? (str.substr(0, length-1) + '...') : str; } -alert('ok'); +function GetPdfMake(invoice, javascript, callback) { +//var docDefinition = { content: 'This is an sample PDF printed wwęęwith pdfMake ĄČĘĖĮŠŲŪŽąčęėįšųž€' }; +//eval(javascript); +//pdfmake +var cb = callback; +var account = invoice.account; + $.get( "../js/templates/clean.js", null, null, 'text') + .done(function( data ) { + //var account = invoice.account; + eval(data); + //var dd = {}; + doc = pdfMake.createPdf(dd); + doc.getDataUrl(cb); + }).fail(function(xhr, status, error) { + console.log(error); + var err = eval("(" + xhr.responseText + ")"); + alert(err.Message); + }); + return; + var dd = { + content: [ + { + columns: [ + { + text: "" + }, + { + text: [account.name, account.id_number, account.vat_number, account.work_email, account.work_phone].join('\n') + }, + { + text: [ + concatStrings(account.address1, account.address2) + "\n", + concatStrings(account.city, account.state, account.postal_code) + ] + } + ] + }, + 'INVOICE', + "-", + { + style: 'tableExample', + table: { + headerRows: 1, + body: [ + ['Sample value 1 \n x', + 'Sample value 2 \n x', + 'Sample value 3 \n x' + ], + ] + }, + layout: 'noBorders' + }, + "-", + 'Another paragraph, this time a little bit longer to make sure, this line will be divided into at least two lines', + { + style: 'tableExample', + table: { + headerRows: 1, + widths: ['auto', '*', 'auto', 'auto', 'auto'], + body: [ + [{text: 'Header 1', style: 'tableHeader'}, {text: 'Header 2', style: 'tableHeader'}, {text: 'Header 3', style: 'tableHeader'}, {text: 'Header 3', style: 'tableHeader'}, {text: 'Header 3', style: 'tableHeader'}], + ['Sample value 1', 'Sample value 2', 'Sample value 3', 'Sample value 2', 'Sample value 3'], + ['Sample value 1', 'Sample value 2', 'Sample value 3', 'Sample value 2', 'Sample value 3'], + ['Sample value 1', 'Sample value 2', 'Sample value 3', 'Sample value 2', 'Sample value 3'], + ['Sample value 1', 'Sample value 2', 'Sample value 3', 'Sample value 2', 'Sample value 3'], + ['Sample value 1', 'Sample value 2', 'Sample value 3', 'Sample value 2', 'Sample value 3'], + ] + }, + layout: 'lightHorizontalLines' + }, + ] + }; + + return doc; +} +/* + var doc = new jsPDF('portrait', 'pt', 'a4'); + + //doc.getStringUnitWidth = function(param) { console.log('getStringUnitWidth: %s', param); return 0}; + + //Set PDF properities + doc.setProperties({ + title: 'Invoice ' + invoice.invoice_number, + subject: '', + author: 'InvoiceNinja.com', + keywords: 'pdf, invoice', + creator: 'InvoiceNinja.com' + }); + + //set default style for report + doc.setFont('Helvetica',''); + + eval(javascript); + + // add footer + if (invoice.invoice_footer) { + doc.setFontType('normal'); + doc.setFontSize('8'); + SetPdfColor(invoice.invoice_design_id == 2 || invoice.invoice_design_id == 3 ? 'White' : 'Black',doc); + var top = doc.internal.pageSize.height - layout.marginLeft; + var numLines = invoice.invoice_footer.split("\n").length - 1; + doc.text(layout.marginLeft, top - (numLines * 8), invoice.invoice_footer); + } + + return doc; + } + */ diff --git a/public/js/pdf.pdfmake.js b/public/js/pdf.pdfmake.js index 139597f9cb07..d7c812c64f7c 100644 --- a/public/js/pdf.pdfmake.js +++ b/public/js/pdf.pdfmake.js @@ -1,2 +1,108 @@ +function GetPdfMake(invoice, javascript, callback) { +//var docDefinition = { content: 'This is an sample PDF printed wwęęwith pdfMake ĄČĘĖĮŠŲŪŽąčęėįšųž€' }; +//eval(javascript); +//pdfmake +var cb = callback; +var account = invoice.account; + $.get( "../js/templates/clean.js", null, null, 'text') + .done(function( data ) { + //var account = invoice.account; + eval(data); + //var dd = {}; + doc = pdfMake.createPdf(dd); + doc.getDataUrl(cb); + }).fail(function(xhr, status, error) { + console.log(error); + var err = eval("(" + xhr.responseText + ")"); + alert(err.Message); + }); + return; + var dd = { + content: [ + { + columns: [ + { + text: "" + }, + { + text: [account.name, account.id_number, account.vat_number, account.work_email, account.work_phone].join('\n') + }, + { + text: [ + concatStrings(account.address1, account.address2) + "\n", + concatStrings(account.city, account.state, account.postal_code) + ] + } + ] + }, + 'INVOICE', + "-", + { + style: 'tableExample', + table: { + headerRows: 1, + body: [ + ['Sample value 1 \n x', + 'Sample value 2 \n x', + 'Sample value 3 \n x' + ], + ] + }, + layout: 'noBorders' + }, + "-", + 'Another paragraph, this time a little bit longer to make sure, this line will be divided into at least two lines', + { + style: 'tableExample', + table: { + headerRows: 1, + widths: ['auto', '*', 'auto', 'auto', 'auto'], + body: [ + [{text: 'Header 1', style: 'tableHeader'}, {text: 'Header 2', style: 'tableHeader'}, {text: 'Header 3', style: 'tableHeader'}, {text: 'Header 3', style: 'tableHeader'}, {text: 'Header 3', style: 'tableHeader'}], + ['Sample value 1', 'Sample value 2', 'Sample value 3', 'Sample value 2', 'Sample value 3'], + ['Sample value 1', 'Sample value 2', 'Sample value 3', 'Sample value 2', 'Sample value 3'], + ['Sample value 1', 'Sample value 2', 'Sample value 3', 'Sample value 2', 'Sample value 3'], + ['Sample value 1', 'Sample value 2', 'Sample value 3', 'Sample value 2', 'Sample value 3'], + ['Sample value 1', 'Sample value 2', 'Sample value 3', 'Sample value 2', 'Sample value 3'], + ] + }, + layout: 'lightHorizontalLines' + }, + ] + }; + return doc; +} +/* + var doc = new jsPDF('portrait', 'pt', 'a4'); + + //doc.getStringUnitWidth = function(param) { console.log('getStringUnitWidth: %s', param); return 0}; + + //Set PDF properities + doc.setProperties({ + title: 'Invoice ' + invoice.invoice_number, + subject: '', + author: 'InvoiceNinja.com', + keywords: 'pdf, invoice', + creator: 'InvoiceNinja.com' + }); + + //set default style for report + doc.setFont('Helvetica',''); + + eval(javascript); + + // add footer + if (invoice.invoice_footer) { + doc.setFontType('normal'); + doc.setFontSize('8'); + SetPdfColor(invoice.invoice_design_id == 2 || invoice.invoice_design_id == 3 ? 'White' : 'Black',doc); + var top = doc.internal.pageSize.height - layout.marginLeft; + var numLines = invoice.invoice_footer.split("\n").length - 1; + doc.text(layout.marginLeft, top - (numLines * 8), invoice.invoice_footer); + } + + return doc; + } + */ diff --git a/public/js/script.js b/public/js/script.js index 4b0d64875d6a..0e7c9862cd46 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -8,17 +8,23 @@ var isIE = /*@cc_on!@*/false || !!document.documentMode; // At least IE6 var invoiceOld; -function generatePDF(invoice, javascript, force) { +function generatePDF(invoice, javascript, force, cb) { invoice = calculateAmounts(invoice); var a = copyInvoice(invoice); var b = copyInvoice(invoiceOld); if (!force && _.isEqual(a, b)) { return; } + pdfmakeMarker = "//pdfmake"; invoiceOld = invoice; report_id = invoice.invoice_design_id; - doc = GetPdf(invoice, javascript); - return doc; + if(true || javascript.slice(0, pdfmakeMarker.length) === pdfmakeMarker) { + GetPdfMake(invoice, javascript, cb); + //doc.getDataUrl(cb); + } else { + doc = GetPdf(invoice, javascript); + cb( doc.output("datauristring")); + } } function copyInvoice(orig) { @@ -797,7 +803,7 @@ function concatStrings() { concatStr += ' '; } } - return data.length ? concatStr : false; + return data.length ? concatStr : ""; } function displayGrid(doc, invoice, data, x, y, layout, options) { diff --git a/public/js/templates/clean.js b/public/js/templates/clean.js new file mode 100644 index 000000000000..d6ffe977c1f3 --- /dev/null +++ b/public/js/templates/clean.js @@ -0,0 +1,73 @@ +dd = { + content: [ + { + columns: [ + { + text: "" + }, + { + text: [account.name, account.id_number, account.vat_number, account.work_email, account.work_phone].join('\n') + }, + { + text: [ + concatStrings(account.address1, account.address2) + "\n", + concatStrings(account.city, account.state, account.postal_code) + ] + } + ] + }, + 'INVOICE', + { + style: 'tableExample', + table: { + headerRows: 1, + widths: ['auto', 'auto', '*'], + body: [ + ['Invoice Number', {style: 'bold', text: invoice.invoice_number}, ""], + ['Invoice Date', invoice.invoice_date, ""], + ['Balance Due', formatMoney(invoice.balance_amount, invoice.client.currency_id), ""], + ] + }, + layout: { + hLineWidth: function (i, node) { + return (i === 0 || i === node.table.body.length) ? 1 : 0; + }, + vLineWidth: function (i, node) { + return 0;//(i === 0 || i === node.table.widths.length) ? 2 : 1; + }, + hLineColor: function (i, node) { + return 'gray';//(i === 0 || i === node.table.body.length) ? 'black' : 'gray'; + }, + /*vLineColor: function (i, node) { + return (i === 0 || i === node.table.widths.length) ? 'black' : 'gray'; + },*/ + // paddingLeft: function(i, node) { return 4; }, + // paddingRight: function(i, node) { return 4; }, + // paddingTop: function(i, node) { return 2; }, + // paddingBottom: function(i, node) { return 2; } + } + }, + '\n', + { + style: 'tableExample', + table: { + headerRows: 1, + widths: ['auto', '*', 'auto', 'auto', 'auto'], + body: [ + [{text: 'Item', style: 'tableHeader'}, {text: 'Description', style: 'tableHeader'}, {text: 'Unit Cost', style: 'tableHeader'}, {text: 'Quantity', style: 'tableHeader'}, {text: 'Line Total', style: 'tableHeader'}], + ['Sample value 1', 'Sample value 2', 'Sample value 3', 'Sample value 2', 'Sample value 3'], + ['Sample value 1', 'Sample value 2', 'Sample value 3', 'Sample value 2', 'Sample value 3'], + ['Sample value 1', 'Sample value 2', 'Sample value 3', 'Sample value 2', 'Sample value 3'], + ['Sample value 1', 'Sample value 2', 'Sample value 3', 'Sample value 2', 'Sample value 3'], + ['Sample value 1', 'Sample value 2', 'Sample value 3', 'Sample value 2', 'Sample value 3'] + ] + }, + layout: 'lightHorizontalLines' + } + ], + styles: { + bold: { + bold: true + } + } +} \ No newline at end of file diff --git a/resources/views/invoices/edit.blade.php b/resources/views/invoices/edit.blade.php index fc67dcce8b5e..27bf78c664eb 100644 --- a/resources/views/invoices/edit.blade.php +++ b/resources/views/invoices/edit.blade.php @@ -688,13 +688,11 @@ return invoice; } - function getPDFString() { + function getPDFString(cb) { var invoice = createInvoiceModel(); var design = getDesignJavascript(); if (!design) return; - var doc = generatePDF(invoice, design); - if (!doc) return; - return doc.output('datauristring'); + generatePDF(invoice, design, false, cb); } function getDesignJavascript() { diff --git a/resources/views/invoices/pdf.blade.php b/resources/views/invoices/pdf.blade.php index 34f593667cbe..563ad157b731 100644 --- a/resources/views/invoices/pdf.blade.php +++ b/resources/views/invoices/pdf.blade.php @@ -81,18 +81,19 @@ var needsRefresh = false; function refreshPDF() { + getPDFString(refreshPDFCB); + } + + function refreshPDFCB(string) { + if (!string) return; PDFJS.workerSrc = '{{ asset('js/pdf_viewer.worker.js') }}'; - if ({{ Auth::check() && Auth::user()->force_pdfjs ? 'false' : 'true' }} && (isFirefox || (isChrome && !isChromium))) { - var string = getPDFString(); - if (!string) return; + if ({{ Auth::check() && Auth::user()->force_pdfjs ? 'false' : 'true' }} && (isFirefox || (isChrome && !isChromium))) { $('#theFrame').attr('src', string).show(); } else { if (isRefreshing) { needsRefresh = true; return; } - var string = getPDFString(); - if (!string) return; isRefreshing = true; var pdfAsArray = convertDataURIToBinary(string); PDFJS.getDocument(pdfAsArray).then(function getPdfHelloWorld(pdf) {