OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // | 5 // |
6 // <window-controls> shadow element implementation. | 6 // <window-controls> shadow element implementation. |
7 // | 7 // |
8 | 8 |
9 var chrome = requireNative('chrome').GetChrome(); | 9 var chrome = requireNative('chrome').GetChrome(); |
10 var forEach = require('utils').forEach; | 10 var forEach = require('utils').forEach; |
(...skipping 22 matching lines...) Expand all Loading... |
33 WindowControls.prototype.createShadowRoot_ = function(node) { | 33 WindowControls.prototype.createShadowRoot_ = function(node) { |
34 // Initialize |template| from HTML template resource and cache result. | 34 // Initialize |template| from HTML template resource and cache result. |
35 var template = WindowControls.prototype.template_element; | 35 var template = WindowControls.prototype.template_element; |
36 if (!template) { | 36 if (!template) { |
37 var element = document.createElement('div'); | 37 var element = document.createElement('div'); |
38 element.innerHTML = getHtmlTemplate(); | 38 element.innerHTML = getHtmlTemplate(); |
39 WindowControls.prototype.template_element = element.firstChild; | 39 WindowControls.prototype.template_element = element.firstChild; |
40 template = WindowControls.prototype.template_element; | 40 template = WindowControls.prototype.template_element; |
41 } | 41 } |
42 // Create shadow root element with template clone as first child. | 42 // Create shadow root element with template clone as first child. |
43 var shadowRoot = node.webkitCreateShadowRoot(); | 43 var shadowRoot = node.createShadowRoot(); |
44 shadowRoot.appendChild(template.content.cloneNode(true)); | 44 shadowRoot.appendChild(template.content.cloneNode(true)); |
45 return shadowRoot; | 45 return shadowRoot; |
46 } | 46 } |
47 | 47 |
48 /** | 48 /** |
49 * @private | 49 * @private |
50 */ | 50 */ |
51 WindowControls.prototype.setupWindowControls_ = function() { | 51 WindowControls.prototype.setupWindowControls_ = function() { |
52 var self = this; | 52 var self = this; |
53 this.shadowRoot_.querySelector("#close-control").addEventListener('click', | 53 this.shadowRoot_.querySelector("#close-control").addEventListener('click', |
(...skipping 15 matching lines...) Expand all Loading... |
69 if (chrome.app.window.current().isMaximized()) { | 69 if (chrome.app.window.current().isMaximized()) { |
70 chrome.app.window.current().restore(); | 70 chrome.app.window.current().restore(); |
71 } else { | 71 } else { |
72 chrome.app.window.current().maximize(); | 72 chrome.app.window.current().maximize(); |
73 } | 73 } |
74 } | 74 } |
75 | 75 |
76 addTagWatcher('WINDOW-CONTROLS', function(addedNode) { | 76 addTagWatcher('WINDOW-CONTROLS', function(addedNode) { |
77 new WindowControls(addedNode); | 77 new WindowControls(addedNode); |
78 }); | 78 }); |
OLD | NEW |