mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-06 22:29:44 +08:00
Header bar tweaks
This commit is contained in:
35
js/ext/angular/src/directive/ionicHeader.js
vendored
35
js/ext/angular/src/directive/ionicHeader.js
vendored
@ -9,11 +9,26 @@ angular.module('ionic.ui.header', ['ngAnimate'])
|
||||
restrict: 'E',
|
||||
replace: true,
|
||||
transclude: true,
|
||||
template: '<header class="bar bar-header" ng-transclude></header>',
|
||||
template: '<header class="bar bar-header">\
|
||||
<div class="buttons">\
|
||||
<button ng-repeat="button in leftButtons" class="button" ng-class="button.type" ng-click="button.click($event, $index)" ng-bind-html="button.content">\
|
||||
</button>\
|
||||
</div>\
|
||||
<h1 class="title" ng-bind="title"></h1>\
|
||||
<div class="buttons">\
|
||||
<button ng-repeat="button in rightButtons" class="button" ng-class="button.type" ng-click="button.click($event, $index)" ng-bind-html="button.content">\
|
||||
</button>\
|
||||
</div>\
|
||||
</header>',
|
||||
|
||||
scope: {
|
||||
leftButtons: '=',
|
||||
rightButtons: '=',
|
||||
title: '=',
|
||||
type: '@',
|
||||
alignTitle: '@',
|
||||
alignTitle: '@'
|
||||
},
|
||||
|
||||
link: function($scope, $element, $attr) {
|
||||
var hb = new ionic.views.HeaderBar({
|
||||
el: $element[0],
|
||||
@ -24,6 +39,22 @@ angular.module('ionic.ui.header', ['ngAnimate'])
|
||||
|
||||
$scope.headerBarView = hb;
|
||||
|
||||
$scope.$watch('leftButtons', function(val) {
|
||||
// Resize the title since the buttons have changed
|
||||
hb.align();
|
||||
});
|
||||
|
||||
$scope.$watch('rightButtons', function(val) {
|
||||
// Resize the title since the buttons have changed
|
||||
hb.align();
|
||||
});
|
||||
|
||||
$scope.$watch('title', function(val) {
|
||||
// Resize the title since the title has changed
|
||||
console.log('Title changed');
|
||||
hb.align();
|
||||
});
|
||||
|
||||
$scope.$on('$destroy', function() {
|
||||
//
|
||||
});
|
||||
|
||||
5
js/ext/angular/src/ionicAngular.js
vendored
5
js/ext/angular/src/ionicAngular.js
vendored
@ -27,4 +27,9 @@ angular.module('ionic.ui', [
|
||||
angular.module('ionic', [
|
||||
'ionic.service',
|
||||
'ionic.ui',
|
||||
|
||||
// Angular deps
|
||||
'ngAnimate',
|
||||
'ngTouch',
|
||||
'ngSanitize'
|
||||
]);
|
||||
|
||||
@ -9,16 +9,34 @@
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular.min.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular-touch.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular-animate.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular-sanitize.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<header-bar type="bar-primary" align-title="left">
|
||||
<button class="button">Tap</button>
|
||||
<h1 class="title">A really really long title here here here here her</h1>
|
||||
</header-bar>
|
||||
<body ng-controller="TestCtrl">
|
||||
<header-bar
|
||||
title="headerTitle"
|
||||
left-buttons="leftButtons"
|
||||
right-buttons="rightButtons"
|
||||
type="bar-primary"></header-bar>
|
||||
|
||||
<content has-header="true">
|
||||
<input type="text" ng-model="headerTitle">
|
||||
</content>
|
||||
<script src="../../../../dist/js/ionic.js"></script>
|
||||
<script src="../../../../dist/js/ionic-angular.js"></script>
|
||||
<script>
|
||||
angular.module('headerTest', ['ionic']);
|
||||
angular.module('headerTest', ['ionic'])
|
||||
|
||||
.controller('TestCtrl', function($scope) {
|
||||
$scope.headerTitle = 'A really long title here';
|
||||
$scope.leftButtons = [
|
||||
{
|
||||
text: 'Hello',
|
||||
click: function(e) {
|
||||
console.log('Click button');
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
var midPoint = window.clientWidth / 2;
|
||||
var box = document.createElement('div');
|
||||
box.style.backgroundColor = 'red';
|
||||
|
||||
@ -6,15 +6,16 @@
|
||||
<!-- Sets initial viewport load and disables zooming -->
|
||||
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
|
||||
<link rel="stylesheet" href="../../../../dist/css/ionic.css">
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.3/angular.min.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.3/angular-touch.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.3/angular-animate.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular.min.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular-touch.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular-animate.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular-sanitize.js"></script>
|
||||
<script src="../../../../dist/js/ionic.js"></script>
|
||||
<script src="../../../../dist/js/ionic-angular.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<pane ng-controller="ModalCtrl">
|
||||
<header-bar type="bar-positive">
|
||||
<h1 class="title">Contacts</h1>
|
||||
<button class="button button-icon" ng-click="openModal()"><i class="icon ion-compose"></i></button>
|
||||
<header-bar type="bar-positive" title="'Contacts'" right-buttons="contactsRightButtons">
|
||||
</header-bar>
|
||||
<content has-header="true">
|
||||
<list>
|
||||
@ -53,8 +54,6 @@
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script src="../../../../dist/js/ionic.js"></script>
|
||||
<script src="../../../../dist/js/ionic-angular.js"></script>
|
||||
<script>
|
||||
angular.module('modalTest', ['ionic'])
|
||||
|
||||
@ -64,6 +63,15 @@
|
||||
{ name: 'Barney Calhoun' },
|
||||
{ name: 'Lamarr the Headcrab' },
|
||||
];
|
||||
$scope.contactsRightButtons = [
|
||||
{
|
||||
type: 'button-icon',
|
||||
content: '<i class="icon ion-compose"></i>',
|
||||
click: function(e) {
|
||||
$scope.openModal();
|
||||
}
|
||||
}
|
||||
];
|
||||
$scope.openModal = function() {
|
||||
$scope.modal.show();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user