mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
Previously the showBack property was setting if the back button should or should not be enabled, and it was also used if the back button should be hidden or not for the view. Changed it so there are now two concepts, where showBack is visual only, and enableBack determines if it should show according to $ionicHistory and navigation info.
46 lines
1.2 KiB
JavaScript
46 lines
1.2 KiB
JavaScript
/**
|
|
* @ngdoc directive
|
|
* @name menuToggle
|
|
* @module ionic
|
|
* @restrict AC
|
|
*
|
|
* @description
|
|
* Toggle a side menu on the given side.
|
|
*
|
|
* @usage
|
|
* Below is an example of a link within a nav bar. Tapping this button
|
|
* would open the given side menu, and tapping it again would close it.
|
|
*
|
|
* ```html
|
|
* <ion-view>
|
|
* <ion-nav-buttons side="left">
|
|
* <button menu-toggle="left" class="button button-icon icon ion-navicon"></button>
|
|
* </ion-nav-buttons>
|
|
* ...
|
|
* </ion-view>
|
|
* ```
|
|
*/
|
|
IonicModule
|
|
.directive('menuToggle', function() {
|
|
return {
|
|
restrict: 'AC',
|
|
link: function($scope, $element, $attr) {
|
|
$scope.$on('$ionicView.beforeEnter', function(ev, viewData) {
|
|
if (viewData.enableBack) {
|
|
var sideMenuCtrl = $element.inheritedData('$ionSideMenusController');
|
|
if (!sideMenuCtrl.enableMenuWithBackViews()) {
|
|
$element.addClass('hide');
|
|
}
|
|
} else {
|
|
$element.removeClass('hide');
|
|
}
|
|
});
|
|
|
|
$element.bind('click', function() {
|
|
var sideMenuCtrl = $element.inheritedData('$ionSideMenusController');
|
|
sideMenuCtrl && sideMenuCtrl.toggle($attr.menuToggle);
|
|
});
|
|
}
|
|
};
|
|
});
|