src/main/webapp/jquery-easyui-1.3.3/src/jquery.slider.js
/**
     * build the slider and set some properties
     */
build the slider and set some properties
build the slider and set some properties
function buildSlider(target) {
        var state = $.data(target, 'slider');
        var opts = state.options;
        var slider = state.slider;
        slider.removeClass('slider-h slider-v slider-disabled');
        slider.addClass(opts.mode == 'h' ? 'slider-h' : 'slider-v');
        slider.addClass(opts.disabled ? 'slider-disabled' : '');
        slider.find('a.slider-handle').draggable({
            axis: opts.mode,
            cursor: 'pointer',
            disabled: opts.disabled,
            onDrag: function (e) {
                var left = e.data.left;
                var width = slider.width();
                if (opts.mode != 'h') {
                    left = e.data.top;
                    width = slider.height();
                }
                if (left < 0 || left > width) {
                    return false;
                } else {
                    var value = pos2value(target, left);
                    adjustValue(value);
                    return false;
                }
            },
            onStartDrag: function () {
                opts.onSlideStart.call(target, opts.value);
            },
            onStopDrag: function (e) {
                var value = pos2value(target, (opts.mode == 'h' ? e.data.left : e.data.top));
                adjustValue(value);
                opts.onSlideEnd.call(target, opts.value);
            }
        });
        function adjustValue(value) {
            var s = Math.abs(value % opts.step);
            if (s < opts.step / 2) {
                value -= s;
            } else {
                value = value - s + opts.step;
            }
            setValue(target, value);
        }
    }
function buildSlider ( target ) { var state = $ . data ( target , 'slider' ) ; var opts = state . options ; var slider = state . slider ; slider . removeClass ( 'slider-h slider-v slider-disabled' ) ; slider . addClass ( opts . mode == 'h' ? 'slider-h' : 'slider-v' ) ; slider . addClass ( opts . disabled ? 'slider-disabled' : '' ) ; slider . find ( 'a.slider-handle' ) . draggable ( { axis : opts . mode , cursor : 'pointer' , disabled : opts . disabled , onDrag : function ( e ) { var left = e . data . left ; var width = slider . width ( ) ; if ( opts . mode != 'h' ) { left = e . data . top ; width = slider . height ( ) ; } if ( left < 0 || left > width ) { return false ; } else { var value = pos2value ( target , left ) ; adjustValue ( value ) ; return false ; } } , onStartDrag : function ( ) { opts . onSlideStart . call ( target , opts . value ) ; } , onStopDrag : function ( e ) { var value = pos2value ( target , ( opts . mode == 'h' ? e . data . left : e . data . top ) ) ; adjustValue ( value ) ; opts . onSlideEnd . call ( target , opts . value ) ; } } ) ; function adjustValue ( value ) { var s = Math . abs ( value % opts . step ) ; if ( s < opts . step / 2 ) { value -= s ; } else { value = value - s + opts . step ; } setValue ( target , value ) ; } }
build the slider and set some properties
build the slider and set some properties