Skip to content

Commit 70ca413

Browse files
committed
Merge pull request #129 from e-cloud/master
minor improvement
2 parents ceefa44 + f0ca9ff commit 70ca413

File tree

7 files changed

+139
-116
lines changed

7 files changed

+139
-116
lines changed

.editorconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
charset = utf-8
8+
end_of_line = lf
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.js]
13+
quote_type = single
14+
curly_bracket_next_line = true
15+
indent_brace_style = Allman
16+
spaces_around_operators = true
17+
spaces_around_brackets = inside
18+
continuation_indent_size = 2

Gruntfile.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ module.exports = function (grunt)
6060
},
6161
module: 'rzModule',
6262
url: function(url) {
63-
return url.replace('src/', '');
63+
return url.replace('src/', '');
6464
},
65-
bootstrap: function (module, script) {
66-
return 'module.run(function($templateCache) {\n' + script + '\n});';
67-
}
65+
bootstrap: function (module, script) {
66+
return 'module.run(function($templateCache) {\n' + script + '\n});';
67+
}
6868
}
6969
}
7070
},

demo/index.html

Lines changed: 64 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!DOCTYPE html>
2-
<html ng-app="plunker">
2+
<html ng-app="rzSliderDemo">
33

44
<head>
55
<meta charset="utf-8"/>
@@ -107,71 +107,76 @@ <h2>Draggable range example</h2>
107107
<h2>Toggle slider example</h2>
108108
<button ng-click="toggle()">Show</button>
109109
<div ng-show="visible">
110-
<rzslider rz-slider-model="toggleSlider.value" rz-slider-floor="toggleSlider.floor" rz-slider-ceil="toggleSlider.ceil"></rzslider>
110+
<rzslider rz-slider-model="toggleSlider.value"
111+
rz-slider-floor="toggleSlider.floor"
112+
rz-slider-ceil="toggleSlider.ceil"></rzslider>
111113
</div>
112114
</article>
113115

114116
</div>
115-
</body>
116117

117-
<script src="../bower_components/angular/angular.min.js"></script>
118+
119+
<script src="../bower_components/angular/angular.js"></script>
118120
<script src="../dist/rzslider.js"></script>
119121
<script>
120-
var app = angular.module('plunker', ['rzModule']);
121-
122-
app.controller('MainCtrl', function($scope, $timeout) {
123-
$scope.priceSlider = {
124-
min: 100,
125-
max: 400,
126-
ceil: 500,
127-
floor: 0
128-
};
129-
130-
$scope.priceSlider2 = 150;
131-
$scope.priceSlider3 = 250;
132-
133-
$scope.translate = function(value) {
134-
return '$' + value;
135-
};
136-
137-
var alphabetArray = 'abcdefghijklmnopqrstuvwxyz'.split('');
138-
$scope.letter = 5;
139-
$scope.letterMax = alphabetArray.length - 1;
140-
$scope.alphabetTranslate = function(value) {
141-
return alphabetArray[value].toUpperCase();
142-
};
143-
144-
$scope.slider_data = {value: 1};
145-
$scope.otherData = {value: 10};
146-
147-
$scope.onStart = function() {
148-
console.info('started', $scope.slider_data.value);
149-
};
150-
151-
$scope.onChange = function() {
152-
console.info('changed', $scope.slider_data.value);
153-
$scope.otherData.value = $scope.slider_data.value * 10;
154-
};
155-
156-
$scope.onEnd = function() {
157-
console.info('ended', $scope.slider_data.value);
158-
};
159-
160-
$scope.visible = false;
161-
162-
$scope.toggle = function() {
163-
$scope.visible = !$scope.visible;
164-
$timeout(function() {
165-
$scope.$broadcast('rzSliderForceRender');
166-
});
167-
};
168-
169-
$scope.toggleSlider = {
170-
value: 1,
171-
ceil: 500,
172-
floor: 0
173-
};
174-
});
122+
var app = angular.module('rzSliderDemo', ['rzModule']);
123+
124+
app.controller('MainCtrl', function($scope, $timeout) {
125+
$scope.priceSlider = {
126+
min: 100,
127+
max: 400,
128+
ceil: 500,
129+
floor: 0
130+
};
131+
132+
$scope.priceSlider2 = 150;
133+
$scope.priceSlider3 = 250;
134+
135+
$scope.translate = function(value) {
136+
return '$' + value;
137+
};
138+
139+
var alphabetArray = 'abcdefghijklmnopqrstuvwxyz'.split('');
140+
$scope.letter = 5;
141+
$scope.letterMax = alphabetArray.length - 1;
142+
$scope.alphabetTranslate = function(value) {
143+
return alphabetArray[value].toUpperCase();
144+
};
145+
146+
$scope.slider_data = {value: 1};
147+
$scope.otherData = {value: 10};
148+
149+
$scope.onStart = function() {
150+
console.info('started', $scope.slider_data.value);
151+
};
152+
153+
$scope.onChange = function() {
154+
console.info('changed', $scope.slider_data.value);
155+
$scope.otherData.value = $scope.slider_data.value * 10;
156+
};
157+
158+
$scope.onEnd = function() {
159+
console.info('ended', $scope.slider_data.value);
160+
};
161+
162+
$scope.visible = false;
163+
164+
$scope.toggle = function() {
165+
$scope.visible = !$scope.visible;
166+
$timeout(function() {
167+
$scope.$broadcast('rzSliderForceRender');
168+
});
169+
};
170+
171+
$scope.toggleSlider = {
172+
value: 1,
173+
ceil: 500,
174+
floor: 0
175+
};
176+
});
175177
</script>
176178

179+
</body>
180+
181+
177182
</html>

dist/rzslider.js

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
*/
1111

1212
/*jslint unparam: true */
13-
/*global angular: false, console: false */
13+
/*global angular: false, console: false, define, module */
1414
(function (root, factory) {
15-
15+
'use strict';
1616
if (typeof define === 'function' && define.amd) {
1717
// AMD. Register as an anonymous module.
1818
define(['angular'], factory);
@@ -28,7 +28,7 @@
2828
}
2929

3030
}(this, function (angular) {
31-
31+
'use strict';
3232
var module = angular.module('rzModule', [])
3333

3434
.value('throttle',
@@ -100,7 +100,7 @@ function throttle(func, wait, options) {
100100
/**
101101
* The slider attributes
102102
*
103-
* @type {*}
103+
* @type {Object}
104104
*/
105105
this.attributes = attributes;
106106

@@ -240,15 +240,15 @@ function throttle(func, wait, options) {
240240
this.deRegFuncs = [];
241241

242242
// Slider DOM elements wrapped in jqLite
243-
this.fullBar = null; // The whole slider bar
244-
this.selBar = null; // Highlight between two handles
245-
this.minH = null; // Left slider handle
246-
this.maxH = null; // Right slider handle
247-
this.flrLab = null; // Floor label
248-
this.ceilLab = null; // Ceiling label
249-
this.minLab = null; // Label above the low value
250-
this.maxLab = null; // Label above the high value
251-
this.cmbLab = null; // Combined label
243+
this.fullBar = null; // The whole slider bar
244+
this.selBar = null; // Highlight between two handles
245+
this.minH = null; // Left slider handle
246+
this.maxH = null; // Right slider handle
247+
this.flrLab = null; // Floor label
248+
this.ceilLab = null; // Ceiling label
249+
this.minLab = null; // Label above the low value
250+
this.maxLab = null; // Label above the high value
251+
this.cmbLab = null; // Combined label
252252

253253
// Initialize slider
254254
this.init();
@@ -413,14 +413,14 @@ function throttle(func, wait, options) {
413413
*
414414
* @param {number|string} value
415415
* @param {jqLite} label
416-
* @param {bool?} useCustomTr
416+
* @param {boolean} [useCustomTr]
417417
* @returns {undefined}
418418
*/
419419
translateFn: function(value, label, useCustomTr)
420420
{
421421
useCustomTr = useCustomTr === undefined ? true : useCustomTr;
422422

423-
var valStr = String(useCustomTr ? this.customTrFn(value) : value),
423+
var valStr = (useCustomTr ? this.customTrFn(value) : value).toString(),
424424
getWidth = false;
425425

426426
if(label.rzsv === undefined || label.rzsv.length !== valStr.length || (label.rzsv.length > 0 && label.rzsw === 0))
@@ -457,7 +457,7 @@ function throttle(func, wait, options) {
457457
}
458458
else
459459
{
460-
this.scope.rzSliderCeil = this.maxValue = this.range ? this.scope.rzSliderHigh : this.scope.rzSliderModel;
460+
this.maxValue = this.scope.rzSliderCeil = this.range ? this.scope.rzSliderHigh : this.scope.rzSliderModel;
461461
}
462462

463463
if(this.scope.rzSliderStep)
@@ -880,7 +880,7 @@ function throttle(func, wait, options) {
880880
*
881881
* @param {jqLite} elem The jqLite wrapped DOM element
882882
* @param {number} width
883-
* @returns {*}
883+
* @returns {number}
884884
*/
885885
setWidth: function(elem, width)
886886
{
@@ -897,7 +897,7 @@ function throttle(func, wait, options) {
897897
*/
898898
valueToOffset: function(val)
899899
{
900-
return (val - this.minValue) * this.maxLeft / this.valueRange;
900+
return (val - this.minValue) * this.maxLeft / this.valueRange || 0;
901901
},
902902

903903
/**
@@ -1272,8 +1272,8 @@ function throttle(func, wait, options) {
12721272
/**
12731273
* Return template URL
12741274
*
1275-
* @param {*} elem
1276-
* @param {*} attrs
1275+
* @param {jqLite} elem
1276+
* @param {Object} attrs
12771277
* @return {string}
12781278
*/
12791279
templateUrl: function(elem, attrs) {
@@ -1301,9 +1301,9 @@ function throttle(func, wait, options) {
13011301
/**
13021302
* @name jqLite
13031303
*
1304-
* @property {number|undefined} rzsl
1305-
* @property {number|undefined} rzsw
1306-
* @property {string|undefined} rzsv
1304+
* @property {number|undefined} rzsl rzslider label left offset
1305+
* @property {number|undefined} rzsw rzslider element width
1306+
* @property {string|undefined} rzsv rzslider label value/text
13071307
* @property {Function} css
13081308
* @property {Function} text
13091309
*/
@@ -1317,8 +1317,8 @@ function throttle(func, wait, options) {
13171317
/**
13181318
* @name ThrottleOptions
13191319
*
1320-
* @property {bool} leading
1321-
* @property {bool} trailing
1320+
* @property {boolean} leading
1321+
* @property {boolean} trailing
13221322
*/
13231323

13241324
module.run(['$templateCache', function($templateCache) {

dist/rzslider.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)