OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 cr.define('print_preview', function() { | 5 cr.define('print_preview', function() { |
6 'use strict'; | 6 'use strict'; |
7 | 7 |
8 /** | 8 /** |
9 * Draggable control for setting a page margin. | 9 * Draggable control for setting a page margin. |
10 * @param {!print_preview.ticket_items.CustomMargins.Orientation} orientation | 10 * @param {!print_preview.ticket_items.CustomMargins.Orientation} orientation |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
180 * @param {!print_preview.Size} pageSize New size of the document's pages. | 180 * @param {!print_preview.Size} pageSize New size of the document's pages. |
181 */ | 181 */ |
182 setPageSize: function(pageSize) { | 182 setPageSize: function(pageSize) { |
183 this.pageSize_ = pageSize; | 183 this.pageSize_ = pageSize; |
184 this.setPositionInPts(this.positionInPts_); | 184 this.setPositionInPts(this.positionInPts_); |
185 }, | 185 }, |
186 | 186 |
187 /** @param {boolean} isVisible Whether the margin control is visible. */ | 187 /** @param {boolean} isVisible Whether the margin control is visible. */ |
188 setIsVisible: function(isVisible) { | 188 setIsVisible: function(isVisible) { |
189 this.getElement().classList.toggle('invisible', !isVisible); | 189 this.getElement().classList.toggle('invisible', !isVisible); |
190 this.getElement().setAttribute('aria-hidden', !isVisible); | |
190 }, | 191 }, |
191 | 192 |
192 /** @return {boolean} Whether the margin control is in an error state. */ | 193 /** @return {boolean} Whether the margin control is in an error state. */ |
193 getIsInError: function() { | 194 getIsInError: function() { |
194 return this.isInError_; | 195 return this.isInError_; |
195 }, | 196 }, |
196 | 197 |
197 /** | 198 /** |
198 * @param {boolean} isInError Whether the margin control is in an error | 199 * @param {boolean} isInError Whether the margin control is in an error |
199 * state. | 200 * state. |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
317 this.marginLineEl_ = this.getElement().getElementsByClassName( | 318 this.marginLineEl_ = this.getElement().getElementsByClassName( |
318 MarginControl.Classes_.LINE)[0]; | 319 MarginControl.Classes_.LINE)[0]; |
319 }, | 320 }, |
320 | 321 |
321 /** @override */ | 322 /** @override */ |
322 enterDocument: function() { | 323 enterDocument: function() { |
323 print_preview.Component.prototype.enterDocument.call(this); | 324 print_preview.Component.prototype.enterDocument.call(this); |
324 this.tracker.add( | 325 this.tracker.add( |
325 this.getElement(), 'mousedown', this.onMouseDown_.bind(this)); | 326 this.getElement(), 'mousedown', this.onMouseDown_.bind(this)); |
326 this.tracker.add( | 327 this.tracker.add( |
327 this.getElement(), | |
328 'webkitTransitionEnd', | |
329 this.onWebkitTransitionEnd_.bind(this)); | |
330 this.tracker.add( | |
331 this.textbox_, 'input', this.onTextboxInput_.bind(this)); | 328 this.textbox_, 'input', this.onTextboxInput_.bind(this)); |
332 this.tracker.add( | 329 this.tracker.add( |
333 this.textbox_, 'keydown', this.onTextboxKeyDown_.bind(this)); | 330 this.textbox_, 'keydown', this.onTextboxKeyDown_.bind(this)); |
334 this.tracker.add( | 331 this.tracker.add( |
335 this.textbox_, 'focus', this.setIsFocused_.bind(this, true)); | 332 this.textbox_, 'focus', this.setIsFocused_.bind(this, true)); |
336 this.tracker.add(this.textbox_, 'blur', this.onTexboxBlur_.bind(this)); | 333 this.tracker.add(this.textbox_, 'blur', this.onTexboxBlur_.bind(this)); |
337 }, | 334 }, |
338 | 335 |
339 /** @override */ | 336 /** @override */ |
340 exitDocument: function() { | 337 exitDocument: function() { |
(...skipping 23 matching lines...) Expand all Loading... | |
364 this.mouseStartPositionInPixels_ = | 361 this.mouseStartPositionInPixels_ = |
365 new print_preview.Coordinate2d(event.x, event.y); | 362 new print_preview.Coordinate2d(event.x, event.y); |
366 this.marginStartPositionInPixels_ = new print_preview.Coordinate2d( | 363 this.marginStartPositionInPixels_ = new print_preview.Coordinate2d( |
367 this.getElement().offsetLeft, this.getElement().offsetTop); | 364 this.getElement().offsetLeft, this.getElement().offsetTop); |
368 this.setIsInError(false); | 365 this.setIsInError(false); |
369 cr.dispatchSimpleEvent(this, MarginControl.EventType.DRAG_START); | 366 cr.dispatchSimpleEvent(this, MarginControl.EventType.DRAG_START); |
370 } | 367 } |
371 }, | 368 }, |
372 | 369 |
373 /** | 370 /** |
374 * Called when opacity CSS transition ends. | |
375 * @private | |
376 */ | |
377 onWebkitTransitionEnd_: function(event) { | |
Dan Beam
2014/10/15 21:37:31
not lgtm, add back before you land
https://code.go
hcarmona
2014/10/17 01:35:53
Acknowledged.
| |
378 if (event.propertyName != 'opacity') | |
379 return; | |
380 var elStyle = window.getComputedStyle(this.getElement()); | |
381 var opacity = parseInt(elStyle.getPropertyValue('opacity'), 10); | |
382 this.textbox_.setAttribute('aria-hidden', opacity == 0); | |
383 }, | |
384 | |
385 /** | |
386 * Called when textbox content changes. Starts text change timeout. | 371 * Called when textbox content changes. Starts text change timeout. |
387 * @private | 372 * @private |
388 */ | 373 */ |
389 onTextboxInput_: function(event) { | 374 onTextboxInput_: function(event) { |
390 if (this.textTimeout_) { | 375 if (this.textTimeout_) { |
391 clearTimeout(this.textTimeout_); | 376 clearTimeout(this.textTimeout_); |
392 this.textTimeout_ = null; | 377 this.textTimeout_ = null; |
393 } | 378 } |
394 this.textTimeout_ = setTimeout( | 379 this.textTimeout_ = setTimeout( |
395 this.onTextboxTimeout_.bind(this), MarginControl.TEXTBOX_TIMEOUT_); | 380 this.onTextboxTimeout_.bind(this), MarginControl.TEXTBOX_TIMEOUT_); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
432 this.setIsFocused_(false); | 417 this.setIsFocused_(false); |
433 cr.dispatchSimpleEvent(this, MarginControl.EventType.TEXT_CHANGE); | 418 cr.dispatchSimpleEvent(this, MarginControl.EventType.TEXT_CHANGE); |
434 } | 419 } |
435 }; | 420 }; |
436 | 421 |
437 // Export | 422 // Export |
438 return { | 423 return { |
439 MarginControl: MarginControl | 424 MarginControl: MarginControl |
440 }; | 425 }; |
441 }); | 426 }); |
OLD | NEW |