webui-popover
Advanced tools
Comparing version 1.2.2 to 1.2.3
{ | ||
"name": "webui-popover", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"authors": [ | ||
@@ -5,0 +5,0 @@ "sandywalker <sanddywalker@gmail.com>" |
@@ -6,2 +6,10 @@ | ||
### 1.2.3 | ||
* fix the bug which cause the popover hide by click when multi popovers in same page. | ||
* optimize event handling for performance | ||
### 1.2.2 | ||
* | ||
* optimize code and clean debug info | ||
### 1.2.1 | ||
@@ -8,0 +16,0 @@ * now option url can be set with jQuery selector (eg: '#myContent') when type equals 'html'. |
@@ -7,3 +7,3 @@ { | ||
"homepage": "https://github.com/sandywalker/webui-popover", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"license":"MIT", | ||
@@ -10,0 +10,0 @@ "devDependencies": { |
@@ -26,2 +26,12 @@ WebUI-Popover | ||
##NPM | ||
```bash | ||
npm install webui-popover | ||
``` | ||
##Bower | ||
```bash | ||
bower install webui-popover | ||
``` | ||
##CDN | ||
@@ -28,0 +38,0 @@ WebUI Popover Support CDN from version 1.2.1, avaliable on [JSDELIVR](http://www.jsdelivr.com/?query=webui-popover) |
@@ -53,3 +53,3 @@ ; | ||
var popovers = []; | ||
var _srcElements = []; | ||
var backdrop = $('<div class="webui-popover-backdrop"></div>'); | ||
@@ -65,4 +65,16 @@ var _globalIdSeed = 0; | ||
var getPopFromElement = function($element) { | ||
return $element.data('plugin_' + pluginName); | ||
}; | ||
var hideAllPop = function() { | ||
for (var i = 0; i < _srcElements.length; i++) { | ||
_srcElements[i].webuiPopover('hide'); | ||
} | ||
$document.trigger('hiddenAll.' + pluginType); | ||
}; | ||
// The actual plugin constructor | ||
@@ -84,3 +96,3 @@ function WebuiPopover(element, options) { | ||
this.init(); | ||
popovers.push(this.$element); | ||
_srcElements.push(this.$element); | ||
} | ||
@@ -117,4 +129,4 @@ | ||
for (var i = 0; i < popovers.length; i++) { | ||
if (popovers[i] === this.$element) { | ||
for (var i = 0; i < _srcElements.length; i++) { | ||
if (_srcElements[i] === this.$element) { | ||
index = i; | ||
@@ -125,3 +137,3 @@ break; | ||
popovers.splice(index, 1); | ||
_srcElements.splice(index, 1); | ||
@@ -203,7 +215,3 @@ | ||
hideAll: function() { | ||
for (var i = 0; i < popovers.length; i++) { | ||
popovers[i].webuiPopover('hide'); | ||
} | ||
$document.trigger('hiddenAll.' + pluginType); | ||
hideAllPop(); | ||
}, | ||
@@ -553,16 +561,30 @@ /*core method ,show popover */ | ||
}, | ||
bodyClickHandler: function() { | ||
bodyClickHandler: function(e) { | ||
_isBodyEventHandled = true; | ||
if (this.getTrigger() === 'click') { | ||
if (this._targetclick) { | ||
this._targetclick = false; | ||
} else { | ||
this.hideAll(); | ||
var canHide = true; | ||
for (var i = 0; i < _srcElements.length; i++) { | ||
var pop = getPopFromElement(_srcElements[i]); | ||
if (pop._opened) { | ||
var popX1 = pop.getTarget().offset().left; | ||
var popY1 = pop.getTarget().offset().top; | ||
var popX2 = pop.getTarget().offset().left + pop.getTarget().width(); | ||
var popY2 = pop.getTarget().offset().top + pop.getTarget().height(); | ||
var inPop = e.pageX >= popX1 && e.pageX <= popX2 && e.pageY >= popY1 && e.pageY <= popY2; | ||
if (inPop) { | ||
canHide = false; | ||
break; | ||
} | ||
} | ||
} | ||
if (canHide) { | ||
hideAllPop(); | ||
} | ||
}, | ||
/* | ||
targetClickHandler: function() { | ||
this._targetclick = true; | ||
}, | ||
*/ | ||
@@ -578,3 +600,3 @@ //reset and init the target events; | ||
this.$target.find('.close').off('click').on('click', $.proxy(this.hide, this, true)); | ||
this.$target.off('click.webui-popover').on('click.webui-popover', $.proxy(this.targetClickHandler, this)); | ||
//this.$target.off('click.webui-popover').on('click.webui-popover', $.proxy(this.targetClickHandler, this)); | ||
}, | ||
@@ -581,0 +603,0 @@ /* utils methods */ |
@@ -11,3 +11,3 @@ { | ||
], | ||
"version":"1.2.2", | ||
"version":"1.2.3", | ||
"author": { | ||
@@ -14,0 +14,0 @@ "name": "Sandy Duan", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
220
705860
31
15556