| 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.CharPicker</title> |
| 11 |
<meta charset=utf-8> |
| 12 |
<!-- common css used by all closure demos; not required for char picker --> |
| 13 |
<link rel="stylesheet" href="css/demo.css"> |
| 14 |
|
| 15 |
<!-- used only for button in this page; not required for char picker--> |
| 16 |
<link rel="stylesheet" href="../css/menubutton.css"> |
| 17 |
|
| 18 |
<!-- only required css for char picker --> |
| 19 |
<link rel="stylesheet" href="../css/charpicker.css"> |
| 20 |
|
| 21 |
<script src="../base.js"></script> |
| 22 |
<script> |
| 23 |
goog.require('goog.i18n.CharPickerData'); |
| 24 |
goog.require('goog.i18n.uChar.LocalNameFetcher'); |
| 25 |
goog.require('goog.ui.CharPicker'); |
| 26 |
</script> |
| 27 |
|
| 28 |
<style> |
| 29 |
#p1_value { |
| 30 |
color: red; |
| 31 |
font-weight: bold; |
| 32 |
font-size: large; |
| 33 |
} |
| 34 |
|
| 35 |
p { |
| 36 |
height: 2em; |
| 37 |
} |
| 38 |
</style> |
| 39 |
</head> |
| 40 |
|
| 41 |
<body> |
| 42 |
<h1>goog.ui.CharPicker</h1> |
| 43 |
<p>You have selected: <span id="p1_value">none</span> |
| 44 |
<div id="char-picker"></div> |
| 45 |
|
| 46 |
<script> |
| 47 |
var picker = new goog.ui.CharPicker(new goog.i18n.CharPickerData(), |
| 48 |
new goog.i18n.uChar.LocalNameFetcher(), |
| 49 |
["\uD869\uDED6", "a", "b", "c"], 10, 1); |
| 50 |
var el = goog.dom.getElement('char-picker'); |
| 51 |
picker.decorate(el); |
| 52 |
|
| 53 |
// Action on selection |
| 54 |
var selectionAction = function() { |
| 55 |
goog.dom.setTextContent(goog.dom.getElement('p1_value'), |
| 56 |
picker.getSelectedChar()); |
| 57 |
}; |
| 58 |
|
| 59 |
// Get selected locale from the char picker. |
| 60 |
goog.events.listen(picker, 'action', function(e) { selectionAction(); }); |
| 61 |
</script> |
| 62 |
<p> |
| 63 |
<input type="button" value="Dispose" onclick="picker.dispose()"> |
| 64 |
</p> |
| 65 |
</body> |
| 66 |
</html> |