state.html revision 1b298c6f0ef597aa4ab0b8bcb25430b6c9a87749
<html>
<head>
<title>YUI 3.0</title>
<script type="text/javascript">
// YUI({
// core: ['*']
// }).use('state', function(Y) {
// YUI({logExclude: {'Event': true}}).use('dump', 'state', function(Y) {
YUI({logInclude: {'Example': true}}).use('dump', 'state', function(Y) {
// YUI({logInclude: {}}).use('dump', 'state', function(Y) {
var newobj = {},
o = {
str: "str",
arr: [
"array1",
true,
{ obj: "obj"},
["array2"]
],
dat: new Date(),
fn: function() {
},
//win: window,
nada: null
};
var configs = new Y.State();
// add a prop
configs.add('myprop', o);
// show all attributes for this item
// show a single attribute for this item
// remove one or more attribute from the item (hash)
configs.remove('myprop', {fn: true});
// remove an attribute from the item (str)
configs.remove('myprop', 'dat');
// remove one or more attributes from the item (array)
configs.remove('myprop', ['nada']);
// add an attribute to an existing prop
configs.add('myprop', {nada:null});
// delete a property
configs.remove('myprop');
var o2 = Y.clone(o);
// Y.log("clone: " + Y.Lang.dump(o2));
configs.add('myprop', o2);
configs.add('myprop2', {
str: 'str2',
nada: null
});
var Y = YUI();
function Main() {
}
Main.NAME = "main";
Main.ATTRS = {
mainA : {
value:"mainA"
},
mainB : {
value:"mainB"
}
}
Main.PLUGINS = [
"mainplugin"
];
function Aggr() {
}
Aggr.NAME = "aggr";
Aggr.ATTRS = {
aggrA : {
value:"aggrA"
}
};
Aggr.PLUGINS = [
"aggplugin"
];
Y.aggregate(Main, Aggr, false, ["ATTRS", "PLUGINS"]);
Y.log(Main.ATTRS, 'info', 'Example');
Y.log(Main.PLUGINS, 'info', 'Example');
});
</script>
<body>
see the console
</body>
</html>