@@ -17,6 +17,8 @@ import {
1717} from '@angular/core' ;
1818import { CommonModule } from '@angular/common' ;
1919import { Router } from '@angular/router' ;
20+
21+ import { ShareModule } from '../../../share/share.module' ;
2022import { MdlModule } from '@angular-mdl/core' ;
2123
2224import { TabControlServiceModal } from './TabControlServiceModal' ;
@@ -85,41 +87,22 @@ export class Md2TabLabel {
8587 [class.disabled]="tab.disabled" (click)="goToTab(tab.reallyTab)">
8688 <span [md2Transclude]="tab.labelRef">{{tab.label}}</span>
8789 </div>
88- <div class="md2-tab-ink-bar" [style.left]="inkBarLeft" [style.width]="inkBarWidth"></div>
90+ <button mdl-button #btn1="mdlButton" (click)="m1.toggle($event, btn1)" id="tab_manage_btn" mdl-ripple>
91+ <i class="fa fa-sort-down fa-lg white"></i>
92+ </button>
93+ <mdl-menu #m1="mdlMenu" mdl-menu-position="bottom-left">
94+ <mdl-menu-item mdl-ripple mdl-menu-item-full-bleed-divider (click)="reloadNow()">刷新当前页</mdl-menu-item>
95+ <mdl-menu-item mdl-ripple mdl-menu-item-full-bleed-divider (click)="closeAll()">关闭所有选项卡</mdl-menu-item>
96+ <mdl-menu-item mdl-ripple mdl-menu-item-full-bleed-divider (click)="closeOther()">关闭其它选项卡</mdl-menu-item>
97+ <mdl-menu-item mdl-ripple mdl-menu-item-full-bleed-divider (click)="closeNow()">关闭当前选项卡</mdl-menu-item>
98+ </mdl-menu>
99+ <div class="md2-tab-ink-bars" [style.left]="inkBarLeft" [style.width]="inkBarWidth"></div>
89100 </div>
90101 </div>
91102
92103 </div>
93104 ` ,
94- styles : [ `
95- md2-tabs { position: absolute; left: 240px; top: 36px; overflow: hidden; display: block; margin-right: 45px; border-radius: 2px; }
96- .md2-tabs-header-wrapper { position: relative; display: block; height: 35px; border-radius: 5px 5px 0 0; display: block; margin: 0; padding: 0; list-style: none;
97- -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; }
98- .md2-tabs-header-wrapper:after { content: ''; display: table; clear: both; }
99- .md2-prev-button,
100- .md2-next-button { position: absolute; top: 0; height: 100%; width: 32px; padding: 10px 0; z-index: 2; cursor: pointer; }
101- .md2-prev-button { left: 0; }
102- .md2-next-button { right: 0; }
103- .md2-prev-button.disabled,
104- .md2-next-button.disabled { opacity: .4; cursor: default; }
105- .md2-prev-button .prev-icon,
106- .md2-next-button .next-icon { display: block; width: 10px; height: 10px; font-size: 0; border-width: 0 0 2px 2px;
107- border-style: solid; border-color: #757575; border-radius: 1px; transform: rotate(45deg); margin: 8px; }
108- .md2-next-button .next-icon { border-width: 2px 2px 0 0; }
109- .md2-tabs-canvas { position: relative; height: 100%; overflow: hidden; display: block; outline: none; }
110- .md2-tabs-canvas.md2-paginated { margin: 0 32px; }
111- .md2-tabs-header { position: relative; display: inline-block; height: 100%; white-space: nowrap; -moz-transition: 0.5s cubic-bezier(0.35,0,0.25,1); -o-transition: 0.5s cubic-bezier(0.35,0,0.25,1); -webkit-transition: 0.5s cubic-bezier(0.35,0,0.25,1); transition: 0.5s cubic-bezier(0.35,0,0.25,1); }
112- .md2-tab-label { position: relative; height: 100%; color: rgba(0,0,0,0.54); font-size: 14px; text-align: center; line-height: 24px; border-radius: 5px 5px 0 0 ; padding: 4px 20px; -moz-transition: background-color .35s cubic-bezier(.35,0,.25,1); -o-transition: background-color .35s cubic-bezier(.35,0,.25,1); -webkit-transition: background-color .35s cubic-bezier(.35,0,.25,1); transition: background-color .35s cubic-bezier(.35,0,.25,1); cursor: pointer; white-space: nowrap; text-transform: uppercase; display: inline-block; font-weight: 500; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; overflow: hidden; -ms-text-overflow: ellipsis; -o-text-overflow: ellipsis; text-overflow: ellipsis; }
113- .md2-tab-label.active { background-color: #fff; }
114- .md2-tab-label a { font-size:16px; vertical-align: super;}
115- .md2-tabs-canvas:focus .md2-tab-label.focus { background: rgba(0,0,0,0.05); }
116- .md2-tab-label.disabled { color: rgba(0,0,0,0.26); pointer-events: none; -webkit-user-select: none; -moz-user-select: none;
117- -ms-user-select: none; user-select: none; -webkit-user-drag: none; opacity: 0.5; cursor: default; }
118- .md2-tab-ink-bar { position: absolute; bottom: 0; height: 2px; background: rgb(255,82,82); transition: .25s cubic-bezier(.35,0,.25,1); }
119- .md2-tabs-body-wrapper { position: relative; min-height: 0; display: block; clear: both; }
120- md2-tab { padding: 16px; display: none; position: relative; }
121- md2-tab.active { display: block; position: relative; }
122- ` ] ,
105+ styleUrls : [ 'tab.component.css' ] ,
123106 host : {
124107 '[class]' : 'class' ,
125108 '(window:resize)' : 'onWindowResize($event)'
@@ -135,10 +118,7 @@ export class Md2Tabs implements OnInit, AfterContentInit {
135118 private offsetLeft = 0 ;
136119 private inkBarLeft = '0' ;
137120 private inkBarWidth = '0' ;
138- tabControlServiceModal : TabControlServiceModal = {
139- tabs : [ { 'name' : '收件箱' , 'link' : '/inbox' } ] ,
140- activeTab : 0
141- } ;
121+ tabControlServiceModal : TabControlServiceModal ;
142122 @Input ( ) class : string ;
143123 @Input ( )
144124 set selectedIndex ( value : any ) {
@@ -196,6 +176,33 @@ export class Md2Tabs implements OnInit, AfterContentInit {
196176 }
197177 }
198178
179+ // tab管理菜单
180+ // 关闭所有页面
181+ closeAll ( ) {
182+ this . tabControlServiceModal . tabs . length = 1 ;
183+ this . tabControlServiceModal . activeTab = 0 ;
184+ }
185+
186+ // 关闭其它页面
187+ closeOther ( ) {
188+ let retainList = [ ] ,
189+ currentTabIndex = this . tabControlServiceModal . activeTab ;
190+ retainList . push ( this . tabControlServiceModal . tabs [ 0 ] ) ;
191+ retainList . push ( this . tabControlServiceModal . tabs [ currentTabIndex ] ) ;
192+ this . tabControlServiceModal . tabs = retainList ;
193+ this . tabControlServiceModal . activeTab = 1 ;
194+ }
195+
196+ // 关闭当前页面
197+ closeNow ( ) {
198+ const index = this . tabControlServiceModal . activeTab ;
199+ if ( index === 0 ) {
200+ return
201+ }
202+ this . tabControlServiceModal . tabs . splice ( index , 1 ) ;
203+ this . tabControlServiceModal . activeTab = index - 1 ;
204+ }
205+
199206 /**
200207 * 判断激活的Tab并调整Tabs的位移,不存在时设为默认
201208 */
@@ -222,10 +229,12 @@ export class Md2Tabs implements OnInit, AfterContentInit {
222229 /**
223230 * 激活的Tab下边框计算
224231 */
225- _updateInkBar ( ) : void {
232+ _updateInkBar ( activeIndex ?: number ) : void {
226233 const elements = this . element ;
227234 if ( ! elements . tabs [ this . tabControlServiceModal . activeTab ] ) { return ; }
228- const tab = elements . tabs [ this . tabControlServiceModal . activeTab ] ;
235+ debugger
236+ const index = activeIndex || this . tabControlServiceModal . activeTab ;
237+ const tab = elements . tabs [ index ] ;
229238 this . inkBarLeft = tab . offsetLeft + 'px' ;
230239 this . inkBarWidth = tab . offsetWidth + 'px' ;
231240 }
@@ -367,7 +376,7 @@ export const MD2_TABS_DIRECTIVES: any[] = [Md2TabLabel, Md2Tabs, Md2Tab];
367376
368377@NgModule ( {
369378 declarations : [ Md2Transclude , Md2TabLabel , Md2Tabs , Md2Tab ] ,
370- imports : [ CommonModule ] ,
379+ imports : [ CommonModule , MdlModule ] ,
371380 exports : MD2_TABS_DIRECTIVES ,
372381} )
373382export class Md2TabsModule {
0 commit comments