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
271b4967
Commit
271b4967
authored
Oct 23, 2015
by
Valentin Hervieu
Committed by
Valentin Hervieu
Nov 11, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a global options method to apply custom default options to all sliders
parent
a3aacff3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
95 additions
and
59 deletions
+95
-59
rzslider.js
dist/rzslider.js
+47
-29
rzslider.min.js
dist/rzslider.min.js
+1
-1
rzslider.js
src/rzslider.js
+47
-29
No files found.
dist/rzslider.js
View file @
271b4967
...
@@ -31,23 +31,47 @@
...
@@ -31,23 +31,47 @@
'use strict'
;
'use strict'
;
var
module
=
angular
.
module
(
'rzModule'
,
[])
var
module
=
angular
.
module
(
'rzModule'
,
[])
.
value
(
'defaultOptions'
,
{
.
factory
(
'RzSliderOptions'
,
function
()
{
floor
:
0
,
var
defaultOptions
=
{
ceil
:
null
,
//defaults to rz-slider-model
floor
:
0
,
step
:
1
,
ceil
:
null
,
//defaults to rz-slider-model
precision
:
0
,
step
:
1
,
translate
:
null
,
precision
:
0
,
draggableRange
:
false
,
translate
:
null
,
showSelectionBar
:
false
,
draggableRange
:
false
,
hideLimitLabels
:
false
,
showSelectionBar
:
false
,
readOnly
:
false
,
hideLimitLabels
:
false
,
disabled
:
false
,
readOnly
:
false
,
interval
:
350
,
disabled
:
false
,
showTicks
:
false
,
interval
:
350
,
showTicksValues
:
false
,
showTicks
:
false
,
onStart
:
null
,
showTicksValues
:
false
,
onChange
:
null
,
scale
:
1
,
onEnd
:
null
onStart
:
null
,
onChange
:
null
,
onEnd
:
null
};
var
globalOptions
=
{};
var
factory
=
{};
/**
* `options({})` allows global configuration of all sliders in the
* application.
*
* var app = angular.module( 'App', ['rzModule'], function( RzSliderOptions ) {
* // show ticks for all sliders
* RzSliderOptions.options( { showTicks: true } );
* });
*/
factory
.
options
=
function
(
value
)
{
angular
.
extend
(
globalOptions
,
value
);
};
factory
.
getOptions
=
function
(
options
)
{
return
angular
.
extend
({},
defaultOptions
,
globalOptions
,
options
);
};
return
factory
;
})
})
.
value
(
'throttle'
,
.
value
(
'throttle'
,
...
@@ -97,7 +121,7 @@
...
@@ -97,7 +121,7 @@
};
};
})
})
.
factory
(
'RzSlider'
,
[
'$timeout'
,
'$document'
,
'$window'
,
'
defaultOptions'
,
'throttle'
,
function
(
$timeout
,
$document
,
$window
,
default
Options
,
throttle
)
{
.
factory
(
'RzSlider'
,
[
'$timeout'
,
'$document'
,
'$window'
,
'
RzSliderOptions'
,
'throttle'
,
function
(
$timeout
,
$document
,
$window
,
RzSlider
Options
,
throttle
)
{
'use strict'
;
'use strict'
;
/**
/**
...
@@ -326,14 +350,8 @@
...
@@ -326,14 +350,8 @@
* Read the user options and apply them to the slider model
* Read the user options and apply them to the slider model
*/
*/
applyOptions
:
function
()
{
applyOptions
:
function
()
{
var
userOpts
=
this
.
scope
.
rzSliderOptions
;
this
.
options
=
RzSliderOptions
.
getOptions
(
this
.
scope
.
rzSliderOptions
);
this
.
options
=
{};
for
(
var
option_name
in
defaultOptions
)
{
if
(
!
userOpts
||
userOpts
[
option_name
]
===
undefined
)
this
.
options
[
option_name
]
=
defaultOptions
[
option_name
];
else
this
.
options
[
option_name
]
=
userOpts
[
option_name
];
}
if
(
this
.
options
.
step
<=
0
)
if
(
this
.
options
.
step
<=
0
)
this
.
options
.
step
=
1
;
this
.
options
.
step
=
1
;
this
.
range
=
this
.
scope
.
rzSliderModel
!==
undefined
&&
this
.
scope
.
rzSliderHigh
!==
undefined
;
this
.
range
=
this
.
scope
.
rzSliderModel
!==
undefined
&&
this
.
scope
.
rzSliderHigh
!==
undefined
;
...
@@ -915,7 +933,7 @@
...
@@ -915,7 +933,7 @@
*/
*/
getWidth
:
function
(
elem
)
{
getWidth
:
function
(
elem
)
{
var
val
=
elem
[
0
].
getBoundingClientRect
();
var
val
=
elem
[
0
].
getBoundingClientRect
();
elem
.
rzsw
=
val
.
right
-
val
.
left
;
elem
.
rzsw
=
(
val
.
right
-
val
.
left
)
*
this
.
options
.
scale
;
return
elem
.
rzsw
;
return
elem
.
rzsw
;
},
},
...
@@ -982,7 +1000,7 @@
...
@@ -982,7 +1000,7 @@
if
(
!
this
.
range
)
{
if
(
!
this
.
range
)
{
return
this
.
minH
;
return
this
.
minH
;
}
}
var
offset
=
this
.
getEventX
(
event
)
-
this
.
sliderElem
.
rzsl
-
this
.
handleHalfWidth
;
var
offset
=
(
this
.
getEventX
(
event
)
-
this
.
sliderElem
.
rzsl
-
this
.
handleHalfWidth
)
*
this
.
options
.
scale
;
return
Math
.
abs
(
offset
-
this
.
minH
.
rzsl
)
<
Math
.
abs
(
offset
-
this
.
maxH
.
rzsl
)
?
this
.
minH
:
this
.
maxH
;
return
Math
.
abs
(
offset
-
this
.
minH
.
rzsl
)
<
Math
.
abs
(
offset
-
this
.
maxH
.
rzsl
)
?
this
.
minH
:
this
.
maxH
;
},
},
...
@@ -1095,7 +1113,7 @@
...
@@ -1095,7 +1113,7 @@
sliderLO
,
newOffset
,
newValue
;
sliderLO
,
newOffset
,
newValue
;
sliderLO
=
this
.
sliderElem
.
rzsl
;
sliderLO
=
this
.
sliderElem
.
rzsl
;
newOffset
=
eventX
-
sliderLO
-
this
.
handleHalfWidth
;
newOffset
=
(
eventX
-
sliderLO
-
this
.
handleHalfWidth
)
*
this
.
options
.
scale
;
if
(
newOffset
<=
0
)
{
if
(
newOffset
<=
0
)
{
if
(
pointer
.
rzsl
===
0
)
if
(
pointer
.
rzsl
===
0
)
...
...
dist/rzslider.min.js
View file @
271b4967
This diff is collapsed.
Click to expand it.
src/rzslider.js
View file @
271b4967
...
@@ -31,23 +31,47 @@
...
@@ -31,23 +31,47 @@
'use strict'
;
'use strict'
;
var
module
=
angular
.
module
(
'rzModule'
,
[])
var
module
=
angular
.
module
(
'rzModule'
,
[])
.
value
(
'defaultOptions'
,
{
.
factory
(
'RzSliderOptions'
,
function
()
{
floor
:
0
,
var
defaultOptions
=
{
ceil
:
null
,
//defaults to rz-slider-model
floor
:
0
,
step
:
1
,
ceil
:
null
,
//defaults to rz-slider-model
precision
:
0
,
step
:
1
,
translate
:
null
,
precision
:
0
,
draggableRange
:
false
,
translate
:
null
,
showSelectionBar
:
false
,
draggableRange
:
false
,
hideLimitLabels
:
false
,
showSelectionBar
:
false
,
readOnly
:
false
,
hideLimitLabels
:
false
,
disabled
:
false
,
readOnly
:
false
,
interval
:
350
,
disabled
:
false
,
showTicks
:
false
,
interval
:
350
,
showTicksValues
:
false
,
showTicks
:
false
,
onStart
:
null
,
showTicksValues
:
false
,
onChange
:
null
,
scale
:
1
,
onEnd
:
null
onStart
:
null
,
onChange
:
null
,
onEnd
:
null
};
var
globalOptions
=
{};
var
factory
=
{};
/**
* `options({})` allows global configuration of all sliders in the
* application.
*
* var app = angular.module( 'App', ['rzModule'], function( RzSliderOptions ) {
* // show ticks for all sliders
* RzSliderOptions.options( { showTicks: true } );
* });
*/
factory
.
options
=
function
(
value
)
{
angular
.
extend
(
globalOptions
,
value
);
};
factory
.
getOptions
=
function
(
options
)
{
return
angular
.
extend
({},
defaultOptions
,
globalOptions
,
options
);
};
return
factory
;
})
})
.
value
(
'throttle'
,
.
value
(
'throttle'
,
...
@@ -97,7 +121,7 @@
...
@@ -97,7 +121,7 @@
};
};
})
})
.
factory
(
'RzSlider'
,
function
(
$timeout
,
$document
,
$window
,
default
Options
,
throttle
)
{
.
factory
(
'RzSlider'
,
function
(
$timeout
,
$document
,
$window
,
RzSlider
Options
,
throttle
)
{
'use strict'
;
'use strict'
;
/**
/**
...
@@ -326,14 +350,8 @@
...
@@ -326,14 +350,8 @@
* Read the user options and apply them to the slider model
* Read the user options and apply them to the slider model
*/
*/
applyOptions
:
function
()
{
applyOptions
:
function
()
{
var
userOpts
=
this
.
scope
.
rzSliderOptions
;
this
.
options
=
RzSliderOptions
.
getOptions
(
this
.
scope
.
rzSliderOptions
);
this
.
options
=
{};
for
(
var
option_name
in
defaultOptions
)
{
if
(
!
userOpts
||
userOpts
[
option_name
]
===
undefined
)
this
.
options
[
option_name
]
=
defaultOptions
[
option_name
];
else
this
.
options
[
option_name
]
=
userOpts
[
option_name
];
}
if
(
this
.
options
.
step
<=
0
)
if
(
this
.
options
.
step
<=
0
)
this
.
options
.
step
=
1
;
this
.
options
.
step
=
1
;
this
.
range
=
this
.
scope
.
rzSliderModel
!==
undefined
&&
this
.
scope
.
rzSliderHigh
!==
undefined
;
this
.
range
=
this
.
scope
.
rzSliderModel
!==
undefined
&&
this
.
scope
.
rzSliderHigh
!==
undefined
;
...
@@ -915,7 +933,7 @@
...
@@ -915,7 +933,7 @@
*/
*/
getWidth
:
function
(
elem
)
{
getWidth
:
function
(
elem
)
{
var
val
=
elem
[
0
].
getBoundingClientRect
();
var
val
=
elem
[
0
].
getBoundingClientRect
();
elem
.
rzsw
=
val
.
right
-
val
.
left
;
elem
.
rzsw
=
(
val
.
right
-
val
.
left
)
*
this
.
options
.
scale
;
return
elem
.
rzsw
;
return
elem
.
rzsw
;
},
},
...
@@ -982,7 +1000,7 @@
...
@@ -982,7 +1000,7 @@
if
(
!
this
.
range
)
{
if
(
!
this
.
range
)
{
return
this
.
minH
;
return
this
.
minH
;
}
}
var
offset
=
this
.
getEventX
(
event
)
-
this
.
sliderElem
.
rzsl
-
this
.
handleHalfWidth
;
var
offset
=
(
this
.
getEventX
(
event
)
-
this
.
sliderElem
.
rzsl
-
this
.
handleHalfWidth
)
*
this
.
options
.
scale
;
return
Math
.
abs
(
offset
-
this
.
minH
.
rzsl
)
<
Math
.
abs
(
offset
-
this
.
maxH
.
rzsl
)
?
this
.
minH
:
this
.
maxH
;
return
Math
.
abs
(
offset
-
this
.
minH
.
rzsl
)
<
Math
.
abs
(
offset
-
this
.
maxH
.
rzsl
)
?
this
.
minH
:
this
.
maxH
;
},
},
...
@@ -1095,7 +1113,7 @@
...
@@ -1095,7 +1113,7 @@
sliderLO
,
newOffset
,
newValue
;
sliderLO
,
newOffset
,
newValue
;
sliderLO
=
this
.
sliderElem
.
rzsl
;
sliderLO
=
this
.
sliderElem
.
rzsl
;
newOffset
=
eventX
-
sliderLO
-
this
.
handleHalfWidth
;
newOffset
=
(
eventX
-
sliderLO
-
this
.
handleHalfWidth
)
*
this
.
options
.
scale
;
if
(
newOffset
<=
0
)
{
if
(
newOffset
<=
0
)
{
if
(
pointer
.
rzsl
===
0
)
if
(
pointer
.
rzsl
===
0
)
...
...
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