| OLD | NEW |
| 1 Polymer({ | 1 Polymer({ |
| 2 is: 'paper-tabs', | 2 is: 'paper-tabs', |
| 3 | 3 |
| 4 behaviors: [ | 4 behaviors: [ |
| 5 Polymer.IronResizableBehavior, | 5 Polymer.IronResizableBehavior, |
| 6 Polymer.IronMenubarBehavior | 6 Polymer.IronMenubarBehavior |
| 7 ], | 7 ], |
| 8 | 8 |
| 9 properties: { | 9 properties: { |
| 10 /** | 10 /** |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 alignBottom: { | 64 alignBottom: { |
| 65 type: Boolean, | 65 type: Boolean, |
| 66 value: false | 66 value: false |
| 67 }, | 67 }, |
| 68 | 68 |
| 69 selectable: { | 69 selectable: { |
| 70 type: String, | 70 type: String, |
| 71 value: 'paper-tab' | 71 value: 'paper-tab' |
| 72 }, | 72 }, |
| 73 | 73 |
| 74 /** |
| 75 * If true, tabs are automatically selected when focused using the |
| 76 * keyboard. |
| 77 */ |
| 78 autoselect: { |
| 79 type: Boolean, |
| 80 value: false |
| 81 }, |
| 82 |
| 83 /** |
| 84 * The delay (in milliseconds) between when the user stops interacting |
| 85 * with the tabs through the keyboard and when the focused item is |
| 86 * automatically selected (if `autoselect` is true). |
| 87 */ |
| 88 autoselectDelay: { |
| 89 type: Number, |
| 90 value: 0 |
| 91 }, |
| 92 |
| 74 _step: { | 93 _step: { |
| 75 type: Number, | 94 type: Number, |
| 76 value: 10 | 95 value: 10 |
| 77 }, | 96 }, |
| 78 | 97 |
| 79 _holdDelay: { | 98 _holdDelay: { |
| 80 type: Number, | 99 type: Number, |
| 81 value: 1 | 100 value: 1 |
| 82 }, | 101 }, |
| 83 | 102 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 100 role: 'tablist' | 119 role: 'tablist' |
| 101 }, | 120 }, |
| 102 | 121 |
| 103 listeners: { | 122 listeners: { |
| 104 'iron-resize': '_onTabSizingChanged', | 123 'iron-resize': '_onTabSizingChanged', |
| 105 'iron-items-changed': '_onTabSizingChanged', | 124 'iron-items-changed': '_onTabSizingChanged', |
| 106 'iron-select': '_onIronSelect', | 125 'iron-select': '_onIronSelect', |
| 107 'iron-deselect': '_onIronDeselect' | 126 'iron-deselect': '_onIronDeselect' |
| 108 }, | 127 }, |
| 109 | 128 |
| 129 keyBindings: { |
| 130 'left:keyup right:keyup': '_onArrowKeyup' |
| 131 }, |
| 132 |
| 110 created: function() { | 133 created: function() { |
| 111 this._holdJob = null; | 134 this._holdJob = null; |
| 135 this._pendingActivationItem = undefined; |
| 136 this._pendingActivationTimeout = undefined; |
| 137 this._bindDelayedActivationHandler = this._delayedActivationHandler.bind
(this); |
| 138 this.addEventListener('blur', this._onBlurCapture.bind(this), true); |
| 112 }, | 139 }, |
| 113 | 140 |
| 114 ready: function() { | 141 ready: function() { |
| 115 this.setScrollDirection('y', this.$.tabsContainer); | 142 this.setScrollDirection('y', this.$.tabsContainer); |
| 116 }, | 143 }, |
| 117 | 144 |
| 145 detached: function() { |
| 146 this._cancelPendingActivation(); |
| 147 }, |
| 148 |
| 118 _noinkChanged: function(noink) { | 149 _noinkChanged: function(noink) { |
| 119 var childTabs = Polymer.dom(this).querySelectorAll('paper-tab'); | 150 var childTabs = Polymer.dom(this).querySelectorAll('paper-tab'); |
| 120 childTabs.forEach(noink ? this._setNoinkAttribute : this._removeNoinkAtt
ribute); | 151 childTabs.forEach(noink ? this._setNoinkAttribute : this._removeNoinkAtt
ribute); |
| 121 }, | 152 }, |
| 122 | 153 |
| 123 _setNoinkAttribute: function(element) { | 154 _setNoinkAttribute: function(element) { |
| 124 element.setAttribute('noink', ''); | 155 element.setAttribute('noink', ''); |
| 125 }, | 156 }, |
| 126 | 157 |
| 127 _removeNoinkAttribute: function(element) { | 158 _removeNoinkAttribute: function(element) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 this.cancelDebouncer('tab-changed'); | 200 this.cancelDebouncer('tab-changed'); |
| 170 }, | 201 }, |
| 171 | 202 |
| 172 _onIronDeselect: function(event) { | 203 _onIronDeselect: function(event) { |
| 173 this.debounce('tab-changed', function() { | 204 this.debounce('tab-changed', function() { |
| 174 this._tabChanged(null, this._previousTab); | 205 this._tabChanged(null, this._previousTab); |
| 175 // See polymer/polymer#1305 | 206 // See polymer/polymer#1305 |
| 176 }, 1); | 207 }, 1); |
| 177 }, | 208 }, |
| 178 | 209 |
| 210 _activateHandler: function() { |
| 211 // Cancel item activations scheduled by keyboard events when any other |
| 212 // action causes an item to be activated (e.g. clicks). |
| 213 this._cancelPendingActivation(); |
| 214 |
| 215 Polymer.IronMenuBehaviorImpl._activateHandler.apply(this, arguments); |
| 216 }, |
| 217 |
| 218 /** |
| 219 * Activates an item after a delay (in milliseconds). |
| 220 */ |
| 221 _scheduleActivation: function(item, delay) { |
| 222 this._pendingActivationItem = item; |
| 223 this._pendingActivationTimeout = this.async( |
| 224 this._bindDelayedActivationHandler, delay); |
| 225 }, |
| 226 |
| 227 /** |
| 228 * Activates the last item given to `_scheduleActivation`. |
| 229 */ |
| 230 _delayedActivationHandler: function() { |
| 231 var item = this._pendingActivationItem; |
| 232 this._pendingActivationItem = undefined; |
| 233 this._pendingActivationTimeout = undefined; |
| 234 item.fire(this.activateEvent, null, { |
| 235 bubbles: true, |
| 236 cancelable: true |
| 237 }); |
| 238 }, |
| 239 |
| 240 /** |
| 241 * Cancels a previously scheduled item activation made with |
| 242 * `_scheduleActivation`. |
| 243 */ |
| 244 _cancelPendingActivation: function() { |
| 245 if (this._pendingActivationTimeout !== undefined) { |
| 246 this.cancelAsync(this._pendingActivationTimeout); |
| 247 this._pendingActivationItem = undefined; |
| 248 this._pendingActivationTimeout = undefined; |
| 249 } |
| 250 }, |
| 251 |
| 252 _onArrowKeyup: function(event) { |
| 253 if (this.autoselect) { |
| 254 this._scheduleActivation(this.focusedItem, this.autoselectDelay); |
| 255 } |
| 256 }, |
| 257 |
| 258 _onBlurCapture: function(event) { |
| 259 // Cancel a scheduled item activation (if any) when that item is |
| 260 // blurred. |
| 261 if (event.target === this._pendingActivationItem) { |
| 262 this._cancelPendingActivation(); |
| 263 } |
| 264 }, |
| 265 |
| 179 get _tabContainerScrollSize () { | 266 get _tabContainerScrollSize () { |
| 180 return Math.max( | 267 return Math.max( |
| 181 0, | 268 0, |
| 182 this.$.tabsContainer.scrollWidth - | 269 this.$.tabsContainer.scrollWidth - |
| 183 this.$.tabsContainer.offsetWidth | 270 this.$.tabsContainer.offsetWidth |
| 184 ); | 271 ); |
| 185 }, | 272 }, |
| 186 | 273 |
| 187 | |
| 188 _scroll: function(e, detail) { | 274 _scroll: function(e, detail) { |
| 189 if (!this.scrollable) { | 275 if (!this.scrollable) { |
| 190 return; | 276 return; |
| 191 } | 277 } |
| 192 | 278 |
| 193 var ddx = (detail && -detail.ddx) || 0; | 279 var ddx = (detail && -detail.ddx) || 0; |
| 194 this._affectScroll(ddx); | 280 this._affectScroll(ddx); |
| 195 }, | 281 }, |
| 196 | 282 |
| 197 _down: function(e) { | 283 _down: function(e) { |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 if (cl.contains('expand')) { | 405 if (cl.contains('expand')) { |
| 320 cl.remove('expand'); | 406 cl.remove('expand'); |
| 321 cl.add('contract'); | 407 cl.add('contract'); |
| 322 this._positionBar(this._pos.width, this._pos.left); | 408 this._positionBar(this._pos.width, this._pos.left); |
| 323 // bar animation done | 409 // bar animation done |
| 324 } else if (cl.contains('contract')) { | 410 } else if (cl.contains('contract')) { |
| 325 cl.remove('contract'); | 411 cl.remove('contract'); |
| 326 } | 412 } |
| 327 } | 413 } |
| 328 }); | 414 }); |
| OLD | NEW |