OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 cr.define('options', function() { | 5 cr.define('options', function() { |
6 /** @const */ var OptionsPage = options.OptionsPage; | 6 /** @const */ var OptionsPage = options.OptionsPage; |
7 | 7 |
8 /** | 8 /** |
9 * Encapsulated handling of a search bubble. | 9 * Encapsulated handling of a search bubble. |
10 * @constructor | 10 * @constructor |
11 */ | 11 */ |
12 function SearchBubble(text) { | 12 function SearchBubble(text) { |
13 var el = cr.doc.createElement('div'); | 13 var el = cr.doc.createElement('div'); |
14 SearchBubble.decorate(el); | 14 SearchBubble.decorate(el); |
15 el.textContent = text; | 15 el.content = text; |
16 return el; | 16 return el; |
17 } | 17 } |
18 | 18 |
19 SearchBubble.decorate = function(el) { | 19 SearchBubble.decorate = function(el) { |
20 el.__proto__ = SearchBubble.prototype; | 20 el.__proto__ = SearchBubble.prototype; |
21 el.decorate(); | 21 el.decorate(); |
22 }; | 22 }; |
23 | 23 |
24 SearchBubble.prototype = { | 24 SearchBubble.prototype = { |
25 __proto__: HTMLDivElement.prototype, | 25 __proto__: HTMLDivElement.prototype, |
26 | 26 |
27 decorate: function() { | 27 decorate: function() { |
28 this.className = 'search-bubble'; | 28 this.className = 'search-bubble'; |
29 | 29 |
30 this.innards_ = cr.doc.createElement('div'); | |
31 this.innards_.className = 'search-bubble-innards'; | |
32 this.appendChild(this.innards_); | |
33 | |
30 // We create a timer to periodically update the position of the bubbles. | 34 // We create a timer to periodically update the position of the bubbles. |
31 // While this isn't all that desirable, it's the only sure-fire way of | 35 // While this isn't all that desirable, it's the only sure-fire way of |
32 // making sure the bubbles stay in the correct location as sections | 36 // making sure the bubbles stay in the correct location as sections |
33 // may dynamically change size at any time. | 37 // may dynamically change size at any time. |
34 this.intervalId = setInterval(this.updatePosition.bind(this), 250); | 38 this.intervalId = setInterval(this.updatePosition.bind(this), 250); |
35 }, | 39 }, |
36 | 40 |
Dan Beam
2012/05/22 03:40:51
can you annotate the @type?
Evan Stade
2012/05/22 03:55:36
Done.
| |
41 set content(text) { | |
42 this.innards_.textContent = text; | |
43 }, | |
44 | |
37 /** | 45 /** |
38 * Attach the bubble to the element. | 46 * Attach the bubble to the element. |
39 */ | 47 */ |
40 attachTo: function(element) { | 48 attachTo: function(element) { |
41 var parent = element.parentElement; | 49 var parent = element.parentElement; |
42 if (!parent) | 50 if (!parent) |
43 return; | 51 return; |
44 if (parent.tagName == 'TD') { | 52 if (parent.tagName == 'TD') { |
45 // To make absolute positioning work inside a table cell we need | 53 // To make absolute positioning work inside a table cell we need |
46 // to wrap the bubble div into another div with position:relative. | 54 // to wrap the bubble div into another div with position:relative. |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
558 // Trim beginning and ending whitespace. | 566 // Trim beginning and ending whitespace. |
559 return text.replace(/^\s+|\s+$/g, ''); | 567 return text.replace(/^\s+|\s+$/g, ''); |
560 }; | 568 }; |
561 | 569 |
562 // Export | 570 // Export |
563 return { | 571 return { |
564 SearchPage: SearchPage | 572 SearchPage: SearchPage |
565 }; | 573 }; |
566 | 574 |
567 }); | 575 }); |
OLD | NEW |