<commit_before>/*
* Copyright (c) 2013 DataTorrent, Inc. ALL Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

var _ = require('underscore');
var kt = require('knights-templar');
var Notifier = require('../Notifier');
var BaseView = require('bassview');
var SingleFileUploadView = require('./SingleFileUploadView');


/**
 * UploadFilesView
 * 
 * View in FileListWidget for uploading file(s).
 *
 * Usage:
 *
 *     var view = new UploadFilesView({
 *
 *         // Files must be DT.lib.UploadFileCollection
 *         // or a child class. Will hold all new files
 *         collection: new UploadFileCollection([]),
 *
 *         // optional: another UploadFileCollection
 *         // or child, 
 *         uploaded: myUploadedFiles // optional
 *     });
 *     
 *     $('body').append(view.render().el);
 *
 * The 'collection' should be empty at 
 * Pass an 'uploaded' collection to test for overwrites.
 *
*/
var UploadFilesView = BaseView.extend({
    
    initialize: function(options) {

        this.uploaded = options.uploaded;
        
        // Listen for upload progress and complete on the model
        this.listenTo(this.collection, 'reset', this.render);
        this.listenTo(this.collection, 'remove', function(model, collection) {
            if (collection.length === 0) {
                this.render();
            }
        });
    },

    FileView: SingleFileUploadView,

    // file type restrictions
    // eg. ['.jar','.zip']
    accept: [],

    multiple: true,

    uploadBtnConfirm: 'upload',

    uploadBtnCancel: 'cancel',

    uploadTitle: 'drag and drop files here',

    uploadText: '(click to choose files)',
    
    events: {
        'change .file_upload': 'onFileChange',<commit_msg>improved documentation of upload files view<commit_after>/*
* Copyright (c) 2013 DataTorrent, Inc. ALL Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

var _ = require('underscore');
var kt = require('knights-templar');
var Notifier = require('../Notifier');
var BaseView = require('bassview');
var SingleFileUploadView = require('./SingleFileUploadView');


/**
 * UploadFilesView
 * 
 * View in FileListWidget for uploading file(s).
 *
 * Usage:
 *
 *     var view = new UploadFilesView({
 *         collection: new DT.lib.UploadFileCollection([])
 *     });
 *     
 *     $('body').append(view.render().el);
 *
 *
*/
var UploadFilesView = BaseView.extend({
    
    /**
     * @param  {DT.lib.UploadFileCollection} options.collection  Holds files to be uploaded, and clears on upload success.
     * @param  {DT.lib.UploadFileCollection} options.uploaded    (optional) Reference to files on server to check against for overwrites.
     */
    initialize: function(options) {

        this.uploaded = options.uploaded;
        
        // Listen for upload progress and complete on the model
        this.listenTo(this.collection, 'reset', this.render);
        this.listenTo(this.collection, 'remove', function(model, collection) {
            if (collection.length === 0) {
                this.render();
            }
        });
    },

    FileView: SingleFileUploadView,

    // file type restrictions
    // eg. ['.jar','.zip']
    accept: [],

    multiple: true,

    uploadBtnConfirm: 'upload',

    uploadBtnCancel: 'cancel',

    uploadTitle: 'drag and drop files here',

    uploadText: '(click to choose files)',
    
    events: {
        'change .file_upload': 'onFileChange',
{'fraction_non_alphanumeric': 0.11705234778701415, 'fraction_numerical': 0.004044035048303752, 'mean_word_length': 2.8916083916083917, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1458327', 'n_tokens_mistral': 1255, 'n_tokens_neox': 1208, 'n_words': 412}