Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
I
i20rzslider
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jedife
i20rzslider
Commits
ef482b3b
Commit
ef482b3b
authored
May 28, 2015
by
Rafal Zajac
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update to latest version
parent
2b9ab0a9
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
40 deletions
+56
-40
rzslider.js
rzslider.js
+56
-40
No files found.
rzslider.js
View file @
ef482b3b
...
@@ -4,16 +4,17 @@
...
@@ -4,16 +4,17 @@
* (c) Rafal Zajac <rzajac@gmail.com>
* (c) Rafal Zajac <rzajac@gmail.com>
* http://github.com/rzajac/angularjs-slider
* http://github.com/rzajac/angularjs-slider
*
*
* Version: v0.1.1
6
* Version: v0.1.1
7
*
*
* Licensed under the MIT license
* Licensed under the MIT license
*/
*/
/*
global angular: false */
/*global angular: false */
angular
.
module
(
'rzModule'
,
[])
angular
.
module
(
'rzModule'
,
[])
.
run
(
function
(
$templateCache
)
{
.
run
([
'$templateCache'
,
function
(
$templateCache
)
{
'use strict'
;
var
template
=
'<span class="rz-bar"></span>'
+
// 0 The slider bar
var
template
=
'<span class="rz-bar"></span>'
+
// 0 The slider bar
'<span class="rz-bar rz-selection"></span>'
+
// 1 Highlight between two handles
'<span class="rz-bar rz-selection"></span>'
+
// 1 Highlight between two handles
'<span class="rz-pointer"></span>'
+
// 2 Left slider handle
'<span class="rz-pointer"></span>'
+
// 2 Left slider handle
...
@@ -24,7 +25,7 @@ angular.module('rzModule', [])
...
@@ -24,7 +25,7 @@ angular.module('rzModule', [])
'<span class="rz-bubble"></span>'
+
// 7 Label above right slider handle
'<span class="rz-bubble"></span>'
+
// 7 Label above right slider handle
'<span class="rz-bubble"></span>'
;
// 8 Range label when the slider handles are close ex. 15 - 17
'<span class="rz-bubble"></span>'
;
// 8 Range label when the slider handles are close ex. 15 - 17
$templateCache
.
put
(
'rzSliderTpl.html'
,
template
);
$templateCache
.
put
(
'rzSliderTpl.html'
,
template
);
})
}
]
)
.
value
(
'throttle'
,
.
value
(
'throttle'
,
/**
/**
...
@@ -38,6 +39,7 @@ angular.module('rzModule', [])
...
@@ -38,6 +39,7 @@ angular.module('rzModule', [])
* @returns {Function}
* @returns {Function}
*/
*/
function
throttle
(
func
,
wait
,
options
)
{
function
throttle
(
func
,
wait
,
options
)
{
'use strict'
;
var
getTime
=
(
Date
.
now
||
function
()
{
var
getTime
=
(
Date
.
now
||
function
()
{
return
new
Date
().
getTime
();
return
new
Date
().
getTime
();
});
});
...
@@ -53,7 +55,7 @@ function throttle(func, wait, options) {
...
@@ -53,7 +55,7 @@ function throttle(func, wait, options) {
};
};
return
function
()
{
return
function
()
{
var
now
=
getTime
();
var
now
=
getTime
();
if
(
!
previous
&&
options
.
leading
===
false
)
previous
=
now
;
if
(
!
previous
&&
options
.
leading
===
false
)
{
previous
=
now
;
}
var
remaining
=
wait
-
(
now
-
previous
);
var
remaining
=
wait
-
(
now
-
previous
);
context
=
this
;
context
=
this
;
args
=
arguments
;
args
=
arguments
;
...
@@ -67,11 +69,13 @@ function throttle(func, wait, options) {
...
@@ -67,11 +69,13 @@ function throttle(func, wait, options) {
timeout
=
setTimeout
(
later
,
remaining
);
timeout
=
setTimeout
(
later
,
remaining
);
}
}
return
result
;
return
result
;
}
}
;
})
})
.
factory
(
'RzSlider'
,
[
'$timeout'
,
'$document'
,
'$window'
,
'throttle'
,
function
(
$timeout
,
$document
,
$window
,
throttle
)
.
factory
(
'RzSlider'
,
[
'$timeout'
,
'$document'
,
'$window'
,
'throttle'
,
function
(
$timeout
,
$document
,
$window
,
throttle
)
{
{
'use strict'
;
/**
/**
* Slider
* Slider
*
*
...
@@ -273,7 +277,7 @@ function throttle(func, wait, options) {
...
@@ -273,7 +277,7 @@ function throttle(func, wait, options) {
{
{
self
.
resetLabelsValue
();
self
.
resetLabelsValue
();
thrLow
();
thrLow
();
if
(
this
.
range
)
thrHigh
();
if
(
self
.
range
)
{
thrHigh
();
}
self
.
resetSlider
();
self
.
resetSlider
();
});
});
...
@@ -281,25 +285,25 @@ function throttle(func, wait, options) {
...
@@ -281,25 +285,25 @@ function throttle(func, wait, options) {
this
.
unbinders
.
push
(
this
.
scope
.
$watch
(
'rzSliderModel'
,
function
(
newValue
,
oldValue
)
this
.
unbinders
.
push
(
this
.
scope
.
$watch
(
'rzSliderModel'
,
function
(
newValue
,
oldValue
)
{
{
if
(
newValue
===
oldValue
)
return
;
if
(
newValue
===
oldValue
)
{
return
;
}
thrLow
();
thrLow
();
}));
}));
this
.
unbinders
.
push
(
this
.
scope
.
$watch
(
'rzSliderHigh'
,
function
(
newValue
,
oldValue
)
this
.
unbinders
.
push
(
this
.
scope
.
$watch
(
'rzSliderHigh'
,
function
(
newValue
,
oldValue
)
{
{
if
(
newValue
===
oldValue
)
return
;
if
(
newValue
===
oldValue
)
{
return
;
}
thrHigh
();
thrHigh
();
}));
}));
this
.
unbinders
.
push
(
this
.
scope
.
$watch
(
'rzSliderFloor'
,
function
(
newValue
,
oldValue
)
this
.
unbinders
.
push
(
this
.
scope
.
$watch
(
'rzSliderFloor'
,
function
(
newValue
,
oldValue
)
{
{
if
(
newValue
===
oldValue
)
return
;
if
(
newValue
===
oldValue
)
{
return
;
}
self
.
resetSlider
();
self
.
resetSlider
();
}));
}));
this
.
unbinders
.
push
(
this
.
scope
.
$watch
(
'rzSliderCeil'
,
function
(
newValue
,
oldValue
)
this
.
unbinders
.
push
(
this
.
scope
.
$watch
(
'rzSliderCeil'
,
function
(
newValue
,
oldValue
)
{
{
if
(
newValue
===
oldValue
)
return
;
if
(
newValue
===
oldValue
)
{
return
;
}
self
.
resetSlider
();
self
.
resetSlider
();
}));
}));
...
@@ -379,7 +383,7 @@ function throttle(func, wait, options) {
...
@@ -379,7 +383,7 @@ function throttle(func, wait, options) {
var
valStr
=
useCustomTr
?
''
+
this
.
customTrFn
(
value
)
:
''
+
value
,
var
valStr
=
useCustomTr
?
''
+
this
.
customTrFn
(
value
)
:
''
+
value
,
getWidth
=
false
;
getWidth
=
false
;
if
(
label
.
rzsv
===
undefined
||
label
.
rzsv
.
length
!=
valStr
.
length
||
(
label
.
rzsv
.
length
>
0
&&
label
.
rzsw
==
0
))
if
(
label
.
rzsv
===
undefined
||
label
.
rzsv
.
length
!=
=
valStr
.
length
||
(
label
.
rzsv
.
length
>
0
&&
label
.
rzsw
=
==
0
))
{
{
getWidth
=
true
;
getWidth
=
true
;
label
.
rzsv
=
valStr
;
label
.
rzsv
=
valStr
;
...
@@ -436,19 +440,19 @@ function throttle(func, wait, options) {
...
@@ -436,19 +440,19 @@ function throttle(func, wait, options) {
// Assign all slider elements to object properties for easy access
// Assign all slider elements to object properties for easy access
angular
.
forEach
(
this
.
sliderElem
.
children
(),
function
(
elem
,
index
)
angular
.
forEach
(
this
.
sliderElem
.
children
(),
function
(
elem
,
index
)
{
{
var
_e
lem
=
angular
.
element
(
elem
);
var
jE
lem
=
angular
.
element
(
elem
);
switch
(
index
)
switch
(
index
)
{
{
case
0
:
this
.
fullBar
=
_e
lem
;
break
;
case
0
:
this
.
fullBar
=
jE
lem
;
break
;
case
1
:
this
.
selBar
=
_e
lem
;
break
;
case
1
:
this
.
selBar
=
jE
lem
;
break
;
case
2
:
this
.
minH
=
_e
lem
;
break
;
case
2
:
this
.
minH
=
jE
lem
;
break
;
case
3
:
this
.
maxH
=
_e
lem
;
break
;
case
3
:
this
.
maxH
=
jE
lem
;
break
;
case
4
:
this
.
flrLab
=
_e
lem
;
break
;
case
4
:
this
.
flrLab
=
jE
lem
;
break
;
case
5
:
this
.
ceilLab
=
_e
lem
;
break
;
case
5
:
this
.
ceilLab
=
jE
lem
;
break
;
case
6
:
this
.
minLab
=
_e
lem
;
break
;
case
6
:
this
.
minLab
=
jE
lem
;
break
;
case
7
:
this
.
maxLab
=
_e
lem
;
break
;
case
7
:
this
.
maxLab
=
jE
lem
;
break
;
case
8
:
this
.
cmbLab
=
_e
lem
;
break
;
case
8
:
this
.
cmbLab
=
jE
lem
;
break
;
}
}
},
this
);
},
this
);
...
@@ -590,7 +594,7 @@ function throttle(func, wait, options) {
...
@@ -590,7 +594,7 @@ function throttle(func, wait, options) {
updateLowHandle
:
function
(
newOffset
)
updateLowHandle
:
function
(
newOffset
)
{
{
var
delta
=
Math
.
abs
(
this
.
minH
.
rzsl
-
newOffset
);
var
delta
=
Math
.
abs
(
this
.
minH
.
rzsl
-
newOffset
);
if
(
delta
===
0
||
delta
===
1
)
return
;
if
(
delta
===
0
||
delta
===
1
)
{
return
;
}
this
.
setLeft
(
this
.
minH
,
newOffset
);
this
.
setLeft
(
this
.
minH
,
newOffset
);
this
.
translateFn
(
this
.
scope
.
rzSliderModel
,
this
.
minLab
);
this
.
translateFn
(
this
.
scope
.
rzSliderModel
,
this
.
minLab
);
...
@@ -749,7 +753,7 @@ function throttle(func, wait, options) {
...
@@ -749,7 +753,7 @@ function throttle(func, wait, options) {
*/
*/
showEl
:
function
(
element
)
showEl
:
function
(
element
)
{
{
if
(
!!
element
.
rzAlwaysHide
)
return
element
;
if
(
!!
element
.
rzAlwaysHide
)
{
return
element
;
}
return
element
.
css
({
opacity
:
1
});
return
element
.
css
({
opacity
:
1
});
},
},
...
@@ -827,10 +831,10 @@ function throttle(func, wait, options) {
...
@@ -827,10 +831,10 @@ function throttle(func, wait, options) {
bindEvents
:
function
()
bindEvents
:
function
()
{
{
this
.
minH
.
on
(
'mousedown'
,
angular
.
bind
(
this
,
this
.
onStart
,
this
.
minH
,
'rzSliderModel'
));
this
.
minH
.
on
(
'mousedown'
,
angular
.
bind
(
this
,
this
.
onStart
,
this
.
minH
,
'rzSliderModel'
));
if
(
this
.
range
)
{
this
.
maxH
.
on
(
'mousedown'
,
angular
.
bind
(
this
,
this
.
onStart
,
this
.
maxH
,
'rzSliderHigh'
))
}
if
(
this
.
range
)
{
this
.
maxH
.
on
(
'mousedown'
,
angular
.
bind
(
this
,
this
.
onStart
,
this
.
maxH
,
'rzSliderHigh'
))
;
}
this
.
minH
.
on
(
'touchstart'
,
angular
.
bind
(
this
,
this
.
onStart
,
this
.
minH
,
'rzSliderModel'
));
this
.
minH
.
on
(
'touchstart'
,
angular
.
bind
(
this
,
this
.
onStart
,
this
.
minH
,
'rzSliderModel'
));
if
(
this
.
range
)
{
this
.
maxH
.
on
(
'touchstart'
,
angular
.
bind
(
this
,
this
.
onStart
,
this
.
maxH
,
'rzSliderHigh'
))
}
if
(
this
.
range
)
{
this
.
maxH
.
on
(
'touchstart'
,
angular
.
bind
(
this
,
this
.
onStart
,
this
.
maxH
,
'rzSliderHigh'
))
;
}
},
},
/**
/**
...
@@ -846,7 +850,7 @@ function throttle(func, wait, options) {
...
@@ -846,7 +850,7 @@ function throttle(func, wait, options) {
event
.
stopPropagation
();
event
.
stopPropagation
();
event
.
preventDefault
();
event
.
preventDefault
();
if
(
this
.
tracking
!==
''
)
{
return
}
if
(
this
.
tracking
!==
''
)
{
return
;
}
// We have to do this in case the HTML where the sliders are on
// We have to do this in case the HTML where the sliders are on
// have been animated into view.
// have been animated into view.
...
@@ -855,7 +859,7 @@ function throttle(func, wait, options) {
...
@@ -855,7 +859,7 @@ function throttle(func, wait, options) {
pointer
.
addClass
(
'rz-active'
);
pointer
.
addClass
(
'rz-active'
);
if
(
event
.
touches
||
(
typeof
(
event
.
originalEvent
)
!=
'undefined'
&&
event
.
originalEvent
.
touches
))
if
(
event
.
touches
||
(
event
.
originalEvent
!==
undefined
&&
event
.
originalEvent
.
touches
))
{
{
$document
.
on
(
'touchmove'
,
angular
.
bind
(
this
,
this
.
onMove
,
pointer
));
$document
.
on
(
'touchmove'
,
angular
.
bind
(
this
,
this
.
onMove
,
pointer
));
$document
.
one
(
'touchend'
,
angular
.
bind
(
this
,
this
.
onEnd
));
$document
.
one
(
'touchend'
,
angular
.
bind
(
this
,
this
.
onEnd
));
...
@@ -884,7 +888,9 @@ function throttle(func, wait, options) {
...
@@ -884,7 +888,9 @@ function throttle(func, wait, options) {
}
}
else
else
{
{
eventX
=
typeof
event
.
originalEvent
!==
'undefined'
?
event
.
originalEvent
.
touches
[
0
].
clientX
:
event
.
touches
[
0
].
clientX
;
eventX
=
event
.
originalEvent
===
undefined
?
event
.
touches
[
0
].
clientX
:
event
.
originalEvent
.
touches
[
0
].
clientX
;
}
}
sliderLO
=
this
.
sliderElem
.
rzsl
;
sliderLO
=
this
.
sliderElem
.
rzsl
;
...
@@ -956,7 +962,7 @@ function throttle(func, wait, options) {
...
@@ -956,7 +962,7 @@ function throttle(func, wait, options) {
this
.
minH
.
removeClass
(
'rz-active'
);
this
.
minH
.
removeClass
(
'rz-active'
);
this
.
maxH
.
removeClass
(
'rz-active'
);
this
.
maxH
.
removeClass
(
'rz-active'
);
if
(
event
.
touches
||
(
typeof
(
event
.
originalEvent
)
!=
'undefined'
&&
event
.
originalEvent
.
touches
))
if
(
event
.
touches
||
(
event
.
originalEvent
!==
undefined
&&
event
.
originalEvent
.
touches
))
{
{
$document
.
off
(
'touchmove'
);
$document
.
off
(
'touchmove'
);
}
}
...
@@ -976,6 +982,8 @@ function throttle(func, wait, options) {
...
@@ -976,6 +982,8 @@ function throttle(func, wait, options) {
.
directive
(
'rzslider'
,
[
'RzSlider'
,
function
(
Slider
)
.
directive
(
'rzslider'
,
[
'RzSlider'
,
function
(
Slider
)
{
{
'use strict'
;
return
{
return
{
restrict
:
'E'
,
restrict
:
'E'
,
scope
:
{
scope
:
{
...
@@ -990,8 +998,16 @@ function throttle(func, wait, options) {
...
@@ -990,8 +998,16 @@ function throttle(func, wait, options) {
rzSliderAlwaysShowBar
:
'=?'
rzSliderAlwaysShowBar
:
'=?'
},
},
/**
* Return template URL
*
* @param {*} elem
* @param {*} attrs
* @return {string}
*/
templateUrl
:
function
(
elem
,
attrs
)
{
templateUrl
:
function
(
elem
,
attrs
)
{
return
attrs
.
rzSliderTplUrl
||
'rzSliderTpl.html'
//noinspection JSUnresolvedVariable
return
attrs
.
rzSliderTplUrl
||
'rzSliderTpl.html'
;
},
},
link
:
function
(
scope
,
elem
,
attr
)
link
:
function
(
scope
,
elem
,
attr
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment