|
1 | 1 | (function($) {
|
2 |
| - $.fn.pinout = function(options) { |
| 2 | + $.fn.pinannotation = function(options) { |
3 | 3 | var $pinWrap = $(this);
|
4 | 4 | var pinHammer;
|
5 | 5 | var freeze = false;
|
|
10 | 10 | placeholderText: 'Add note',
|
11 | 11 | image: '',
|
12 | 12 | openPopUpOnAdd: false,
|
| 13 | + closeOtherPopups: true, |
13 | 14 | onLoadPlugin: function() {},
|
14 | 15 | onPinRemove: function() {},
|
15 | 16 | onPinAdded: function() {},
|
|
39 | 40 | var openPin = function($pin) {
|
40 | 41 | console.log('open pin ', $pin.find('.pin-popup').length);
|
41 | 42 |
|
42 |
| - if ($pin.find('.pin-popup').length > 0) return; |
| 43 | + if (settings.closeOtherPopups) { |
| 44 | + $pinWrap.find('.pin-popup').remove(); |
| 45 | + } |
43 | 46 |
|
44 | 47 | $('<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);
|
45 | 48 | $pin.find('.pin-popup textarea').val('');
|
|
51 | 54 |
|
52 | 55 | var closePin = function($pin) {
|
53 | 56 | console.log('close pin ');
|
54 |
| - |
55 | 57 | if ($.isFunction(settings.onPinPopUpClose)) {
|
56 | 58 | settings.onPinPopUpClose.call(this);
|
57 | 59 | }
|
|
104 | 106 | $(`<div/>`, { class: 'pin', style: 'left:' + posX + '%; top:' + posY + '%;', 'data-annotation': '' }).appendTo($pinWrap);
|
105 | 107 |
|
106 | 108 | if (settings.openPopUpOnAdd) {
|
107 |
| - openPin($pinWrap.find('.pin')); |
| 109 | + openPin($pinWrap.find('.pin').last()); |
108 | 110 | }
|
109 | 111 | };
|
110 | 112 |
|
|
0 commit comments