Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: 29720e7e7f
Fetching contributors…

Cannot retrieve contributors at this time

94 lines (88 sloc) 2.58 kB
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>Controller Example</title>
<style type="text/css">
body {font-family: verdana}
.tabs {
padding: 0px; margin: 0px;
}
.tabs li {
float: left;
padding: 10px;
background-color: #F6F6F6;
list-style: none;
margin-left: 10px;
}
.tabs li a {
color: #1C94C4;
font-weight: bold;
text-decoration: none;
}
.tabs li.active a {
color: #F6A828;
cursor: default;
}
.tab {
border: solid 1px #F6A828;
}
/* clearfix from jQueryUI */
.ui-helper-clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
.ui-helper-clearfix { display: inline-block; }
/* required comment for clearfix to work in Opera \*/
* html .ui-helper-clearfix { height:1%; }
.ui-helper-clearfix { display:block; }
/* end clearfix */
</style>
</head>
<body>
<div id="demo-html">
<ul id="tabs" class="tabs ui-helper-clearfix">
<li><a href="#tab1">Model</a></li>
<li><a href="#tab2">View</a></li>
<li><a href="#tab3">Controller</a></li>
</ul>
<div id="tab1" class="tab">
Model Content
</div>
<div id="tab2" class="tab">
View Content
</div>
<div id="tab3" class="tab">
Controller Content
</div>
</div>
<script type="text/javascript" src="../../steal/steal.js"></script>
<script type="text/javascript" id="demo-source">
steal('jquery','can/control', function($, Control){
// create a new Tabs class
var Tabs = Control({
// initialize widget
init: function( el ) {
// activate the first tab
$( el ).children( 'li:first' ).addClass( 'active' );
// hide the other tabs
var tab = this.tab;
this.element.children( 'li:gt(0)' ).each(function() {
tab( $( this ) ).hide();
});
},
// helper function finds the tab for a given li
tab: function( li ) {
return $( li.find( 'a' ).attr( 'href' ) );
},
// hides old active tab, shows new one
'li click': function( el, ev ) {
ev.preventDefault();
this.tab( this.element.find( '.active' )
.removeClass( 'active' ) ).hide()
this.tab( el.addClass( 'active' ) ).show();
}
});
// adds the controller to the element
new Tabs( '#tabs' );
});
</script>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.