Refactor comments for clarity and consistency
Replaced non-English comments with English equivalents across `EnvelopeViewer.razor` and `pdf-viewer.js` to improve code readability and maintainability. Updated comments to clarify the purpose of variables, methods, and DOM manipulation logic without altering functionality. These changes ensure the codebase is more accessible to a broader audience.
This commit is contained in:
@@ -489,7 +489,7 @@ window.pdfViewer = {
|
||||
* @returns {object} { total, signed, unsigned, currentIndex, canGoPrev, canGoNext }
|
||||
*/
|
||||
getSignatureNavState() {
|
||||
// Global imza listesi yoksa bo? state d<>n
|
||||
// Return empty state if global signature list is empty
|
||||
if (!this._allSignatures || this._allSignatures.length === 0) {
|
||||
return {
|
||||
total: 0,
|
||||
@@ -501,25 +501,26 @@ window.pdfViewer = {
|
||||
};
|
||||
}
|
||||
|
||||
// T<>M sayfalardaki imzalar? say (database'den gelen global liste)
|
||||
const total = this._allSignatures.length; // Global: Toplam imza say?s?
|
||||
const signed = this.appliedSignatures.length; // ?mzalananlar
|
||||
const unsigned = total - signed; // Hesaplanan: ?mzalanmayanlar
|
||||
|
||||
// Mevcut görüntülenen imzanın sıra numarasını bul
|
||||
// Count signatures across ALL pages (from database global list)
|
||||
const total = this._allSignatures.length; // Global: Total signature count
|
||||
const signed = this.appliedSignatures.length; // Signed signatures
|
||||
const unsigned = total - signed; // Calculated: Unsigned signatures
|
||||
|
||||
// Find the current viewed signature index
|
||||
let currentIndex = 0;
|
||||
if (this._lastViewedSignatureId) {
|
||||
const index = this._allSignatures.findIndex(s => s.id === this._lastViewedSignatureId);
|
||||
currentIndex = index !== -1 ? index + 1 : 0; // 1-based index (kullanıcıya göstermek için)
|
||||
currentIndex = index !== -1 ? index + 1 : 0; // 1-based index (for user display)
|
||||
}
|
||||
|
||||
return {
|
||||
total: total,
|
||||
signed: signed,
|
||||
unsigned: unsigned,
|
||||
currentIndex: currentIndex, // Şu an hangi imzada (1-5 arası)
|
||||
canGoPrev: total > 0, // Her zaman aktif (e?er imza varsa)
|
||||
canGoNext: total > 0 // Her zaman aktif (e?er imza varsa)
|
||||
currentIndex: currentIndex, // Current signature index (1-5 range)
|
||||
canGoPrev: total > 0, // Always active (if signatures exist)
|
||||
canGoNext: total > 0 // Always active (if signatures exist)
|
||||
};
|
||||
},
|
||||
|
||||
@@ -529,63 +530,64 @@ window.pdfViewer = {
|
||||
* Cross-page navigation: searches ALL pages for next unsigned signature.
|
||||
*/
|
||||
async goToNextSignature(dotNetRef) {
|
||||
// Global imza listesi yoksa <20>?k
|
||||
// Exit if no global signature list
|
||||
if (!this._allSignatures || this._allSignatures.length === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Mevcut g<>r<EFBFBD>nt<6E>lenen imzan?n index'ini bul
|
||||
// Find current displayed signature's index
|
||||
let currentIndex = -1;
|
||||
if (this._lastViewedSignatureId) {
|
||||
currentIndex = this._allSignatures.findIndex(s => s.id === this._lastViewedSignatureId);
|
||||
}
|
||||
|
||||
// Bir sonraki imzay? al (imzalanm?? olup olmad???na bakmadan)
|
||||
// Get next signature (regardless of signed status)
|
||||
let nextIndex = currentIndex + 1;
|
||||
|
||||
// Sonsuz d<>ng<6E>: Son imzadaysa ilk imzaya d<>n
|
||||
// Infinite loop: If at last signature, return to first
|
||||
if (nextIndex >= this._allSignatures.length) {
|
||||
nextIndex = 0; // ?lk imzaya d<>n
|
||||
nextIndex = 0; // Return to first signature
|
||||
}
|
||||
|
||||
const nextSignature = this._allSignatures[nextIndex];
|
||||
|
||||
// Farkl? sayfadaysa sayfa de?i?tir
|
||||
// Change page if signature is on different page
|
||||
if (nextSignature.page !== this.pageNum) {
|
||||
// Sayfa de?i?tir
|
||||
// Change page
|
||||
this.pageNum = nextSignature.page;
|
||||
this.queueRenderPage(this.pageNum);
|
||||
|
||||
// Render tamamlanana kadar bekle
|
||||
// Wait until render completes
|
||||
let waitCount = 0;
|
||||
while (this.pageRendering && waitCount < 20) {
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
waitCount++;
|
||||
}
|
||||
|
||||
// Blazor'a haber ver - signature butonlar?n? yeniden ?iz
|
||||
// Notify Blazor - re-render signature buttons
|
||||
if (dotNetRef) {
|
||||
await dotNetRef.invokeMethodAsync('OnPageChangedBySignatureNav', this.pageNum);
|
||||
}
|
||||
|
||||
// Butonlar?n DOM'a eklenmesini bekle
|
||||
// Wait for buttons to be added to DOM
|
||||
await new Promise(resolve => setTimeout(resolve, 150));
|
||||
}
|
||||
|
||||
// Son g<>r<EFBFBD>nt<6E>lenen imzay? kaydet
|
||||
|
||||
// Save last viewed signature
|
||||
this._lastViewedSignatureId = nextSignature.id;
|
||||
|
||||
// ?mza imzalanm?? m? kontrol et
|
||||
// Check if signature is signed
|
||||
const isApplied = this.appliedSignatures.some(s => s.id === nextSignature.id);
|
||||
|
||||
if (isApplied) {
|
||||
// ?mzalanm?? - overlay container'? bul ve scroll yap
|
||||
// Signed - find overlay container and scroll
|
||||
const container = document.querySelector(`.applied-signature[data-signature-id="${nextSignature.id}"]`);
|
||||
if (container) {
|
||||
this.scrollToElement(container);
|
||||
}
|
||||
} else {
|
||||
// ?mzalanmam?? - butonu bul ve scroll yap
|
||||
// Unsigned - find button and scroll
|
||||
const button = this.signatureButtons.find(btn =>
|
||||
parseInt(btn.getAttribute('data-signature-id')) === nextSignature.id
|
||||
);
|
||||
@@ -594,7 +596,7 @@ window.pdfViewer = {
|
||||
}
|
||||
}
|
||||
|
||||
// Counter'? g<>ncelle (Blazor'a bildir)
|
||||
// Update counter (notify Blazor)
|
||||
if (dotNetRef) {
|
||||
dotNetRef.invokeMethodAsync('OnSignatureNavChanged');
|
||||
}
|
||||
@@ -611,58 +613,58 @@ window.pdfViewer = {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Mevcut g<>r<EFBFBD>nt<6E>lenen imzan?n index'ini bul
|
||||
let currentIndex = this._allSignatures.length; // Varsay?lan: son imzadan sonra
|
||||
// Find current displayed signature's index
|
||||
let currentIndex = this._allSignatures.length; // Default: after last signature
|
||||
if (this._lastViewedSignatureId) {
|
||||
currentIndex = this._allSignatures.findIndex(s => s.id === this._lastViewedSignatureId);
|
||||
}
|
||||
|
||||
// Bir <20>nceki imzay? al
|
||||
// Get previous signature
|
||||
let prevIndex = currentIndex - 1;
|
||||
|
||||
// Sonsuz d<>ng<6E>: ?lk imzadaysa son imzaya git
|
||||
// Infinite loop: If at first signature, go to last
|
||||
if (prevIndex < 0) {
|
||||
prevIndex = this._allSignatures.length - 1; // Son imzaya git
|
||||
prevIndex = this._allSignatures.length - 1; // Go to last signature
|
||||
}
|
||||
|
||||
const prevSignature = this._allSignatures[prevIndex];
|
||||
|
||||
// Change page if needed
|
||||
if (prevSignature.page !== this.pageNum) {
|
||||
// Sayfa de?i?tir
|
||||
// Change page
|
||||
this.pageNum = prevSignature.page;
|
||||
this.queueRenderPage(this.pageNum);
|
||||
|
||||
// Render tamamlanana kadar bekle
|
||||
// Wait until render completes
|
||||
let waitCount = 0;
|
||||
while (this.pageRendering && waitCount < 20) {
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
waitCount++;
|
||||
}
|
||||
|
||||
// Blazor'a haber ver - signature butonlar?n? yeniden <20>iz
|
||||
// Notify Blazor - re-render signature buttons
|
||||
if (dotNetRef) {
|
||||
await dotNetRef.invokeMethodAsync('OnPageChangedBySignatureNav', this.pageNum);
|
||||
}
|
||||
|
||||
// DOM g<>ncellenmesini bekle
|
||||
// Wait for DOM update
|
||||
await new Promise(resolve => setTimeout(resolve, 150));
|
||||
}
|
||||
|
||||
// Son g<>r<EFBFBD>nt<6E>lenen imzay? kaydet
|
||||
// Save last viewed signature
|
||||
this._lastViewedSignatureId = prevSignature.id;
|
||||
|
||||
// ?mza imzalanm?? m? kontrol et
|
||||
// Check if signature is signed
|
||||
const isApplied = this.appliedSignatures.some(s => s.id === prevSignature.id);
|
||||
|
||||
if (isApplied) {
|
||||
// ?mzalanm?? - overlay container'? bul ve scroll yap
|
||||
// Signed - find overlay container and scroll
|
||||
const container = document.querySelector(`.applied-signature[data-signature-id="${prevSignature.id}"]`);
|
||||
if (container) {
|
||||
this.scrollToElement(container);
|
||||
}
|
||||
} else {
|
||||
// ?mzalanmam?? - butonu bul ve scroll yap
|
||||
// Unsigned - find button and scroll
|
||||
const button = this.signatureButtons.find(btn =>
|
||||
parseInt(btn.getAttribute('data-signature-id')) === prevSignature.id
|
||||
);
|
||||
@@ -1070,8 +1072,8 @@ window.pdfViewer = {
|
||||
|
||||
// Text information container
|
||||
const infoContainer = document.createElement('div');
|
||||
infoContainer.className = 'signature-info-text'; // ✅ Class ekle (querySelector için)
|
||||
infoContainer.setAttribute('data-base-font-size', '9'); // ✅ Base font size sakla
|
||||
infoContainer.className = 'signature-info-text'; // ✅ Add class (for querySelector)
|
||||
infoContainer.setAttribute('data-base-font-size', '9'); // ✅ Store base font size
|
||||
infoContainer.style.fontSize = '9px';
|
||||
infoContainer.style.lineHeight = '1.4';
|
||||
infoContainer.style.color = '#495057';
|
||||
|
||||
Reference in New Issue
Block a user