Show toast to user when trying to draw without a document open
This commit is contained in:
parent
42f5e4cf9d
commit
278fa9a79b
@ -44,7 +44,11 @@ function makeStampImage(callback) {
|
||||
}
|
||||
|
||||
function activateTextTool() {
|
||||
var text = prompt("");
|
||||
if (!canUseDrawTools()) {
|
||||
showToast("Please open a document first.");
|
||||
return;
|
||||
}
|
||||
var text = prompt("Enter a line of text to add to the document:");
|
||||
if (text == "") {
|
||||
return;
|
||||
}
|
||||
@ -69,6 +73,10 @@ function activateTextTool() {
|
||||
}
|
||||
|
||||
function activateStampDrawTool() {
|
||||
if (!canUseDrawTools()) {
|
||||
showToast("Please open a document first.");
|
||||
return;
|
||||
}
|
||||
makeStampImage(function (image) {
|
||||
activeDrawImage = image;
|
||||
enableGuideBox(image);
|
||||
@ -76,6 +84,10 @@ function activateStampDrawTool() {
|
||||
}
|
||||
|
||||
function activateNotarySignatureTool() {
|
||||
if (!canUseDrawTools()) {
|
||||
showToast("Please open a document first.");
|
||||
return;
|
||||
}
|
||||
if (!inStorage("notary_signature")) {
|
||||
showAlert("Please set a notary signature in the settings.");
|
||||
return;
|
||||
@ -91,6 +103,10 @@ function activateNotarySignatureTool() {
|
||||
}
|
||||
|
||||
function activateNotaryCertificateTool() {
|
||||
if (!canUseDrawTools()) {
|
||||
showToast("Please open a document first.");
|
||||
return;
|
||||
}
|
||||
initCertificateBuilder();
|
||||
|
||||
certificateBuilderCallback = function () {
|
||||
@ -108,6 +124,10 @@ function activateNotaryCertificateTool() {
|
||||
}
|
||||
|
||||
function activateClientSignaturePad() {
|
||||
if (!canUseDrawTools()) {
|
||||
showToast("Please open a document first.");
|
||||
return;
|
||||
}
|
||||
initSignaturePad();
|
||||
signaturePadCallback = function () {
|
||||
if (clientSignatureSvg != "" && signaturePad.isEmpty()) {
|
||||
@ -228,6 +248,14 @@ function getMousePos(canvas, evt) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if drawing tools should be available (i.e. there's a document to draw on)
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
function canUseDrawTools() {
|
||||
return $("#page-canvas-container .page-canvas").length > 0;
|
||||
}
|
||||
|
||||
// Hide it at start
|
||||
// doesn't work in CSS because of reasons
|
||||
disableGuideBox();
|
@ -386,6 +386,10 @@ function getNewCanvas(pagenumber) {
|
||||
}
|
||||
|
||||
function addPage() {
|
||||
if ($("#page-canvas-container .page-canvas").length == 0) {
|
||||
showToast("Please open a document first.");
|
||||
return;
|
||||
}
|
||||
pageNumber++;
|
||||
var canvas = getNewCanvas(pageNumber);
|
||||
var prevPageCanvas = $("#page-canvas-container .page-canvas#pdf-canvas-page-" + (pageNumber - 1))[0];
|
||||
|
Loading…
x
Reference in New Issue
Block a user