mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
80 lines
2.0 KiB
JavaScript
80 lines
2.0 KiB
JavaScript
(function(ionic) {
|
|
'use strict';
|
|
|
|
angular.module('ionic.ui.header', ['ngAnimate'])
|
|
|
|
|
|
.directive('headerBar', function() {
|
|
return {
|
|
restrict: 'E',
|
|
replace: true,
|
|
transclude: true,
|
|
template: '<header class="bar bar-header">\
|
|
<div class="buttons">\
|
|
<button ng-repeat="button in leftButtons" class="button" ng-class="button.type" ng-click="button.tap($event, $index)" ng-bind-html="button.content">\
|
|
</button>\
|
|
</div>\
|
|
<h1 class="title" ng-bind-html="title"></h1>\
|
|
<div class="buttons">\
|
|
<button ng-repeat="button in rightButtons" class="button no-animation" ng-class="button.type" ng-click="button.tap($event, $index)" ng-bind-html="button.content">\
|
|
</button>\
|
|
</div>\
|
|
</header>',
|
|
|
|
scope: {
|
|
leftButtons: '=',
|
|
rightButtons: '=',
|
|
title: '=',
|
|
type: '@',
|
|
alignTitle: '@'
|
|
},
|
|
|
|
link: function($scope, $element, $attr) {
|
|
var hb = new ionic.views.HeaderBar({
|
|
el: $element[0],
|
|
alignTitle: $scope.alignTitle || 'center'
|
|
});
|
|
|
|
$element.addClass($scope.type);
|
|
|
|
$scope.headerBarView = hb;
|
|
|
|
$scope.$watch('leftButtons', function(val) {
|
|
// Resize the title since the buttons have changed
|
|
hb.align();
|
|
});
|
|
|
|
$scope.$watch('rightButtons', function(val) {
|
|
console.log('Right buttons changed');
|
|
// Resize the title since the buttons have changed
|
|
hb.align();
|
|
});
|
|
|
|
$scope.$watch('title', function(val) {
|
|
// Resize the title since the title has changed
|
|
hb.align();
|
|
});
|
|
}
|
|
};
|
|
})
|
|
|
|
.directive('footerBar', function() {
|
|
return {
|
|
restrict: 'E',
|
|
replace: true,
|
|
transclude: true,
|
|
template: '<footer class="bar bar-footer" ng-transclude>\
|
|
</footer>',
|
|
|
|
scope: {
|
|
type: '@',
|
|
},
|
|
|
|
link: function($scope, $element, $attr) {
|
|
$element.addClass($scope.type);
|
|
}
|
|
};
|
|
});
|
|
|
|
})(ionic);
|