Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions website/static/js/jquery.caret.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,19 @@
$inputor = this.$inputor;
if (oDocument.selection) {
offset = this.getIEOffset(pos);
offset.top += $(oWindow).scrollTop() + $inputor.scrollTop();
offset.left += $(oWindow).scrollLeft() + $inputor.scrollLeft();
// Check if oWindow is a window object by checking for window-specific properties
function isValidWindow(obj) {
return obj && typeof obj === 'object' && 'scrollTo' in obj && obj.document && obj.self === obj;
}
// Then use this function in your conditionals
if (isValidWindow(oWindow)) {
offset.top += $(oWindow).scrollTop();
offset.left += $(oWindow).scrollLeft();
} else {
console.error('oWindow is not a valid window object.');
}
offset.top += $inputor.scrollTop();
offset.left += $inputor.scrollLeft();
return offset;
} else {
offset = $inputor.offset();
Expand Down