mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 18:14:32 -04:00
Fix for dev channel Chrome crash
This commit is contained in:
parent
d1de95303b
commit
898e31c8b5
@ -29885,6 +29885,7 @@ var isChrome = !!window.chrome && !isOpera && !isEdge; // Chrome 1+
|
|||||||
var isChromium = isChrome && navigator.userAgent.indexOf('Chromium') >= 0;
|
var isChromium = isChrome && navigator.userAgent.indexOf('Chromium') >= 0;
|
||||||
var isIE = /*@cc_on!@*/false || !!document.documentMode; // At least IE6
|
var isIE = /*@cc_on!@*/false || !!document.documentMode; // At least IE6
|
||||||
|
|
||||||
|
var pdfDoc;
|
||||||
var invoiceOld;
|
var invoiceOld;
|
||||||
var refreshTimer;
|
var refreshTimer;
|
||||||
function generatePDF(invoice, javascript, force, cb) {
|
function generatePDF(invoice, javascript, force, cb) {
|
||||||
@ -29901,23 +29902,23 @@ function generatePDF(invoice, javascript, force, cb) {
|
|||||||
refreshTimer = setTimeout(function() {
|
refreshTimer = setTimeout(function() {
|
||||||
generatePDF(invoice, javascript, true, cb);
|
generatePDF(invoice, javascript, true, cb);
|
||||||
}, 500);
|
}, 500);
|
||||||
return;
|
return pdfDoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
invoice = calculateAmounts(invoice);
|
invoice = calculateAmounts(invoice);
|
||||||
var a = copyObject(invoice);
|
var a = copyObject(invoice);
|
||||||
var b = copyObject(invoiceOld);
|
var b = copyObject(invoiceOld);
|
||||||
if (!force && _.isEqual(a, b)) {
|
if (_.isEqual(a, b)) {
|
||||||
return;
|
return pdfDoc;
|
||||||
}
|
}
|
||||||
invoiceOld = invoice;
|
invoiceOld = invoice;
|
||||||
doc = GetPdfMake(invoice, javascript, cb);
|
pdfDoc = GetPdfMake(invoice, javascript, cb);
|
||||||
|
|
||||||
if (cb) {
|
if (cb) {
|
||||||
doc.getDataUrl(cb);
|
pdfDoc.getDataUrl(cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
return doc;
|
return pdfDoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
function copyObject(orig) {
|
function copyObject(orig) {
|
||||||
|
@ -7,6 +7,7 @@ var isChrome = !!window.chrome && !isOpera && !isEdge; // Chrome 1+
|
|||||||
var isChromium = isChrome && navigator.userAgent.indexOf('Chromium') >= 0;
|
var isChromium = isChrome && navigator.userAgent.indexOf('Chromium') >= 0;
|
||||||
var isIE = /*@cc_on!@*/false || !!document.documentMode; // At least IE6
|
var isIE = /*@cc_on!@*/false || !!document.documentMode; // At least IE6
|
||||||
|
|
||||||
|
var pdfDoc;
|
||||||
var invoiceOld;
|
var invoiceOld;
|
||||||
var refreshTimer;
|
var refreshTimer;
|
||||||
function generatePDF(invoice, javascript, force, cb) {
|
function generatePDF(invoice, javascript, force, cb) {
|
||||||
@ -23,23 +24,23 @@ function generatePDF(invoice, javascript, force, cb) {
|
|||||||
refreshTimer = setTimeout(function() {
|
refreshTimer = setTimeout(function() {
|
||||||
generatePDF(invoice, javascript, true, cb);
|
generatePDF(invoice, javascript, true, cb);
|
||||||
}, 500);
|
}, 500);
|
||||||
return;
|
return pdfDoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
invoice = calculateAmounts(invoice);
|
invoice = calculateAmounts(invoice);
|
||||||
var a = copyObject(invoice);
|
var a = copyObject(invoice);
|
||||||
var b = copyObject(invoiceOld);
|
var b = copyObject(invoiceOld);
|
||||||
if (!force && _.isEqual(a, b)) {
|
if (_.isEqual(a, b)) {
|
||||||
return;
|
return pdfDoc;
|
||||||
}
|
}
|
||||||
invoiceOld = invoice;
|
invoiceOld = invoice;
|
||||||
doc = GetPdfMake(invoice, javascript, cb);
|
pdfDoc = GetPdfMake(invoice, javascript, cb);
|
||||||
|
|
||||||
if (cb) {
|
if (cb) {
|
||||||
doc.getDataUrl(cb);
|
pdfDoc.getDataUrl(cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
return doc;
|
return pdfDoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
function copyObject(orig) {
|
function copyObject(orig) {
|
||||||
|
@ -196,7 +196,6 @@
|
|||||||
{!! Former::text('product_key')->useDatalist($products->toArray(), 'product_key')
|
{!! Former::text('product_key')->useDatalist($products->toArray(), 'product_key')
|
||||||
->data_bind("value: product_key, valueUpdate: 'afterkeydown', attr: {name: 'invoice_items[' + \$index() + '][product_key]'}")
|
->data_bind("value: product_key, valueUpdate: 'afterkeydown', attr: {name: 'invoice_items[' + \$index() + '][product_key]'}")
|
||||||
->addClass('datalist')
|
->addClass('datalist')
|
||||||
->onkeyup('onItemChange()')
|
|
||||||
->raw()
|
->raw()
|
||||||
!!}
|
!!}
|
||||||
</td>
|
</td>
|
||||||
@ -206,12 +205,12 @@
|
|||||||
<input type="text" data-bind="value: task_public_id, attr: {name: 'invoice_items[' + $index() + '][task_public_id]'}" style="display: none"/>
|
<input type="text" data-bind="value: task_public_id, attr: {name: 'invoice_items[' + $index() + '][task_public_id]'}" style="display: none"/>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input onkeyup="onItemChange()" data-bind="value: prettyCost, valueUpdate: 'afterkeydown', attr: {name: 'invoice_items[' + $index() + '][cost]'}"
|
<input data-bind="value: prettyCost, valueUpdate: 'afterkeydown', attr: {name: 'invoice_items[' + $index() + '][cost]'}"
|
||||||
style="text-align: right" class="form-control"/>
|
style="text-align: right" class="form-control invoice-item"/>
|
||||||
</td>
|
</td>
|
||||||
<td style="{{ $account->hide_quantity ? 'display:none' : '' }}">
|
<td style="{{ $account->hide_quantity ? 'display:none' : '' }}">
|
||||||
<input onkeyup="onItemChange()" data-bind="value: prettyQty, valueUpdate: 'afterkeydown', attr: {name: 'invoice_items[' + $index() + '][qty]'}"
|
<input data-bind="value: prettyQty, valueUpdate: 'afterkeydown', attr: {name: 'invoice_items[' + $index() + '][qty]'}"
|
||||||
style="text-align: right" class="form-control" name="quantity"/>
|
style="text-align: right" class="form-control invoice-item" name="quantity"/>
|
||||||
</td>
|
</td>
|
||||||
<td style="display:none;" data-bind="visible: $root.invoice_item_taxes.show">
|
<td style="display:none;" data-bind="visible: $root.invoice_item_taxes.show">
|
||||||
<select class="form-control" style="width:100%" data-bind="value: tax, options: $root.tax_rates, optionsText: 'displayName', attr: {name: 'invoice_items[' + $index() + '][tax]'}"></select>
|
<select class="form-control" style="width:100%" data-bind="value: tax, options: $root.tax_rates, optionsText: 'displayName', attr: {name: 'invoice_items[' + $index() + '][tax]'}"></select>
|
||||||
@ -727,7 +726,8 @@
|
|||||||
|
|
||||||
var $input = $('select#client');
|
var $input = $('select#client');
|
||||||
$input.combobox().on('change', function(e) {
|
$input.combobox().on('change', function(e) {
|
||||||
var clientId = parseInt($('input[name=client]').val(), 10);
|
var oldId = model.invoice().client().public_id();
|
||||||
|
var clientId = parseInt($('input[name=client]').val(), 10) || 0;
|
||||||
if (clientId > 0) {
|
if (clientId > 0) {
|
||||||
var selected = clientMap[clientId];
|
var selected = clientMap[clientId];
|
||||||
model.loadClient(selected);
|
model.loadClient(selected);
|
||||||
@ -735,7 +735,7 @@
|
|||||||
$('.client-input').val(getClientDisplayName(selected));
|
$('.client-input').val(getClientDisplayName(selected));
|
||||||
// if there's an invoice number pattern we'll apply it now
|
// if there's an invoice number pattern we'll apply it now
|
||||||
setInvoiceNumber(selected);
|
setInvoiceNumber(selected);
|
||||||
} else {
|
} else if (oldId) {
|
||||||
model.loadClient($.parseJSON(ko.toJSON(new ClientModel())));
|
model.loadClient($.parseJSON(ko.toJSON(new ClientModel())));
|
||||||
model.invoice().client().country = false;
|
model.invoice().client().country = false;
|
||||||
}
|
}
|
||||||
@ -750,7 +750,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$('#invoice_footer, #terms, #public_notes, #invoice_number, #invoice_date, #due_date, #start_date, #po_number, #discount, #currency_id, #invoice_design_id, #recurring, #is_amount_discount, #partial, #custom_text_value1, #custom_text_value2').change(function() {
|
$('#invoice_footer, #terms, #public_notes, #invoice_number, #invoice_date, #due_date, #start_date, #po_number, #discount, #currency_id, #invoice_design_id, #recurring, #is_amount_discount, #partial, #custom_text_value1, #custom_text_value2').change(function() {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
refreshPDF(true);
|
refreshPDF(true);
|
||||||
}, 1);
|
}, 1);
|
||||||
});
|
});
|
||||||
@ -789,8 +789,6 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
$('label.radio').addClass('radio-inline');
|
$('label.radio').addClass('radio-inline');
|
||||||
|
|
||||||
applyComboboxListeners();
|
|
||||||
|
|
||||||
@if ($invoice->client->id)
|
@if ($invoice->client->id)
|
||||||
$input.trigger('change');
|
$input.trigger('change');
|
||||||
@ -806,12 +804,15 @@
|
|||||||
@if (isset($tasks) && $tasks)
|
@if (isset($tasks) && $tasks)
|
||||||
NINJA.formIsChanged = true;
|
NINJA.formIsChanged = true;
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
applyComboboxListeners();
|
||||||
});
|
});
|
||||||
|
|
||||||
function applyComboboxListeners() {
|
function applyComboboxListeners() {
|
||||||
var selectorStr = '.invoice-table input, .invoice-table select, .invoice-table textarea';
|
var selectorStr = '.invoice-table input, .invoice-table select, .invoice-table textarea';
|
||||||
$(selectorStr).off('blur').on('blur', function() {
|
$(selectorStr).off('change').on('change', function(event) {
|
||||||
refreshPDF(true);
|
onItemChange();
|
||||||
|
refreshPDF(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('textarea').on('keyup focus', function(e) {
|
$('textarea').on('keyup focus', function(e) {
|
||||||
@ -821,7 +822,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
@if (Auth::user()->account->fill_products)
|
@if (Auth::user()->account->fill_products)
|
||||||
$('.datalist').on('input', function() {
|
$('.datalist').off('input').on('input', function() {
|
||||||
var key = $(this).val();
|
var key = $(this).val();
|
||||||
for (var i=0; i<products.length; i++) {
|
for (var i=0; i<products.length; i++) {
|
||||||
var product = products[i];
|
var product = products[i];
|
||||||
@ -839,11 +840,10 @@
|
|||||||
model.tax(self.model.getTaxRateById(product.default_tax_rate.public_id));
|
model.tax(self.model.getTaxRateById(product.default_tax_rate.public_id));
|
||||||
}
|
}
|
||||||
@endif
|
@endif
|
||||||
break;
|
model.product_key(key);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onItemChange();
|
|
||||||
refreshPDF();
|
|
||||||
});
|
});
|
||||||
@endif
|
@endif
|
||||||
}
|
}
|
||||||
@ -963,14 +963,14 @@
|
|||||||
if (contact.send_invoice()) {
|
if (contact.send_invoice()) {
|
||||||
parts.push(contact.displayName());
|
parts.push(contact.displayName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return parts.join('\n');
|
return parts.join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
function preparePdfData(action) {
|
function preparePdfData(action) {
|
||||||
var invoice = createInvoiceModel();
|
var invoice = createInvoiceModel();
|
||||||
var design = getDesignJavascript();
|
var design = getDesignJavascript();
|
||||||
if (!design) return;
|
if (!design) return;
|
||||||
|
|
||||||
doc = generatePDF(invoice, design, true);
|
doc = generatePDF(invoice, design, true);
|
||||||
|
@ -258,15 +258,15 @@ function InvoiceModel(data) {
|
|||||||
self.addItem = function() {
|
self.addItem = function() {
|
||||||
var itemModel = new ItemModel();
|
var itemModel = new ItemModel();
|
||||||
@if ($account->hide_quantity)
|
@if ($account->hide_quantity)
|
||||||
itemModel.qty(1);
|
itemModel.qty(1);
|
||||||
@endif
|
@endif
|
||||||
self.invoice_items.push(itemModel);
|
self.invoice_items.push(itemModel);
|
||||||
applyComboboxListeners();
|
applyComboboxListeners();
|
||||||
return itemModel;
|
return itemModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
ko.mapping.fromJS(data, self.mapping, self);
|
ko.mapping.fromJS(data, self.mapping, self);
|
||||||
} else {
|
} else {
|
||||||
self.addItem();
|
self.addItem();
|
||||||
}
|
}
|
||||||
|
@ -89,14 +89,15 @@
|
|||||||
var needsRefresh = false;
|
var needsRefresh = false;
|
||||||
|
|
||||||
function refreshPDF(force) {
|
function refreshPDF(force) {
|
||||||
|
//console.log('refresh PDF - force: ' + force + ' ' + (new Date()).getTime())
|
||||||
return getPDFString(refreshPDFCB, force);
|
return getPDFString(refreshPDFCB, force);
|
||||||
}
|
}
|
||||||
|
|
||||||
function refreshPDFCB(string) {
|
function refreshPDFCB(string) {
|
||||||
if (!string) return;
|
if (!string) return;
|
||||||
PDFJS.workerSrc = '{{ asset('js/pdf_viewer.worker.js') }}';
|
PDFJS.workerSrc = '{{ asset('js/pdf_viewer.worker.js') }}';
|
||||||
if ({{ Auth::check() && Auth::user()->force_pdfjs ? 'false' : 'true' }} && (isFirefox || (isChrome && !isChromium))) {
|
if ({{ Auth::check() && Auth::user()->force_pdfjs ? 'false' : 'true' }} && (isFirefox || isChrome)) {
|
||||||
$('#theFrame').attr('src', string).show();
|
$('#theFrame').attr('src', string).show();
|
||||||
} else {
|
} else {
|
||||||
if (isRefreshing) {
|
if (isRefreshing) {
|
||||||
//needsRefresh = true;
|
//needsRefresh = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user