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() {
|
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 == "") {
|
if (text == "") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -69,6 +73,10 @@ function activateTextTool() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function activateStampDrawTool() {
|
function activateStampDrawTool() {
|
||||||
|
if (!canUseDrawTools()) {
|
||||||
|
showToast("Please open a document first.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
makeStampImage(function (image) {
|
makeStampImage(function (image) {
|
||||||
activeDrawImage = image;
|
activeDrawImage = image;
|
||||||
enableGuideBox(image);
|
enableGuideBox(image);
|
||||||
@ -76,6 +84,10 @@ function activateStampDrawTool() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function activateNotarySignatureTool() {
|
function activateNotarySignatureTool() {
|
||||||
|
if (!canUseDrawTools()) {
|
||||||
|
showToast("Please open a document first.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!inStorage("notary_signature")) {
|
if (!inStorage("notary_signature")) {
|
||||||
showAlert("Please set a notary signature in the settings.");
|
showAlert("Please set a notary signature in the settings.");
|
||||||
return;
|
return;
|
||||||
@ -91,6 +103,10 @@ function activateNotarySignatureTool() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function activateNotaryCertificateTool() {
|
function activateNotaryCertificateTool() {
|
||||||
|
if (!canUseDrawTools()) {
|
||||||
|
showToast("Please open a document first.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
initCertificateBuilder();
|
initCertificateBuilder();
|
||||||
|
|
||||||
certificateBuilderCallback = function () {
|
certificateBuilderCallback = function () {
|
||||||
@ -108,6 +124,10 @@ function activateNotaryCertificateTool() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function activateClientSignaturePad() {
|
function activateClientSignaturePad() {
|
||||||
|
if (!canUseDrawTools()) {
|
||||||
|
showToast("Please open a document first.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
initSignaturePad();
|
initSignaturePad();
|
||||||
signaturePadCallback = function () {
|
signaturePadCallback = function () {
|
||||||
if (clientSignatureSvg != "" && signaturePad.isEmpty()) {
|
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
|
// Hide it at start
|
||||||
// doesn't work in CSS because of reasons
|
// doesn't work in CSS because of reasons
|
||||||
disableGuideBox();
|
disableGuideBox();
|
@ -386,6 +386,10 @@ function getNewCanvas(pagenumber) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function addPage() {
|
function addPage() {
|
||||||
|
if ($("#page-canvas-container .page-canvas").length == 0) {
|
||||||
|
showToast("Please open a document first.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
pageNumber++;
|
pageNumber++;
|
||||||
var canvas = getNewCanvas(pageNumber);
|
var canvas = getNewCanvas(pageNumber);
|
||||||
var prevPageCanvas = $("#page-canvas-container .page-canvas#pdf-canvas-page-" + (pageNumber - 1))[0];
|
var prevPageCanvas = $("#page-canvas-container .page-canvas#pdf-canvas-page-" + (pageNumber - 1))[0];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user