OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 installClass('PluginPlaceholderElement', function(PluginPlaceholderElementProtot
ype) { | 7 installClass('PluginPlaceholderElement', function(PluginPlaceholderElementProtot
ype) { |
| 8 // FIXME: Load this from a .css file. |
| 9 var styleSource = |
| 10 '#plugin-placeholder {' + |
| 11 ' width: 100%;' + |
| 12 ' height: 100%;' + |
| 13 ' overflow: hidden;' + |
| 14 ' display: flex;' + |
| 15 ' align-items: center;' + |
| 16 ' background: gray;' + |
| 17 ' font: 12px -webkit-control;' + |
| 18 '}' + |
| 19 '#plugin-placeholder-content {' + |
| 20 ' text-align: center;' + |
| 21 ' margin: auto;' + |
| 22 '}'; |
| 23 |
8 PluginPlaceholderElementPrototype.createdCallback = function() { | 24 PluginPlaceholderElementPrototype.createdCallback = function() { |
9 // FIXME: Move style out of script and into CSS. | 25 this.id = 'plugin-placeholder'; |
10 | 26 |
11 this.id = 'plugin-placeholder'; | 27 var styleElement = document.createElement('style'); |
12 this.style.width = '100%'; | 28 styleElement.textContent = styleSource; |
13 this.style.height = '100%'; | |
14 this.style.overflow = 'hidden'; | |
15 this.style.display = 'flex'; | |
16 this.style.alignItems = 'center'; | |
17 this.style.backgroundColor = 'gray'; | |
18 this.style.font = '12px -webkit-control'; | |
19 | 29 |
20 var contentElement = document.createElement('div'); | 30 var contentElement = document.createElement('div'); |
21 contentElement.id = 'plugin-placeholder-content'; | 31 contentElement.id = 'plugin-placeholder-content'; |
22 contentElement.style.textAlign = 'center'; | |
23 contentElement.style.margin = 'auto'; | |
24 | 32 |
25 var messageElement = document.createElement('div'); | 33 var messageElement = document.createElement('div'); |
26 messageElement.id = 'plugin-placeholder-message'; | 34 messageElement.id = 'plugin-placeholder-message'; |
27 | 35 |
28 contentElement.appendChild(messageElement); | 36 contentElement.appendChild(messageElement); |
| 37 this.appendChild(styleElement); |
29 this.appendChild(contentElement); | 38 this.appendChild(contentElement); |
30 | 39 |
31 this.messageElement = messageElement; | 40 this.messageElement = messageElement; |
32 }; | 41 }; |
33 | 42 |
34 Object.defineProperty(PluginPlaceholderElementPrototype, 'message', { | 43 Object.defineProperty(PluginPlaceholderElementPrototype, 'message', { |
35 get: function() { return this.messageElement.textContent; }, | 44 get: function() { return this.messageElement.textContent; }, |
36 set: function(message) { this.messageElement.textContent = message; }, | 45 set: function(message) { this.messageElement.textContent = message; }, |
37 }); | 46 }); |
38 }); | 47 }); |
OLD | NEW |