- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / resources / print_preview / search / fedex_tos.js
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
3 // found in the LICENSE file.
4
5 cr.define('print_preview', function() {
6   'use strict';
7
8   /**
9    * Widget that renders a terms-of-service agreement for using the FedEx Office
10    * print destination.
11    * @constructor
12    * @extends {print_preview.Component}
13    */
14   function FedexTos() {
15     print_preview.Component.call(this);
16   };
17
18   /**
19    * Enumeration of event types dispatched by the widget.
20    * @enum {string}
21    */
22   FedexTos.EventType = {
23     // Dispatched when the user agrees to the terms-of-service.
24     AGREE: 'print_preview.FedexTos.AGREE'
25   };
26
27   FedexTos.prototype = {
28     __proto__: print_preview.Component.prototype,
29
30     /** @param {boolean} isVisible Whether the widget is visible. */
31     setIsVisible: function(isVisible) {
32       if (isVisible) {
33         var heightHelperEl = this.getElement().querySelector('.height-helper');
34         this.getElement().style.height = heightHelperEl.offsetHeight + 'px';
35       } else {
36         this.getElement().style.height = 0;
37       }
38     },
39
40     /** @override */
41     createDom: function() {
42       this.setElementInternal(this.cloneTemplateInternal('fedex-tos-template'));
43       var tosTextEl = this.getElement().querySelector('.tos-text');
44       tosTextEl.innerHTML = localStrings.getStringF(
45           'fedexTos',
46           '<a href="http://www.fedex.com/us/office/copyprint/online/' +
47               'googlecloudprint/termsandconditions">',
48           '</a>');
49     },
50
51     /** @override */
52     enterDocument: function() {
53       var agreeCheckbox = this.getElement().querySelector('.agree-checkbox');
54       this.tracker.add(
55           agreeCheckbox, 'click', this.onAgreeCheckboxClick_.bind(this));
56     },
57
58     /**
59      * Called when the agree checkbox is clicked. Dispatches a AGREE event.
60      * @private
61      */
62     onAgreeCheckboxClick_: function() {
63       cr.dispatchSimpleEvent(this, FedexTos.EventType.AGREE);
64     }
65   };
66
67   // Export
68   return {
69     FedexTos: FedexTos
70   };
71 });