Skip to content

Commit 21a9679

Browse files
committed
added closeOtherPopups setting
1 parent 001bcf1 commit 21a9679

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.prettierrc.js

src/jquery-pin-annotation.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(function($) {
2-
$.fn.pinout = function(options) {
2+
$.fn.pinannotation = function(options) {
33
var $pinWrap = $(this);
44
var pinHammer;
55
var freeze = false;
@@ -10,6 +10,7 @@
1010
placeholderText: 'Add note',
1111
image: '',
1212
openPopUpOnAdd: false,
13+
closeOtherPopups: true,
1314
onLoadPlugin: function() {},
1415
onPinRemove: function() {},
1516
onPinAdded: function() {},
@@ -39,7 +40,9 @@
3940
var openPin = function($pin) {
4041
console.log('open pin ', $pin.find('.pin-popup').length);
4142

42-
if ($pin.find('.pin-popup').length > 0) return;
43+
if (settings.closeOtherPopups) {
44+
$pinWrap.find('.pin-popup').remove();
45+
}
4346

4447
$('<div/>', { class: 'pin-popup', append: `<textarea placeholder='${settings.placeholderText}' class='annotation-text-pin'> ${$pin.data('annotation')} </textarea>${popUpDom.btn_save} ${popUpDom.btn_remove}` }).appendTo($pin);
4548
$pin.find('.pin-popup textarea').val('');
@@ -51,7 +54,6 @@
5154

5255
var closePin = function($pin) {
5356
console.log('close pin ');
54-
5557
if ($.isFunction(settings.onPinPopUpClose)) {
5658
settings.onPinPopUpClose.call(this);
5759
}
@@ -104,7 +106,7 @@
104106
$(`<div/>`, { class: 'pin', style: 'left:' + posX + '%; top:' + posY + '%;', 'data-annotation': '' }).appendTo($pinWrap);
105107

106108
if (settings.openPopUpOnAdd) {
107-
openPin($pinWrap.find('.pin'));
109+
openPin($pinWrap.find('.pin').last());
108110
}
109111
};
110112

0 commit comments

Comments
 (0)