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

Unified Diff: chrome/browser/resources/print_preview/data/ticket_items/media_size.js

Issue 253163002: Add media size select element and ticket item. Do not expose in the UI yet. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/print_preview/data/ticket_items/media_size.js
diff --git a/chrome/browser/resources/print_preview/data/ticket_items/media_size.js b/chrome/browser/resources/print_preview/data/ticket_items/media_size.js
new file mode 100644
index 0000000000000000000000000000000000000000..cc31b3e4054f1097fbecfaadee2813d3e169cb8c
--- /dev/null
+++ b/chrome/browser/resources/print_preview/data/ticket_items/media_size.js
@@ -0,0 +1,74 @@
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
Vitaly Buka (NO REVIEWS) 2014/04/29 19:01:52 We don't use (c) now Just Copyright 2014
Aleksey Shlyapnikov 2014/04/29 19:35:48 Done.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+cr.define('print_preview.ticket_items', function() {
+ 'use strict';
+
+ /**
+ * Media size ticket item.
+ * @param {!print_preview.AppState} appState App state used to persist media
+ * size selection.
+ * @param {!print_preview.DestinationStore} destinationStore Destination store
+ * used to determine if a destination has the media size capability.
+ * @constructor
+ * @extends {print_preview.ticket_items.TicketItem}
+ */
+ function MediaSize(appState, destinationStore) {
+ print_preview.ticket_items.TicketItem.call(
+ this,
+ appState,
+ print_preview.AppState.Field.MEDIA_SIZE,
+ destinationStore);
+ };
+
+ MediaSize.prototype = {
+ __proto__: print_preview.ticket_items.TicketItem.prototype,
+
+ /** @override */
+ wouldValueBeValid: function(value) {
+ if (!this.isCapabilityAvailable()) {
+ return false;
+ }
+ return this.capability.option.some(function(option) {
+ return option.width_microns == value.width_microns &&
+ option.height_microns == value.height_microns &&
+ option.is_continuous_feed == value.is_continuous_feed &&
+ option.vendor_id == value.vendor_id;
+ });
+ },
+
+ /** @override */
+ isCapabilityAvailable: function() {
+ return false && !!this.capability;
Vitaly Buka (NO REVIEWS) 2014/04/29 19:01:52 TODO with name and bug here
Aleksey Shlyapnikov 2014/04/29 19:35:48 Done.
+ },
+
+ /** @return {Object} Media size capability of the selected destination. */
+ get capability() {
+ var destination = this.getSelectedDestInternal();
+ return (destination &&
+ destination.capabilities &&
+ destination.capabilities.printer &&
+ destination.capabilities.printer.media_size) ||
+ null;
+ },
+
+ /** @override */
+ getDefaultValueInternal: function() {
+ var defaultOptions = this.capability.option.filter(function(option) {
+ return option.is_default;
+ });
+ return defaultOptions.length > 0 ? defaultOptions[0] : null;
+ },
+
+ /** @override */
+ getCapabilityNotAvailableValueInternal: function() {
+ return {};
+ }
+ };
+
+ // Export
+ return {
+ MediaSize: MediaSize
+ };
+});

Powered by Google App Engine
This is Rietveld 408576698