Skip to content
This repository was archived by the owner on May 25, 2019. It is now read-only.

Commit 4c84697

Browse files
committed
New demo file with event listeners example.
1 parent 5b83552 commit 4c84697

File tree

1 file changed

+64
-5
lines changed

1 file changed

+64
-5
lines changed

demo/demo.html

Lines changed: 64 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@
1010
body {
1111
padding: 2em;
1212
}
13+
pre {
14+
border: 1px solid #999;
15+
padding: 1em;
16+
background-color: #FFE;
17+
}
1318
.sliderExample {
14-
width: 500px;
19+
width: 640px;
1520
padding: 2em;
1621
background-color: #f5f5f5;
1722
border: 1px solid #f0f0f0;
@@ -41,9 +46,9 @@
4146

4247
<h1>AngularUI Slider demo</h1>
4348
<div class="sliderExample">
44-
<strong>Step slider</strong>
49+
<strong>Step slider with event listeners (see console log)</strong>
4550
<div ui-slider min="0" max="50" ng-model="demoVals.sliderExample1"></div>
46-
<input type="text" ng-model="demoVals.sliderExample1" />
51+
<input type="text" ng-model="demoVals.sliderExample1" />
4752
</div>
4853

4954
<div class="sliderExample">
@@ -134,6 +139,40 @@ <h2>Examples with decimals</h2>
134139
Blue: <input ng-model="colorpicker.blue">
135140
<div id="swatch"></div>
136141
</div>
142+
143+
<div class="sliderExample">
144+
<strong>Step slider with event listeners(see console log)</strong>
145+
<div ui-slider="slider.options" min="0" max="50" ng-model="demoVals.sliderExample1"></div>
146+
<input type="text" ng-model="demoVals.sliderExample1" />
147+
148+
<p>This slider has event listeners attached to it, assigned by defining the listeners in the option passed to the slider. For example in controller:</p>
149+
150+
<pre>
151+
$scope.slider = {
152+
'options': {
153+
start: function (event, ui) { $log.info('Slider start'); },
154+
stop: function (event, ui) { $log.info('Slider stop'); }
155+
</pre>
156+
157+
<p>And in markup</p>
158+
159+
<pre>
160+
&lt;div ui-slider="slider.options"
161+
min="0"
162+
max="50"
163+
ng-model="demoVals.sliderExample1"&gt;&lt;/div&gt;
164+
</pre>
165+
166+
<p>Options may also be set in in service uiSliderConfig, ie:</p>
167+
<pre>
168+
app.factory('uiSliderConfig', function ($log) {
169+
return {
170+
start: function (event, ui) { $log.info('Slider start'); },
171+
stop: function (event, ui) { $log.info('Slider stop'); }
172+
};
173+
});
174+
</pre>
175+
</div>
137176

138177

139178
<script type="text/javascript" src="bower_components/jquery/jquery.min.js"></script>
@@ -157,14 +196,34 @@ <h2>Examples with decimals</h2>
157196
}
158197
};
159198
});
160-
app.controller('sliderDemoCtrl', function($scope, colorpicker) {
199+
200+
/*
201+
// To set an option for all sliders
202+
app.factory('uiSliderConfig', function ($log) {
203+
return {
204+
start: function (event, ui) { $log.info('Event: Slider start - set with uiSliderConfig', event); },
205+
stop: function (event, ui) { $log.info('Event: Slider stop - set with uiSliderCOnfig', event); },
206+
};
207+
});
208+
*/
209+
210+
app.controller('sliderDemoCtrl', function($scope, $log, colorpicker) {
211+
161212
function refreshSwatch (ev, ui) {
162213
var red = $scope.colorpicker.red,
163214
green = $scope.colorpicker.green,
164215
blue = $scope.colorpicker.blue;
165216
colorpicker.refreshSwatch(red, green, blue);
166217
}
167-
218+
219+
// Slider options with event handlers
220+
$scope.slider = {
221+
'options': {
222+
start: function (event, ui) { $log.info('Event: Slider start - set with slider options', event); },
223+
stop: function (event, ui) { $log.info('Event: Slider stop - set with slider options', event); }
224+
}
225+
}
226+
168227
$scope.demoVals = {
169228
sliderExample3: 14,
170229
sliderExample4: 14,

0 commit comments

Comments
 (0)