5 function classNames(obj) {
8 if (obj.hasOwnProperty(key) && obj[key]) {
13 return classNames.join(' ');
27 * Controls how the items are aligned horizontally when they are placed
29 * Options are `start`, `center`, `end`, `justified` and `around`.
31 * @attribute bottomJustify
41 * Controls how the items are aligned horizontally.
42 * Options are `start`, `center`, `end`, `justified` and `around`.
54 * Controls how the items are aligned horizontally when they are placed
56 * Options are `start`, `center`, `end`, `justified` and `around`.
58 * @attribute middleJustify
69 attached: function() {
70 this._observer = this._observe(this);
71 this._updateAriaLabelledBy();
74 detached: function() {
76 this._observer.disconnect();
80 _observe: function(node) {
81 var observer = new MutationObserver(function() {
82 this._updateAriaLabelledBy();
84 observer.observe(node, {
91 _updateAriaLabelledBy: function() {
93 var contents = Polymer.dom(this.root).querySelectorAll('content');
94 for (var content, index = 0; content = contents[index]; index++) {
95 var nodes = Polymer.dom(content).getDistributedNodes();
96 for (var node, jndex = 0; node = nodes[jndex]; jndex++) {
97 if (node.classList && node.classList.contains('title')) {
99 labelledBy.push(node.id);
101 var id = 'paper-toolbar-label-' + Math.floor(Math.random() * 10000);
108 if (labelledBy.length > 0) {
109 this.setAttribute('aria-labelledby', labelledBy.join(' '));
113 _computeBarClassName: function(barJustify) {
118 'toolbar-tools': true
121 // If a blank string or any falsy value is given, no other class name is
124 var justifyClassName = (barJustify === 'justified') ?
126 barJustify + '-justified';
128 classObj[justifyClassName] = true;
131 return classNames(classObj);