Skip to content

Commit

Permalink
Added "PDF Bootstrap" option, to disable including default Bootstrap …
Browse files Browse the repository at this point in the history
…CSS in form/list PDF views, possible workaround for issues with Bootstrap in DOMPDF.
  • Loading branch information
cheesegrits committed Dec 18, 2018
1 parent 9186572 commit df7d0b6
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,8 @@ COM_FABRIK_FIELD_PDF_SIZE_DESC="If the PDF is not rendering, increase the paper
COM_FABRIK_FIELD_PDF_SIZE_LABEL="PDF Paper size"
COM_FABRIK_FIELD_PDF_TEMPLATE_DESC="If none selected then the main template will be used"
COM_FABRIK_FIELD_PDF_TEMPLATE_LABEL="PDF template"
COM_FABRIK_FIELD_PDF_INCLUDE_BOOTSTRAP_DESC="Include the default Bootstrap CSS files when generating PDF views. Output using a Bootstrap template without the CSS won't look very good, but both DOMPDF and MPDF do have known issues with some Bootstrap features, so disabling this may be the only way to generate a PDF"
COM_FABRIK_FIELD_PDF_INCLUDE_BOOTSTRAP_LABEL="PDF Bootstrap"
COM_FABRIK_FIELD_POPUP_WIDTH_LABEL="Popup Width"
COM_FABRIK_FIELD_POPUP_WIDTH_DESC="If Ajaxify Links is selected, you may optionally specify the width, height, and x & y offsets of the popup window"
COM_FABRIK_FIELD_POPUP_HEIGHT_LABEL="Popup Height"
Expand Down
10 changes: 10 additions & 0 deletions administrator/components/com_fabrik/models/forms/form.xml
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,16 @@
<option value="folio">folio</option>
</field>

<field name="pdf_include_bootstrap"
type="radio"
class="btn-group"
default="1"
description="COM_FABRIK_FIELD_PDF_INCLUDE_BOOTSTRAP_DESC"
label="COM_FABRIK_FIELD_PDF_INCLUDE_BOOTSTRAP_LABEL">
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>


</fieldset>

Expand Down
10 changes: 10 additions & 0 deletions administrator/components/com_fabrik/models/forms/list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,16 @@
<option value="executive">executive</option>
<option value="folio">folio</option>
</field>

<field name="pdf_include_bootstrap"
type="radio"
class="btn-group"
default="1"
description="COM_FABRIK_FIELD_PDF_INCLUDE_BOOTSTRAP_DESC"
label="COM_FABRIK_FIELD_PDF_INCLUDE_BOOTSTRAP_LABEL">
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
</fieldset>

<fieldset name="layout">
Expand Down
8 changes: 6 additions & 2 deletions components/com_fabrik/views/form/view.pdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ public function display($tpl = null)

if (parent::display($tpl) !== false)
{
FabrikhelperHTML::loadBootstrapCSS(true);

/** @var JDocumentpdf $document */
$document = $this->doc;

Expand All @@ -47,6 +45,12 @@ public function display($tpl = null)
$size = $this->app->input->get('pdf_size', $params->get('pdf_size', 'A4'));
$orientation = $this->app->input->get('pdf_orientation', $params->get('pdf_orientation', 'portrait'));
$document->setPaper($size, $orientation);

if ($this->app->input->get('pdf_include_bootstrap', $params->get('pdf_include_bootstrap', '0')) === '1')
{
FabrikhelperHTML::loadBootstrapCSS(true);
}

$this->output();
}
}
Expand Down
7 changes: 6 additions & 1 deletion components/com_fabrik/views/list/view.pdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public function display($tpl = null)

if (parent::display($tpl) !== false)
{
FabrikhelperHTML::loadBootstrapCSS(true);
$model = $this->getModel();
$params = $model->getParams();
$size = $this->app->input->get('pdf_size', $params->get('pdf_size', 'A4'));
Expand All @@ -48,6 +47,12 @@ public function display($tpl = null)
//$this->filters = array();
$this->showFilters = false;
$this->hasButtons = false;

if ($this->app->input->get('pdf_include_bootstrap', $params->get('pdf_include_bootstrap', '0')) === '1')
{
FabrikhelperHTML::loadBootstrapCSS(true);
}

$this->output();
}
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/fabrik_form/stripe/stripe-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

100 changes: 60 additions & 40 deletions plugins/fabrik_form/stripe/stripe.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,17 @@ define(['jquery', 'fab/fabrik'], function (jQuery, Fabrik) {
Fabrik.FabrikStripeForm = null;
Fabrik.FabrikStripeFormSubmitting = false;

if (this.options.couponElement !== '')
{
this.couponElement = self.form.formElements.get(this.options.couponElement);
var couponElEvnt = this.couponElement.getBlurEvent();

self.form.dispatchEvent(
'',
this.options.couponElement,
couponElEvnt,
function (e) {
self.getCoupon(e);
}
);
}
else
{
this.couponElement = false;
}

if (this.options.productElement !== '')
{
this.productElement = self.form.formElements.get(this.options.productElement);
var productElEvnt = this.productElement.getBlurEvent();
var productElEvnt;

if (this.productElement.hasSubElements()) {
productElEvnt = this.productElement.getChangeEvent();
}
else {
productElEvnt = this.productElement.getBlurEvent();
}

self.form.dispatchEvent(
'',
Expand All @@ -66,43 +54,75 @@ define(['jquery', 'fab/fabrik'], function (jQuery, Fabrik) {
self.getCost(e);
}
);
}
else
{
this.productElement = false;
}

if (this.options.qtyElement !== '')
{
this.qtyElement = self.form.formElements.get(this.options.qtyElement);
var qtyElEvnt = this.qtyElement.getBlurEvent();
if (this.options.qtyElement !== '')
{
this.qtyElement = self.form.formElements.get(this.options.qtyElement);
var qtyElEvnt;

self.form.dispatchEvent(
'',
this.options.qtyElement,
qtyElEvnt,
function (e) {
self.getCost(e);
if (this.productElement.hasSubElements()) {
qtyElEvnt = this.productElement.getChangeEvent();
}
else {
qtyElEvnt = this.productElement.getBlurEvent();
}
);

// if it's a field, watch for input events, like HTML 5 'number' controls, etc
if (this.qtyElement.plugin === 'fabrikfield') {
self.form.dispatchEvent(
'',
this.options.qtyElement,
'input',
qtyElEvnt,
function (e) {
self.getCost(e);
}
);

// if it's a field, watch for input events, like HTML 5 'number' controls, etc
if (this.qtyElement.plugin === 'fabrikfield') {
self.form.dispatchEvent(
'',
this.options.qtyElement,
'input',
function (e) {
self.getCost(e);
}
);
}
}
else
{
this.qtyElement = false;
}
}
else
{
this.qtyElement = false;
this.productElement = false;
this.qtyElement = false;
}

if (this.options.couponElement !== '')
{
this.couponElement = self.form.formElements.get(this.options.couponElement);
var couponElEvnt = this.couponElement.getBlurEvent();

self.form.dispatchEvent(
'',
this.options.couponElement,
couponElEvnt,
function (e) {
if (self.options.productElement !== '') {
self.getCost(e);
}
else {
self.getCoupon(e);
}
}
);
}
else
{
this.couponElement = false;
}

if (this.options.totalElement !== '')
{
this.totalElement = self.form.formElements.get(this.options.totalElement);
Expand Down

0 comments on commit df7d0b6

Please sign in to comment.