@@ -136,30 +136,29 @@ angular.module('ui.slider', []).value('uiSliderConfig',{}).directive('uiSlider',
136136 } ) ;
137137 } ;
138138
139+ var postLink = function ( scope , element , attrs , ngModel ) {
140+ // Add tick marks if 'tick' and 'step' attributes have been setted on element.
141+ // Support horizontal slider bar so far. 'tick' and 'step' attributes are required.
142+ var options = angular . extend ( { } , scope . $eval ( attrs . uiSlider ) ) ;
143+ var properties = [ 'max' , 'step' , 'tick' ] ;
144+ angular . forEach ( properties , function ( property ) {
145+ if ( angular . isDefined ( attrs [ property ] ) ) {
146+ options [ property ] = attrs [ property ] ;
147+ }
148+ } ) ;
149+ if ( angular . isDefined ( options [ 'tick' ] ) && angular . isDefined ( options [ 'step' ] ) ) {
150+ var total = parseInt ( parseInt ( options [ 'max' ] ) / parseInt ( options [ 'step' ] ) ) ;
151+ for ( var i = total ; i >= 0 ; i -- ) {
152+ var left = ( ( i / total ) * 100 ) + '%' ;
153+ $ ( "<div/>" ) . addClass ( "ui-slider-tick" ) . appendTo ( element ) . css ( { left : left } ) ;
154+ } ;
155+ }
156+ }
157+
139158 return {
140159 pre : preLink ,
141160 post : postLink
142161 } ;
143162 }
144163 } ;
145164} ] ) ;
146-
147- function postLink ( scope , element , attrs , ngModel ) {
148- // Add tick marks if 'tick' and 'step' attributes have been setted on element.
149- // Support horizontal slider bar so far. 'tick' and 'step' attributes are required.
150- var options = angular . extend ( { } , scope . $eval ( attrs . uiSlider ) ) ;
151- var properties = [ 'max' , 'step' , 'tick' ] ;
152- angular . forEach ( properties , function ( property ) {
153- if ( angular . isDefined ( attrs [ property ] ) ) {
154- options [ property ] = attrs [ property ] ;
155- }
156- } ) ;
157- if ( angular . isDefined ( options [ 'tick' ] ) && angular . isDefined ( options [ 'step' ] ) ) {
158- var total = parseInt ( parseInt ( options [ 'max' ] ) / parseInt ( options [ 'step' ] ) ) ;
159- for ( var i = total ; i >= 0 ; i -- ) {
160- console . log ( i ) ;
161- var left = ( ( i / total ) * 100 ) + '%' ;
162- $ ( "<div/>" ) . addClass ( "ui-slider-tick" ) . appendTo ( element ) . css ( { left : left } ) ;
163- } ;
164- }
165- }
0 commit comments