Created
February 9, 2011 23:27
-
-
Save anonymous/819564 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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.setSelectedItem(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) | |
{ | |
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