Skip to content

Commit 254fa7f

Browse files
committed
Disabled items in range angular-slider#206
Own implementation of disabling specific items in slider range of elements.
1 parent 121acd2 commit 254fa7f

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

src/rzSliderTpl.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
<li ng-repeat="t in ticks track by $index" class="rz-tick"
1515
ng-class="{'rz-selected': t.selected}" ng-style="t.style"
1616
ng-attr-uib-tooltip="{{ t.tooltip }}" ng-attr-tooltip-placement="{{t.tooltipPlacement}}"
17-
ng-attr-tooltip-append-to-body="{{ t.tooltip ? true : undefined}}">
17+
ng-attr-tooltip-append-to-body="{{ t.tooltip ? true : undefined}}"
18+
ng-disabled="t.disabled">
1819
<span ng-if="t.value != null" class="rz-tick-value"
1920
ng-attr-uib-tooltip="{{ t.valueTooltip }}"
2021
ng-attr-tooltip-placement="{{t.valueTooltipPlacement}}">{{ t.value }}</span>

src/rzslider.js

+13
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
id: null,
4848
translate: null,
4949
getLegend: null,
50+
getDisabled: null,
5051
stepsArray: null,
5152
bindIndexForStepsArray: false,
5253
draggableRange: false,
@@ -588,6 +589,7 @@
588589
};
589590

590591
this.getLegend = this.options.getLegend;
592+
this.getDisabled = this.options.getDisabled;
591593
}
592594

593595
if (this.options.vertical) {
@@ -621,6 +623,13 @@
621623
return step.legend;
622624
return null;
623625
};
626+
627+
this.getDisabled = function(index) {
628+
var step = this.options.stepsArray[index];
629+
if (angular.isObject(step))
630+
return step.disabled;
631+
return null;
632+
};
624633
},
625634

626635
/**
@@ -1024,6 +1033,8 @@
10241033
if (legend)
10251034
tick.legend = legend;
10261035
}
1036+
if (self.getDisabled)
1037+
tick.disabled = self.getDisabled(value, self.options.id);
10271038
return tick;
10281039
});
10291040
},
@@ -2141,6 +2152,8 @@
21412152
* @param {number} newValue new model value
21422153
*/
21432154
positionTrackingHandle: function(newValue) {
2155+
if(this.scope.ticks[newValue].disabled)
2156+
return false;
21442157
var valueChanged = false;
21452158
newValue = this.applyMinMaxLimit(newValue);
21462159
if (this.range) {

src/rzslider.less

+10
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,16 @@
160160
&.rz-selected {
161161
background: @selectedTicksColor;
162162
}
163+
&[disabled] {
164+
cursor: not-allowed;
165+
opacity: 0.6;
166+
.rz-tick-value,
167+
.rz-tick-legend,
168+
* {
169+
cursor: not-allowed;
170+
opacity: 0.6;
171+
}
172+
}
163173
}
164174

165175
.rz-tick-value {

0 commit comments

Comments
 (0)