A whole lotta shit

This commit is contained in:
Max Lynch
2013-10-21 10:44:35 -05:00
parent 073b30c818
commit aad3bb92b5
48 changed files with 25083 additions and 320 deletions

View File

@ -1,6 +1,6 @@
angular.module('ionic.ui.tabs', [])
angular.module('ionic.ui.tabs', ['ngAnimate'])
.controller('TabsCtrl', function($scope) {
.controller('TabsCtrl', ['$scope', '$element', '$animate', function($scope, $element, $animate) {
var _this = this;
angular.extend(this, ionic.controllers.TabBarController.prototype);
@ -8,83 +8,119 @@ angular.module('ionic.ui.tabs', [])
ionic.controllers.TabBarController.call(this, {
tabBar: {
tryTabSelect: function() {},
setSelectedItem: function(index) {
console.log('TAB BAR SET SELECTED INDEX', index);
},
addItem: function(item) {
console.log('TAB BAR ADD ITEM', item);
}
setSelectedItem: function(index) {},
addItem: function(item) {}
}
});
this.add = function(controller) {
this.addController(controller);
this.select(0);
};
this.select = function(controllerIndex) {
var oldIndex = _this.getSelectedIndex();
$scope.activeAnimation = $scope.animation;
/*
if(controllerIndex > oldIndex) {
} else if(controllerIndex < oldIndex) {
$scope.activeAnimation = $scope.animation + '-reverse';
}
*/
_this.selectController(controllerIndex);
};
$scope.controllers = this.controllers;
}])
$scope.$watch('controllers', function(newV, oldV) {
console.log("CControlelrs changed", newV, oldV);
//$scope.$apply();
});
})
.directive('tabController', function() {
.directive('tabs', function() {
return {
restrict: 'E',
replace: true,
scope: {},
scope: {
animation: '@'
},
transclude: true,
controller: 'TabsCtrl',
//templateUrl: 'ext/angular/tmpl/ionicTabBar.tmpl.html',
template: '<div class="view"><div ng-transclude></div><tab-bar></tab-bar></div>',
template: '<div class="view"><tab-controller-bar></tab-controller-bar></div>',
compile: function(element, attr, transclude, tabsCtrl) {
return function($scope, $element, $attr) {
$scope.$watch('activeAnimation', function(value) {
//$element.removeClass($scope.animation + ' ' + $scope.animation + '-reverse');
$element.addClass($scope.activeAnimation);
});
transclude($scope, function(cloned) {
$element.prepend(cloned);
});
};
}
};
})
// Generic controller directive
.directive('tabContent', function() {
return {
restrict: 'CA',
replace: true,
require: '^tabController',
scope: true,
link: function(scope, element, attrs, tabsCtrl) {
scope.$watch('isVisible', function(value) {
if(!value) {
element[0].style.display = 'none';
} else {
element[0].style.display = 'block';
}
});
scope.title = attrs.title;
scope.icon = attrs.icon;
scope.iconOn = attrs.iconOn;
scope.iconOff = attrs.iconOff;
tabsCtrl.addController(scope);
}
};
})
.directive('tabBar', function() {
.directive('tab', ['$animate', function($animate) {
return {
restrict: 'E',
require: '^tabController',
replace: true,
require: '^tabs',
scope: true,
transclude: 'element',
compile: function(element, attr, transclude) {
return function($scope, $element, $attr, tabsCtrl) {
var childScope, childElement;
$scope.$watch('isVisible', function(value) {
if(childElement) {
$animate.leave(childElement);
childElement = undefined;
}
if(childScope) {
childScope.$destroy();
childScope = undefined;
}
if(value) {
childScope = $scope.$new();
transclude(childScope, function(clone) {
childElement = clone;
childElement.addClass('view-full');
$animate.enter(clone, $element.parent(), $element);
});
}
});
$scope.title = $attr.title;
$scope.icon = $attr.icon;
$scope.iconOn = $attr.iconOn;
$scope.iconOff = $attr.iconOff;
tabsCtrl.add($scope);
}
}
};
}])
.directive('tabControllerBar', function() {
return {
restrict: 'E',
require: '^tabs',
transclude: true,
replace: true,
scope: true,
template: '<div class="tabs tabs-primary">' +
'<tab-item title="{{controller.title}}" icon="{{controller.icon}}" icon-on="{{controller.iconOn}}" icon-off="{{controller.iconOff}}" active="controller.isVisible" index="$index" ng-repeat="controller in controllers"></tab-item>' +
'<tab-controller-item title="{{controller.title}}" icon="{{controller.icon}}" icon-on="{{controller.iconOn}}" icon-off="{{controller.iconOff}}" active="controller.isVisible" index="$index" ng-repeat="controller in controllers"></tab-controller-item>' +
'</div>'
};
})
.directive('tabItem', function() {
.directive('tabControllerItem', function() {
return {
restrict: 'E',
replace: true,
require: '^tabController',
require: '^tabs',
scope: {
title: '@',
iconOn: '@',
@ -94,9 +130,8 @@ angular.module('ionic.ui.tabs', [])
index: '='
},
link: function(scope, element, attrs, tabsCtrl) {
console.log('Linked item', scope);
scope.selectTab = function(index) {
tabsCtrl.selectController(scope.index);
tabsCtrl.select(scope.index);
};
},
template:
@ -106,4 +141,37 @@ angular.module('ionic.ui.tabs', [])
'<i class="{{iconOff}}" ng-if="!active"></i> {{title}}' +
'</a>'
};
})
.directive('tabBar', function() {
return {
restrict: 'E',
replace: true,
transclude: true,
template: '<div class="tabs tabs-primary" ng-transclude>' +
'</div>'
}
})
.directive('tabItem', function() {
return {
restrict: 'E',
replace: true,
scope: {
title: '@',
iconOn: '@',
iconOff: '@',
active: '=',
tabSelected: '@',
index: '='
},
link: function(scope, element, attrs) {
},
template:
'<a href="#" ng-class="{active:active}" ng-click="tabSelected()" class="tab-item">' +
'<i class="{{icon}}" ng-if="icon"></i>' +
'<i class="{{iconOn}}" ng-if="active"></i>' +
'<i class="{{iconOff}}" ng-if="!active"></i> {{title}}' +
'</a>'
};
});