Skip to content

Commit

Permalink
fix(syoPopover): binda eventos de instâncias compartilhadas
Browse files Browse the repository at this point in the history
Desde a alteração 66858ea,
não estava mais sendo possível bindar eventos quando uma
instância de popover era compartilhada.
  • Loading branch information
Gustavo Henke committed Oct 24, 2014
1 parent cad2f23 commit 19f9ac5
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/scripts/popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@
definition.scope = true;
definition.restrict = "A";
definition.link = function( scope, element, attrs ) {
var popover, controller;
var currentEvent = {
in: "click",
out: getOutEvent( "click" )
};
var popover, controller, currentEvent;

element.parents().on( "scroll", function( evt ) {
// Fecha o popover se ele estiver aberto e aplica um digest
Expand All @@ -72,6 +68,7 @@
attrs.$observe( "syoPopover", function( config ) {
var mustBind = true;
config = scope.$eval( config );
config.event = config.event || "click";

controller = findByConfig( config );
if ( controller ) {
Expand All @@ -88,7 +85,7 @@

// Coloca o popover no DOM
$document.find( "body" ).append( popover );
} else {
} else if ( currentEvent ) {
// O evento mudou?
if ( currentEvent.in !== config.event ) {
// Sim, então vamos remover os listeners que adicionamos
Expand All @@ -100,9 +97,11 @@
}
}

currentEvent.in = config.event;
currentEvent.out = getOutEvent( config.event );
instances.push( controller );
currentEvent = {
in: config.event,
out: getOutEvent( config.event )
};

if ( mustBind ) {
// Binda o evento de entrada
Expand Down

0 comments on commit 19f9ac5

Please sign in to comment.