resurtm
11 years ago
16 changed files with 1498 additions and 9 deletions
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,51 @@ |
|||||||
|
/* always keep this link here when updating this file: https://github.com/jharding/typeahead.js-bootstrap.css */ |
||||||
|
|
||||||
|
.twitter-typeahead .tt-query, |
||||||
|
.twitter-typeahead .tt-hint { |
||||||
|
margin-bottom: 0; |
||||||
|
} |
||||||
|
|
||||||
|
.tt-dropdown-menu { |
||||||
|
min-width: 160px; |
||||||
|
margin-top: 2px; |
||||||
|
padding: 5px 0; |
||||||
|
background-color: #fff; |
||||||
|
border: 1px solid #ccc; |
||||||
|
border: 1px solid rgba(0,0,0,.2); |
||||||
|
*border-right-width: 2px; |
||||||
|
*border-bottom-width: 2px; |
||||||
|
-webkit-border-radius: 6px; |
||||||
|
-moz-border-radius: 6px; |
||||||
|
border-radius: 6px; |
||||||
|
-webkit-box-shadow: 0 5px 10px rgba(0,0,0,.2); |
||||||
|
-moz-box-shadow: 0 5px 10px rgba(0,0,0,.2); |
||||||
|
box-shadow: 0 5px 10px rgba(0,0,0,.2); |
||||||
|
-webkit-background-clip: padding-box; |
||||||
|
-moz-background-clip: padding; |
||||||
|
background-clip: padding-box; |
||||||
|
} |
||||||
|
|
||||||
|
.tt-suggestion { |
||||||
|
display: block; |
||||||
|
padding: 3px 20px; |
||||||
|
} |
||||||
|
|
||||||
|
.tt-suggestion.tt-is-under-cursor { |
||||||
|
color: #fff; |
||||||
|
background-color: #0081c2; |
||||||
|
background-image: -moz-linear-gradient(top, #0088cc, #0077b3); |
||||||
|
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0077b3)); |
||||||
|
background-image: -webkit-linear-gradient(top, #0088cc, #0077b3); |
||||||
|
background-image: -o-linear-gradient(top, #0088cc, #0077b3); |
||||||
|
background-image: linear-gradient(to bottom, #0088cc, #0077b3); |
||||||
|
background-repeat: repeat-x; |
||||||
|
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0077b3', GradientType=0) |
||||||
|
} |
||||||
|
|
||||||
|
.tt-suggestion.tt-is-under-cursor a { |
||||||
|
color: #fff; |
||||||
|
} |
||||||
|
|
||||||
|
.tt-suggestion p { |
||||||
|
margin: 0; |
||||||
|
} |
@ -0,0 +1,93 @@ |
|||||||
|
<?php |
||||||
|
/** |
||||||
|
* @link http://www.yiiframework.com/ |
||||||
|
* @copyright Copyright (c) 2008 Yii Software LLC |
||||||
|
* @license http://www.yiiframework.com/license/ |
||||||
|
*/ |
||||||
|
|
||||||
|
namespace yiiunit\framework\base; |
||||||
|
|
||||||
|
use yii\base\Component; |
||||||
|
use yii\base\Event; |
||||||
|
use yiiunit\TestCase; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Qiang Xue <qiang.xue@gmail.com> |
||||||
|
* @since 2.0 |
||||||
|
*/ |
||||||
|
class EventTest extends TestCase |
||||||
|
{ |
||||||
|
public $counter; |
||||||
|
|
||||||
|
public function setUp() |
||||||
|
{ |
||||||
|
$this->counter = 0; |
||||||
|
Event::off(ActiveRecord::className(), 'save'); |
||||||
|
Event::off(Post::className(), 'save'); |
||||||
|
Event::off(User::className(), 'save'); |
||||||
|
} |
||||||
|
|
||||||
|
public function testOn() |
||||||
|
{ |
||||||
|
Event::on(Post::className(), 'save', function ($event) { |
||||||
|
$this->counter += 1; |
||||||
|
}); |
||||||
|
Event::on(ActiveRecord::className(), 'save', function ($event) { |
||||||
|
$this->counter += 3; |
||||||
|
}); |
||||||
|
$this->assertEquals(0, $this->counter); |
||||||
|
$post = new Post; |
||||||
|
$post->save(); |
||||||
|
$this->assertEquals(4, $this->counter); |
||||||
|
$user = new User; |
||||||
|
$user->save(); |
||||||
|
$this->assertEquals(7, $this->counter); |
||||||
|
} |
||||||
|
|
||||||
|
public function testOff() |
||||||
|
{ |
||||||
|
$handler = function ($event) { |
||||||
|
$this->counter ++; |
||||||
|
}; |
||||||
|
$this->assertFalse(Event::hasHandlers(Post::className(), 'save')); |
||||||
|
Event::on(Post::className(), 'save', $handler); |
||||||
|
$this->assertTrue(Event::hasHandlers(Post::className(), 'save')); |
||||||
|
Event::off(Post::className(), 'save', $handler); |
||||||
|
$this->assertFalse(Event::hasHandlers(Post::className(), 'save')); |
||||||
|
} |
||||||
|
|
||||||
|
public function testHasHandlers() |
||||||
|
{ |
||||||
|
$this->assertFalse(Event::hasHandlers(Post::className(), 'save')); |
||||||
|
$this->assertFalse(Event::hasHandlers(ActiveRecord::className(), 'save')); |
||||||
|
Event::on(Post::className(), 'save', function ($event) { |
||||||
|
$this->counter += 1; |
||||||
|
}); |
||||||
|
$this->assertTrue(Event::hasHandlers(Post::className(), 'save')); |
||||||
|
$this->assertFalse(Event::hasHandlers(ActiveRecord::className(), 'save')); |
||||||
|
|
||||||
|
$this->assertFalse(Event::hasHandlers(User::className(), 'save')); |
||||||
|
Event::on(ActiveRecord::className(), 'save', function ($event) { |
||||||
|
$this->counter += 1; |
||||||
|
}); |
||||||
|
$this->assertTrue(Event::hasHandlers(User::className(), 'save')); |
||||||
|
$this->assertTrue(Event::hasHandlers(ActiveRecord::className(), 'save')); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
class ActiveRecord extends Component |
||||||
|
{ |
||||||
|
public function save() |
||||||
|
{ |
||||||
|
$this->trigger('save'); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
class Post extends ActiveRecord |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
class User extends ActiveRecord |
||||||
|
{ |
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue