mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-07 06:57:02 +08:00
Side menu controller with tests
This commit is contained in:
22
hacking/SideMenu.js
Normal file
22
hacking/SideMenu.js
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
(function(window, document, ionic) {
|
||||||
|
SideMenu = function(opts) {
|
||||||
|
this.el = opts.el;
|
||||||
|
this.width = opts.width;
|
||||||
|
this.isEnabled = opts.isEnabled || true;
|
||||||
|
};
|
||||||
|
|
||||||
|
SideMenu.prototype = {
|
||||||
|
getFullWidth: function() {
|
||||||
|
return this.width;
|
||||||
|
},
|
||||||
|
setIsEnabled: function(isEnabled) {
|
||||||
|
this.isEnabled = isEnabled;
|
||||||
|
},
|
||||||
|
bringUp: function() {
|
||||||
|
this.el.style.zIndex = 0;
|
||||||
|
},
|
||||||
|
pushDown: function() {
|
||||||
|
this.el.style.zIndex = -1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})(this, document, ion = this.ionic || {});
|
||||||
16
hacking/SideMenu.unit.js
Normal file
16
hacking/SideMenu.unit.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
describe('SideMenu', function() {
|
||||||
|
var menu;
|
||||||
|
|
||||||
|
beforeEach(function() {
|
||||||
|
var d = document.createElement('div');
|
||||||
|
menu = new SideMenu({
|
||||||
|
el: d,
|
||||||
|
width: 270
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should init', function() {
|
||||||
|
expect(menu.width).toEqual(270);
|
||||||
|
expect(menu.isEnabled).toEqual(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
32
hacking/sideMenu.html
Normal file
32
hacking/sideMenu.html
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Side Menu</title>
|
||||||
|
|
||||||
|
<!-- Sets initial viewport load and disables zooming -->
|
||||||
|
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
|
||||||
|
<link href="/vendor/font-awesome/css/font-awesome.css" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="../dist/ionic.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
|
||||||
|
<header class="bar bar-header bar-dark">
|
||||||
|
<a href="#" class="button"><i class="icon-reorder"></i></a>
|
||||||
|
<h1 class="title">Tab Bars</h1>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<main class="has-header content content-padded">
|
||||||
|
<h1>Swipe me, side to side</h1>
|
||||||
|
</main>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<script src="../../js/ionic-events.js"></script>
|
||||||
|
<script src="../../js/ionic-gestures.js"></script>
|
||||||
|
<script src="TabBar.js"></script>
|
||||||
|
<script src="TabBarController.js"></script>
|
||||||
|
<script>
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user