Bugs popover

This commit is contained in:
Juan Ferrer Toribio 2017-01-09 14:54:47 +01:00
parent c2530acafd
commit 1f1fcce5a8
2 changed files with 13 additions and 11 deletions

View File

@ -2,7 +2,7 @@
<vn-textfield vn-one label="Search" model="$ctrl.search"></vn-textfield>
<vn-icon icon="keyboard_arrow_down" ng-click="searchbar.onClick($event)" style="cursor: pointer;"></vn-icon>
<vn-icon-button icon="search"></vn-icon-button>
<vn-popover>
<vn-popover id="popover">
<vn-search-panel></vn-search-panel>
</vn-popover>
</vn-horizontal>

View File

@ -14,9 +14,20 @@ export function directive(resolver) {
return resolver.getTemplate(_NAME, attrs);
},
controller: function($element) {
var self = this;
var doc = angular.element(document);
function docMouseDownHandler (event) {
if (event != self.lastEvent)
self.hide();
}
this.onMouseDown = function(event) {
this.lastEvent = event;
};
this.hide = function ()
{
$element[0].style.display = 'none';
doc.off('mousedown', docMouseDownHandler);
}
this.show = function(parent) {
var node = $element[0];
var style = node.style;
@ -60,16 +71,7 @@ export function directive(resolver) {
}
style.display = 'block';
var self = this;
var doc = angular.element(document);
var clickHandler = function(event) {
if (event != self.lastEvent) {
style.display = 'none';
doc.off('mousedown', clickHandler);
}
}
doc.on('mousedown', clickHandler);
doc.on('mousedown', docMouseDownHandler);
};
}
}