/////////////////////////////////////////////////////////////////////////// // Copyright © 2014 - 2018 Esri. All Rights Reserved. // // Licensed under the Apache License Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /////////////////////////////////////////////////////////////////////////// define([ 'dojo/_base/declare', 'dojo/_base/lang', 'dojo/_base/array', 'dojo/_base/html', 'dojo/on', 'dojo/Evented', 'dojo/query', 'dijit/_WidgetBase', 'dijit/_TemplatedMixin', 'dojo/text!./templates/TabContainer3.html', 'jimu/dijit/ViewStack' ], function(declare, lang, array, html, on, Evented, query, _WidgetBase, _TemplatedMixin, template, ViewStack){ return declare([_WidgetBase, _TemplatedMixin, Evented], { templateString: template, 'baseClass':'jimu-tab3', declaredClass: 'jimu.dijit.TabContainer3', _currentIndex: -1, //options: selected: '', tabs: null,//[{title,content}] average: true, //public methods: //selectTab //hideShelter //showShelter //event: tabChanged //css classes: //tab-item-td postCreate: function(){ this.inherited(arguments); this._initSelf(); if(this.selected){ this.selectTab(this.selected); }else if(this.tabs.length > 0){ this.selectTab(this.tabs[0].title); } }, selectTab: function(title){ var tds = query('td', this.tabTr); array.forEach(tds, lang.hitch(this, function(td, index) { html.removeClass(td, 'jimu-state-active'); if (td.label === title) { html.addClass(td, 'jimu-state-active'); this._currentIndex = index; } })); this.controlNode.removeChild(this.controlTable); html.place(this.controlTable, this.controlNode); this.viewStack.switchView(title); this.emit('tabChanged', title); }, addTab: function(tabConfig){ if(!this.average){ //remove last td int this.tabTr var lastTd = query('td:last-child', this.tabTr); if(lastTd.length > 0){ html.destroy(lastTd[0]); } } //create tab var tabsHasSameTitle = array.filter(this.tabs, function(tab){ return tab.title === tabConfig.title; }); if(tabsHasSameTitle.length > 0){ console.error('tab title conflict: ' + tabConfig.title); return; } this.tabs.push(tabConfig); this._createTab(tabConfig); if(!this.average){ var strTabItemTd = '