|
52 | 52 |
|
53 | 53 | this.options = options || {};
|
54 | 54 | this.arrowSize = 15
|
| 55 | + this.docClickHandler = null |
55 | 56 | this.show()
|
56 | 57 | }
|
57 | 58 |
|
|
94 | 95 |
|
95 | 96 | $(document).unbind('mousedown', this.docClickHandler);
|
96 | 97 | $(document).off('.oc.popover')
|
| 98 | + |
| 99 | + this.docClickHandler = null |
97 | 100 | }
|
98 | 101 |
|
99 | 102 | Popover.prototype.show = function(options) {
|
|
165 | 168 | /*
|
166 | 169 | * Bind events
|
167 | 170 | */
|
168 |
| - this.$container.on('close.oc.popover', function(e){ |
169 |
| - self.hide() |
170 |
| - }) |
171 |
| - |
172 |
| - this.$container.on('click', '[data-dismiss=popover]', function(e){ |
173 |
| - self.hide() |
174 |
| - return false |
175 |
| - }) |
176 |
| - |
177 |
| - this.docClickHandler = $.proxy(this.onDocumentClick, this) |
178 |
| - $(document).bind('mousedown', this.docClickHandler); |
179 |
| - |
180 |
| - if (this.options.closeOnEsc) { |
181 |
| - $(document).on('keyup.oc.popover', function(e){ |
182 |
| - if ($(e.target).hasClass('select2-offscreen')) |
183 |
| - return false |
184 |
| - |
185 |
| - if (e.keyCode == 27) { |
186 |
| - self.hide() |
187 |
| - return false |
188 |
| - } |
189 |
| - }) |
190 |
| - } |
| 171 | + this.$container.on('close.oc.popover', function(e){ |
| 172 | + self.hide() |
| 173 | + }) |
| 174 | + |
| 175 | + this.$container.on('click', '[data-dismiss=popover]', function(e){ |
| 176 | + self.hide() |
| 177 | + return false |
| 178 | + }) |
| 179 | + |
| 180 | + this.docClickHandler = $.proxy(this.onDocumentClick, this) |
| 181 | + $(document).bind('mousedown', this.docClickHandler); |
| 182 | + |
| 183 | + if (this.options.closeOnEsc) { |
| 184 | + $(document).on('keyup.oc.popover', function(e){ |
| 185 | + if ($(e.target).hasClass('select2-offscreen')) |
| 186 | + return false |
| 187 | + |
| 188 | + if (e.keyCode == 27) { |
| 189 | + self.hide() |
| 190 | + return false |
| 191 | + } |
| 192 | + }) |
| 193 | + } |
191 | 194 | }
|
192 | 195 |
|
193 | 196 | Popover.prototype.getContent = function () {
|
|
0 commit comments