Skip to content

Commit

Permalink
Add property to info window to allow to close the info windows if an …
Browse files Browse the repository at this point in the history
…other is opened
  • Loading branch information
GeLoLabs authored and wodor committed Jan 7, 2012
1 parent ae71ac0 commit e065082
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Model/Overlays/InfoWindow.php
Expand Up @@ -44,6 +44,11 @@ class InfoWindow extends AbstractOptionsAsset implements IExtendable
* @var string Event which opens the info window
*/
protected $openEvent = MouseEvent::CLICK;

/**
* @var boolean TRUE if the info window closes when one is opened else FALSE
*/
protected $autoClose = false;

/**
* Create an info window
Expand Down Expand Up @@ -247,4 +252,27 @@ public function setOpenEvent($openEvent)
else
throw new \InvalidArgumentException(sprintf('The only available open event are : %s', implode(', ', MouseEvent::getMouseEvents())));
}

/**
* Gets the auto close flag
*
* @return boolean TRUE if all opened info windows close when one is opened else FALSE
*/
public function isAutoClose()
{
return $this->autoClose;
}

/**
* Sets the auto close flag
*
* @param boolean $autoClose TRUE if all opened info windows close when one is opened else FALSE
*/
public function setAutoClose($autoClose)
{
if(is_bool($autoClose))
$this->autoClose = $autoClose;
else
throw new \InvalidArgumentException('The info window auto close flag must be a boolean value.');
}
}
14 changes: 14 additions & 0 deletions Tests/Model/Overlays/InfoWindowTest.php
Expand Up @@ -38,12 +38,26 @@ public function testDefaultValues()
{
parent::testDefaultValues();

$this->assertFalse(self::$object->isAutoClose());
$this->assertNull(self::$object->getPosition());
$this->assertNull(self::$object->getPixelOffset());
$this->assertEquals(self::$object->getContent(), '<p>Default content</p>');
$this->assertFalse(self::$object->isOpen());
$this->assertTrue(self::$object->isAutoOpen());
$this->assertEquals(self::$object->getOpenEvent(), 'click');
$this->assertFalse(self::$object->isAutoClose());
}

/**
* Checks the auto close getter & setter
*/
public function testAutoClose()
{
self::$object->setAutoClose(true);
$this->assertTrue(self::$object->isAutoClose());

self::$object->setAutoClose(false);
$this->assertFalse(self::$object->isAutoClose());
}

/**
Expand Down

0 comments on commit e065082

Please sign in to comment.