| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * A TabView provides the ability to create tabs and switch between tabs. It's | 6 * A TabView provides the ability to create tabs and switch between tabs. It's |
| 7 * responsible for creating the DOM and managing the visibility of each tab. | 7 * responsible for creating the DOM and managing the visibility of each tab. |
| 8 * The first added tab is active by default and the others hidden. | 8 * The first added tab is active by default and the others hidden. |
| 9 */ | 9 */ |
| 10 var TabView = (function() { | 10 var TabView = (function() { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 /** | 43 /** |
| 44 * Adds a tab with the specified id and title. | 44 * Adds a tab with the specified id and title. |
| 45 * @param {string} id | 45 * @param {string} id |
| 46 * @param {string} title | 46 * @param {string} title |
| 47 * @return {!Element} The tab body element. | 47 * @return {!Element} The tab body element. |
| 48 */ | 48 */ |
| 49 addTab: function(id, title) { | 49 addTab: function(id, title) { |
| 50 if (this.tabElements_[id]) | 50 if (this.tabElements_[id]) |
| 51 throw 'Tab already exists: ' + id; | 51 throw 'Tab already exists: ' + id; |
| 52 | 52 |
| 53 var head = document.createElement('div'); | 53 var head = document.createElement('span'); |
| 54 head.className = this.TAB_HEAD_CLASS_; | 54 head.className = this.TAB_HEAD_CLASS_; |
| 55 head.textContent = title + ' [' + id + ']'; | 55 head.textContent = title; |
| 56 head.title = title; | 56 head.title = title; |
| 57 this.headBar_.appendChild(head); | 57 this.headBar_.appendChild(head); |
| 58 head.addEventListener('click', this.switchTab_.bind(this, id)); | 58 head.addEventListener('click', this.switchTab_.bind(this, id)); |
| 59 | 59 |
| 60 var body = document.createElement('div'); | 60 var body = document.createElement('div'); |
| 61 body.className = this.TAB_BODY_CLASS_; | 61 body.className = this.TAB_BODY_CLASS_; |
| 62 body.id = id; | 62 body.id = id; |
| 63 this.root_.appendChild(body); | 63 this.root_.appendChild(body); |
| 64 | 64 |
| 65 this.tabElements_[id] = new TabDom(head, body); | 65 this.tabElements_[id] = new TabDom(head, body); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 | 110 |
| 111 /** Initializes the bar containing the tab heads. */ | 111 /** Initializes the bar containing the tab heads. */ |
| 112 initializeHeadBar_: function() { | 112 initializeHeadBar_: function() { |
| 113 this.headBar_ = document.createElement('div'); | 113 this.headBar_ = document.createElement('div'); |
| 114 this.root_.appendChild(this.headBar_); | 114 this.root_.appendChild(this.headBar_); |
| 115 this.headBar_.style.textAlign = 'center'; | 115 this.headBar_.style.textAlign = 'center'; |
| 116 }, | 116 }, |
| 117 }; | 117 }; |
| 118 return TabView; | 118 return TabView; |
| 119 })(); | 119 })(); |
| OLD | NEW |