7 function classNames(obj) {
10 if (obj.hasOwnProperty(key) && obj[key]) {
15 return classNames.join(' ');
29 * Controls how the items are aligned horizontally when they are placed
31 * Options are `start`, `center`, `end`, `justified` and `around`.
33 * @attribute bottomJustify
43 * Controls how the items are aligned horizontally.
44 * Options are `start`, `center`, `end`, `justified` and `around`.
56 * Controls how the items are aligned horizontally when they are placed
58 * Options are `start`, `center`, `end`, `justified` and `around`.
60 * @attribute middleJustify
71 attached: function() {
72 this._observer = this._observe(this);
73 this._updateAriaLabelledBy();
76 detached: function() {
78 this._observer.disconnect();
82 _observe: function(node) {
83 var observer = new MutationObserver(function() {
84 this._updateAriaLabelledBy();
86 observer.observe(node, {
93 _updateAriaLabelledBy: function() {
95 var contents = Polymer.dom(this.root).querySelectorAll('content');
96 for (var content, index = 0; content = contents[index]; index++) {
97 var nodes = Polymer.dom(content).getDistributedNodes();
98 for (var node, jndex = 0; node = nodes[jndex]; jndex++) {
99 if (node.classList && node.classList.contains('title')) {
101 labelledBy.push(node.id);
103 var id = 'paper-toolbar-label-' + Math.floor(Math.random() * 10000);
110 if (labelledBy.length > 0) {
111 this.setAttribute('aria-labelledby', labelledBy.join(' '));
115 _computeBarClassName: function(barJustify) {
120 'toolbar-tools': true
123 // If a blank string or any falsy value is given, no other class name is
126 var justifyClassName = (barJustify === 'justified') ?
128 barJustify + '-justified';
130 classObj[justifyClassName] = true;
133 return classNames(classObj);