OLD | NEW |
| (Empty) |
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. | |
4 | |
5 /** | |
6 * @fileoverview Implements a compatibility layer for older versions of | |
7 * CFInstall.js . | |
8 **/ | |
9 | |
10 goog.provide('google.cf.installer.OverlayDelegate'); | |
11 | |
12 goog.require('google.cf.installer.InteractionDelegate'); | |
13 goog.require('google.cf.installer.frame'); | |
14 | |
15 /** | |
16 * Constructs an InteractionDelegate compatible with previous versions of | |
17 * CFInstall.js . | |
18 * @constructor | |
19 * @implements {google.cf.installer.InteractionDelegate} | |
20 */ | |
21 google.cf.installer.OverlayDelegate = function(args) { | |
22 this.args_ = args; | |
23 }; | |
24 | |
25 /** | |
26 * Indicates whether the overlay CSS has already been injected. | |
27 * @type {boolean} | |
28 * @private | |
29 */ | |
30 google.cf.installer.OverlayDelegate.styleInjected_ = false; | |
31 | |
32 /** | |
33 * Generates the CSS for the overlay. | |
34 * @private | |
35 */ | |
36 google.cf.installer.OverlayDelegate.injectCss_ = function() { | |
37 if (google.cf.installer.OverlayDelegate.styleInjected_) | |
38 return; | |
39 goog.style.installStyles('.chromeFrameOverlayContent {' + | |
40 'position: absolute;' + | |
41 'margin-left: -400px;' + | |
42 'margin-top: -300px;' + | |
43 'left: 50%;' + | |
44 'top: 50%;' + | |
45 'border: 1px solid #93B4D9;' + | |
46 'background-color: white;' + | |
47 'z-index: 2001;' + | |
48 '}' + | |
49 '.chromeFrameOverlayContent iframe {' + | |
50 'width: 800px;' + | |
51 'height: 600px;' + | |
52 'border: none;' + | |
53 '}' + | |
54 '.chromeFrameOverlayCloseBar {' + | |
55 'height: 1em;' + | |
56 'text-align: right;' + | |
57 'background-color: #CADEF4;' + | |
58 '}' + | |
59 '.chromeFrameOverlayUnderlay {' + | |
60 'position: absolute;' + | |
61 'width: 100%;' + | |
62 'height: 100%;' + | |
63 'background-color: white;' + | |
64 'opacity: 0.5;' + | |
65 '-moz-opacity: 0.5;' + | |
66 '-webkit-opacity: 0.5;' + | |
67 '-ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";' + | |
68 'filter: alpha(opacity=50);' + | |
69 'z-index: 2000;' + | |
70 '}'); | |
71 google.cf.installer.OverlayDelegate.styleInjected_ = true; | |
72 }; | |
73 | |
74 /** | |
75 * Generates the HTML for the overlay. | |
76 * @private | |
77 */ | |
78 google.cf.installer.OverlayDelegate.injectHtml_ = function() { | |
79 google.cf.installer.OverlayDelegate.injectCss_(); | |
80 if (document.getElementById('chromeFrameOverlayContent')) { | |
81 return; // Was previously created. Bail. | |
82 } | |
83 | |
84 var n = document.createElement('span'); | |
85 n.innerHTML = '<div class="chromeFrameOverlayUnderlay"></div>' + | |
86 '<table class="chromeFrameOverlayContent"' + | |
87 'id="chromeFrameOverlayContent"' + | |
88 'cellpadding="0" cellspacing="0">' + | |
89 '<tr class="chromeFrameOverlayCloseBar">' + | |
90 '<td>' + | |
91 // TODO(user): i18n | |
92 '<button id="chromeFrameCloseButton">close</button>' + | |
93 '</td>' + | |
94 '</tr>' + | |
95 '<tr>' + | |
96 '<td id="chromeFrameIframeHolder"></td>' + | |
97 '</tr>' + | |
98 '</table>'; | |
99 | |
100 var b = document.body; | |
101 // Insert underlay nodes into the document in the right order. | |
102 while (n.firstChild) { | |
103 b.insertBefore(n.lastChild, b.firstChild); | |
104 } | |
105 }; | |
106 | |
107 /** | |
108 * @inheritDoc | |
109 */ | |
110 google.cf.installer.OverlayDelegate.prototype.getIFrameContainer = | |
111 function() { | |
112 google.cf.installer.OverlayDelegate.injectHtml_(); | |
113 document.getElementById('chromeFrameCloseButton').onclick = | |
114 goog.bind(this.reset, this); | |
115 return /** @type {!HTMLElement} */( | |
116 document.getElementById('chromeFrameIframeHolder')); | |
117 }; | |
118 | |
119 /** | |
120 * @inheritDoc | |
121 */ | |
122 google.cf.installer.OverlayDelegate.prototype.customizeIFrame = | |
123 function(iframe) { | |
124 google.cf.installer.frame.setProperties(iframe, this.args_); | |
125 }; | |
126 | |
127 /** | |
128 * @inheritDoc | |
129 */ | |
130 google.cf.installer.OverlayDelegate.prototype.show = function() { | |
131 // Should start it out hidden and reveal/resize here. | |
132 }; | |
133 | |
134 /** | |
135 * @inheritDoc | |
136 */ | |
137 google.cf.installer.OverlayDelegate.prototype.reset = function() { | |
138 // IE has a limit to the # of <style> tags allowed, so we avoid | |
139 // tempting the fates. | |
140 if (google.cf.installer.OverlayDelegate.hideInjected_) | |
141 return; | |
142 | |
143 goog.style.installStyles( | |
144 '.chromeFrameOverlayContent { display: none; } ' + | |
145 '.chromeFrameOverlayUnderlay { display: none; }'); | |
146 document.getElementById('chromeFrameIframeHolder').removeChild( | |
147 document.getElementById('chromeFrameIframeHolder').firstChild); | |
148 | |
149 document.getElementById('chromeFrameCloseButton').onclick = null; | |
150 | |
151 // TODO(user): put this in somewhere. | |
152 // // Hide the dialog for a year (or until cookies are deleted). | |
153 // var age = 365 * 24 * 60 * 60 * 1000; | |
154 // document.cookie = "disableGCFCheck=1;path=/;max-age="+age; | |
155 google.cf.installer.OverlayDelegate.hideInjected_ = true; | |
156 }; | |
OLD | NEW |