Last active
August 29, 2015 14:04
-
-
Save raypulver/ff901e7c18546fa30f91 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* directive.ionimagetitleview.js | |
This directive is a copy of ionView which allows you to set a title="<html can go here>" and real-title="Document <title> goes here". The purpose of this directive is to allow for HTML to be embedded in the header of an ion-view without having it printed as | |
the document title, instead substituting an actual title. | |
*/ | |
angular.module('ionic.imagetitleview', []).directive('ionImageTitleView', ['$ionicViewService', '$rootScope', '$animate', function ($ionicViewService, $rootScope, $animate) { | |
return { | |
restrict: 'EA', | |
priority: 1000, | |
scope: { | |
leftButtons: '=', | |
rightButtons: '=', | |
title: '@', | |
realTitle: '@', | |
hideBackButton: '@', | |
hideNavBar: '@', | |
}, | |
compile: function(tElement, tAttrs, transclude) { | |
tElement.addClass('pane'); | |
tElement[0].removeAttribute('title'); | |
return function link($scope, $element, $attr) { | |
$rootScope.$broadcast('viewState.viewEnter', { | |
title: $scope.realTitle, | |
navDirection: $scope.$navDirection || $scope.$parent.$navDirection | |
}); | |
// Should we hide a back button when this tab is shown | |
$scope.hideBackButton = $scope.$eval($scope.hideBackButton); | |
if($scope.hideBackButton) { | |
$rootScope.$broadcast('viewState.showBackButton', false); | |
} | |
// Should the nav bar be hidden for this view or not? | |
$rootScope.$broadcast('viewState.showNavBar', ($scope.hideNavBar !== 'true') ); | |
// watch for changes in the left buttons | |
$scope.$watch('leftButtons', function(value) { | |
$scope.$emit('viewState.leftButtonsChanged', $scope.leftButtons); | |
}); | |
$scope.$watch('rightButtons', function(val) { | |
$scope.$emit('viewState.rightButtonsChanged', $scope.rightButtons); | |
}); | |
// watch for changes in the title | |
$scope.$watch('title', function(val) { | |
$scope.$emit('viewState.titleUpdated', $scope); | |
}); | |
}; | |
} | |
}; | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment