<commit_before>/**
 * @file Presenter
 * @author treelite(<EMAIL>)
 */

define(function (require) {

    var inherits = require('saber-lang/inherits');
    var extend = require('saber-lang/extend');
    var bind = require('saber-lang/bind');
    var Abstract = require('./Abstract');
    var Resolver = require('saber-promise');
    var globalConfig = require('./config');

    /**
     * Presenter
     *
     * @constructor
     * @param {Object} options 配置参数
     * @param {Object} options.view view配置项
     * @param {Object} options.model model配置项
     * @param {Object=} options.events 事件
     */
    function Presenter(options) {
        Abstract.call(this, options);
        this.init();
    }

    inherits(Presenter, Abstract);

    /**
     * 初始化
     *
     * @public
     */
    Presenter.prototype.init = function () {
        var Constructor;

        if (this.view
            && this.view.constructor !== Object
        ) {
            Constructor = this.view.constructor;
        }
        else {
            Constructor = globalConfig.View || require('./View');
        }
        this.view = new Constructor(this.view);

        if (this.model
            && this.model.constructor !== Object
        ) {
            Constructor = this.model.constructor;
        }
        else {
            Constructor = globalConfig.Model || require('./Model');
        }
        this.model = new Constructor(this.model);

        Abstract.prototype.init.call(this);
    };

    /**
     * 数据设置
     *
     * @public
     * @param {string} path 当前的路径
     */
    Presenter.prototype.set = function (path) {
        this.path = path;
    };

    /**
     * 页面跳转
     *
     * @public
     * @param {string} url 跳转地址
     * @param {Object=} query 查询条件
     * @param {Object=} options 跳转参数
     */
    Presenter.prototype.redirect = function (url, query, options) {
        var router = globalConfig.router;

        router.redirect(url, query, options);
    };

    /**
     * 加载页面
     *
     * 页面入口
     * 完成数据请求，页面渲染
     *
     * @public
     * @param {HTMLElement} main 视图容器
     * @param {string} path 当前的访问路径
     * @param {Object} query 查询条件
     * @param {Object} params 路径参数
     * @param {Object=} options 附加数据
     * @return {Promise}
     */
    Presenter.prototype.enter = function (main, path, query, params, options) {
        this.path = path;

        this.options = extend({}, options);
        this.view.set(main);

        this.emit('enter');

        this.model.set(query, params, path);
        return this.model.fetch().then(bind(this.view.render, this.view));
    };

    /**
     * 唤醒页面
     *
     * @public
     * @param {string} path 当前的访问地址
     * @param {Object} query 查询条件
     * @param {Object} params 路径参数
     * @param {Object} options 附加数据
     * @return {Promise}
     */
    Presenter.prototype.wakeup = function (path, query, params, options) {
        this.path = path;

        this.options = extend({}, options);

        this.emit('wakeup');

        return Resolver.resolved();
    };

    /**
     * 页面就绪
     * 进行DOM事件注册
     *
     * @public
     */
    Presenter.prototype.ready = function () {
        this.emit('ready');
        this.view.ready();
    };<commit_msg>Del params, combine to query<commit_after>/**
 * @file Presenter
 * @author treelite(<EMAIL>)
 */

define(function (require) {

    var inherits = require('saber-lang/inherits');
    var extend = require('saber-lang/extend');
    var bind = require('saber-lang/bind');
    var Abstract = require('./Abstract');
    var Resolver = require('saber-promise');
    var globalConfig = require('./config');

    /**
     * Presenter
     *
     * @constructor
     * @param {Object} options 配置参数
     * @param {Object} options.view view配置项
     * @param {Object} options.model model配置项
     * @param {Object=} options.events 事件
     */
    function Presenter(options) {
        Abstract.call(this, options);
        this.init();
    }

    inherits(Presenter, Abstract);

    /**
     * 初始化
     *
     * @public
     */
    Presenter.prototype.init = function () {
        var Constructor;

        if (this.view
            && this.view.constructor !== Object
        ) {
            Constructor = this.view.constructor;
        }
        else {
            Constructor = globalConfig.View || require('./View');
        }
        this.view = new Constructor(this.view);

        if (this.model
            && this.model.constructor !== Object
        ) {
            Constructor = this.model.constructor;
        }
        else {
            Constructor = globalConfig.Model || require('./Model');
        }
        this.model = new Constructor(this.model);

        Abstract.prototype.init.call(this);
    };

    /**
     * 数据设置
     *
     * @public
     * @param {string} path 当前的路径
     */
    Presenter.prototype.set = function (path) {
        this.path = path;
    };

    /**
     * 页面跳转
     *
     * @public
     * @param {string} url 跳转地址
     * @param {Object=} query 查询条件
     * @param {Object=} options 跳转参数
     */
    Presenter.prototype.redirect = function (url, query, options) {
        var router = globalConfig.router;

        router.redirect(url, query, options);
    };

    /**
     * 加载页面
     *
     * 页面入口
     * 完成数据请求，页面渲染
     *
     * @public
     * @param {HTMLElement} main 视图容器
     * @param {string} path 当前的访问路径
     * @param {Object} query 查询条件
     * @param {Object=} options 附加数据
     * @return {Promise}
     */
    Presenter.prototype.enter = function (main, path, query, options) {
        this.path = path;

        this.options = extend({}, options);
        this.view.set(main);

        this.emit('enter');

        return this.model.fetch(query).then(bind(this.view.render, this.view));
    };

    /**
     * 唤醒页面
     *
     * @public
     * @param {string} path 当前的访问地址
     * @param {Object} query 查询条件
     * @param {Object} params 路径参数
     * @param {Object} options 附加数据
     * @return {Promise}
     */
    Presenter.prototype.wakeup = function (path, query, options) {
        this.path = path;

        this.options = extend({}, options);

        this.emit('wakeup');

        return Resolver.resolved();
    };

    /**
     * 页面就绪
     * 进行DOM事件注册
     *
     * @public
     */
    Presenter.prototype.ready = function () {
        this.emit('ready');
        this.view.ready();
    };
{'fraction_non_alphanumeric': 0.14150943396226415, 'fraction_numerical': 0.0, 'mean_word_length': 1.85759209344115, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '6564967', 'n_tokens_mistral': 2102, 'n_tokens_neox': 2114, 'n_words': 407}