<NME> buicUpload.js
<BEF> /**
 * @param {Object} $ - Global jQuery object
 * @param {Object} bolt - The Bolt module
 */
(function ($, bolt) {
    'use strict';

    /**
     * BUIC upload widget.
     *
     * @license http://opensource.org/licenses/mit-license.php MIT License
     * @author rarila
     *
     * @class buicUpload
     * @memberOf jQuery.widget.bolt
     */
    $.widget('bolt.buicUpload', /** @lends jQuery.widget.bolt.buicUpload.prototype */ {
        /**
         * Event reporting that a file was selected.
         *
         * @event jQuery.widget.bolt.buicUpload#buicuploaduploaded
         * @property {string} path - The path to the selected file
         */

        /**
         * The constructor of the upload widget.
         *
         * @private
         */
        _create: function () {
            var fieldset = this.element,
                fileInput = $('input[type=file]', fieldset),
                dropZone = $('.elm-dropzone', fieldset),
                //
                accept = $(fileInput).attr('accept'),
                extensions = accept ? accept.replace(/^\./, '').split(/,\./) : [],
                pattern = new RegExp('(\\.|\\/)(' + extensions.join('|') + ')$', 'i');

            // Set maxSize, if not set on creation.
            if (this.options.maxSize === null) {
                var tempSize = Math.floor(bolt.conf('uploadConfig.maxSize'));
                this.options.maxSize = bolt.utils.filterInt(tempSize, 2000000);
            }

            /**
             * Refs to UI elements of this widget.
             *
             * @type {Object}
             * @name _ui
             * @memberOf jQuery.widget.bolt.buicUpload.prototype
             * @private
             *
             * @property {?Object} progress - Progress bar widget
             */
            this._ui = {
                progress: null
            };

            // Initialize the upload widget.
            fileInput.fileupload({
                dataType: 'json',
                dropZone: dropZone,
                pasteZone: null,
                maxFileSize: this.options.maxSize > 0 ? this.options.maxSize : undefined,
                minFileSize: undefined,
                acceptFileTypes: accept ? pattern : undefined,
                maxNumberOfFiles: undefined,
                messages: {
                    maxFileSize: '>:' + bolt.utils.humanBytes(this.options.maxSize),
                    minFileSize: '<',
                    acceptFileTypes: 'T:.' + extensions.join(', .'),
                    maxNumberOfFiles: '#'
                }
            });

            // Binds event handlers.
            this._on({
                'fileuploadprocessfail': this._onProcessFail,
                'fileuploadsubmit':      this._onUploadSubmit,
                'fileuploadprogress':    this._onUploadProgress,
                'fileuploadalways':      this._onUploadAlways,
                'fileuploaddone':        this._onUploadDone
            });
        },

        /**
         * Upload processing failed.
         *
         * @private
         *
         * @param {Object} event
         */
        _onProcessFail: function (event, data) {
            var currentFile = data.files[data.index],
                    type = currentFile.error.substr(0, 1),
                    alert,
                    context = {
                        '%FILENAME%': currentFile.name,
                        '%FILESIZE%': bolt.utils.humanBytes(currentFile.size),
                        '%FILETYPE%': currentFile.type,
                        '%ALLOWED%': currentFile.error.substr(2)
                    };

            switch (type) {
                case '>':
                case '>':
                    alert = bolt.data('field.uploads.template.large-file', context);
                    break;

                case 'T':
                    alert = bolt.data('field.uploads.template.wrong-type', context);
                    break;

                default:
                    alert = '<p>' + currentFile.error + '</p>';
            }
            bootbox.alert(alert);
        },

        /**
         * Upload starts.
         *
         * @private
         *
         * @param {Object} event
         * @param {Object} data
         */
        _onUploadSubmit: function (event, data) {
            this._progress('add', data.files);
        },

        /**
         * Signal upload progress.
         *
         * @private
         *
         * @param {Object} event
         * @param {Object} data
         */
        _onUploadProgress: function (event, data) {
            this._progress('set', data.files, data.loaded / data.total);
        },

        /**
         * After successful or failed upload.
         *
         * @private
         *
         * @param {Object} event
         * @param {Object} data
         */
        _onUploadAlways: function (event, data) {
            this._progress('remove', data.files);
        },

        /**
         * Files successfully uploaded.
         *
         * @private
         * @fires jQuery.widget.bolt.buicUpload#buicuploaduploaded
         *
         * @param {Object} event
         * @param {Object} data
         */
        _onUploadDone: function (event, data) {
            var self = this;

            $.each(data.result, function (idx, file) {
                if (file.error) {
                    bootbox.alert(bolt.data('field.uploads.template.error', {'%ERROR%': file.error}));
                } else {
                    self._trigger('uploaded', event, file);
                }
            });
        },

        /**
         * Send commands to buicProgress to display upload progress.
         *
         * @private
         *
         * @param {string} command - Command to send
         * @param {array}  files   - Files to process
         * @param {number} [done]  - Percentage of bytes already uploaded
         */
        _progress: function (command, files, done) {
            var self = this;

            if (self._ui.progress === null) {
                self._ui.progress = $(':bolt-buicProgress', self.element);
            }

            $.each(files, function () {
                self._ui.progress.buicProgress(command, this.name, done);
            });
        },

        /**
         * Default options.
         *
         * @property {?number} maxSize - Maximum upload size in bytes. 0 means unlimited.
         */
        options: {
            maxSize: null
        }
    });
})(jQuery, Bolt);

<MSG> Fix indent
<DFF> @@ -92,14 +92,14 @@
          */
         _onProcessFail: function (event, data) {
             var currentFile = data.files[data.index],
-                    type = currentFile.error.substr(0, 1),
-                    alert,
-                    context = {
-                        '%FILENAME%': currentFile.name,
-                        '%FILESIZE%': bolt.utils.humanBytes(currentFile.size),
-                        '%FILETYPE%': currentFile.type,
-                        '%ALLOWED%': currentFile.error.substr(2)
-                    };
+                type = currentFile.error.substr(0, 1),
+                alert,
+                context = {
+                    '%FILENAME%': currentFile.name,
+                    '%FILESIZE%': bolt.utils.humanBytes(currentFile.size),
+                    '%FILETYPE%': currentFile.type,
+                    '%ALLOWED%': currentFile.error.substr(2)
+                };
 
             switch (type) {
                 case '>':

{'commit': "diff --git a/app/src/js/widgets/buic/buicUpload.js b/app/src/js/widgets/buic/buicUpload.js\nindex e3354a301..0118f384b 100644\n--- a/app/src/js/widgets/buic/buicUpload.js\n+++ b/app/src/js/widgets/buic/buicUpload.js\n@@ -92,14 +92,14 @@\n          */\n         _onProcessFail: function (event, data) {\n             var currentFile = data.files[data.index],\n-                    type = currentFile.error.substr(0, 1),\n-                    alert,\n-                    context = {\n-                        '%FILENAME%': currentFile.name,\n-                        '%FILESIZE%': bolt.utils.humanBytes(currentFile.size),\n-                        '%FILETYPE%': currentFile.type,\n-                        '%ALLOWED%': currentFile.error.substr(2)\n-                    };\n+                type = currentFile.error.substr(0, 1),\n+                alert,\n+                context = {\n+                    '%FILENAME%': currentFile.name,\n+                    '%FILESIZE%': bolt.utils.humanBytes(currentFile.size),\n+                    '%FILETYPE%': currentFile.type,\n+                    '%ALLOWED%': currentFile.error.substr(2)\n+                };\n \n             switch (type) {\n                 case '>':\n", 'commit_subject': 'Fix indent', 'repo_name': 'bolt/bolt', 'committer': {'name': 'rarila', 'email': 'b257af45fbc9f52d0e728490f2c2da9e4f66647e@gmx.net', 'time_sec': '1450103192', 'tz_offset': '60', 'date': {'seconds': '1450103192'}}, 'commit_tree': '57125896db518a82c2fd64b05f8866a66087585d', 'commit_message': 'Fix indent', 'language_name': 'JavaScript', 'license': 'mit', 'hunks': "@@ -92,14 +92,14 @@\n          */\n         _onProcessFail: function (event, data) {\n             var currentFile = data.files[data.index],\n-                    type = currentFile.error.substr(0, 1),\n-                    alert,\n-                    context = {\n-                        '%FILENAME%': currentFile.name,\n-                        '%FILESIZE%': bolt.utils.humanBytes(currentFile.size),\n-                        '%FILETYPE%': currentFile.type,\n-                        '%ALLOWED%': currentFile.error.substr(2)\n-                    };\n+                type = currentFile.error.substr(0, 1),\n+                alert,\n+                context = {\n+                    '%FILENAME%': currentFile.name,\n+                    '%FILESIZE%': bolt.utils.humanBytes(currentFile.size),\n+                    '%FILETYPE%': currentFile.type,\n+                    '%ALLOWED%': currentFile.error.substr(2)\n+                };\n \n             switch (type) {\n                 case '>':\n", 'addition_count': 8, 'deletion_count': 8, 'src_file': 'a/app/src/js/widgets/buic/buicUpload.js', 'tgt_file': 'b/app/src/js/widgets/buic/buicUpload.js', 'file_extension': '.js', 'before_file': "/**\n * @param {Object} $ - Global jQuery object\n * @param {Object} bolt - The Bolt module\n */\n(function ($, bolt) {\n    'use strict';\n\n    /**\n     * BUIC upload widget.\n     *\n     * @license http://opensource.org/licenses/mit-license.php MIT License\n     * @author rarila\n     *\n     * @class buicUpload\n     * @memberOf jQuery.widget.bolt\n     */\n    $.widget('bolt.buicUpload', /** @lends jQuery.widget.bolt.buicUpload.prototype */ {\n        /**\n         * Event reporting that a file was selected.\n         *\n         * @event jQuery.widget.bolt.buicUpload#buicuploaduploaded\n         * @property {string} path - The path to the selected file\n         */\n\n        /**\n         * The constructor of the upload widget.\n         *\n         * @private\n         */\n        _create: function () {\n            var fieldset = this.element,\n                fileInput = $('input[type=file]', fieldset),\n                dropZone = $('.elm-dropzone', fieldset),\n                //\n                accept = $(fileInput).attr('accept'),\n                extensions = accept ? accept.replace(/^\\./, '').split(/,\\./) : [],\n                pattern = new RegExp('(\\\\.|\\\\/)(' + extensions.join('|') + ')$', 'i');\n\n            // Set maxSize, if not set on creation.\n            if (this.options.maxSize === null) {\n                var tempSize = Math.floor(bolt.conf('uploadConfig.maxSize'));\n                this.options.maxSize = bolt.utils.filterInt(tempSize, 2000000);\n            }\n\n            /**\n             * Refs to UI elements of this widget.\n             *\n             * @type {Object}\n             * @name _ui\n             * @memberOf jQuery.widget.bolt.buicUpload.prototype\n             * @private\n             *\n             * @property {?Object} progress - Progress bar widget\n             */\n            this._ui = {\n                progress: null\n            };\n\n            // Initialize the upload widget.\n            fileInput.fileupload({\n                dataType: 'json',\n                dropZone: dropZone,\n                pasteZone: null,\n                maxFileSize: this.options.maxSize > 0 ? this.options.maxSize : undefined,\n                minFileSize: undefined,\n                acceptFileTypes: accept ? pattern : undefined,\n                maxNumberOfFiles: undefined,\n                messages: {\n                    maxFileSize: '>:' + bolt.utils.humanBytes(this.options.maxSize),\n                    minFileSize: '<',\n                    acceptFileTypes: 'T:.' + extensions.join(', .'),\n                    maxNumberOfFiles: '#'\n                }\n            });\n\n            // Binds event handlers.\n            this._on({\n                'fileuploadprocessfail': this._onProcessFail,\n                'fileuploadsubmit':      this._onUploadSubmit,\n                'fileuploadprogress':    this._onUploadProgress,\n                'fileuploadalways':      this._onUploadAlways,\n                'fileuploaddone':        this._onUploadDone\n            });\n        },\n\n        /**\n         * Upload processing failed.\n         *\n         * @private\n         *\n         * @param {Object} event\n         */\n        _onProcessFail: function (event, data) {\n            var currentFile = data.files[data.index],\n                    type = currentFile.error.substr(0, 1),\n                    alert,\n                    context = {\n                        '%FILENAME%': currentFile.name,\n                        '%FILESIZE%': bolt.utils.humanBytes(currentFile.size),\n                        '%FILETYPE%': currentFile.type,\n                        '%ALLOWED%': currentFile.error.substr(2)\n                    };\n\n            switch (type) {\n                case '>':\n                case '>':\n                    alert = bolt.data('field.uploads.template.large-file', context);\n                    break;\n\n                case 'T':\n                    alert = bolt.data('field.uploads.template.wrong-type', context);\n                    break;\n\n                default:\n                    alert = '<p>' + currentFile.error + '</p>';\n            }\n            bootbox.alert(alert);\n        },\n\n        /**\n         * Upload starts.\n         *\n         * @private\n         *\n         * @param {Object} event\n         * @param {Object} data\n         */\n        _onUploadSubmit: function (event, data) {\n            this._progress('add', data.files);\n        },\n\n        /**\n         * Signal upload progress.\n         *\n         * @private\n         *\n         * @param {Object} event\n         * @param {Object} data\n         */\n        _onUploadProgress: function (event, data) {\n            this._progress('set', data.files, data.loaded / data.total);\n        },\n\n        /**\n         * After successful or failed upload.\n         *\n         * @private\n         *\n         * @param {Object} event\n         * @param {Object} data\n         */\n        _onUploadAlways: function (event, data) {\n            this._progress('remove', data.files);\n        },\n\n        /**\n         * Files successfully uploaded.\n         *\n         * @private\n         * @fires jQuery.widget.bolt.buicUpload#buicuploaduploaded\n         *\n         * @param {Object} event\n         * @param {Object} data\n         */\n        _onUploadDone: function (event, data) {\n            var self = this;\n\n            $.each(data.result, function (idx, file) {\n                if (file.error) {\n                    bootbox.alert(bolt.data('field.uploads.template.error', {'%ERROR%': file.error}));\n                } else {\n                    self._trigger('uploaded', event, file);\n                }\n            });\n        },\n\n        /**\n         * Send commands to buicProgress to display upload progress.\n         *\n         * @private\n         *\n         * @param {string} command - Command to send\n         * @param {array}  files   - Files to process\n         * @param {number} [done]  - Percentage of bytes already uploaded\n         */\n        _progress: function (command, files, done) {\n            var self = this;\n\n            if (self._ui.progress === null) {\n                self._ui.progress = $(':bolt-buicProgress', self.element);\n            }\n\n            $.each(files, function () {\n                self._ui.progress.buicProgress(command, this.name, done);\n            });\n        },\n\n        /**\n         * Default options.\n         *\n         * @property {?number} maxSize - Maximum upload size in bytes. 0 means unlimited.\n         */\n        options: {\n            maxSize: null\n        }\n    });\n})(jQuery, Bolt);\n", 'message': 'Fix indent', 'author_name': 'rarila', 'lang': 'js'}