Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: third_party/google_input_tools/src/chrome/os/floatingwindow/floatingwindow.js

Issue 1257313003: Update Google Input Tools (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Free up grd resources. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The ChromeOS IME Authors. All Rights Reserved.
2 // limitations under the License.
3 // See the License for the specific language governing permissions and
4 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5 // distributed under the License is distributed on an "AS-IS" BASIS,
6 // Unless required by applicable law or agreed to in writing, software
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // You may obtain a copy of the License at
11 // you may not use this file except in compliance with the License.
12 // Licensed under the Apache License, Version 2.0 (the "License");
13 //
14 goog.provide('i18n.input.chrome.FloatingWindow');
15
16 goog.require('goog.dom.DomHelper');
17 goog.require('goog.dom.TagName');
18 goog.require('goog.style');
19 goog.require('goog.ui.Container');
20 goog.require('i18n.input.chrome.Env');
21 goog.require('i18n.input.chrome.FloatingWindowDragger');
22
23
24 goog.scope(function() {
25 var Env = i18n.input.chrome.Env;
26 var FloatingWindowDragger = i18n.input.chrome.FloatingWindowDragger;
27
28
29
30 /**
31 * The floating window in chrome OS.
32 *
33 * @param {!chrome.app.window.AppWindow} parentWindow The parent app window.
34 * @param {boolean=} opt_enableDragger Whether to enable dragger feature.
35 * @param {string=} opt_cssFile The optional css file.
36 * @constructor
37 * @extends {goog.ui.Container}
38 */
39 i18n.input.chrome.FloatingWindow = function(parentWindow, opt_enableDragger,
40 opt_cssFile) {
41 goog.base(this, undefined, undefined,
42 new goog.dom.DomHelper(parentWindow.contentWindow.document));
43
44 /**
45 * The parent app window.
46 *
47 * @protected {!chrome.app.window.AppWindow}
48 */
49 this.parentWindow = parentWindow;
50
51 /** @protected {!Env} */
52 this.env = Env.getInstance();
53
54 /** @protected {boolean} */
55 this.enableDragger = goog.isDef(opt_enableDragger) ? opt_enableDragger : true;
56
57 if (opt_cssFile) {
58 this.installCss(opt_cssFile);
59 }
60 };
61 var FloatingWindow = i18n.input.chrome.FloatingWindow;
62 goog.inherits(FloatingWindow, goog.ui.Container);
63
64
65 /**
66 * The dragger for floating window.
67 *
68 * @private {FloatingWindowDragger}
69 */
70 FloatingWindow.prototype.dragger_;
71
72
73 /**
74 * Install css in this windows.
75 *
76 * @param {string} file The css file.
77 */
78 FloatingWindow.prototype.installCss = function(file) {
79 var dh = this.getDomHelper();
80 var doc = dh.getDocument();
81 var head = dh.getElementsByTagNameAndClass('head')[0];
82
83 var styleSheet = dh.createDom(goog.dom.TagName.LINK, {
84 'rel': 'stylesheet',
85 'href': file
86 });
87 dh.appendChild(head, styleSheet);
88 };
89
90
91 /** @override */
92 FloatingWindow.prototype.enterDocument = function() {
93 goog.base(this, 'enterDocument');
94
95 this.setFocusable(false);
96 this.setFocusableChildrenAllowed(false);
97
98 if (this.enableDragger) {
99 this.dragger_ = new FloatingWindowDragger(
100 this.parentWindow, this.getElement());
101 }
102 };
103
104
105 /** @override */
106 FloatingWindow.prototype.setVisible = function(isVisible) {
107 if (isVisible) {
108 this.parentWindow.show();
109 } else {
110 this.parentWindow.hide();
111 }
112 return goog.base(this, 'setVisible', isVisible);
113 };
114
115
116 /**
117 * Changes the position of the floating window.
118 *
119 * @param {!goog.math.Coordinate} position The coordinate of the position of the
120 * screen.
121 */
122 FloatingWindow.prototype.reposition = function(position) {
123 var outerBounds = this.parentWindow.outerBounds;
124 if (outerBounds.left != position.x || outerBounds.top != position.y) {
125 outerBounds.setPosition(position.x, position.y);
126 }
127 };
128
129
130 /**
131 * Changes the size of the floating window.
132 *
133 * @param {number} width The width of the new window.
134 * @param {number} height The height of the new window.
135 */
136 FloatingWindow.prototype.resize = function(width, height) {
137 this.parentWindow.outerBounds.setSize(width, height);
138 };
139
140
141 /**
142 * Gets the size of the floating window.
143 *
144 * @return {!goog.math.Size} The element's size.
145 */
146 FloatingWindow.prototype.size = function() {
147 return goog.style.getSize(this.getElement());
148 };
149
150
151 /** @override */
152 FloatingWindow.prototype.disposeInternal = function() {
153 this.parentWindow.close();
154 goog.dispose(this.dragger_);
155 goog.base(this, 'disposeInternal');
156 };
157 }); // goog.scope
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698