%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/985914/root/data/old/home/stash/atlassian-stash/static/feature/commits/
Upload File :
Create Path :
Current File : //proc/985914/root/data/old/home/stash/atlassian-stash/static/feature/commits/commits-table.js

define('feature/commits/commits-table', [
    'aui',
    'jquery',
    'util/events',
    'widget/paged-table'
], function(
    _aui,
    $,
    events,
    PagedTable
) {

        function CommitTable(getCommitsUrlBuilder, options) {
            this.getCommitsUrlBuilder = getCommitsUrlBuilder;

            var defaults = {
                target: "#commits-table",
                ajaxDataType: 'html',
                tableMessageClass: 'commits-table-message',
                allFetchedMessageHtml: '<p class="no-more-results">' + _aui.escapeHtml(AJS.I18n.getText('stash.web.commits.allcommitsfetched')) + '</p>',
                noneFoundMessageHtml: '<h3 class="no-results entity-empty">' + _aui.escapeHtml(AJS.I18n.getText('stash.web.commits.nocommitsfetched')) + '</h3>'
            };
            options = $.extend({}, defaults, options);

            PagedTable.call(this, options);

            this.$spinner.addClass('commits-table-spinner');
        }

        $.extend(CommitTable.prototype, PagedTable.prototype);

        CommitTable.prototype.buildUrl = function (start, limit) {
            return this.getCommitsUrlBuilder()
                .withParams({
                    start : start,
                    limit : limit,
                    contents: ''
                }).build();
        };

        CommitTable.prototype.onDataLoaded = function(start, limit, data) {
            if (typeof data === 'string') {
                // real ajax request
                data = this.createDataFromJQuery(start, limit, $(data));
            }
            return PagedTable.prototype.onDataLoaded.call(this, start, limit, data);
        };

        CommitTable.prototype.attachNewContent = function (data, attachmentMethod) {
            PagedTable.prototype.attachNewContent.call(this, data, attachmentMethod);

            events.trigger('stash.widget.commitsTable.contentAdded', this, data);
        };

        CommitTable.prototype.handleNewRows = function (data, attachmentMethod) {
            this.$table.show().children("tbody")[attachmentMethod !== 'html' ? attachmentMethod : 'append'](data.values);
        };

        CommitTable.prototype.focusInitialRow = function() {
            this.$table.find("tbody tr.commit-row:first").addClass("focused-commit");
        };

        CommitTable.prototype.initShortcuts = function() {
            var self = this,
                sel = this.$table.selector,
                openItemDisabled = false,
                options = {
                    "focusedClass": "focused-commit",
                    "wrapAround": false,
                    "escToCancel": false
                },
                focusedRowSelector = sel + " .commit-row." + options.focusedClass,
                rowSelector = focusedRowSelector + ", " +               //Always include the currently selected element, even if it's a filtered merge row
                sel + ".show-merges .commit-row, " +                    //When not filtering merges, include every row
                sel + ":not(.show-merges) .commit-row:not(.merge)";     //When filtering merges, don't include merge rows

            this._onDisableOpenItemHandler = function(){
                openItemDisabled = true;
            };
            this._onEnableOpenItemHandler = function(){
                openItemDisabled = false;
            };
            events.on('stash.keyboard.shortcuts.disableOpenItemHandler', this._onDisableOpenItemHandler);
            events.on('stash.keyboard.shortcuts.enableOpenItemHandler', this._onEnableOpenItemHandler);

            this.bindMoveToNextHandler = function(keys) {
                (this.moveToNextItem ? this : _aui.whenIType(keys)).moveToNextItem(rowSelector, options).execute(function() {
                    if ($(rowSelector).last().hasClass(options.focusedClass)) {
                        window.scrollTo(0, document.documentElement.scrollHeight);
                    }
                });
            };

            this.bindMoveToPreviousHandler = function(keys) {
                (this.moveToPrevItem ? this : _aui.whenIType(keys)).moveToPrevItem(rowSelector, options);
            };

            this.bindOpenItemHandler = function(keys) {
                (this.execute ? this : _aui.whenIType(keys)).execute(function() {
                    if (!openItemDisabled) {
                        var $focusedItem = _aui.$(focusedRowSelector);
                        if ($focusedItem.length) {
                            window.location.href = $focusedItem.find('td.changeset a').attr('href');
                        }
                    }
                });
            };

            this.bindToggleMergesHandler = function(keys) {
                (this.execute ? this : _aui.whenIType(keys)).execute(function() {
                    self.$table.toggleClass("show-merges");
                });
            };

            PagedTable.prototype.initShortcuts.call(this);
        };
        CommitTable.prototype.resetShortcuts = function() {
            PagedTable.prototype.resetShortcuts.call(this);
            events.off('stash.keyboard.shortcuts.disableOpenItemHandler', this._onDisableOpenItemHandler);
            events.off('stash.keyboard.shortcuts.enableOpenItemHandler', this._onEnableOpenItemHandler);
        };

        return CommitTable;
    });

Zerion Mini Shell 1.0