Angular cleanup and content working

This commit is contained in:
Max Lynch
2013-10-01 17:34:14 -05:00
parent 4fcad719a3
commit 9100bae246
11 changed files with 615 additions and 235 deletions

View File

@ -0,0 +1,46 @@
angular.module('ionic.ui.content', {})
/*
.directive('content', function() {
return {
restrict: 'E',
replace: true,
template: '<div class="content"></div>'
}
});
*/
/*
.directive('content', function() {
return {
restrict: 'E',
replace: true,
transclude: true,
scope: {
hasHeader: '@',
hasTabs: '@'
},
template: '<div class="content" ng-class="{\'has-header\': hasHeader, \'has-tabs\': hasTabs}" ng-transclude></div>'
}
})
*/
.directive('content', function() {
return {
restrict: 'E',
replace: true,
transclude: true,
scope: true,
template: '<div class="content" ng-class="{\'has-header\': hasHeader, \'has-tabs\': hasTabs}"></div>',
compile: function(element, attr, transclude, navCtrl) {
return function($scope, $element, $attr) {
$scope.hasHeader = attr.hasHeader;
$scope.hasTabs = attr.hasTabs;
var newScope = $scope.$parent.$new();
$element.append(transclude(newScope));
};
}
}
})

View File

@ -1,24 +1,8 @@
angular.module('ionic.ui', ['ngTouch'])
.directive('content', function() {
return {
restrict: 'E',
replace: true,
transclude: true,
scope: true,
template: '<div class="content" ng-class="{\'has-header\': hasHeader, \'has-tabs\': hasTabs}"></div>',
compile: function(element, attr, transclude, navCtrl) {
return function($scope, $element, $attr) {
$scope.hasHeader = attr.hasHeader;
};
}
}
})
angular.module('ionic.ui.nav', ['ionic.ui'])
.controller('NavCtrl', function($scope, $element, $compile) {
var _this = this;
angular.extend(this, ionic.controllers.NavController.prototype);
ionic.controllers.NavController.call(this, {
@ -42,7 +26,6 @@ angular.module('ionic.ui', ['ngTouch'])
}
$scope.pushController = function(controller) {
//console.log('PUSHING OCNTROLLER', controller);
_this.push(controller);
}

View File

@ -1,4 +1,4 @@
angular.module('ionic.ui', [])
angular.module('ionic.ui.sideMenu', [])
.controller('SideMenuCtrl', function($scope) {
var _this = this;

View File

@ -1,17 +1,4 @@
angular.module('ionic.ui', [])
.directive('content', function() {
return {
restrict: 'E',
replace: true,
transclude: true,
scope: {
hasHeader: '@',
hasTabs: '@'
},
template: '<div class="content" ng-class="{\'has-header\': hasHeader, \'has-tabs\': hasTabs}" ng-transclude></div>'
}
})
angular.module('ionic.ui.tabs', ['ionic.ui.content'])
.controller('TabsCtrl', function($scope) {
var _this = this;

View File

@ -1,9 +0,0 @@
angular.module('ionic.ui.content', {})
.directive('content', function() {
return {
restrict: 'E',
replace: true,
template: '<div class="content"></div>'
}
});

View File

@ -48,7 +48,8 @@
</nav-controller>
<script src="../../../../dist/ionic.js"></script>
<script src="../src/ionicNav.js"></script>
<script src="../src/directive/ionicContent.js"></script>
<script src="../src/directive/ionicNav.js"></script>
<script>
var pageNumber = 0;

View File

@ -32,13 +32,13 @@
</ul>
</menu>
<menu side="right">
<h2>Right</h2>
<h2>Items</h2>
</menu>
</side-menu-controller>
<script src="../../../../dist/ionic.js"></script>
<script src="../src/ionicSideMenu.js"></script>
<script src="../src/directive/ionicSideMenu.js"></script>
<script>
angular.module('sideMenuTest', ['ionic.ui'])
angular.module('sideMenuTest', ['ionic.ui.sideMenu'])
/*
var Controller = function(opts) {

View File

@ -0,0 +1,129 @@
<html ng-app="sideMenuTest">
<head>
<meta charset="utf-8">
<title>Sub Controllers</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">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.2/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.2/angular-touch.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.2/angular-animate.js"></script>
</head>
<body>
<side-menu-controller>
<div class="full-section" side-menu-content>
<header class="bar bar-header bar-dark">
<a href="#" class="button"><i class="icon-reorder"></i></a>
<h1 class="title">Slide me</h1>
</header>
<div class="content has-header">
<h1>Slide me side to side!</h1>
</div>
</div>
<menu side="left">
<h2>Left</h2>
<ul class="list">
<a href="#" class="list-item" ng-repeat="item in list">
{{item.text}}
</a>
</ul>
</menu>
<menu side="right">
<h2>Items</h2>
<tab-controller>
<div title="Home" icon="icon-home" class="tab-content">
<header class="bar bar-header bar-dark">
<h1 class="title">Tab Bars</h1>
</header>
<content has-header="true" has-tabs="true">
<h1>Home</h1>
<ul class="list">
<a href="#" class="list-item" ng-repeat="item in items">
{{item.title}}
</a>
</ul>
</content>
</div>
<div title="About" icon="icon-info" class="tab-content">
<header class="bar bar-header bar-success">
<h1 class="title">About</h1>
</header>
<content has-header="true" has-tabs="true">
<h1>About Us</h1>
</content>
</div>
<div title="Settings" icon="icon-gear" class="tab-content">
<header class="bar bar-header bar-dark">
<h1 class="title">Settings</h1>
</header>
<content has-header="true" has-tabs="true">
<h1>Settings</h1>
</content>
</div>
</tab-controller>
</menu>
</side-menu-controller>
<script src="../../../../dist/ionic.js"></script>
<script src="../src/ionicSideMenu.js"></script>
<script src="../src/ionicTabBar.js"></script>
<script>
angular.module('sideMenuTest', ['ionic.ui'])
/*
var Controller = function(opts) {
var _this = this;
this.el = opts.el;
this.animateClass = opts.animateClass;
// Bind release and drag listeners
window.ionic.onGesture('drag', function(e) {
_this.onDrag && _this.onDrag(e);
}, this.el);
window.ionic.onGesture('release', function(e) {
_this.endDrag && _this._endDrag(e);
}, this.el);
};
Controller.prototype = {
onDrag: function(e) {},
endDrag: function(e) {},
getTranslateX: function() {
var r = /translate3d\((-?.+)px/;
var d = r.exec(this.el.style.webkitTransform);
if(d && d.length > 0) {
return parseFloat(d[1]);
}
return 0;
},
setTranslateX: function(amount) {
this.el.style.webkitTransform = 'translate3d(' + amount + 'px, 0, 0)';
},
enableAnimation: function() {
this.el.classList.add(this.animateClass);
},
disableAnimation: function() {
this.el.classList.remove(this.animateClass);
}
};
var l = new SideMenu({ el: document.getElementById('my-left-panel'), width: 270 });
var r = new SideMenu({ el: document.getElementById('my-right-panel'), width: 270 });
var c = new Controller({ el: document.createElement('content') });
var ctrl = new SideMenuController({
left: l,
right: r,
content: c
});
*/
</script>
</body>
</html>

View File

@ -50,7 +50,8 @@
</tab-controller>
<script src="../../../../dist/ionic.js"></script>
<script src="../src/ionicTabBar.js"></script>
<script src="../src/directive/ionicContent.js"></script>
<script src="../src/directive/ionicTabBar.js"></script>
<script>
angular.module('tabsTest', ['ionic.ui'])