<commit_before>var Backbone = require("backbone");
var _ = require("underscore");
var BaseViews = require("edit_channel/views");
var Models = require("edit_channel/models");
require("share.less");
var stringHelper = require("edit_channel/utils/string_helper");

var VIEWER_SHARE_MODES = [{'share_mode': 'view', 'text': 'Can view'}]
var EDITOR_SHARE_MODES = [{'share_mode': 'edit', 'text': 'Can edit'}].concat(VIEWER_SHARE_MODES);

var ShareModalView = BaseViews.BaseModalView.extend({
    template: require("./hbtemplates/share_modal.handlebars"),
    initialize: function(options) {
        _.bindAll(this, "close");
        this.render(this.close, {
            channel: this.model.toJSON()
        });
        this.save_changes = false;
        this.share_view = new ShareView({
            el: this.$(".modal-body"),
            container: this,
            model: this.model,
            current_user: options.current_user
        });
    }
});

var ShareView = BaseViews.BaseView.extend({
    template: require("./hbtemplates/share_dialog.handlebars"),

    initialize: function(options) {
        _.bindAll(this, "send_invite");
        this.container = options.container;
        this.current_user = options.current_user;
        this.originalData = this.model.toJSON();
        this.render();
        var self = this;
        Promise.all([this.fetch_model(this.model), this.fetch_model(this.current_user)]).then(function(data){
            self.load_lists();
        });
    },
    events:{
        'keypress #share_email_address' : 'send_invite',
         "click #share_invite_button" : "send_invite"
    },

    render: function() {
        this.$el.html(this.template({
            channel:this.model.toJSON(),
            user: this.current_user.toJSON(),
            share_modes: this.get_share_modes()
        }));
    },
    get_share_modes: function(){
        if (!this.share_modes){
            if(_.find(window.current_channel.get("editors"), function(u){return u === this.current_user.id})){
                this.share_modes = EDITOR_SHARE_MODES;
            }else{
                this.share_modes = VIEWER_SHARE_MODES;
            }
        }
        return this.share_modes;
    },
    load_lists:function(){
        this.editor_list = this.model.get("editors").concat(this.model.get("viewers"));
        this.editor_list.splice(this.editor_list.indexOf(this.current_user.id), 1);
        this.collection = new Models.UserCollection();
        this.pending_collection = new Models.InvitationCollection();<commit_msg>Made boolean more explicit<commit_after>var Backbone = require("backbone");
var _ = require("underscore");
var BaseViews = require("edit_channel/views");
var Models = require("edit_channel/models");
require("share.less");
var stringHelper = require("edit_channel/utils/string_helper");

var VIEWER_SHARE_MODES = [{'share_mode': 'view', 'text': 'Can view'}]
var EDITOR_SHARE_MODES = [{'share_mode': 'edit', 'text': 'Can edit'}].concat(VIEWER_SHARE_MODES);

var ShareModalView = BaseViews.BaseModalView.extend({
    template: require("./hbtemplates/share_modal.handlebars"),
    initialize: function(options) {
        _.bindAll(this, "close");
        this.render(this.close, {
            channel: this.model.toJSON()
        });
        this.save_changes = false;
        this.share_view = new ShareView({
            el: this.$(".modal-body"),
            container: this,
            model: this.model,
            current_user: options.current_user
        });
    }
});

var ShareView = BaseViews.BaseView.extend({
    template: require("./hbtemplates/share_dialog.handlebars"),

    initialize: function(options) {
        _.bindAll(this, "send_invite");
        this.container = options.container;
        this.current_user = options.current_user;
        this.originalData = this.model.toJSON();
        this.render();
        var self = this;
        Promise.all([this.fetch_model(this.model), this.fetch_model(this.current_user)]).then(function(data){
            self.load_lists();
        });
    },
    events:{
        'keypress #share_email_address' : 'send_invite',
         "click #share_invite_button" : "send_invite"
    },

    render: function() {
        this.$el.html(this.template({
            channel:this.model.toJSON(),
            user: this.current_user.toJSON(),
            share_modes: this.get_share_modes()
        }));
    },
    get_share_modes: function(){
        if (!this.share_modes){
            var user_is_editor = _.find(window.current_channel.get("editors"), function(u){return u === this.current_user.id});
            if(user_is_editor){
                this.share_modes = EDITOR_SHARE_MODES;
            }else{
                this.share_modes = VIEWER_SHARE_MODES;
            }
        }
        return this.share_modes;
    },
    load_lists:function(){
        this.editor_list = this.model.get("editors").concat(this.model.get("viewers"));
        this.editor_list.splice(this.editor_list.indexOf(this.current_user.id), 1);
        this.collection = new Models.UserCollection();
        this.pending_collection = new Models.InvitationCollection();
{'fraction_non_alphanumeric': 0.1423570595099183, 'fraction_numerical': 0.00038895371450797355, 'mean_word_length': 2.787187039764359, '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': '6961834', 'n_tokens_mistral': 1565, 'n_tokens_neox': 1535, 'n_words': 239}