<commit_before>/**
 * @author <NAME> from Ubrainians for imCode
 * 23.06.18
 */
define(
    'imcms-files-tab-builder',
    ['imcms-super-admin-tab', 'imcms-i18n-texts', 'imcms-components-builder', 'imcms-files-rest-api',
        'imcms-modal-window-builder', 'imcms-field-wrapper', 'jquery', 'imcms-bem-builder', 'imcms-file-to-row-transformer',
        'imcms-file-editor'],
    function (SuperAdminTab, texts, components, filesRestApi, modal, fieldWrapper, $, BEM, fileToRow, fileEditor) {

        texts = texts.superAdmin.files;

        let $fileContainer;
        let $fileSecondContainer;

        const firstFilesLoader = {
            files: false,
            callback: [],
            whenFilesLoaded: function (callback) {
                (this.files) ? callback(this.files) : this.callback.push(callback);
            },
            runCallbacks: function (files) {
                this.files = files;

                this.callback.forEach(callback => {
                    callback(files);
                });
            }
        };

        const secondFilesLoader = {
            files: false,
            callback: [],
            whenFilesLoaded: function (callback) {
                (this.files) ? callback(this.files) : this.callback.push(callback);
            },
            runCallbacks: function (files) {
                this.files = files;

                this.callback.forEach(callback => {
                    callback(files);
                });
            }
        };

        filesRestApi.read()
            .done(files => {
                firstFilesLoader.runCallbacks(files);
                secondFilesLoader.runCallbacks(files);
            })
            .fail(() => modal.buildErrorWindow(texts.error.loadError));

        function buildFirstInstanceFiles() {
            $fileContainer = $('<div>', {
                'class': 'first-files'
            });

            firstFilesLoader.whenFilesLoaded(files => {
                $fileContainer.append(files.map(file => fileToRow.transformFirstColumn(file, fileEditor)));
            });

            return $fileContainer;
        }

        function buildSecondInstanceFiles() {
            $fileSecondContainer = $('<div>', {
                'class': 'second-files'
            });

            secondFilesLoader.whenFilesLoaded(files => {
                $fileSecondContainer.append(files.map(file => fileToRow.transformSecondColumn(file, fileEditor)));
            });

            return $fileSecondContainer;
        }

        function buildDocumentsContainer() {
            return fileEditor.displayDocs();
        }

        let filesContainer;

        function buildTableFilesContainer() {
            return filesContainer = new BEM({
                block: 'files-table',
                elements: {
                    'first-instance': buildFirstInstanceFiles(),
                    'second-instance': buildSecondInstanceFiles()
                }
            }).buildBlockStructure('<div>', {})
        }

        function buildMoveButtons() {
            let $buttonMoveLeft = components.buttons.positiveButton({
                text: texts.moveLeft,
                click: fileEditor.moveFileLeft
            });
            let $buttonMoveRight = components.buttons.positiveButton({
                text: texts.moveRight,
                click: fileEditor.moveFileRight
            });

            return new BEM({
                block: 'buttons-move',
                elements: {
                    'left-move': $buttonMoveLeft,
                    'right-move': $buttonMoveRight,
                }
            }).buildBlockStructure('<div>')
        }

        function buildCopyButtons() {
            let $buttonCopyLeft = components.buttons.positiveButton({
                text: texts.copyLeft,
                click: fileEditor.copyFileLeft
            });
            let $buttonCopyRight = components.buttons.positiveButton({
                text: texts.copyRight,
                click: fileEditor.copyFileRight
            });

            return new BEM({
                block: 'buttons-copy',
                elements: {
                    'left-copy': $buttonCopyLeft,
                    'right-copy': $buttonCopyRight,
                }
            }).buildBlockStructure('<div>');
        }

        let $actionButtonsContainer;

        function buildFirstActionButtonsContainer() {
            return $actionButtonsContainer = new BEM({
                block: 'first-files-action',
                elements: {
                    'add-file': components.controls.add(fileEditor.addFileInFirstColumn).attr("title", texts.add),
                    'upload-file': components.controls.upload(fileEditor.uploadFileInFirstColumn).attr("title", texts.upload)
                }
            }).buildBlockStructure('<div>', {})
        }

        let $actionSecondButtonsContainer;

        function buildSecondActionButtonsContainer() {
            return $actionSecondButtonsContainer = new BEM({
                block: 'second-files-action',
                elements: {
                    'add-file': components.controls.add(fileEditor.addFileInSecondColumn).attr("title", texts.add),
                    'upload-file': components.controls.upload(fileEditor.uploadFileInSecondColumn).attr("title", texts.upload)
                }
            }).buildBlockStructure('<div>', {})
        }

        function buildButtonsActionContainer() {
            return new BEM({
                block: 'buttons-action',
                elements: {
                    'first-action': buildFirstActionButtonsContainer(),
                    "second-action": buildSecondActionButtonsContainer()
                }
            }).buildBlockStructure('<div>')
        }


        return new SuperAdminTab(texts.name, [
            buildTableFilesContainer(),
            buildMoveButtons(),
            buildCopyButtons(),
            buildButtonsActionContainer(),
            buildDocumentsContainer()
        ]);
    }
);
<commit_msg>Issue IMCMS-332: New design to super admin page: files tab - Added title for move and copy buttons;<commit_after>/**
 * @author <NAME> from Ubrainians for imCode
 * 23.06.18
 */
define(
    'imcms-files-tab-builder',
    ['imcms-super-admin-tab', 'imcms-i18n-texts', 'imcms-components-builder', 'imcms-files-rest-api',
        'imcms-modal-window-builder', 'imcms-field-wrapper', 'jquery', 'imcms-bem-builder', 'imcms-file-to-row-transformer',
        'imcms-file-editor'],
    function (SuperAdminTab, texts, components, filesRestApi, modal, fieldWrapper, $, BEM, fileToRow, fileEditor) {

        texts = texts.superAdmin.files;

        let $fileContainer;
        let $fileSecondContainer;

        const firstFilesLoader = {
            files: false,
            callback: [],
            whenFilesLoaded: function (callback) {
                (this.files) ? callback(this.files) : this.callback.push(callback);
            },
            runCallbacks: function (files) {
                this.files = files;

                this.callback.forEach(callback => {
                    callback(files);
                });
            }
        };

        const secondFilesLoader = {
            files: false,
            callback: [],
            whenFilesLoaded: function (callback) {
                (this.files) ? callback(this.files) : this.callback.push(callback);
            },
            runCallbacks: function (files) {
                this.files = files;

                this.callback.forEach(callback => {
                    callback(files);
                });
            }
        };

        filesRestApi.read()
            .done(files => {
                firstFilesLoader.runCallbacks(files);
                secondFilesLoader.runCallbacks(files);
            })
            .fail(() => modal.buildErrorWindow(texts.error.loadError));

        function buildFirstInstanceFiles() {
            $fileContainer = $('<div>', {
                'class': 'first-files'
            });

            firstFilesLoader.whenFilesLoaded(files => {
                $fileContainer.append(files.map(file => fileToRow.transformFirstColumn(file, fileEditor)));
            });

            return $fileContainer;
        }

        function buildSecondInstanceFiles() {
            $fileSecondContainer = $('<div>', {
                'class': 'second-files'
            });

            secondFilesLoader.whenFilesLoaded(files => {
                $fileSecondContainer.append(files.map(file => fileToRow.transformSecondColumn(file, fileEditor)));
            });

            return $fileSecondContainer;
        }

        function buildDocumentsContainer() {
            return fileEditor.displayDocs();
        }

        let filesContainer;

        function buildTableFilesContainer() {
            return filesContainer = new BEM({
                block: 'files-table',
                elements: {
                    'first-instance': buildFirstInstanceFiles(),
                    'second-instance': buildSecondInstanceFiles()
                }
            }).buildBlockStructure('<div>', {})
        }

        function buildMoveButtons() {
            let $buttonMoveLeft = components.buttons.positiveButton({
                text: texts.moveLeft,
                click: fileEditor.moveFileLeft
            });
            let $buttonMoveRight = components.buttons.positiveButton({
                text: texts.moveRight,
                click: fileEditor.moveFileRight
            });

            return new BEM({
                block: 'buttons-move',
                elements: {
                    'left-move': $buttonMoveLeft,
                    'right-move': $buttonMoveRight,
                }
            }).buildBlockStructure('<div>')
        }

        function buildCopyButtons() {
            let $buttonCopyLeft = components.buttons.positiveButton({
                text: texts.copyLeft,
                click: fileEditor.copyFileLeft
            });
            let $buttonCopyRight = components.buttons.positiveButton({
                text: texts.copyRight,
                click: fileEditor.copyFileRight
            });

            return new BEM({
                block: 'buttons-copy',
                elements: {
                    'left-copy': $buttonCopyLeft,
                    'right-copy': $buttonCopyRight,
                }
            }).buildBlockStructure('<div>');
        }

        let $actionButtonsContainer;

        function buildFirstActionButtonsContainer() {
            return $actionButtonsContainer = new BEM({
                block: 'first-files-action',
                elements: {
                    'add-file': components.controls.add(fileEditor.addFileInFirstColumn).attr("title", texts.add),
                    'upload-file': components.controls.upload(fileEditor.uploadFileInFirstColumn).attr("title", texts.upload)
                }
            }).buildBlockStructure('<div>', {})
        }

        let $actionSecondButtonsContainer;

        function buildSecondActionButtonsContainer() {
            return $actionSecondButtonsContainer = new BEM({
                block: 'second-files-action',
                elements: {
                    'add-file': components.controls.add(fileEditor.addFileInSecondColumn).attr("title", texts.add),
                    'upload-file': components.controls.upload(fileEditor.uploadFileInSecondColumn).attr("title", texts.upload)
                }
            }).buildBlockStructure('<div>', {})
        }

        function buildButtonsActionContainer() {
            return new BEM({
                block: 'buttons-action',
                elements: {
                    'first-action': buildFirstActionButtonsContainer(),
                    "second-action": buildSecondActionButtonsContainer()
                }
            }).buildBlockStructure('<div>')
        }

        function buildTitleMove() {
            return $('<div>', {
                'class': 'title-move',
                text: texts.title.titleByMove
            });
        }

        function buildTitleCopy() {
            return $('<div>', {
                'class': 'title-copy',
                text: texts.title.titleByCopy
            });
        }


        return new SuperAdminTab(texts.name, [
            buildTableFilesContainer(),
            buildTitleMove(),
            buildMoveButtons(),
            buildTitleCopy(),
            buildCopyButtons(),
            buildButtonsActionContainer(),
            buildDocumentsContainer()
        ]);
    }
);

{'fraction_non_alphanumeric': 0.11348136399682791, 'fraction_numerical': 0.001506740681998414, 'mean_word_length': 1.6120546810273406, 'pattern_counts': {'":': 2, '<': 23, '<?xml version=': 0, '>': 39, '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': '1468630', 'n_tokens_mistral': 3141, 'n_tokens_neox': 2973, 'n_words': 500}