Added a 'Live Preview' option when using a large font

This commit is contained in:
Hillel Coren 2016-01-10 16:22:40 +02:00
parent c6ff456d4d
commit 08fd14a4c1
3 changed files with 20 additions and 1 deletions

View File

@ -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;

View File

@ -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',
);

View File

@ -393,6 +393,11 @@
{!! Former::text('pdfupload') !!}
</div>
@if ($account->hasLargeFont())
<label for="livePreview" class="control-label" style="padding-right:10px">
<input id="livePreview" type="checkbox"/> {{ trans('texts.live_preview') }}
</label>
@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() {