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
3 // found in the LICENSE file.
6 * @fileoverview Displays the Chrome Frame installation flow in a Closure
10 goog.provide('google.cf.installer.DialogInteractionDelegate');
12 goog.require('goog.math.Size');
13 goog.require('goog.style');
14 goog.require('goog.ui.Dialog');
15 goog.require('goog.userAgent');
17 goog.require('google.cf.installer.InteractionDelegate');
20 * An implementation of google.cf.installer.InteractionDelegate that decorates
21 * the installation flow using a goog.ui.Dialog .
23 * @implements {google.cf.installer.InteractionDelegate}
25 google.cf.installer.DialogInteractionDelegate = function() {
29 * Whether we have already injected the dialog styles into the page.
33 google.cf.installer.DialogInteractionDelegate.injectedCss_ = false;
36 * Injects the dialog styles into the page.
39 google.cf.installer.DialogInteractionDelegate.injectCss_ = function() {
40 if (google.cf.installer.DialogInteractionDelegate.injectedCss_)
43 google.cf.installer.DialogInteractionDelegate.injectedCss_ = true;
45 goog.style.installStyles(
46 '.xdgcfinstall-dlg {' +
47 'background: #c1d9ff;' +
48 'border: 1px solid #3a5774;' +
51 'position: absolute;' +
54 '.xdgcfinstall-dlg-bg {' +
57 'position: absolute;' +
61 '.xdgcfinstall-dlg-title {' +
62 'background: #e0edfe;' +
66 'font-weight: bold;' +
70 'position: relative;' +
71 '_zoom: 1; /* Ensures proper width in IE6 RTL. */' +
74 '.xdgcfinstall-dlg-title-close {' +
75 /* Client apps may override the URL at which they serve the sprite. */
76 'background: #e0edfe' +
77 'url(//ssl.gstatic.com/editor/editortoolbar.png)' +
78 'no-repeat -528px 0;' +
82 'position: absolute;' +
86 'padding: 0px 0px 0px 0px;' +
90 '.xdgcfinstall-dlg-content {' +
91 'background-color: #fff;' +
99 * @type {goog.ui.Dialog}
102 google.cf.installer.DialogInteractionDelegate.prototype.dialog_ = null;
107 google.cf.installer.DialogInteractionDelegate.prototype.getIFrameContainer =
109 google.cf.installer.DialogInteractionDelegate.injectCss_();
111 this.dialog_ = new goog.ui.Dialog('xdgcfinstall-dlg', true);
112 this.dialog_.setButtonSet(null);
113 // TODO(user): The IFrame must be 'visible' or else calculation of its
114 // contents' dimensions is incorrect on IE, yet the following line also
115 // disables interaction with and dims the page contents. It would be best to
116 // only do that when show() is called. Best way is probably to push the mask
117 // elements offscreen.
118 this.dialog_.setVisible(true);
119 goog.style.setPosition(this.dialog_.getDialogElement(), -5000, -5000);
120 return /** @type {!HTMLElement} */(this.dialog_.getContentElement());
126 google.cf.installer.DialogInteractionDelegate.prototype.customizeIFrame =
133 google.cf.installer.DialogInteractionDelegate.prototype.show =
135 if (goog.userAgent.IE) {
136 // By default, in IE, the dialog does not respect the width of its contents.
137 // So we set its dimensions here. We need to specifically add some space for
139 var iframeSize = goog.style.getBorderBoxSize(
140 this.dialog_.getContentElement().getElementsByTagName('iframe')[0]);
141 var titleSize = goog.style.getBorderBoxSize(this.dialog_.getTitleElement());
142 goog.style.setContentBoxSize(this.dialog_.getDialogElement(),
145 iframeSize.height + titleSize.height));
147 // Ask the dialog to re-center itself based on the new dimensions.
148 this.dialog_.reposition();
155 google.cf.installer.DialogInteractionDelegate.prototype.reset = function() {
157 this.dialog_.setVisible(false);
158 this.dialog_.dispose();