4
<title>history-hash test</title>
12
#log { margin-top: 1em; }
25
<body class="yui3-skin-sam">
27
<h1>history-hash test</h1>
31
<li><label><input type="checkbox" id="asparagus">Asparagus</label></li>
32
<li><label><input type="checkbox" id="bluebird">Bluebird</label></li>
33
<li><label><input type="checkbox" id="coffee">Coffee</label></li>
37
<label><input type="radio" name="mode" id="add" checked>addValue</label>
38
<label><input type="radio" name="mode" id="replace">replaceValue</label>
43
<li><a href="http://www.yahoo.com">Yahoo!</a></li>
44
<li><a href="#foo=bar/baz">#foo=bar/baz</a></li>
47
<div id="photos"></div>
50
<script src="../../../../build/yui/yui.js"></script>
56
'history-hash': 'debug',
57
'history-hash-ie': 'debug'
59
useBrowserConsole: false
60
}).use('console', 'event-delegate', 'history-hash', 'json-stringify', function (Y) {
61
new Y.Console().render('#log');
63
var history = new Y.History(),
64
bookmarked = history.get(),
66
asparagus: 'http://farm5.static.flickr.com/4005/4686935131_253e921bf7_m.jpg', // http://www.flickr.com/photos/allenr/4686935131/
67
bluebird : 'http://farm1.static.flickr.com/26/66307916_811efccdfc_m.jpg', // http://www.flickr.com/photos/allenr/66307916/
68
coffee : 'http://farm4.static.flickr.com/3336/4638474362_093edb7565_m.jpg' // http://www.flickr.com/photos/allenr/4638474362/
71
menuNode = Y.one('#menu'),
72
photosNode = Y.one('#photos');
74
function refresh(state) {
75
menuNode.all('input[type="checkbox"]').set('checked', false);
76
photosNode.setContent('');
78
Y.Object.each(state, function (value, key) {
79
if (Y.Object.owns(images, key)) {
80
var img = new Image();
82
img.src = images[key];
85
menuNode.one('#' + key).set('checked', true);
86
photosNode.append(img);
91
Y.on('history:change', function (e) {
95
menuNode.delegate('click', function (e) {
96
var node = e.currentTarget,
99
history[add.get('checked') ? 'addValue' : 'replaceValue'](
100
node.get('id'), node.get('checked') ? '1' : null);
103
// Refresh with the bookmarked state, if any.
104
Y.log('Bookmarked state: ' + Y.JSON.stringify(bookmarked));