123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- goog.provide('goog.ui.TabBarRenderer');
- goog.require('goog.a11y.aria.Role');
- goog.require('goog.object');
- goog.require('goog.ui.ContainerRenderer');
- goog.ui.TabBarRenderer = function() {
- goog.ui.ContainerRenderer.call(this, goog.a11y.aria.Role.TAB_LIST);
- };
- goog.inherits(goog.ui.TabBarRenderer, goog.ui.ContainerRenderer);
- goog.addSingletonGetter(goog.ui.TabBarRenderer);
- goog.tagUnsealableClass(goog.ui.TabBarRenderer);
- goog.ui.TabBarRenderer.CSS_CLASS = goog.getCssName('goog-tab-bar');
- goog.ui.TabBarRenderer.prototype.getCssClass = function() {
- return goog.ui.TabBarRenderer.CSS_CLASS;
- };
- goog.ui.TabBarRenderer.prototype.setStateFromClassName = function(
- tabBar, className, baseClass) {
-
- if (!this.locationByClass_) {
- this.createLocationByClassMap_();
- }
-
-
- var location = this.locationByClass_[className];
- if (location) {
- tabBar.setLocation(location);
- } else {
- goog.ui.TabBarRenderer.superClass_.setStateFromClassName.call(
- this, tabBar, className, baseClass);
- }
- };
- goog.ui.TabBarRenderer.prototype.getClassNames = function(tabBar) {
- var classNames =
- goog.ui.TabBarRenderer.superClass_.getClassNames.call(this, tabBar);
-
- if (!this.classByLocation_) {
- this.createClassByLocationMap_();
- }
-
- classNames.push(this.classByLocation_[tabBar.getLocation()]);
- return classNames;
- };
- goog.ui.TabBarRenderer.prototype.createClassByLocationMap_ = function() {
- var baseClass = this.getCssClass();
-
- this.classByLocation_ = goog.object.create(
- goog.ui.TabBar.Location.TOP, goog.getCssName(baseClass, 'top'),
- goog.ui.TabBar.Location.BOTTOM, goog.getCssName(baseClass, 'bottom'),
- goog.ui.TabBar.Location.START, goog.getCssName(baseClass, 'start'),
- goog.ui.TabBar.Location.END, goog.getCssName(baseClass, 'end'));
- };
- goog.ui.TabBarRenderer.prototype.createLocationByClassMap_ = function() {
-
- if (!this.classByLocation_) {
- this.createClassByLocationMap_();
- }
-
- this.locationByClass_ = goog.object.transpose(this.classByLocation_);
- };
|