<commit_before>/**
 * ------------------------------------------
 * 滚动控件实现文件
 * @version  1.0
 * @author   genify(<EMAIL>)
 * ------------------------------------------
 */
/** @module util/scroll/simple */
NEJ.define([
    'base/global',
    'base/klass',
    'base/element',
    'base/event',
    'base/util',
    'util/event',
    'util/dragger/dragger',
    'util/animation/easeinout'
],function(NEJ,_e,_v,_u,_t,_t0,_t1,_p,_o,_f,_r){
    // variable declaration
    var _pro;
    /**
     * 滚动控件
     * 
     * 结构举例
     * ```html
     * <div class="xbc" id="bbox">
     *    <div class="bar x" id="xbar"><!-- 水平滚动条 --></div>
     *    <div class="bar y" id="ybar"><!-- 垂直滚动条 --></div>
     *    <div class="abc" id="box">
     *      <!-- 滚动内容 -->
     *      <p>11111111111111111</p>
     *      <p>11111111111111111</p>
     *      <p>11111111111111111</p>
     *      <p>11111111111111111</p>
     *      <p>11111111111111111</p>
     *    </div>
     * </div>
     * ```
     * 
     * 脚本举例
     * ```javascript
     * NEJ.define([
     *     'base/event',
     *     'util/scroll/simple'
     * ],function(_v,_t){
     *     // 应用模拟滚动行为
     *     _t._$$SimpleScroll._$allocate({
     *         xbar:'xbar',
     *         // 纵向滚动条至少保留20px高度，上下留5px间隙
     *         ybar:{body:'ybar',min:20,top:5,bottom:5},
     *         parent:'box'
     *     });
     *
     *     // 滚动过程可以通过监听parent上的onscroll事件获得
     *     _v._$addEvent(
     *         'box','scroll',function(_event){
     *             var _node = _v._$getElement(_event);
     *             // get scrollTop from _node.scrollTop
     *         }
     *     );
     * });
     * ```
     *
     * @class    module:util/scroll/simple._$$SimpleScroll
     * @extends  module:util/event._$$EventTarget
     *
     * @param    {Object}       config  - 可选配置参数
     * @property {Node|Object}  xbar    - 水平滚动条节点或者配置信息，如果不配置min值则默认取body的初始宽度，配置如{body:'bar-id',track:':parent',min:10,speed:1,left:10,right:10,step:10,hover:'js-hover'}
     * @property {Node|Object}  ybar    - 垂直滚动条节点或者配置信息，如果不配置min值则默认取body的初始高度，配置如{body:'bar-id',track:'parent-id',min:10,speed:1,top:10,bottom:10,step:10,hover:'js-hover'}
     * @property {String|Node}  parent  - 滚动容器节点，默认为滚动条的父容器，滚动过程触发该节点上的onscroll事件
     * @property {String|Node}  trigger - 滚动条显示隐藏触点，不传表示不做显示隐藏切换
     */
    _p._$$SimpleScroll = _k._$klass();
    _pro = _p._$$SimpleScroll._$extend(_t._$$EventTarget);
    /**
     * 初始化控件
     * 
     * @protected
     * @method module:util/scroll/simple._$$SimpleScroll#__init
     * @return {Void}
     */
    _pro.__init = function(){
        this.__aopt = {
            to:{},
            from:{},
            duration:500,
            onstop:this.__doStopBarOpacity._$bind(this),
            onupdate:this.__doUpdateBarOpacity._$bind(this)
        };
        this.__dopt = {
            x:{
                direction:1,
                ondragend:this.__onUpdateBarEnd._$bind(this,'x'),
                onbeforechange:this.__onBeforeUpdateBar._$bind(this,'x')
            },
            y:{
                direction:2,
                ondragend:this.__onUpdateBarEnd._$bind(this,'y'),
                onbeforechange:this.__onBeforeUpdateBar._$bind(this,'y')
            }
        };
        this.__dragger = {};
        this.__super();
    };
    /**
     * 控件重置
     *
     * @protected
     * @method module:util/scroll/simple._$$SimpleScroll#__reset
     * @param  {Object} arg0 - 可选配置参数
     * @return {Void}
     */
    _pro.__reset = (function(){
        var _bcnf = {
            x:{
                min:0,
                speed:1,
                step:50,
                interval:50,
                left:0,
                right:0,
                hover:'js-hover',
                sb:'scrollWidth',
                cb:'clientWidth',
                ob:'offsetWidth',
                sr:'scrollLeft',
                ss:'width',
                sp:'left',
                dr:'right'
            },
            y:{
                min:0,
                speed:1,
                interval:50,
                step:50,
                top:0,
                bottom:0,
                hover:'js-hover',
                sb:'scrollHeight',
                cb:'clientHeight',
                ob:'offsetHeight',
                sr:'scrollTop',
                ss:'height',
                sp:'top',
                dr:'bottom'
            }
        };
        // init scrollbar
        var _doInitBar = function(_name,_conf){
            if (!(_conf||_o).body){
                _conf = {body:_conf};
            }
            var _result = NEJ.X(
                NEJ.X({},_bcnf[_name]),_conf
            );
            _result.body = _e._$get(_result.body);
            if (!!_result.body&&!!_result.track){
                if (_result.track==':parent'){
                    _result.track = _result.body.parentNode;
                }
                _result.track = _e._$get(_result.track);
            }
            if (!_result.min){
                _result.min = !_result.body?10:(_result.body[_result.ob]||10);
            }
            return _result;
        };
        var _doInitBarDrag = function(_name,_body){
            if (!_body) return;
            var _options = this.__dopt[_name];
            _options.body = _body;
            _options.view = this.__parent;
            this.__dragger[_name] =
                _p._$$Dragger._$allocate(_options);
        };
        return function(_options){
            this.__super(_options);
            this.__bar = {
                x:_doInitBar('x',_options.xbar),
                y:_doInitBar('y',_options.ybar)
            };<commit_msg>bugfix syntax error for simple scroll<commit_after>/**
 * ------------------------------------------
 * 滚动控件实现文件
 * @version  1.0
 * @author   genify(<EMAIL>)
 * ------------------------------------------
 */
/** @module util/scroll/simple */
NEJ.define([
    'base/global',
    'base/klass',
    'base/element',
    'base/event',
    'base/util',
    'util/event',
    'util/dragger/dragger',
    'util/animation/easeinout'
],function(NEJ,_k,_e,_v,_u,_t,_t0,_t1,_p,_o,_f,_r){
    // variable declaration
    var _pro;
    /**
     * 滚动控件
     * 
     * 结构举例
     * ```html
     * <div class="xbc" id="bbox">
     *    <div class="bar x" id="xbar"><!-- 水平滚动条 --></div>
     *    <div class="bar y" id="ybar"><!-- 垂直滚动条 --></div>
     *    <div class="abc" id="box">
     *      <!-- 滚动内容 -->
     *      <p>11111111111111111</p>
     *      <p>11111111111111111</p>
     *      <p>11111111111111111</p>
     *      <p>11111111111111111</p>
     *      <p>11111111111111111</p>
     *    </div>
     * </div>
     * ```
     * 
     * 脚本举例
     * ```javascript
     * NEJ.define([
     *     'base/event',
     *     'util/scroll/simple'
     * ],function(_v,_t){
     *     // 应用模拟滚动行为
     *     _t._$$SimpleScroll._$allocate({
     *         xbar:'xbar',
     *         // 纵向滚动条至少保留20px高度，上下留5px间隙
     *         ybar:{body:'ybar',min:20,top:5,bottom:5},
     *         parent:'box'
     *     });
     *
     *     // 滚动过程可以通过监听parent上的onscroll事件获得
     *     _v._$addEvent(
     *         'box','scroll',function(_event){
     *             var _node = _v._$getElement(_event);
     *             // get scrollTop from _node.scrollTop
     *         }
     *     );
     * });
     * ```
     *
     * @class    module:util/scroll/simple._$$SimpleScroll
     * @extends  module:util/event._$$EventTarget
     *
     * @param    {Object}       config  - 可选配置参数
     * @property {Node|Object}  xbar    - 水平滚动条节点或者配置信息，如果不配置min值则默认取body的初始宽度，配置如{body:'bar-id',track:':parent',min:10,speed:1,left:10,right:10,step:10,hover:'js-hover'}
     * @property {Node|Object}  ybar    - 垂直滚动条节点或者配置信息，如果不配置min值则默认取body的初始高度，配置如{body:'bar-id',track:'parent-id',min:10,speed:1,top:10,bottom:10,step:10,hover:'js-hover'}
     * @property {String|Node}  parent  - 滚动容器节点，默认为滚动条的父容器，滚动过程触发该节点上的onscroll事件
     * @property {String|Node}  trigger - 滚动条显示隐藏触点，不传表示不做显示隐藏切换
     */
    _p._$$SimpleScroll = _k._$klass();
    _pro = _p._$$SimpleScroll._$extend(_t._$$EventTarget);
    /**
     * 初始化控件
     * 
     * @protected
     * @method module:util/scroll/simple._$$SimpleScroll#__init
     * @return {Void}
     */
    _pro.__init = function(){
        this.__aopt = {
            to:{},
            from:{},
            duration:500,
            onstop:this.__doStopBarOpacity._$bind(this),
            onupdate:this.__doUpdateBarOpacity._$bind(this)
        };
        this.__dopt = {
            x:{
                direction:1,
                ondragend:this.__onUpdateBarEnd._$bind(this,'x'),
                onbeforechange:this.__onBeforeUpdateBar._$bind(this,'x')
            },
            y:{
                direction:2,
                ondragend:this.__onUpdateBarEnd._$bind(this,'y'),
                onbeforechange:this.__onBeforeUpdateBar._$bind(this,'y')
            }
        };
        this.__dragger = {};
        this.__super();
    };
    /**
     * 控件重置
     *
     * @protected
     * @method module:util/scroll/simple._$$SimpleScroll#__reset
     * @param  {Object} arg0 - 可选配置参数
     * @return {Void}
     */
    _pro.__reset = (function(){
        var _bcnf = {
            x:{
                min:0,
                speed:1,
                step:50,
                interval:50,
                left:0,
                right:0,
                hover:'js-hover',
                sb:'scrollWidth',
                cb:'clientWidth',
                ob:'offsetWidth',
                sr:'scrollLeft',
                ss:'width',
                sp:'left',
                dr:'right'
            },
            y:{
                min:0,
                speed:1,
                interval:50,
                step:50,
                top:0,
                bottom:0,
                hover:'js-hover',
                sb:'scrollHeight',
                cb:'clientHeight',
                ob:'offsetHeight',
                sr:'scrollTop',
                ss:'height',
                sp:'top',
                dr:'bottom'
            }
        };
        // init scrollbar
        var _doInitBar = function(_name,_conf){
            if (!(_conf||_o).body){
                _conf = {body:_conf};
            }
            var _result = NEJ.X(
                NEJ.X({},_bcnf[_name]),_conf
            );
            _result.body = _e._$get(_result.body);
            if (!!_result.body&&!!_result.track){
                if (_result.track==':parent'){
                    _result.track = _result.body.parentNode;
                }
                _result.track = _e._$get(_result.track);
            }
            if (!_result.min){
                _result.min = !_result.body?10:(_result.body[_result.ob]||10);
            }
            return _result;
        };
        var _doInitBarDrag = function(_name,_body){
            if (!_body) return;
            var _options = this.__dopt[_name];
            _options.body = _body;
            _options.view = this.__parent;
            this.__dragger[_name] =
                _t0._$$Dragger._$allocate(_options);
        };
        return function(_options){
            this.__super(_options);
            this.__bar = {
                x:_doInitBar('x',_options.xbar),
                y:_doInitBar('y',_options.ybar)
            };
{'fraction_non_alphanumeric': 0.1654327516305306, 'fraction_numerical': 0.0247664375110171, 'mean_word_length': 1.406064461407973, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 10, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '632016', 'n_tokens_mistral': 4048, 'n_tokens_neox': 3933, 'n_words': 445}