Support disabling the review-panel toggle, like a standard checkbox.

This commit is contained in:
Paulo Reis 2017-02-02 12:08:17 +00:00
parent fe33fa1f65
commit f50967295d
2 changed files with 10 additions and 3 deletions

View file

@ -6,16 +6,23 @@ define [
scope:
onToggle: '='
ngModel: '='
disabled: '=?'
onDisabledClick: '=?'
link: (scope) ->
if !scope.disabled?
scope.disabled = false
scope.onChange = (args...) ->
scope.onToggle(scope.localModel)
scope.handleClick = () ->
if scope.disabled
scope.onDisabledClick()
scope.localModel = scope.ngModel
scope.$watch "ngModel", (value) ->
scope.localModel = value
template: """
<div class="rp-toggle">
<input id="rp-toggle-{{$id}}" type="checkbox" class="rp-toggle-hidden-input" ng-model="localModel" ng-change="onChange()" />
<div class="rp-toggle" ng-click="handleClick();">
<input id="rp-toggle-{{$id}}" ng-disabled="disabled" type="checkbox" class="rp-toggle-hidden-input" ng-model="localModel" ng-change="onChange()" />
<label for="rp-toggle-{{$id}}" class="rp-toggle-btn"></label>
</div>
"""

View file

@ -643,7 +643,7 @@
.rp-toggle {
display: inline-block;
vertical-align: middle;
margin-left: 5px;
padding-left: 5px;
}
.rp-toggle-hidden-input {
display: none;