Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(724)

Side by Side Diff: chrome/browser/resources/print_preview/margin_settings.js

Issue 8394020: Print Preview: Improving accessibility of margins UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/resources/print_preview/margin_textbox.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 * Creates a Margins object that holds four margin values. The units in which 9 * Creates a Margins object that holds four margin values. The units in which
10 * the values are expressed can be any numeric value. 10 * the values are expressed can be any numeric value.
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 setDefaultValuesAndRegeneratePreview(false); 260 setDefaultValuesAndRegeneratePreview(false);
261 }, 261 },
262 262
263 /** 263 /**
264 * Listener executed when the mouse is over the sidebar. If the custom 264 * Listener executed when the mouse is over the sidebar. If the custom
265 * margin lines are displayed, then, it fades them out. 265 * margin lines are displayed, then, it fades them out.
266 * @private 266 * @private
267 */ 267 */
268 onSidebarMouseOver_: function(e) { 268 onSidebarMouseOver_: function(e) {
269 if (!this.forceDisplayingMarginLines_) 269 if (!this.forceDisplayingMarginLines_)
270 this.marginsUI.hide(); 270 this.marginsUI.hide(false);
271 }, 271 },
272 272
273 /** 273 /**
274 * Listener executed when the mouse is over the main view. If the custom 274 * Listener executed when the mouse is over the main view. If the custom
275 * margin lines are hidden, then, it fades them in. 275 * margin lines are hidden, then, it fades them in.
276 * @private 276 * @private
277 */ 277 */
278 onMainviewMouseOver_: function() { 278 onMainviewMouseOver_: function() {
279 this.forceDisplayingMarginLines_ = false; 279 this.forceDisplayingMarginLines_ = false;
280 this.marginsUI.show(); 280 this.marginsUI.show();
(...skipping 10 matching lines...) Expand all
291 this.onPDFGenerationError_.bind(this)); 291 this.onPDFGenerationError_.bind(this));
292 }, 292 },
293 293
294 /** 294 /**
295 * Executes when an 'PDFGenerationError' event occurs. 295 * Executes when an 'PDFGenerationError' event occurs.
296 * @private 296 * @private
297 */ 297 */
298 onPDFGenerationError_: function() { 298 onPDFGenerationError_: function() {
299 if (this.isCustomMarginsSelected()) { 299 if (this.isCustomMarginsSelected()) {
300 this.removeCustomMarginEventListeners_(); 300 this.removeCustomMarginEventListeners_();
301 this.marginsUI.hide(); 301 this.marginsUI.hide(true);
302 } 302 }
303 }, 303 },
304 304
305 /** 305 /**
306 * Executes whenever a "DragEvent" occurs. 306 * Executes whenever a "DragEvent" occurs.
307 * @param {cr.Event} e The event that triggered this listener. 307 * @param {cr.Event} e The event that triggered this listener.
308 */ 308 */
309 onDragEvent_: function(e) { 309 onDragEvent_: function(e) {
310 var dragDeltaInPoints = this.convertDragDeltaToPoints_(e.dragDelta); 310 var dragDeltaInPoints = this.convertDragDeltaToPoints_(e.dragDelta);
311 this.marginsUI.lastClickedMarginsUIPair.updateWhileDragging( 311 this.marginsUI.lastClickedMarginsUIPair.updateWhileDragging(
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 419
420 /** 420 /**
421 * Adds listeners when the custom margins option is selected. 421 * Adds listeners when the custom margins option is selected.
422 * @private 422 * @private
423 */ 423 */
424 addCustomMarginEventListeners_: function() { 424 addCustomMarginEventListeners_: function() {
425 $('mainview').onmouseover = this.onMainviewMouseOver_.bind(this); 425 $('mainview').onmouseover = this.onMainviewMouseOver_.bind(this);
426 $('sidebar').onmouseover = this.onSidebarMouseOver_.bind(this); 426 $('sidebar').onmouseover = this.onSidebarMouseOver_.bind(this);
427 this.eventTracker_.add( 427 this.eventTracker_.add(
428 this.marginsUI, 'DragEvent', this.onDragEvent_.bind(this), false); 428 this.marginsUI, 'DragEvent', this.onDragEvent_.bind(this), false);
429 this.eventTracker_.add(document, 'marginTextboxFocused',
430 this.onMarginTextboxFocused_.bind(this), false);
429 }, 431 },
430 432
431 /** 433 /**
432 * Removes the event listeners associated with the custom margins option. 434 * Removes the event listeners associated with the custom margins option.
433 * @private 435 * @private
434 */ 436 */
435 removeCustomMarginEventListeners_: function() { 437 removeCustomMarginEventListeners_: function() {
436 $('mainview').onmouseover = null; 438 $('mainview').onmouseover = null;
437 $('sidebar').onmouseover = null; 439 $('sidebar').onmouseover = null;
438 this.eventTracker_.remove(this.marginsUI, 'DragEvent'); 440 this.eventTracker_.remove(this.marginsUI, 'DragEvent');
439 this.marginsUI.hide(); 441 this.eventTracker_.remove(document, 'marginTextboxFocused');
442 this.marginsUI.hide(true);
440 }, 443 },
441 444
442 /** 445 /**
443 * Updates |this.marginsUI| depending on the specified margins and the 446 * Updates |this.marginsUI| depending on the specified margins and the
444 * position of the page within the plugin. 447 * position of the page within the plugin.
445 * @private 448 * @private
446 */ 449 */
447 drawCustomMarginsUI_: function() { 450 drawCustomMarginsUI_: function() {
448 // TODO(dpapad): find out why passing |!this.areMarginsSettingsValid()| 451 // TODO(dpapad): find out why passing |!this.areMarginsSettingsValid()|
449 // directly produces the opposite value even though 452 // directly produces the opposite value even though
(...skipping 13 matching lines...) Expand all
463 * Called when there is change in the preview position or size. 466 * Called when there is change in the preview position or size.
464 */ 467 */
465 onPreviewPositionChanged: function() { 468 onPreviewPositionChanged: function() {
466 if (this.isCustomMarginsSelected() && previewArea.pdfLoaded && 469 if (this.isCustomMarginsSelected() && previewArea.pdfLoaded &&
467 pageSettings.totalPageCount != undefined) { 470 pageSettings.totalPageCount != undefined) {
468 this.drawCustomMarginsUI_(); 471 this.drawCustomMarginsUI_();
469 } 472 }
470 }, 473 },
471 474
472 /** 475 /**
476 * Executes when a margin textbox is focused. Used for improved
477 * accessibility.
478 * @private
479 */
480 onMarginTextboxFocused_: function() {
481 this.forceDisplayingMarginLines_ = true;
482 this.marginsUI.show();
483 },
484
485 /**
473 * Executes when user selects a different margin option, ie, 486 * Executes when user selects a different margin option, ie,
474 * |this.marginList_.selectedIndex| is changed. 487 * |this.marginList_.selectedIndex| is changed.
475 * @private 488 * @private
476 */ 489 */
477 onMarginsChanged_: function() { 490 onMarginsChanged_: function() {
478 if (this.isDefaultMarginsSelected()) 491 if (this.isDefaultMarginsSelected())
479 this.onDefaultMarginsSelected_(); 492 this.onDefaultMarginsSelected_();
480 else if (this.isNoMarginsSelected()) 493 else if (this.isNoMarginsSelected())
481 this.onNoMarginsSelected_(); 494 this.onNoMarginsSelected_();
482 else if (this.isCustomMarginsSelected()) 495 else if (this.isCustomMarginsSelected())
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 } 616 }
604 }; 617 };
605 618
606 return { 619 return {
607 MarginSettings: MarginSettings, 620 MarginSettings: MarginSettings,
608 PageLayout: PageLayout, 621 PageLayout: PageLayout,
609 setNumberFormatAndMeasurementSystem: 622 setNumberFormatAndMeasurementSystem:
610 MarginSettings.setNumberFormatAndMeasurementSystem, 623 MarginSettings.setNumberFormatAndMeasurementSystem,
611 }; 624 };
612 }); 625 });
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/print_preview/margin_textbox.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698