Skip to content

Instantly share code, notes, and snippets.

@hatched
Forked from anonymous/gist:819564
Created February 10, 2011 00:14
Show Gist options
  • Save hatched/819645 to your computer and use it in GitHub Desktop.
Save hatched/819645 to your computer and use it in GitHub Desktop.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript" src="http://yui.yahooapis.com/combo?3.2.0/build/yui/yui.js&3.2.0/build/loader/loader.js"></script>
</head>
<body class="yui3-skin-sam yui-skin-sam">
<div id="tsTest_TabStrip">
<ul>
<li><a href="#tab1_Tab">Tab #1</a></li>
<li><a href="#tab2_Tab">Tab #2</a></li>
</ul>
<div>
<div id="tab1_Tab"><h3>Tab #1</h3></div>
<div id="tab2_Tab"><h3>Tab #2</h3></div>
</div>
</div>
<input type="button" id="btnReset" value="Reset"/>
<script type="text/javascript">
//<[CDATA[
var btnReset;
var tsTest;
btnReset_Click = function()
{
tsTest.setSelectedIndex(0); // <-------------
};
tsTest_SelectionChange = function(e)
{
// do stuff...
};
myTest = function()
{
/*
* TabStrip Class
*/
YUI().add(
"roflcopter.TabStrip",
function(Y)
{
Y.namespace("roflcopter").TabStrip = Y.Base.create(
"roflcopter.TabStrip",
Y.Base,
[],
{
/*
* Class definition
*/
Control: null,
ContentID: "",
ID: "",
initializer: function(config)
{
var me = this;
var myOptions = {};
null == config && (config = {});
null != config.ContentID && (me.ContentID = config.ContentID);
null != config.ID && (me.ID = config.ID);
if(me.ContentID == "")
{
me.ContentID = me.ID + "_TabStrip";
}
myOptions.srcNode = "#" + me.ContentID;
me.Control = new Y.TabView(myOptions);
me.Control.on(
"selectionChange",
function(e)
{
me.fire(
"selectionChange",
{
newVal: e.newVal,
prevVal: e.prevVal
}
);
}
);
me.Control.render();
},
setSelectedIndex: function(index)
{
console.log(this);
this.Control.selectChild(index);
}
},
{
ATTRS:
{
}
}
);
},
"0.0.0.0",
{
requires:
[
"base-build",
"tabview"
]
}
);
YUI().use(
"roflcopter.TabStrip",
function(Y)
{
tsTest = new Y.roflcopter.TabStrip({ID: "tsTest"});
tsTest.after("selectionChange", function(e){tsTest_SelectionChange(e);}, this);
}
);
YUI().use(
"yui2-button",
function(Y)
{
btnReset = new Y.YUI2.widget.Button("btnReset");
btnReset.on("click", btnReset_Click, this);
}
);
};
window.onload = function()
{
myTest();
};
//]]>
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment