| 1 |
<!DOCTYPE html> |
| 2 |
<html> |
| 3 |
<!-- |
| 4 |
Copyright 2010 The Closure Library Authors. All Rights Reserved. |
| 5 |
|
| 6 |
Use of this source code is governed by the Apache License, Version 2.0. |
| 7 |
See the COPYING file for details. |
| 8 |
--> |
| 9 |
<head> |
| 10 |
<title>goog.ui.Component</title> |
| 11 |
<meta charset="utf-8"> |
| 12 |
<script src="../base.js"></script> |
| 13 |
<script> |
| 14 |
goog.require('goog.ui.Component'); |
| 15 |
goog.require('goog.Timer'); |
| 16 |
</script> |
| 17 |
<script src="../demos/samplecomponent.js"></script> |
| 18 |
<script> |
| 19 |
function initPage() { |
| 20 |
// Shows default initial label |
| 21 |
var box1 = new goog.demos.SampleComponent(); |
| 22 |
box1.render(goog.dom.getElement('target1')); |
| 23 |
|
| 24 |
// Shows label taken from DIV text |
| 25 |
var box2 = new goog.demos.SampleComponent(); |
| 26 |
box2.decorate(goog.dom.getElement('target2')); |
| 27 |
|
| 28 |
// Shows initial Label + setting label |
| 29 |
var box3 = new goog.demos.SampleComponent('Counting...'); |
| 30 |
box3.decorate(goog.dom.getElement('target3')); |
| 31 |
|
| 32 |
var t = new goog.Timer(2000); |
| 33 |
var value = 0; |
| 34 |
goog.events.listen(t, goog.Timer.TICK, function (e) { |
| 35 |
box3.setLabelText((++value).toString()); |
| 36 |
}); |
| 37 |
t.start(); |
| 38 |
} |
| 39 |
goog.events.listen(window, goog.events.EventType.LOAD, initPage); |
| 40 |
</script> |
| 41 |
|
| 42 |
<link rel="stylesheet" href="css/demo.css"> |
| 43 |
<style> |
| 44 |
.goog-sample-component { |
| 45 |
height: 1em; |
| 46 |
padding: 1em; |
| 47 |
color: white; |
| 48 |
text-align: center; |
| 49 |
font-size: 150%; |
| 50 |
} |
| 51 |
</style> |
| 52 |
</head> |
| 53 |
<body> |
| 54 |
<h1>goog.ui.Component</h1> |
| 55 |
|
| 56 |
<!-- This div will have a Sample Component added to its contents. --> |
| 57 |
<div id="target1"> |
| 58 |
<p>Click on this big, colored box:</p> |
| 59 |
</div> |
| 60 |
|
| 61 |
<hr /> |
| 62 |
|
| 63 |
<div> |
| 64 |
<p>Or this box:</p> |
| 65 |
<!-- This div will have its contents decorated by a Sample Component. --> |
| 66 |
<div style="width: 50%" id="target2">Label from decorated DIV.</div> |
| 67 |
</div> |
| 68 |
|
| 69 |
<hr /> |
| 70 |
<p>This box's label keeps changing:</p> |
| 71 |
<!-- This div will also have its contents decorated by a Sample Component. --> |
| 72 |
<div style="width: 50%; float: right;" id="target3"></div> |
| 73 |
|
| 74 |
</body> |
| 75 |
</html> |