Skip to content
This repository has been archived by the owner on Sep 8, 2020. It is now read-only.

add hideprev and hideafter to uiLayoutContainer #158

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,21 @@ percentage
</div>
```

### splitbar

Type: `Ojbect`

A Javascript object to control the display or previous button and next button.

`prevButton`: Boolean (Default: true).
`nextButton`: Boolean (Deafutl: true).


```
<div ui-layout-container splitbar="{prevButton: false, nextButton: false}"></div>

```

## Events

Events are broadcast on the scope where ui-layout is attached. This means they are available to any controller inside of a ui-layout container.
Expand Down
8 changes: 7 additions & 1 deletion src/ui-layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,9 @@ angular.module('ui.layout', [])
pre: function(scope, element, attrs, ctrl) {
scope.container = LayoutContainer.Container();
scope.container.element = element;
var splitbarOpts = angular.extend({}, scope.$eval(attrs.splitbar));
scope.prevButton = splitbarOpts && splitbarOpts.prevButton !== undefined ? splitbarOpts.prevButton : true;
scope.nextButton = splitbarOpts && splitbarOpts.nextButton !== undefined ? splitbarOpts.nextButton : true;

ctrl.addContainer(scope.container);

Expand All @@ -796,6 +799,7 @@ angular.module('ui.layout', [])
if(!element.hasClass('stretch')) element.addClass('stretch');
if(!element.hasClass('ui-layout-container')) element.addClass('ui-layout-container');


scope.$watch('container.size', function(newValue) {
element.css(ctrl.sizeProperties.sizeProperty, newValue + 'px');
});
Expand All @@ -808,7 +812,9 @@ angular.module('ui.layout', [])
var parent = element.parent();
var children = parent.children();
var index = ctrl.indexOfElement(element);
var splitbar = angular.element('<div ui-splitbar><a><span class="ui-splitbar-icon"></span></a><a><span class="ui-splitbar-icon"></span></a></div>');
var splitbar = angular.element('<div ui-splitbar><a ng-show="prevButton"><span class="ui-splitbar-icon"></span></a>'
+ '<a ng-show="nextButton"><span class="ui-splitbar-icon"></span></a></div>');

if(0 < index && !ctrl.hasSplitbarBefore(scope.container)) {
angular.element(children[index-1]).after(splitbar);
$compile(splitbar)(scope);
Expand Down