-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathOutdatedBrowser.php
51 lines (41 loc) · 1.18 KB
/
OutdatedBrowser.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
namespace sammaye\outdatedBrowser;
use yii\base\Widget;
use yii\helpers\Html;
use sammaye\outdatedBrowser\OutdatedBrowserAsset;
class Outdatedbrowser extends Widget
{
public $bgColor = '#f25648';
public $color = '#ffffff';
public $lowerThan =null;
public $language = 'en';
public $onlyIe7 = false;
public function run()
{
$bundle = OutdatedBrowserAsset::register($this->getView());
$this->getView()->registerJs("
$(function() {
" . ($this->onlyIe7 ? "
if($('#outdated').length > 0){
" : "") . "
// plugin function, place inside DOM ready function
outdatedBrowser({
bgColor: '" . $this->bgColor . "',
color: '" . $this->color . "',
lowerThan: " . ($this->lowerThan !== null ? "'" . $this->lowerThan . "'" : "''") . ",
languagePath: '" . $bundle->baseUrl ."/outdatedbrowser/lang/" . $this->language . ".html'
})
" . ($this->onlyIe7 ? "
}
" : "") . "
});
");
if($this->onlyIe7){
echo '<!--[if lt IE 8]>' .
Html::tag('div', '', ['id' => 'outdated']) .
'<![endif]-->';
}else{
echo Html::tag('div', '', ['id' => 'outdated']);
}
}
}