<commit_before>/*global define:false*/
define([
    'jquery', 'backbone', 'underscore', '../utilities/channels', './viewContext', '../utilities/enclose', './lifeCycle',
    '../utilities/getProperty'
], function ($, Backbone, _, channels, ViewContext, enclose, lifeCycle, getProperty) {
    'use strict';

    var BEFORE_RENDER_DONE = 'beforeRenderDone',
        RENDER_DONE = 'renderDone',
        AFTER_RENDER_DONE = 'afterRenderDone',
        BaseView = Backbone.View.extend({
        options : {
            name : 'BaseView',
            appendView : true,
            ModelType : undefined,
            bindings : [
                // Example: [stringObjectToListenTo, stringEventName, stringCallbackFunction]
                //          ['model', 'change:something', 'callbackFunction']
                // Bindings have to be all strings, since config does not have access to the view's context
                // if strings are provided it is assumed that the context is the view
            ],
            templateHtml : undefined,
            modelData : undefined,
            rivetConfig : undefined
        },
        defaultBindings : [],
        initialize : initialize,
        start : start,
        render : render,
        dataToJSON : dataToJSON,
        bindEventListeners : bindEventListeners,
        remove : remove,
        children : null,
        addChild : addChild,
        removeChild : removeChild,
        refreshChildren : refreshChildren,
        removeAllChildren : removeAllChildren,
        appendOrInsertView : appendOrInsertView,
        setEl : setEl

        // Dynamically created, so the cache is not shared on the prototype:
        // elementCache: elementCache
    });

    BaseView.beforeRenderDone = BEFORE_RENDER_DONE;
    BaseView.renderDone = RENDER_DONE;
    BaseView.afterRenderDone = AFTER_RENDER_DONE;

    // Share channels among all Views
    BaseView.prototype.channels = BaseView.prototype.channels || channels;

    return BaseView;

    function initialize (options) {
        var self = this;
        // TODO: remove?
        this.options = _.extend({}, this.options, options);
        this.elementCache = _.memoize(elementCache);

        _setTemplate.call(this);
        _setModel.call(this, options);
        _setBoundEventListeners.call(this);
        _.each(options.plugins, function(plugin) {
             plugin.call(self);
        });

        this.children = [];
    }

    /**
     * Wrapper method for lifecycle methods.
     *<commit_msg>adding clone method<commit_after>/*global define:false*/
define([
    'jquery', 'backbone', 'underscore', '../utilities/channels', './viewContext', '../utilities/enclose', './lifeCycle',
    '../utilities/getProperty'
], function ($, Backbone, _, channels, ViewContext, enclose, lifeCycle, getProperty) {
    'use strict';

    var BEFORE_RENDER_DONE = 'beforeRenderDone',
        RENDER_DONE = 'renderDone',
        AFTER_RENDER_DONE = 'afterRenderDone',
        BaseView = Backbone.View.extend({
        options : {
            name : 'BaseView',
            appendView : true,
            ModelType : undefined,
            bindings : [
                // Example: [stringObjectToListenTo, stringEventName, stringCallbackFunction]
                //          ['model', 'change:something', 'callbackFunction']
                // Bindings have to be all strings, since config does not have access to the view's context
                // if strings are provided it is assumed that the context is the view
            ],
            templateHtml : undefined,
            modelData : undefined,
            rivetConfig : undefined
        },
        defaultBindings : [],
        initialize : initialize,
        start : start,
        render : render,
        dataToJSON : dataToJSON,
        bindEventListeners : bindEventListeners,
        remove : remove,
        children : null,
        addChild : addChild,
        removeChild : removeChild,
        refreshChildren : refreshChildren,
        removeAllChildren : removeAllChildren,
        appendOrInsertView : appendOrInsertView,
        setEl : setEl

        // Dynamically created, so the cache is not shared on the prototype:
        // elementCache: elementCache
    });

    BaseView.beforeRenderDone = BEFORE_RENDER_DONE;
    BaseView.renderDone = RENDER_DONE;
    BaseView.afterRenderDone = AFTER_RENDER_DONE;

    // Share channels among all Views
    BaseView.prototype.channels = BaseView.prototype.channels || channels;

    return BaseView;

    function initialize (options) {
        var self = this;
        options = _.clone(options, true);
        // TODO: remove?
        this.options = _.extend({}, this.options, options);
        this.elementCache = _.memoize(elementCache);

        _setTemplate.call(this);
        _setModel.call(this, options);
        _setBoundEventListeners.call(this);
        _.each(options.plugins, function(plugin) {
             plugin.call(self);
        });

        this.children = [];
    }

    /**
     * Wrapper method for lifecycle methods.
     *
{'fraction_non_alphanumeric': 0.10094637223974763, 'fraction_numerical': 0.0, 'mean_word_length': 2.202651515151515, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3787655', 'n_tokens_mistral': 1344, 'n_tokens_neox': 1317, 'n_words': 329}