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 /** | 5 /** |
6 * @fileoverview | 6 * @fileoverview |
7 * A module that contains basic utility components and methods for the | 7 * A module that contains basic utility components and methods for the |
8 * chromoting project | 8 * chromoting project |
9 * | 9 * |
10 */ | 10 */ |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 this.listeners = []; | 368 this.listeners = []; |
369 }; | 369 }; |
370 | 370 |
371 | 371 |
372 /** @interface */ | 372 /** @interface */ |
373 base.EventSource = function() {}; | 373 base.EventSource = function() {}; |
374 | 374 |
375 /** | 375 /** |
376 * Add a listener |fn| to listen to |type| event. | 376 * Add a listener |fn| to listen to |type| event. |
377 * @param {string} type | 377 * @param {string} type |
378 * @param {function(?=):void} fn | 378 * @param {Function} fn |
379 */ | 379 */ |
380 base.EventSource.prototype.addEventListener = function(type, fn) {}; | 380 base.EventSource.prototype.addEventListener = function(type, fn) {}; |
381 | 381 |
382 /** | 382 /** |
383 * Remove a listener |fn| to listen to |type| event. | 383 * Remove a listener |fn| to listen to |type| event. |
384 * @param {string} type | 384 * @param {string} type |
385 * @param {function(?=):void} fn | 385 * @param {Function} fn |
386 */ | 386 */ |
387 base.EventSource.prototype.removeEventListener = function(type, fn) {}; | 387 base.EventSource.prototype.removeEventListener = function(type, fn) {}; |
388 | 388 |
389 | 389 |
390 /** | 390 /** |
391 * @constructor | 391 * @constructor |
392 * Since this class is implemented as a mixin, the constructor may not be | 392 * Since this class is implemented as a mixin, the constructor may not be |
393 * called. All initializations should be done in defineEvents. | 393 * called. All initializations should be done in defineEvents. |
394 * @implements {base.EventSource} | 394 * @implements {base.EventSource} |
395 */ | 395 */ |
(...skipping 28 matching lines...) Expand all Loading... |
424 * @param {string} type | 424 * @param {string} type |
425 */ | 425 */ |
426 function(type) { | 426 function(type) { |
427 base.debug.assert(typeof type == 'string'); | 427 base.debug.assert(typeof type == 'string'); |
428 this.eventMap_[type] = new base.EventEntry(); | 428 this.eventMap_[type] = new base.EventEntry(); |
429 }, this); | 429 }, this); |
430 }, | 430 }, |
431 | 431 |
432 /** | 432 /** |
433 * @param {string} type | 433 * @param {string} type |
434 * @param {function(?=):void} fn | 434 * @param {Function} fn |
435 */ | 435 */ |
436 addEventListener: function(type, fn) { | 436 addEventListener: function(type, fn) { |
437 base.debug.assert(typeof fn == 'function'); | 437 base.debug.assert(typeof fn == 'function'); |
438 base.EventSourceImpl.isDefined(this, type); | 438 base.EventSourceImpl.isDefined(this, type); |
439 | 439 |
440 var listeners = this.eventMap_[type].listeners; | 440 var listeners = this.eventMap_[type].listeners; |
441 listeners.push(fn); | 441 listeners.push(fn); |
442 }, | 442 }, |
443 | 443 |
444 /** | 444 /** |
445 * @param {string} type | 445 * @param {string} type |
446 * @param {function(?=):void} fn | 446 * @param {Function} fn |
447 */ | 447 */ |
448 removeEventListener: function(type, fn) { | 448 removeEventListener: function(type, fn) { |
449 base.debug.assert(typeof fn == 'function'); | 449 base.debug.assert(typeof fn == 'function'); |
450 base.EventSourceImpl.isDefined(this, type); | 450 base.EventSourceImpl.isDefined(this, type); |
451 | 451 |
452 var listeners = this.eventMap_[type].listeners; | 452 var listeners = this.eventMap_[type].listeners; |
453 // find the listener to remove. | 453 // find the listener to remove. |
454 for (var i = 0; i < listeners.length; i++) { | 454 for (var i = 0; i < listeners.length; i++) { |
455 var listener = listeners[i]; | 455 var listener = listeners[i]; |
456 if (listener == fn) { | 456 if (listener == fn) { |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 */ | 621 */ |
622 base.resizeWindowToContent = function() { | 622 base.resizeWindowToContent = function() { |
623 var appWindow = chrome.app.window.current(); | 623 var appWindow = chrome.app.window.current(); |
624 var outerBounds = appWindow.outerBounds; | 624 var outerBounds = appWindow.outerBounds; |
625 var borderY = outerBounds.height - appWindow.innerBounds.height; | 625 var borderY = outerBounds.height - appWindow.innerBounds.height; |
626 appWindow.resizeTo(outerBounds.width, document.body.clientHeight + borderY); | 626 appWindow.resizeTo(outerBounds.width, document.body.clientHeight + borderY); |
627 // Sometimes, resizing the window causes its position to be reset to (0, 0), | 627 // Sometimes, resizing the window causes its position to be reset to (0, 0), |
628 // so restore it explicitly. | 628 // so restore it explicitly. |
629 appWindow.moveTo(outerBounds.left, outerBounds.top); | 629 appWindow.moveTo(outerBounds.left, outerBounds.top); |
630 }; | 630 }; |
OLD | NEW |