实现新的UINavBar,并改为仅使用Bootstrap,不再使用AlloyUI
This commit is contained in:
parent
7204689656
commit
e27b45a361
@ -10,3 +10,4 @@
|
||||
|
||||
require_once "ui_tab.php";
|
||||
require_once 'ui_sidebar.php';
|
||||
require_once "ui_navbar.php";
|
||||
|
15
tools.php
15
tools.php
@ -8,9 +8,18 @@
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<meta name="viewport" content="initial-scale=1.0, user-scalable=yes, minimum-scale=0.25, maximum-scale=5.0, width=device-width" />
|
||||
<script src="3rdpty/aui/aui-min.js"></script>
|
||||
<link href="3rdpty/aui-css/css/bootstrap.min.css" rel="stylesheet"/></link>
|
||||
</head>
|
||||
<script src="3rdpty/jquery-3.1.0.js"></script>
|
||||
|
||||
<!-- Latest compiled and minified CSS -->
|
||||
<link rel="stylesheet" href="3rdpty/bootstrap/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
|
||||
|
||||
<!-- Optional theme -->
|
||||
<link rel="stylesheet" href="3rdpty/bootstrap/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
|
||||
|
||||
<!-- Latest compiled and minified JavaScript -->
|
||||
<script src="3rdpty/bootstrap/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
';
|
||||
}
|
||||
|
154
ui_navbar.php
Normal file
154
ui_navbar.php
Normal file
@ -0,0 +1,154 @@
|
||||
<?php
|
||||
|
||||
//参考:http://www.w3schools.com/bootstrap/bootstrap_navbar.asp
|
||||
|
||||
class MenuItem
|
||||
{
|
||||
private $text=null;
|
||||
private $link=null;
|
||||
private $sub_menu=null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$a = func_get_args();
|
||||
$i = func_num_args();
|
||||
|
||||
if (method_exists($this,$f='__construct'.$i))
|
||||
call_user_func_array(array($this,$f),$a);
|
||||
}
|
||||
|
||||
public function __construct1($s)
|
||||
{
|
||||
$this->sub_menu=$s;
|
||||
}
|
||||
|
||||
public function __construct2($t,$l)
|
||||
{
|
||||
$this->Set($t,$l);
|
||||
}
|
||||
|
||||
public function __construct3($t,$l,$s)
|
||||
{
|
||||
$this->Set($t,$l);
|
||||
$this->sub_menu=$s;
|
||||
}
|
||||
|
||||
public function Set($t,$l)
|
||||
{
|
||||
$this->text=$t;
|
||||
$this->link=$l;
|
||||
}
|
||||
|
||||
public function SetSubMenu($sm)
|
||||
{
|
||||
$this->sub_menu=$sm;
|
||||
}
|
||||
|
||||
public function GetText()
|
||||
{
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
public function GetLink()
|
||||
{
|
||||
return $this->link;
|
||||
}
|
||||
|
||||
public function GetSubMenu()
|
||||
{
|
||||
return $this->sub_menu;
|
||||
}
|
||||
};//class MenuItem
|
||||
|
||||
class UINavBar
|
||||
{
|
||||
private $style="navbar-default";
|
||||
private $fix_top=true;
|
||||
private $brand=null;
|
||||
private $brand_link=null;
|
||||
private $menu=null;
|
||||
private $active=null;
|
||||
|
||||
public function __construct($m,$a)
|
||||
{
|
||||
$this->menu=$m;
|
||||
$this->active=$a;
|
||||
}
|
||||
|
||||
public function set_style($s)
|
||||
{
|
||||
if($s==null||strlen($s)<=0)
|
||||
$this->style="";
|
||||
else
|
||||
$this->style="navbar-".$s;
|
||||
}
|
||||
|
||||
/**
|
||||
* @b 标题文本
|
||||
* @l 标题链接
|
||||
*/
|
||||
public function set_brand($b,$l)
|
||||
{
|
||||
$this->brand=$b;
|
||||
$this->brand_link=$l;
|
||||
}
|
||||
|
||||
private function echo_menu($m)
|
||||
{
|
||||
if($m==null)return;
|
||||
|
||||
foreach($m as $mi)
|
||||
{
|
||||
$sub_menu=$mi->GetSubMenu();
|
||||
|
||||
if($sub_menu!=null) //子菜单
|
||||
{
|
||||
echo '<li class="dropdown">
|
||||
<a class="dropdown-toggle" data-toggle="dropdown" href="'.$mi->GetLink().'" role="button" aria-haspopup="true" aria-expanded="false">'.$mi->GetText().'
|
||||
<span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">';
|
||||
$this->echo_menu($sub_menu);
|
||||
echo '</ul>
|
||||
</li>';
|
||||
}
|
||||
else
|
||||
{
|
||||
if($this->active==$mi->GetLink())
|
||||
echo '<li class="active">';
|
||||
else
|
||||
echo '<li>';
|
||||
|
||||
echo '<a href="'.$mi->GetLink().'">'.$mi->GetText().'</a></li>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function out_html()
|
||||
{
|
||||
echo '<nav class="navbar '.$this->style.'">
|
||||
<div class="container-fluid">';
|
||||
|
||||
if($this->brand!=null&&strlen($this->brand)>0)
|
||||
{
|
||||
echo '<div class="navbar-header">';
|
||||
|
||||
if($this->brand_link!=null&&strlen($this->brand_link)>0)
|
||||
echo '<a class="navbar-brand" href="'.$this->brand_link.'">'.$this->brand.'</a>';
|
||||
else
|
||||
echo '<font class="navbar-brand">'.$this->brand.'</font>';
|
||||
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
echo '<div class="navbar-collapse">
|
||||
<ul class="nav navbar-nav">';
|
||||
|
||||
if($this->menu!=null)
|
||||
$this->echo_menu($this->menu->GetSubMenu());
|
||||
|
||||
echo '</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>';
|
||||
}
|
||||
};//class UINavBar
|
Loading…
x
Reference in New Issue
Block a user