This repository has been archived by the owner on Nov 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 121
/
example.html
executable file
·182 lines (159 loc) · 5.66 KB
/
example.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<!DOCTYPE html>
<html>
<head>
<title>Slider for AngularJS</title>
<!--<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootswatch/2.3.1/spruce/bootstrap.min.css">-->
<style>
slider {
display: block;
position: relative;
height: 30px;
width: 500px;
}
slider span.bar {
height: 50%;
z-index: 0;
background: #eee;
left: 0;
top: 25%;
cursor: pointer;
}
slider span.bar.selection, slider span.bar.unselected {
}
slider span.bar.selection {
background: #0a0;
opacity: 0.5;
}
slider span.bar.unselected {
width: auto;
background: #a00;
opacity: 0.5;
}
slider span.pointer {
cursor: pointer;
width: 15px;
top: 0;
bottom: 0;
background-color: #00a;
}
slider span.pointer:hover {
}
slider span.pointer.active {
}
slider span.bubble {
font-size: 0.7em;
line-height: 1.4em;
font-family: sans-serif;
text-align: center;
text-shadow: none;
top: -1.3em;
cursor: pointer;
}
slider span.bubble.selection, slider span.bubble.limit {
top: 25%;
}
slider span.bubble.selection {
}
slider span.bubble.limit {
}
slider span.bubble.low, slider span.bubble.high {
}
::-ms-tooltip {
display: none;
}
#slider-container {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: -moz-none;
-ms-user-select: none;
user-select: none;
}
</style>
</head>
<body id='ng-app' ng-app="ExampleApp">
<div id='slider-container' ng-controller="MainCtrl">
Floor: <input type='text' ng-model='floor' ng-init='floor = 1' /><br />
Ceiling: <input type='text' ng-model='ceiling' ng-init='ceiling = 10' /><br />
Step Width: <input type='text' ng-model='step' ng-init='step = 1' /><br />
Precision: <input type='text' ng-model='precision' ng-init='precision = 2' /><br />
Buffer: <input type='text' ng-model='buffer' ng-init='buffer = 2' /><br />
Stickiness: <input type='text' ng-model='stickiness' ng-init='stickiness = 3' /><br />
Slider Widths: <input type="text" ng-model="sliderWidth" ng-init="sliderWidth = '500px'" ng-change="fireResizeEvent()" />
<h2>Normal</h2>
<h3>Single Knob</h3>
<slider floor='{{ floor }}' ceiling='{{ ceiling }}' step='{{ step }}' precision='{{ precision }}' stickiness='{{ stickiness }}'
ng-model='value' style="width: {{ sliderWidth }};"></slider>
Value: <input ng-model="value" type="text" />
<h3>Dual Knob</h3>
<slider floor='{{ floor }}' ceiling='{{ ceiling }}' step='{{ step }}' precision='{{ precision }}' buffer='{{ buffer }}'
stickiness='{{ stickiness }}' ng-model='values.low' ng-model-range='values.high' translate-fn='translate'
translate-range-fn='translateRange' translate-combined-fn='translateCombined' style="width: {{ sliderWidth }};"></slider>
Values: <input ng-model="values.low" type="text" /><input ng-model="values.high" type="text" />
<h2>w/ Scaling functions (y=x^3)</h2>
<h3>Single Knob</h3>
<slider floor='{{ floor }}' ceiling='{{ ceiling }}' step='{{ step }}' precision='{{ precision }}' stickiness='{{ stickiness }}'
ng-model='value' scale-fn='scale' inverse-scale-fn='inverseScale' style="width: {{ sliderWidth }};"></slider>
<h3>Dual Knob</h3>
<slider floor='{{ floor }}' ceiling='{{ ceiling }}' step='{{ step }}' precision='{{ precision }}' buffer='{{ buffer }}'
stickiness='{{ stickiness }}' ng-model='values.low' ng-model-range='values.high' scale-fn='scale' inverse-scale-fn='inverseScale'
translate-fn='translate' style="width: {{ sliderWidth }};"></slider>
<h2>in ngRepeat</h2>
<div ng-repeat="scope in scopes">
<slider floor='{{ floor }}' ceiling='{{ ceiling }}' step='{{ step }}' precision='{{ precision }}' stickiness='{{ stickiness }}'
ng-model='scope.value' style="width: {{ sliderWidth }};"></slider>
</div>
<button type="button" ng-click="addScope()">Add Slider</button><br />
</div>
<script type="text/javascript" src="lib/jquery-2.0.3.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular-touch.min.js"></script>
<script src="src/rangeInputSupported.js"></script>
<script src="src/angular-slider.js"></script>
<script>
function dump(obj) {
var out = '';
for(var i in obj) {
out += i + ": " + obj[i] + "\n";
}
return out;
}
angular.module('ExampleApp', ['vr.directives.slider']).controller('MainCtrl', ['$scope', function($scope) {
$scope.scopes = [];
$scope.value = 5;
$scope.values = {
low : 4,
high: 7
};
$scope.scale = function(value) {
return Math.pow(value, 3);
};
$scope.inverseScale = function(value) {
var sign = value == 0?1:(value / Math.abs(value));
return sign * Math.pow(Math.abs(value), 1 / 3);
};
$scope.addScope = function() {
$scope.scopes.push({
values: {
low : 4,
high: 7
},
value : 5
});
};
$scope.translate = function(value) {
return '$' + value;
};
$scope.translateCombined = function(low, high) {
return $scope.translate(low.toFixed($scope.precision)) + " *** " + $scope.translate(high.toFixed($scope.precision));
};
$scope.translateRange = function(low, high) {
return $scope.translate((high - low).toFixed($scope.precision));
};
$scope.fireResizeEvent = function() {
$scope.$broadcast('refreshSlider');
};
}]);
</script>
</body>
</html>