From 08fd14a4c1fbf399ac9aeaa0b76642c6e2cae512 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 10 Jan 2016 16:22:40 +0200 Subject: [PATCH] Added a 'Live Preview' option when using a large font --- app/Models/Account.php | 6 +++++- resources/lang/en/texts.php | 1 + resources/views/invoices/edit.blade.php | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/app/Models/Account.php b/app/Models/Account.php index 456facf62df5..04e32fad7818 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -20,7 +20,6 @@ class Account extends Eloquent protected $presenter = 'App\Ninja\Presenters\AccountPresenter'; protected $dates = ['deleted_at']; protected $hidden = ['ip']; - public $fonts_obj = null; public static $basicSettings = [ ACCOUNT_COMPANY_DETAILS, @@ -897,6 +896,11 @@ class Account extends Eloquent return $css; } + public function hasLargeFont() + { + return stripos($this->getBodyFontName(), 'chinese') || stripos($this->getHeaderFontName(), 'chinese'); + } + public function getFontsUrl($protocol = ''){ if ($this->isPro()){ $bodyFont = $this->body_font_id; diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 3b1582a3df20..10e253be27b0 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -1031,4 +1031,5 @@ return array( 'body_font_id' => 'Body Font', 'color_font_help' => 'Note: the primary color and fonts are also used in the client portal and custom email designs.', + 'live_preview' => 'Live Preview', ); \ No newline at end of file diff --git a/resources/views/invoices/edit.blade.php b/resources/views/invoices/edit.blade.php index e62313d6f8ae..a0d91604697c 100644 --- a/resources/views/invoices/edit.blade.php +++ b/resources/views/invoices/edit.blade.php @@ -393,6 +393,11 @@ {!! Former::text('pdfupload') !!} + @if ($account->hasLargeFont()) + + @endif @if (!Utils::isPro() || \App\Models\InvoiceDesign::count() == COUNT_FREE_DESIGNS_SELF_HOST) {!! Former::select('invoice_design_id')->style('display:inline;width:150px;background-color:white !important')->raw()->fromQuery($invoiceDesigns, 'name', 'id')->data_bind("value: invoice_design_id")->addOption(trans('texts.more_designs') . '...', '-1') !!} @@ -942,11 +947,20 @@ return invoice; } + window.generatedPDF = false; function getPDFString(cb, force) { + @if ($account->hasLargeFont()) + console.log('checked: %s', $('#livePreview').is(':checked')); + if (!$('#livePreview').is(':checked') && window.generatedPDF) { + console.log('returning'); + return; + } + @endif var invoice = createInvoiceModel(); var design = getDesignJavascript(); if (!design) return; generatePDF(invoice, design, force, cb); + window.generatedPDF = true; } function getDesignJavascript() {