Changeset - d6efaa91e967
kallithea/public/js/base.js
Show inline comments
 
@@ -365,74 +365,74 @@ function _toQueryString(o) {
 
}
 

	
 
/**
 
 * Load HTML into DOM using Ajax
 
 *
 
 * @param $target: load html async and place it (or an error message) here
 
 * @param success: success callback function
 
 * @param args: query parameters to pass to url
 
 */
 
function asynchtml(url, $target, success, args){
 
    if(args===undefined){
 
        args=null;
 
    }
 
    $target.html(_TM['Loading ...']).css('opacity','0.3');
 

	
 
    return $.ajax({url: url, data: args, headers: {'X-PARTIAL-XHR': '1'}, cache: false, dataType: 'html'})
 
        .done(function(html) {
 
                $target.html(html);
 
                $target.css('opacity','1.0');
 
                //execute the given original callback
 
                if (success !== undefined && success) {
 
                    success();
 
                }
 
            })
 
        .fail(function(jqXHR, textStatus, errorThrown) {
 
        .fail(function(jqXHR, textStatus) {
 
                if (textStatus == "abort")
 
                    return;
 
                $target.html('<span class="bg-danger">ERROR: {0}</span>'.format(textStatus));
 
                $target.css('opacity','1.0');
 
            })
 
        ;
 
}
 

	
 
function ajaxGET(url, success, failure) {
 
    if(failure === undefined) {
 
        failure = function(jqXHR, textStatus, errorThrown) {
 
        failure = function(jqXHR, textStatus) {
 
                if (textStatus != "abort")
 
                    alert("Ajax GET error: " + textStatus);
 
            };
 
    }
 
    return $.ajax({url: url, headers: {'X-PARTIAL-XHR': '1'}, cache: false})
 
        .done(success)
 
        .fail(failure);
 
}
 

	
 
function ajaxPOST(url, postData, success, failure) {
 
    postData['_session_csrf_secret_token'] = _session_csrf_secret_token;
 
    var postData = _toQueryString(postData);
 
    if(failure === undefined) {
 
        failure = function(jqXHR, textStatus, errorThrown) {
 
        failure = function(jqXHR, textStatus) {
 
                if (textStatus != "abort")
 
                    alert("Error posting to server: " + textStatus);
 
            };
 
    }
 
    return $.ajax({url: url, data: postData, type: 'POST', headers: {'X-PARTIAL-XHR': '1'}, cache: false})
 
        .done(success)
 
        .fail(failure);
 
}
 

	
 

	
 
/**
 
 * activate .show_more links
 
 * the .show_more must have an id that is the the id of an element to hide prefixed with _
 
 * the parentnode will be displayed
 
 */
 
function show_more_event(){
 
    $('.show_more').click(function(e){
 
        var el = e.currentTarget;
 
        $('#' + el.id.substring(1)).hide();
 
        $(el.parentNode).show();
 
    });
 
}
 

	
 

	
 
@@ -440,49 +440,49 @@ function _onSuccessFollow(target){
 
    var $target = $(target);
 
    var $f_cnt = $('#current_followers_count');
 
    if ($target.hasClass('follow')) {
 
        $target.removeClass('follow').addClass('following');
 
        $target.prop('title', _TM['Stop following this repository']);
 
        if ($f_cnt.html()) {
 
            var cnt = Number($f_cnt.html())+1;
 
            $f_cnt.html(cnt);
 
        }
 
    } else {
 
        $target.removeClass('following').addClass('follow');
 
        $target.prop('title', _TM['Start following this repository']);
 
        if ($f_cnt.html()) {
 
            var cnt = Number($f_cnt.html())-1;
 
            $f_cnt.html(cnt);
 
        }
 
    }
 
}
 

	
 
function toggleFollowingRepo(target, follows_repository_id){
 
    var args = {
 
        'follows_repository_id': follows_repository_id,
 
        '_session_csrf_secret_token': _session_csrf_secret_token
 
    }
 
    $.post(TOGGLE_FOLLOW_URL, args, function(data){
 
    $.post(TOGGLE_FOLLOW_URL, args, function(){
 
            _onSuccessFollow(target);
 
        });
 
    return false;
 
}
 

	
 
function showRepoSize(target, repo_name){
 
    var args = '_session_csrf_secret_token=' + _session_csrf_secret_token;
 

	
 
    if(!$("#" + target).hasClass('loaded')){
 
        $("#" + target).html(_TM['Loading ...']);
 
        var url = pyroutes.url('repo_size', {"repo_name":repo_name});
 
        $.post(url, args, function(data) {
 
            $("#" + target).html(data);
 
            $("#" + target).addClass('loaded');
 
        });
 
    }
 
    return false;
 
}
 

	
 
/**
 
 * load tooltips dynamically based on data attributes, used for .lazy-cs changeset links
 
 */
 
function get_changeset_tooltip() {
 
    var $target = $(this);
 
@@ -534,49 +534,49 @@ function tooltip_activate(){
 
}
 

	
 

	
 
/**
 
 * Quick filter widget
 
 *
 
 * @param target: filter input target
 
 * @param nodes: list of nodes in html we want to filter.
 
 * @param display_element function that takes current node from nodes and
 
 *    does hide or show based on the node
 
 */
 
var q_filter = (function() {
 
    var _namespace = {};
 
    var namespace = function (target) {
 
        if (!(target in _namespace)) {
 
            _namespace[target] = {};
 
        }
 
        return _namespace[target];
 
    };
 
    return function (target, $nodes, display_element) {
 
        var $nodes = $nodes;
 
        var $q_filter_field = $('#' + target);
 
        var F = namespace(target);
 

	
 
        $q_filter_field.keyup(function (e) {
 
        $q_filter_field.keyup(function () {
 
            clearTimeout(F.filterTimeout);
 
            F.filterTimeout = setTimeout(F.updateFilter, 600);
 
        });
 

	
 
        F.filterTimeout = null;
 

	
 
        F.updateFilter = function () {
 
            // Reset timeout
 
            F.filterTimeout = null;
 

	
 
            var obsolete = [];
 

	
 
            var req = $q_filter_field.val().toLowerCase();
 

	
 
            var showing = 0;
 
            $nodes.each(function () {
 
                var n = this;
 
                var target_element = display_element(n);
 
                if (req && n.innerHTML.toLowerCase().indexOf(req) == -1) {
 
                    $(target_element).hide();
 
                }
 
                else {
 
                    $(target_element).show();
 
                    showing += 1;
 
@@ -642,49 +642,49 @@ function _get_add_comment_div(target_id)
 
// Set $comment_div state - showing or not showing form and Add button.
 
// An Add button is shown on non-empty forms when no form is shown.
 
// The form is controlled by show_form_opt - if undefined, form is only shown for general comments.
 
function comment_div_state($comment_div, f_path, line_no, show_form_opt) {
 
    var show_form = show_form_opt !== undefined ? show_form_opt : !f_path && !line_no;
 
    var $forms = $comment_div.children('.comment-inline-form');
 
    var $buttonrow = $comment_div.children('.add-button-row');
 
    var $comments = $comment_div.children('.comment:not(.submitting)');
 
    $forms.remove();
 
    $buttonrow.remove();
 
    if (show_form) {
 
        _comment_div_append_form($comment_div, f_path, line_no);
 
    } else if ($comments.length) {
 
        _comment_div_append_add($comment_div, f_path, line_no);
 
    } else {
 
        $comment_div.parent('tr').remove();
 
    }
 
}
 

	
 
// append an Add button to $comment_div and hook it up to show form
 
function _comment_div_append_add($comment_div, f_path, line_no) {
 
    var addlabel = TRANSLATION_MAP['Add Another Comment'];
 
    var $add = $('<div class="add-button-row"><span class="btn btn-default btn-xs add-button">{0}</span></div>'.format(addlabel));
 
    $comment_div.append($add);
 
    $add.children('.add-button').click(function(e) {
 
    $add.children('.add-button').click(function() {
 
        comment_div_state($comment_div, f_path, line_no, true);
 
    });
 
}
 

	
 
// append a comment form to $comment_div
 
function _comment_div_append_form($comment_div, f_path, line_no) {
 
    var $form_div = $('#comment-inline-form-template').children()
 
        .clone()
 
        .addClass('comment-inline-form');
 
    $comment_div.append($form_div);
 
    var $preview = $comment_div.find("div.comment-preview");
 
    var $form = $comment_div.find("form");
 
    var $textarea = $form.find('textarea');
 

	
 
    $form.submit(function(e) {
 
        e.preventDefault();
 

	
 
        var text = $textarea.val();
 
        var review_status = $form.find('input:radio[name=changeset_status]:checked').val();
 
        var pr_close = $form.find('input:checkbox[name=save_close]:checked').length ? 'on' : '';
 
        var pr_delete = $form.find('input:checkbox[name=save_delete]:checked').length ? 'delete' : '';
 

	
 
        if (!text && !review_status && !pr_close && !pr_delete) {
 
            alert("Please provide a comment");
 
@@ -750,85 +750,85 @@ function _comment_div_append_form($comme
 
            }).replaceAll($status.contents());
 
            $('<div>', {
 
                'class': 'btn-group'
 
            }).append(
 
                $('<button>', {
 
                    'class': 'btn btn-default btn-xs',
 
                    text: _TM['Retry']
 
                }).click(function() {
 
                    $status.text(_TM['Submitting ...']);
 
                    $preview.addClass('submitting').removeClass('failed');
 
                    ajaxPOST(AJAX_COMMENT_URL, postData, success, failure);
 
                }),
 
                $('<button>', {
 
                    'class': 'btn btn-default btn-xs',
 
                    text: _TM['Cancel']
 
                }).click(function() {
 
                    comment_div_state($comment_div, f_path, line_no);
 
                })
 
            ).appendTo($status);
 
        }
 
        ajaxPOST(AJAX_COMMENT_URL, postData, success, failure);
 
    });
 

	
 
    // add event handler for hide/cancel buttons
 
    $form.find('.hide-inline-form').click(function(e) {
 
    $form.find('.hide-inline-form').click(function() {
 
        comment_div_state($comment_div, f_path, line_no);
 
    });
 

	
 
    tooltip_activate();
 
    if ($textarea.length > 0) {
 
        MentionsAutoComplete($textarea);
 
    }
 
    if (f_path) {
 
        $textarea.focus();
 
    }
 
}
 

	
 

	
 
function deleteComment(comment_id) {
 
    var url = AJAX_COMMENT_DELETE_URL.replace('__COMMENT_ID__', comment_id);
 
    var postData = {};
 
    function success(o) {
 
    function success() {
 
        $('#comment-'+comment_id).remove();
 
        // Ignore that this might leave a stray Add button (or have a pending form with another comment) ...
 
    }
 
    ajaxPOST(url, postData, success);
 
}
 

	
 

	
 
/**
 
 * Double link comments
 
 */
 
function linkInlineComments($firstlinks, $comments){
 
    if ($comments.length > 0) {
 
        $firstlinks.html('<a href="#{0}">First comment</a>'.format($comments.prop('id')));
 
    }
 
    if ($comments.length <= 1) {
 
        return;
 
    }
 

	
 
    $comments.each(function(i, e){
 
    $comments.each(function(i){
 
            var prev = '';
 
            if (i > 0){
 
                var prev_anchor = $($comments.get(i-1)).prop('id');
 
                prev = '<a href="#{0}">Previous comment</a>'.format(prev_anchor);
 
            }
 
            var next = '';
 
            if (i+1 < $comments.length){
 
                var next_anchor = $($comments.get(i+1)).prop('id');
 
                next = '<a href="#{0}">Next comment</a>'.format(next_anchor);
 
            }
 
            $(this).find('.comment-prev-next-links').html(
 
                '<div class="prev-comment">{0}</div>'.format(prev) +
 
                '<div class="next-comment">{0}</div>'.format(next));
 
        });
 
}
 

	
 
/* activate files.html stuff */
 
function fileBrowserListeners(node_list_url, url_base){
 
    var $node_filter = $('#node_filter');
 

	
 
    var filterTimeout = null;
 
    var nodes = null;
 

	
 
    function initFilter(){
 
@@ -905,90 +905,90 @@ function fileBrowserListeners(node_list_
 
            initFilter();
 
        });
 
    $node_filter.click(function(){
 
            if($node_filter.hasClass('init')){
 
                $node_filter.val('');
 
                $node_filter.removeClass('init');
 
            }
 
        });
 
    $node_filter.keyup(function(e){
 
            clearTimeout(filterTimeout);
 
            filterTimeout = setTimeout(updateFilter(e),600);
 
        });
 
}
 

	
 

	
 
function initCodeMirror(textarea_id, baseUrl, resetUrl){
 
    var myCodeMirror = CodeMirror.fromTextArea($('#' + textarea_id)[0], {
 
            mode: "null",
 
            lineNumbers: true,
 
            indentUnit: 4,
 
            autofocus: true
 
        });
 
    CodeMirror.modeURL = baseUrl + "/codemirror/mode/%N/%N.js";
 

	
 
    $('#reset').click(function(e){
 
    $('#reset').click(function(){
 
            window.location=resetUrl;
 
        });
 

	
 
    $('#file_enable').click(function(){
 
            $('#upload_file_container').hide();
 
            $('#filename_container').show();
 
            $('#body').show();
 
        });
 

	
 
    $('#upload_file_enable').click(function(){
 
            $('#upload_file_container').show();
 
            $('#filename_container').hide();
 
            $('#body').hide();
 
        });
 

	
 
    return myCodeMirror
 
}
 

	
 
function setCodeMirrorMode(codeMirrorInstance, mode) {
 
    CodeMirror.autoLoadMode(codeMirrorInstance, mode);
 
}
 

	
 

	
 
function _getIdentNode(n){
 
    //iterate thrugh nodes until matching interesting node
 

	
 
    if (typeof n == 'undefined'){
 
        return -1
 
    }
 

	
 
    if(typeof n.id != "undefined" && n.id.match('L[0-9]+')){
 
        return n
 
    }
 
    else{
 
        return _getIdentNode(n.parentNode);
 
    }
 
}
 

	
 
/* generate links for multi line selects that can be shown by files.html page_highlights.
 
 * This is a mouseup handler for hlcode from CodeHtmlFormatter and pygmentize */
 
function getSelectionLink(e) {
 
function getSelectionLink() {
 
    //get selection from start/to nodes
 
    if (typeof window.getSelection != "undefined") {
 
        var s = window.getSelection();
 

	
 
        var from = _getIdentNode(s.anchorNode);
 
        var till = _getIdentNode(s.focusNode);
 

	
 
        var f_int = parseInt(from.id.replace('L',''));
 
        var t_int = parseInt(till.id.replace('L',''));
 

	
 
        var yoffset = 35;
 
        var ranges = [parseInt(from.id.replace('L','')), parseInt(till.id.replace('L',''))];
 
        if (ranges[0] > ranges[1]){
 
            //highlight from bottom
 
            yoffset = -yoffset;
 
            ranges = [ranges[1], ranges[0]];
 
        }
 
        var $hl_div = $('div#linktt');
 
        // if we select more than 2 lines
 
        if (ranges[0] != ranges[1]){
 
            if ($hl_div.length) {
 
                $hl_div.html('');
 
            } else {
 
                $hl_div = $('<div id="linktt" class="hl-tip-box">');
 
@@ -1115,109 +1115,109 @@ function autocompleteFormatter(oResultDa
 
    }
 

	
 
    return '';
 
}
 

	
 
function SimpleUserAutoComplete($inputElement) {
 
    $inputElement.select2({
 
        formatInputTooShort: $inputElement.attr('placeholder'),
 
        initSelection : function (element, callback) {
 
            $.ajax({
 
                url: pyroutes.url('users_and_groups_data'),
 
                dataType: 'json',
 
                data: {
 
                    key: element.val()
 
                },
 
                success: function(data){
 
                  callback(data.results[0]);
 
                }
 
            });
 
        },
 
        minimumInputLength: 1,
 
        ajax: {
 
            url: pyroutes.url('users_and_groups_data'),
 
            dataType: 'json',
 
            data: function(term, page){
 
            data: function(term){
 
              return {
 
                query: term
 
              };
 
            },
 
            results: function (data, page){
 
            results: function (data){
 
              return data;
 
            },
 
            cache: true
 
        },
 
        formatSelection: autocompleteFormatter,
 
        formatResult: autocompleteFormatter,
 
        id: function(item) { return item.nname; },
 
    });
 
}
 

	
 
function MembersAutoComplete($inputElement, $typeElement) {
 

	
 
    $inputElement.select2({
 
        placeholder: $inputElement.attr('placeholder'),
 
        minimumInputLength: 1,
 
        ajax: {
 
            url: pyroutes.url('users_and_groups_data'),
 
            dataType: 'json',
 
            data: function(term, page){
 
            data: function(term){
 
              return {
 
                query: term,
 
                types: 'users,groups'
 
              };
 
            },
 
            results: function (data, page){
 
            results: function (data){
 
              return data;
 
            },
 
            cache: true
 
        },
 
        formatSelection: autocompleteFormatter,
 
        formatResult: autocompleteFormatter,
 
        id: function(item) { return item.type == 'user' ? item.nname : item.grname },
 
    }).on("select2-selecting", function(e) {
 
        // e.choice.id is automatically used as selection value - just set the type of the selection
 
        $typeElement.val(e.choice.type);
 
    });
 
}
 

	
 
function MentionsAutoComplete($inputElement) {
 
  $inputElement.atwho({
 
    at: "@",
 
    callbacks: {
 
      remoteFilter: function(query, callback) {
 
        $.getJSON(
 
          pyroutes.url('users_and_groups_data'),
 
          {
 
            query: query,
 
            types: 'users'
 
          },
 
          function(data) {
 
            callback(data.results)
 
          }
 
        );
 
      },
 
      sorter: function(query, items, searchKey) {
 
      sorter: function(query, items) {
 
        return items;
 
      }
 
    },
 
    displayTpl: function(item) {
 
        return "<li>" +
 
            autocompleteGravatar(
 
                "{0} {1} ({2})".format(item.fname, item.lname, item.nname).html_escape(),
 
                '${gravatar_lnk}', 16) +
 
            "</li>";
 
    },
 
    insertTpl: "${atwho-at}${nname}"
 
  });
 
}
 

	
 

	
 
// Set caret at the given position in the input element
 
function _setCaretPosition($inputElement, caretPos) {
 
    $inputElement.each(function(){
 
        if(this.createTextRange) { // IE
 
            var range = this.createTextRange();
 
            range.move('character', caretPos);
 
            range.select();
 
        }
 
        else if(this.selectionStart) { // other recent browsers
 
@@ -1246,150 +1246,150 @@ function addReviewMember(id,fname,lname,
 
        '         <span class="reviewer_status" data-toggle="tooltip" title="not_reviewed">\n'+
 
        '             <i class="icon-circle changeset-status-not_reviewed"></i>\n'+
 
        '         </span>\n'+
 
        (gravatarelm ?
 
        '         {0}\n' :
 
        '')+
 
        '         <span>{1}</span>\n'+
 
        '         <a href="#" class="reviewer_member_remove" onclick="removeReviewMember({2})">\n'+
 
        '             <i class="icon-minus-circled"></i>\n'+
 
        '         </a> (add not saved)\n'+
 
        '       </span>\n'+
 
        '     </li>\n'
 
        ).format(gravatarelm, displayname.html_escape(), id);
 
    // check if we don't have this ID already in
 
    var ids = [];
 
    $('#review_members').find('li').each(function() {
 
            ids.push(this.id);
 
        });
 
    if(ids.indexOf('reviewer_'+id) == -1){
 
        //only add if it's not there
 
        $('#review_members').append(element);
 
    }
 
}
 

	
 
function removeReviewMember(reviewer_id, repo_name, pull_request_id){
 
function removeReviewMember(reviewer_id){
 
    var $li = $('#reviewer_{0}'.format(reviewer_id));
 
    $li.find('div div').css("text-decoration", "line-through");
 
    $li.find('input').prop('name', 'review_members_removed');
 
    $li.find('.reviewer_member_remove').replaceWith('&nbsp;(remove not saved)');
 
}
 

	
 
/* activate auto completion of users as PR reviewers */
 
function PullRequestAutoComplete($inputElement) {
 
    $inputElement.select2(
 
    {
 
        placeholder: $inputElement.attr('placeholder'),
 
        minimumInputLength: 1,
 
        ajax: {
 
            url: pyroutes.url('users_and_groups_data'),
 
            dataType: 'json',
 
            data: function(term, page){
 
            data: function(term){
 
              return {
 
                query: term
 
              };
 
            },
 
            results: function (data, page){
 
            results: function (data){
 
              return data;
 
            },
 
            cache: true
 
        },
 
        formatSelection: autocompleteFormatter,
 
        formatResult: autocompleteFormatter,
 
    }).on("select2-selecting", function(e) {
 
        addReviewMember(e.choice.id, e.choice.fname, e.choice.lname, e.choice.nname,
 
                        e.choice.gravatar_lnk, e.choice.gravatar_size);
 
        $inputElement.select2("close");
 
        e.preventDefault();
 
    });
 
}
 

	
 

	
 
function addPermAction(perm_type) {
 
    var template =
 
        '<td><input type="radio" value="{1}.none" name="perm_new_member_{0}" id="perm_new_member_{0}"></td>' +
 
        '<td><input type="radio" value="{1}.read" checked="checked" name="perm_new_member_{0}" id="perm_new_member_{0}"></td>' +
 
        '<td><input type="radio" value="{1}.write" name="perm_new_member_{0}" id="perm_new_member_{0}"></td>' +
 
        '<td><input type="radio" value="{1}.admin" name="perm_new_member_{0}" id="perm_new_member_{0}"></td>' +
 
        '<td>' +
 
                '<input class="form-control" id="perm_new_member_name_{0}" name="perm_new_member_name_{0}" value="" type="text" placeholder="{2}">' +
 
                '<input id="perm_new_member_type_{0}" name="perm_new_member_type_{0}" value="" type="hidden">' +
 
        '</td>' +
 
        '<td></td>';
 
    var $last_node = $('.last_new_member').last(); // empty tr between last and add
 
    var next_id = $('.new_members').length;
 
    $last_node.before($('<tr class="new_members">').append(template.format(next_id, perm_type, _TM['Type name of user or member to grant permission'])));
 
    MembersAutoComplete($("#perm_new_member_name_"+next_id), $("#perm_new_member_type_"+next_id));
 
}
 

	
 
function ajaxActionRevokePermission(url, obj_id, obj_type, field_id, extra_data) {
 
    function success(o) {
 
    function success() {
 
            $('#' + field_id).remove();
 
        }
 
    function failure(o) {
 
            alert(_TM['Failed to revoke permission'] + ": " + o.status);
 
        }
 
    var query_params = {};
 
    // put extra data into POST
 
    if (extra_data !== undefined && (typeof extra_data === 'object')){
 
        for(var k in extra_data){
 
            query_params[k] = extra_data[k];
 
        }
 
    }
 

	
 
    if (obj_type=='user'){
 
        query_params['user_id'] = obj_id;
 
        query_params['obj_type'] = 'user';
 
    }
 
    else if (obj_type=='user_group'){
 
        query_params['user_group_id'] = obj_id;
 
        query_params['obj_type'] = 'user_group';
 
    }
 

	
 
    ajaxPOST(url, query_params, success, failure);
 
}
 

	
 
/* Multi selectors */
 

	
 
function MultiSelectWidget(selected_id, available_id, form_id){
 
    var $availableselect = $('#' + available_id);
 
    var $selectedselect = $('#' + selected_id);
 

	
 
    //fill available only with those not in selected
 
    var $selectedoptions = $selectedselect.children('option');
 
    $availableselect.children('option').filter(function(i, e){
 
            for(var j = 0, node; node = $selectedoptions[j]; j++){
 
                if(node.value == e.value){
 
                    return true;
 
                }
 
            }
 
            return false;
 
        }).remove();
 

	
 
    $('#add_element').click(function(e){
 
    $('#add_element').click(function(){
 
            $selectedselect.append($availableselect.children('option:selected'));
 
        });
 
    $('#remove_element').click(function(e){
 
    $('#remove_element').click(function(){
 
            $availableselect.append($selectedselect.children('option:selected'));
 
        });
 

	
 
    $('#'+form_id).submit(function(){
 
            $selectedselect.children('option').each(function(i, e){
 
                e.selected = 'selected';
 
            });
 
        });
 
}
 

	
 

	
 
/**
 
 Branch Sorting callback for select2, modifying the filtered result so prefix
 
 matches come before matches in the line.
 
 **/
 
function branchSort(results, container, query) {
 
    if (query.term) {
 
        return results.sort(function (a, b) {
 
            // Put closed branches after open ones (a bit of a hack ...)
 
            var aClosed = a.text.indexOf("(closed)") > -1,
 
                bClosed = b.text.indexOf("(closed)") > -1;
 
            if (aClosed && !bClosed) {
 
                return 1;
 
            }
kallithea/public/js/graph.js
Show inline comments
 
@@ -13,49 +13,49 @@
 
// This software may be used and distributed according to the terms
 
// of the GNU General Public License, incorporated herein by reference.
 

	
 
var colors = [
 
	[ 1.0, 0.0, 0.0 ],
 
	[ 1.0, 1.0, 0.0 ],
 
	[ 0.0, 1.0, 0.0 ],
 
	[ 0.0, 1.0, 1.0 ],
 
	[ 0.0, 0.0, 1.0 ],
 
	[ 1.0, 0.0, 1.0 ],
 
	[ 1.0, 1.0, 0.0 ],
 
	[ 0.0, 0.0, 0.0 ]
 
];
 

	
 
function BranchRenderer(canvas_id, content_id, row_id_prefix) {
 
	// canvas_id is canvas to render into
 
	// content_id's height is applied to canvas
 
	// row_id_prefix is prefix that is applied to get row id's
 
	this.canvas = document.getElementById(canvas_id);
 
	var content = document.getElementById(content_id);
 

	
 
	if (!document.createElement("canvas").getContext)
 
		this.canvas = window.G_vmlCanvasManager.initElement(this.canvas);
 
	if (!this.canvas) { // canvas creation did for some reason fail - fail silently
 
		this.render = function(data) {};
 
		this.render = function() {};
 
		return;
 
	}
 
	this.ctx = this.canvas.getContext('2d');
 
	this.ctx.strokeStyle = 'rgb(0, 0, 0)';
 
	this.ctx.fillStyle = 'rgb(0, 0, 0)';
 
	this.cur = [0, 0];
 
	this.line_width = 2.0;
 
	this.dot_radius = 3.5;
 
	this.close_x = 1.5 * this.dot_radius;
 
	this.close_y = 0.5 * this.dot_radius;
 

	
 
	this.calcColor = function(color, bg, fg) {
 
		color %= colors.length;
 
		var red = (colors[color][0] * fg) || bg;
 
		var green = (colors[color][1] * fg) || bg;
 
		var blue = (colors[color][2] * fg) || bg;
 
		red = Math.round(red * 255);
 
		green = Math.round(green * 255);
 
		blue = Math.round(blue * 255);
 
		var s = 'rgb(' + red + ', ' + green + ', ' + blue + ')';
 
		return s;
 
	}
 

	
 
	this.setColor = function(color, bg, fg) {
kallithea/templates/admin/auth/auth_settings.html
Show inline comments
 
@@ -87,48 +87,48 @@
 
                    <span class="help-block">${setting["description"]}</span>
 
                </div>
 
            </div>
 
            %else:
 
            <div class="form-group">
 
                <label class="control-label" for="${fullsetting}">${_(displayname)}</label>
 
                <div>This field is of type ${setting['type']}, which cannot be displayed. Must be one of [string|int|bool|select].</div>
 
                <span class="help-block">${setting["description"]}</span>
 
            </div>
 
            %endif
 
        %endfor
 
    %endfor
 
            <div class="form-group">
 
                <div class="buttons">
 
                    ${h.submit('save',_('Save'),class_="btn btn-default")}
 
                </div>
 
            </div>
 
    ${h.end_form()}
 
    </div>
 
</div>
 

	
 
<script>'use strict';
 
    $('.toggle-plugin').click(function(e){
 
        var $auth_plugins_input = $('#auth_plugins');
 
        function notEmpty(element, index, array) {
 
        function notEmpty(element) {
 
            return (element != "");
 
        }
 
        var elems = $auth_plugins_input.val().split(',').filter(notEmpty);
 
        var $cur_button = $(e.currentTarget);
 
        var plugin_id = $cur_button.data('plugin_id');
 

	
 
        if($cur_button.hasClass('active')){
 
            elems.splice(elems.indexOf(plugin_id), 1);
 
            $auth_plugins_input.val(elems.join(','));
 
            $cur_button.removeClass('active');
 
            $cur_button.html(_TM['Disabled']);
 
        }
 
        else{
 
            if(elems.indexOf(plugin_id) == -1){
 
                elems.push(plugin_id);
 
            }
 
            $auth_plugins_input.val(elems.join(','));
 
            $cur_button.addClass('active');
 
            $cur_button.html(_TM['Enabled']);
 
        }
 
    });
 
</script>
 
</%def>
kallithea/templates/admin/gists/edit.html
Show inline comments
 
@@ -96,49 +96,49 @@
 
                                    // default plain text
 
                                    $(opt).prop('selected', true);
 
                                    modes_select.options[0] = opt;
 
                                } else {
 
                                    modes_select.options[index++] = opt;
 
                                }
 
                            }
 
                        });
 

	
 
                        var $filename_input = $(${h.js('#filename_' + h.FID('f',file.path))});
 
                        // on select change set new mode
 
                        $mimetype_select.change(function(e){
 
                            var selected = e.currentTarget;
 
                            var node = selected.options[selected.selectedIndex];
 
                            var detected_mode = CodeMirror.findModeByMIME(node.value);
 
                            setCodeMirrorMode(myCodeMirror, detected_mode);
 

	
 
                            var proposed_ext = CodeMirror.findExtensionByMode(detected_mode);
 
                            var file_data = CodeMirror.getFilenameAndExt($filename_input.val());
 
                            var filename = file_data['filename'] || 'filename1';
 
                            $filename_input.val(filename + '.' + proposed_ext);
 
                        });
 

	
 
                        // on type the new filename set mode
 
                        $filename_input.keyup(function(e){
 
                        $filename_input.keyup(function(){
 
                            var file_data = CodeMirror.getFilenameAndExt(this.value);
 
                            if(file_data['ext'] != null){
 
                                var detected_mode = CodeMirror.findModeByExtension(file_data['ext']) || CodeMirror.findModeByMIME('text/plain');
 

	
 
                                if (detected_mode){
 
                                    setCodeMirrorMode(myCodeMirror, detected_mode);
 
                                    $mimetype_select.val(detected_mode.mime);
 
                                }
 
                            }
 
                        });
 

	
 
                        // set mode on page load
 
                        var detected_mode = CodeMirror.findModeByExtension(${h.js(file.extension)});
 

	
 
                        if (detected_mode){
 
                            setCodeMirrorMode(myCodeMirror, detected_mode);
 
                            $mimetype_select.val(detected_mode.mime);
 
                        }
 
                    });
 
                </script>
 

	
 
            %endfor
 

	
 
            <div>
kallithea/templates/admin/gists/new.html
Show inline comments
 
@@ -72,41 +72,41 @@
 
                            // default plain text
 
                            $(opt).prop('selected', true);
 
                            modes_select.options[0] = opt;
 
                        } else {
 
                            modes_select.options[index++] = opt;
 
                        }
 
                    }
 
                });
 

	
 
                var $filename_input = $('#filename');
 
                // on select change set new mode
 
                $mimetype_select.change(function(e){
 
                    var selected = e.currentTarget;
 
                    var node = selected.options[selected.selectedIndex];
 
                    var detected_mode = CodeMirror.findModeByMIME(node.value);
 
                    setCodeMirrorMode(myCodeMirror, detected_mode);
 

	
 
                    var proposed_ext = CodeMirror.findExtensionByMode(detected_mode);
 
                    var file_data = CodeMirror.getFilenameAndExt($filename_input.val());
 
                    var filename = file_data['filename'] || 'filename1';
 
                    $filename_input.val(filename + '.' + proposed_ext);
 
                });
 

	
 
                // on type the new filename set mode
 
                $filename_input.keyup(function(e){
 
                $filename_input.keyup(function(){
 
                    var file_data = CodeMirror.getFilenameAndExt(this.value);
 
                    if(file_data['ext'] != null){
 
                        var detected_mode = CodeMirror.findModeByExtension(file_data['ext']) || CodeMirror.findModeByMIME('text/plain');
 
                        if (detected_mode){
 
                            setCodeMirrorMode(myCodeMirror, detected_mode);
 
                            $mimetype_select.val(detected_mode.mime);
 
                        }
 
                    }
 
                });
 
            });
 
          </script>
 
        </div>
 
    </div>
 

	
 
</div>
 
</%def>
kallithea/templates/admin/repos/repo_creating.html
Show inline comments
 
@@ -31,37 +31,37 @@
 
            <div class="progress progress-striped active">
 
                <div class="progress-bar" role="progressbar"
 
                    aria-valuenow="100" aria-valuemin="0" aria-valuemax="100">
 
                </div>
 
            </div>
 
        </div>
 
        <div id="progress_error" style="display: none;">
 
            <div class="alert alert-danger">
 
                ${_("We're sorry but error occurred during this operation. Please check your Kallithea server logs, or contact administrator.")}
 
            </div>
 
        </div>
 
    </div>
 
</div>
 

	
 
<script>'use strict';
 
(function worker() {
 
  $.ajax({
 
    url: ${h.js(h.url('repo_check_home', repo_name=c.repo_name, repo=c.repo, task_id=c.task_id))},
 
    success: function(data) {
 
      if(data.result === true){
 
          //redirect to created fork if our ajax loop tells us to do so.
 
          window.location = ${h.js(h.url('summary_home', repo_name = c.repo))};
 
      }
 
    },
 
    complete: function(resp, status) {
 
    complete: function(resp) {
 
      if (resp.status == 200){
 
          // Schedule the next request when the current one's complete
 
          setTimeout(worker, 1000);
 
      }
 
      else{
 
          $("#progress").html($('#progress_error').html());
 
      }
 
    }
 
  });
 
})();
 
</script>
 
</%def>
kallithea/templates/admin/settings/settings_hooks.html
Show inline comments
 
@@ -32,34 +32,34 @@ ${h.form(url('admin_settings_hooks'), me
 
                    </div>
 
            </div>
 
        %endfor
 

	
 
        <div class="form-group form-inline">
 
            <label>
 
                ${h.text('new_hook_ui_key',size=15,class_='form-control')}
 
            </label>
 
            <div>
 
                ${h.text('new_hook_ui_value',size=50,class_='form-control')}
 
            </div>
 
        </div>
 
        <div class="form-group">
 
            <div class="buttons">
 
                ${h.submit('save',_('Save'),class_="btn btn-default")}
 
            </div>
 
        </div>
 
</div>
 
${h.end_form()}
 
% endif
 

	
 
<script>'use strict';
 
function delete_hook(hook_id, field_id) {
 
    var sUrl = ${h.js(h.url('admin_settings_hooks_delete'))};
 
    function success(o) {
 
    function success() {
 
            $('#' + field_id).remove();
 
        }
 
    function failure(o) {
 
    function failure() {
 
            alert(${h.js(_('Failed to remove hook'))});
 
        }
 
    var postData = {'hook_id': hook_id};
 
    ajaxPOST(sUrl, postData, success, failure);
 
}
 
</script>
kallithea/templates/admin/settings/settings_vcs.html
Show inline comments
 
@@ -50,31 +50,31 @@ ${h.form(url('admin_settings'), method='
 
                        ${h.text('paths_root_path',size=60,readonly="readonly",class_='form-control')}
 
                        <span id="path_unlock" data-toggle="tooltip" class="input-group-btn"
 
                            title="${_('Click to unlock. You must restart Kallithea in order to make this setting take effect.')}">
 
                            <button type="button" class="btn btn-default btn-sm"><i id="path_unlock_icon" class="icon-lock"></i></button>
 
                        </span>
 
                    </div>
 
                    <span class="help-block">${_('Filesystem location where repositories are stored. After changing this value, a restart and rescan of the repository folder are both required.')}</span>
 
                </div>
 
            </div>
 
            %else:
 
            ## form still requires this but we cannot internally change it anyway
 
            ${h.hidden('paths_root_path',size=30,readonly="readonly")}
 
            %endif
 
            <div class="form-group">
 
                <div class="buttons">
 
                    ${h.submit('save',_('Save Settings'),class_="btn btn-default")}
 
                    ${h.reset('reset',_('Reset'),class_="btn btn-default")}
 
                </div>
 
           </div>
 
    </div>
 
    ${h.end_form()}
 

	
 
    <script>'use strict';
 
        $(document).ready(function(){
 
            $('#path_unlock').on('click', function(e){
 
            $('#path_unlock').on('click', function(){
 
                $('#path_unlock_icon').removeClass('icon-lock');
 
                $('#path_unlock_icon').addClass('icon-lock-open-alt');
 
                $('#paths_root_path').removeAttr('readonly');
 
            });
 
        });
 
    </script>
kallithea/templates/base/base.html
Show inline comments
 
@@ -171,49 +171,49 @@
 
                  <li><a href="${h.url('repo_fork_home',repo_name=c.repo_name)}"><i class="icon-fork"></i>${_('Fork')}</a></li>
 
                  <li><a href="${h.url('pullrequest_home',repo_name=c.repo_name)}"><i class="icon-git-pull-request"></i>${_('Create Pull Request')}</a></li>
 
              %endif
 
             </ul>
 
        </li>
 
    </ul>
 
    </div>
 
    </div>
 
  </nav>
 
  <script>'use strict';
 
    $(document).ready(function() {
 
      var bcache = {};
 

	
 
      var branch_switcher_placeholder = '<i class="icon-exchange"></i>' + ${h.jshtml(_('Switch To'))} + ' <span class="caret"></span>';
 
      $("#branch_switcher").select2({
 
          placeholder: branch_switcher_placeholder,
 
          dropdownAutoWidth: true,
 
          sortResults: prefixFirstSort,
 
          formatResult: function(obj) {
 
              return obj.text.html_escape();
 
          },
 
          formatSelection: function(obj) {
 
              return obj.text.html_escape();
 
          },
 
          formatNoMatches: function(term) {
 
          formatNoMatches: function() {
 
              return ${h.jshtml(_('No matches found'))};
 
          },
 
          escapeMarkup: function(m) {
 
              if (m == branch_switcher_placeholder)
 
                  return branch_switcher_placeholder;
 
              return Select2.util.escapeMarkup(m);
 
          },
 
          containerCssClass: "branch-switcher",
 
          dropdownCssClass: "repo-switcher-dropdown",
 
          query: function(query) {
 
              var key = 'cache';
 
              var cached = bcache[key];
 
              if (cached) {
 
                  var data = {
 
                      results: []
 
                  };
 
                  // filter results
 
                  $.each(cached.results, function() {
 
                      var section = this.text;
 
                      var children = [];
 
                      $.each(this.children, function() {
 
                          if (query.term.length === 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0) {
 
                              children.push({
 
                                  'id': this.id,
 
@@ -420,49 +420,49 @@
 
                        tmpl += '<span class="label label-repo" title="${_('Git repository')}">git</span> ';
 
                    }
 
                    if(obj_dict['private']){
 
                        tmpl += '<i class="icon-lock"></i>';
 
                    }
 
                    else if(visual_show_public_icon){
 
                        tmpl += '<i class="icon-globe"></i>';
 
                    }
 
                    tmpl += '</span>';
 
                }
 
                if(obj_dict && state.type == 'group'){
 
                        tmpl += '<i class="icon-folder"></i>';
 
                }
 
                tmpl += state.text.html_escape();
 
                return tmpl;
 
            }
 

	
 
            var repo_switcher_placeholder = '<i class="icon-database"></i>' + ${h.jshtml(_('Repositories'))} + ' <span class="caret"></span>';
 
            $("#repo_switcher").select2({
 
                placeholder: repo_switcher_placeholder,
 
                dropdownAutoWidth: true,
 
                sortResults: prefixFirstSort,
 
                formatResult: format,
 
                formatSelection: format,
 
                formatNoMatches: function(term){
 
                formatNoMatches: function(){
 
                    return ${h.jshtml(_('No matches found'))};
 
                },
 
                containerCssClass: "repo-switcher",
 
                dropdownCssClass: "repo-switcher-dropdown",
 
                escapeMarkup: function(m){
 
                    if (m == repo_switcher_placeholder)
 
                        return repo_switcher_placeholder;
 
                    return Select2.util.escapeMarkup(m);
 
                },
 
                query: function(query){
 
                  var key = 'cache';
 
                  var cached = cache[key] ;
 
                  if(cached) {
 
                    var data = {results: []};
 
                    //filter results
 
                    $.each(cached.results, function(){
 
                        var section = this.text;
 
                        var children = [];
 
                        $.each(this.children, function(){
 
                            if(query.term.length == 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0 ){
 
                                children.push({'id': this.id, 'text': this.text, 'type': this.type, 'obj': this.obj});
 
                            }
 
                        });
 
                        if(children.length !== 0){
kallithea/templates/base/perms_summary.html
Show inline comments
 
@@ -90,41 +90,41 @@
 
                  %endif
 
              %endfor
 
              <tr id="empty_${section}" style="display: none"><td colspan="${3 if actions else 2}">${_('No permission defined')}</td></tr>
 
              </tbody>
 
          %endif
 
         </table>
 
        </div>
 
        %endif
 
     %endfor
 
</div>
 
<script>'use strict';
 
    $(document).ready(function(){
 
        function show_empty(section){
 
            var visible = $('.section_{0} tr.perm_row:visible'.format(section)).length;
 
            if(visible == 0){
 
                $('#empty_{0}'.format(section)).show();
 
            }
 
            else{
 
                $('#empty_{0}'.format(section)).hide();
 
            }
 
        }
 
        function update_show($checkbox){
 
            var section = $checkbox.data('section');
 

	
 
            var elems = $('.filter_' + section).each(function(el){
 
            var elems = $('.filter_' + section).each(function(){
 
                var perm_type = $checkbox.data('perm_type');
 
                var checked = $checkbox.prop('checked');
 
                if(checked){
 
                    $('.'+section+'_'+perm_type).show();
 
                }
 
                else{
 
                    $('.'+section+'_'+perm_type).hide();
 
                }
 
            });
 
            show_empty(section);
 
        }
 
        $('.perm_filter').on('change', function(){update_show($(this));});
 
        $('.perm_filter[value=none]').each(function(){this.checked = false; update_show($(this));});
 
    });
 
</script>
 
</%def>
kallithea/templates/changelog/changelog.html
Show inline comments
 
@@ -69,49 +69,49 @@ ${self.repo_context_bar('changelog', c.f
 
                <div id="graph_nodes">
 
                    <canvas id="graph_canvas" style="width:0"></canvas>
 
                </div>
 

	
 
                <div id="graph_content" style="${'margin: 0px' if c.changelog_for_path else ''}">
 
                  ${changelog_table.changelog(c.repo_name, c.cs_pagination, c.cs_statuses, c.cs_comments,
 
                                              show_checkbox=not c.changelog_for_path,
 
                                              show_branch=not c.branch_name,
 
                                              resize_js='graph.render(jsdata)')}
 
                  <input type="checkbox" id="singlerange" style="display:none"/>
 
                </div>
 

	
 
                ${c.cs_pagination.pager()}
 

	
 
        <script src="${h.url('/js/graph.js', ver=c.kallithea_version)}"></script>
 
        <script>'use strict';
 
            var jsdata = ${h.js(c.jsdata)};
 
            var graph = new BranchRenderer('graph_canvas', 'graph_content', 'chg_');
 

	
 
            $(document).ready(function(){
 
                var $checkboxes = $('.changeset_range');
 

	
 
                pyroutes.register('changeset_home', ${h.js(h.url('changeset_home', repo_name='%(repo_name)s', revision='%(revision)s'))}, ['repo_name', 'revision']);
 

	
 
                function checkbox_checker(e) {
 
                function checkbox_checker() {
 
                    var $checked_checkboxes = $checkboxes.filter(':checked');
 
                    var $singlerange = $('#singlerange');
 

	
 
                    $('#rev_range_container').hide();
 
                    $checkboxes.show();
 
                    $singlerange.show();
 

	
 
                    if ($checked_checkboxes.length > 0) {
 
                        $checked_checkboxes.first().parent('td').append($singlerange);
 
                        var singlerange = $singlerange.prop('checked');
 
                        var rev_end = $checked_checkboxes.first().prop('name');
 
                        if ($checked_checkboxes.length > 1 || singlerange) {
 
                            var rev_start = $checked_checkboxes.last().prop('name');
 
                            $('#rev_range_container').prop('href',
 
                                pyroutes.url('changeset_home', {'repo_name': ${h.js(c.repo_name)},
 
                                                                'revision': rev_start + '...' + rev_end}));
 
                            $('#rev_range_container').html(
 
                                 _TM['Show Selected Changesets {0} &rarr; {1}'].format(rev_start.substr(0, 12), rev_end.substr(0, 12)));
 
                            $('#rev_range_container').show();
 
                            $('#open_new_pr').prop('href', pyroutes.url('pullrequest_home',
 
                                                                        {'repo_name': ${h.js(c.repo_name)},
 
                                                                         'rev_start': rev_start,
 
                                                                         'rev_end': rev_end}));
 
                            $('#open_new_pr').html(_TM['Open New Pull Request for {0} &rarr; {1}'].format(rev_start.substr(0, 12), rev_end.substr(0, 12)));
 
@@ -150,49 +150,49 @@ ${self.repo_context_bar('changelog', c.f
 
                        $('#singlerange').hide().prop('checked', false);
 
                        $('#rev_range_clear').hide();
 
                        %if c.revision:
 
                            $('#open_new_pr').prop('href', pyroutes.url('pullrequest_home',
 
                                                                        {'repo_name': ${h.js(c.repo_name)},
 
                                                                         'rev_end':${h.js(c.first_revision.raw_id)}}));
 
                            $('#open_new_pr').html(_TM['Open New Pull Request from {0}'].format(${h.jshtml(c.revision)}));
 
                        %else:
 
                            $('#open_new_pr').prop('href', pyroutes.url('pullrequest_home',
 
                                                                        {'repo_name': ${h.js(c.repo_name)},
 
                                                                        'branch':${h.js(c.first_revision.branch)}}));
 
                            $('#open_new_pr').html(_TM['Open New Pull Request from {0}'].format(${h.jshtml(c.first_revision.branch)}));
 
                        %endif
 
                        $('#compare_fork').show();
 
                        $checkboxes.closest('tr').removeClass('out-of-range');
 
                    }
 
                }
 
                checkbox_checker();
 
                $checkboxes.click(function() {
 
                    checkbox_checker();
 
                    graph.render(jsdata);
 
                });
 
                $('#singlerange').click(checkbox_checker);
 

	
 
                $('#rev_range_clear').click(function(e){
 
                $('#rev_range_clear').click(function(){
 
                    $checkboxes.prop('checked', false);
 
                    checkbox_checker();
 
                    graph.render(jsdata);
 
                });
 

	
 
                var $msgs = $('.message');
 
                // get first element height
 
                var el = $('#graph_content tr')[0];
 
                var row_h = el.clientHeight;
 
                $msgs.each(function() {
 
                    var m = this;
 

	
 
                    var h = m.clientHeight;
 
                    if(h > row_h){
 
                        var offset = row_h - (h+12);
 
                        $(m.nextElementSibling).css('display', 'block');
 
                        $(m.nextElementSibling).css('margin-top', offset+'px');
 
                    }
 
                });
 

	
 
                // change branch filter
 
                $("#branch_filter").select2({
 
                    dropdownAutoWidth: true,
 
                    maxResults: 50,
kallithea/templates/changelog/changelog_table.html
Show inline comments
 
@@ -91,31 +91,31 @@
 
              %if cs.extinct:
 
                <span class="label label-extinct" title="Extinct">Extinct</span>
 
              %endif
 
              %if cs.unstable:
 
                <span class="label label-unstable" title="Unstable">Unstable</span>
 
              %endif
 
              %if cs.phase:
 
                <span class="label label-phase" title="Phase">${cs.phase}</span>
 
              %endif
 
              %if show_branch:
 
                %for branch in cs.branches:
 
                  <span class="label label-branch" title="${_('Branch %s' % branch)}">${h.link_to(branch,h.url('changelog_home',repo_name=repo_name,branch=branch))}</span>
 
                %endfor
 
              %endif
 
            </div>
 
          </div>
 
        </td>
 
      </tr>
 
      %endfor
 
    </tbody>
 
    </table>
 

	
 
<script>'use strict';
 
  $(document).ready(function() {
 
    $('#changesets .expand_commit').on('click',function(e){
 
    $('#changesets .expand_commit').on('click',function(){
 
      $(this).next('.mid').find('.message > div').toggleClass('hidden');
 
      ${resize_js};
 
    });
 
  });
 
</script>
 
</%def>
kallithea/templates/changeset/changeset.html
Show inline comments
 
@@ -165,40 +165,40 @@ ${self.repo_context_bar('changelog', c.c
 
    <%namespace name="diff_block" file="/changeset/diff_block.html"/>
 
    ${diff_block.diff_block_js()}
 
    <% a_rev, cs_rev, file_diff_data = c.changes[c.changeset.raw_id] %>
 
    ${diff_block.diff_block(c.repo_name, 'rev', a_rev, a_rev,
 
                            c.repo_name, 'rev', cs_rev, cs_rev, file_diff_data)}
 
    % if c.limited_diff:
 
      <h4>${_('Changeset was too big and was cut off...')} <a href="${h.url.current(fulldiff=1, **request.GET.mixed())}">${_('Show full diff anyway')}</a></h4>
 
    % endif
 
    </div>
 

	
 
    ## template for inline comment form
 
    ${comment.comment_inline_form()}
 

	
 
    ## render comments and inlines
 
    ${comment.generate_comments()}
 

	
 
    ## main comment form and it status
 
    ${comment.comments()}
 

	
 
    </div>
 

	
 
    ## FORM FOR MAKING JS ACTION AS CHANGESET COMMENTS
 
    <script>'use strict';
 
      $(document).ready(function(){
 
          $('.code-difftable').on('click', '.add-bubble', function(e){
 
          $('.code-difftable').on('click', '.add-bubble', function(){
 
              show_comment_form($(this));
 
          });
 

	
 
          move_comments($(".comments .comments-list-chunk"));
 

	
 
          // hack: re-navigate to target after JS is done ... if a target is set and setting href thus won't reload
 
          if (window.location.hash != "") {
 
              window.location.href = window.location.href;
 
          }
 
      });
 

	
 
    </script>
 

	
 
  </div>
 
</%def>
kallithea/templates/changeset/diff_block.html
Show inline comments
 
@@ -77,49 +77,49 @@
 
            ${diff|n}
 
            %if op and cs_filename.rsplit('.')[-1] in ['png', 'gif', 'jpg', 'bmp']:
 
              <div class="btn btn-image-diff-show">Show images</div>
 
              %if op == 'M':
 
                <div id="${id_fid}_image-diff" class="btn btn-image-diff-swap" style="display:none">Press to swap images</div>
 
              %endif
 
              <div>
 
                %if op in 'DM':
 
                  <img id="${id_fid}_image-diff-img-a" class="img-diff img-diff-swapable" style="display:none"
 
                      realsrc="${h.url('files_raw_home',repo_name=a_repo_name,revision=a_rev,f_path=a_filename)}" />
 
                %endif
 
                %if op in 'AM':
 
                  <img id="${id_fid}_image-diff-img-b" class="img-diff img-diff-swapable" style="display:none"
 
                      realsrc="${h.url('files_raw_home',repo_name=cs_repo_name,revision=cs_rev,f_path=cs_filename)}" />
 
                %endif
 
              </div>
 
            %endif
 
        </div>
 
    </div>
 
</%def>
 

	
 
<%def name="diff_block_js()">
 
<script>'use strict';
 
$(document).ready(function(){
 
    $('.btn-image-diff-show').click(function(e){
 
    $('.btn-image-diff-show').click(function(){
 
        $('.btn-image-diff-show').hide();
 
        $('.btn-image-diff-swap').show();
 
        $('.img-diff-swapable')
 
            .each(function(i,e){
 
                    $(e).prop('src', $(e).attr('realsrc'));
 
                })
 
            .show();
 
        });
 

	
 
    $('.btn-image-diff-swap').mousedown(function(e){
 
        $('#'+e.currentTarget.id+'-img-a.img-diff-swapable')
 
          .before($('#'+e.currentTarget.id+'-img-b.img-diff-swapable'));
 
    });
 
    function reset(e){
 
        $('#'+e.currentTarget.id+'-img-a.img-diff-swapable')
 
          .after($('#'+e.currentTarget.id+'-img-b.img-diff-swapable'));
 
    }
 
    $('.btn-image-diff-swap').mouseup(reset);
 
    $('.btn-image-diff-swap').mouseleave(reset);
 

	
 
    $('.diff-collapse-button').click(function(e) {
 
        $('.diff_block').toggleClass('hidden');
 
        var $button = $(e.currentTarget);
 
        var $target = $('.' + $button.data('target'));
kallithea/templates/compare/compare_cs.html
Show inline comments
 
@@ -52,34 +52,34 @@
 
      <div>
 
        ${h.link_to_ref(c.cs_repo.repo_name, c.cs_ref_type, c.cs_ref_name, c.cs_rev)}
 
        ${_('is')}
 
        <a href="${c.swap_url}">${_('%s changesets') % (len(c.cs_ranges_org))}</a>
 
        ${_('behind')}
 
        ${h.link_to_ref(c.a_repo.repo_name, c.a_ref_type, c.a_ref_name)}
 
      </div>
 
    %endif
 
  %endif
 
</div>
 

	
 
%if c.is_ajax_preview:
 
<div id="jsdata" style="display:none">${h.js(c.jsdata)}</div>
 
%else:
 
<script src="${h.url('/js/graph.js', ver=c.kallithea_version)}"></script>
 
%endif
 

	
 
<script>'use strict';
 
    var jsdata = ${h.js(c.jsdata)};
 
    var graph = new BranchRenderer('graph_canvas', 'graph_content_pr', 'chg_');
 

	
 
    $(document).ready(function(){
 
        graph.render(jsdata);
 

	
 
        $('.expand_commit').click(function(e){
 
        $('.expand_commit').click(function(){
 
            $(this).next('.mid').find('.message').toggleClass('expanded');
 
            graph.render(jsdata);
 
        });
 
    });
 
    $(window).resize(function(){
 
        graph.render(jsdata);
 
    });
 

	
 
</script>
kallithea/templates/compare/compare_diff.html
Show inline comments
 
@@ -146,41 +146,41 @@ ${self.repo_context_bar('changelog')}
 
                  query.callback(data);
 
                }
 
              });
 
          }
 
        }
 
    });
 
    }
 

	
 
    make_revision_dropdown("#compare_org",   ${h.js(c.a_repo.repo_name)},  ${h.js(c.a_ref_name)},  'cache');
 
    make_revision_dropdown("#compare_other", ${h.js(c.cs_repo.repo_name)}, ${h.js(c.cs_ref_name)}, 'cache2');
 

	
 
    function values_changed() {
 
        var values = $('#compare_org').select2('data') && $('#compare_other').select2('data');
 
        if (values) {
 
             $('#compare_revs').removeClass("disabled");
 
             // TODO: the swap button ... if any
 
        } else {
 
             $('#compare_revs').addClass("disabled");
 
             // TODO: the swap button ... if any
 
        }
 
    }
 
    values_changed();
 
    $('#compare_org').change(values_changed);
 
    $('#compare_other').change(values_changed);
 
    $('#compare_revs').on('click', function(e){
 
    $('#compare_revs').on('click', function(){
 
        var org = $('#compare_org').select2('data');
 
        var other = $('#compare_other').select2('data');
 
        if (!org || !other) {
 
            return;
 
        }
 

	
 
        var compare_url = ${h.js(h.url('compare_url',repo_name=c.repo_name,org_ref_type='__other_ref_type__',org_ref_name='__org__',other_ref_type='__org_ref_type__',other_ref_name='__other__', other_repo=c.cs_repo.repo_name))};
 
        var u = compare_url.replace('__other_ref_type__',org.type)
 
                           .replace('__org__',org.text)
 
                           .replace('__org_ref_type__',other.type)
 
                           .replace('__other__',other.text);
 
        window.location = u;
 
    });
 
   });
 
    </script>
 
</%def>
kallithea/templates/files/files_add.html
Show inline comments
 
@@ -86,40 +86,40 @@ ${self.repo_context_bar('files')}
 
                            $(opt).attr('mode', m.mode);
 
                            if (m.mime == 'text/plain') {
 
                                // default plain text
 
                                $(opt).prop('selected', true);
 
                                modes_select.options[0] = opt;
 
                            } else {
 
                                modes_select.options[index++] = opt;
 
                            }
 
                        }
 
                    });
 
                    var $filename_input = $('#filename');
 
                    $mimetype_select.change(function(e){
 
                        var selected = e.currentTarget;
 
                        var node = selected.options[selected.selectedIndex];
 
                        var detected_mode = CodeMirror.findModeByMIME(node.value);
 
                        setCodeMirrorMode(myCodeMirror, detected_mode);
 

	
 
                        var proposed_ext = CodeMirror.findExtensionByMode(detected_mode);
 
                        var file_data = CodeMirror.getFilenameAndExt($filename_input.val());
 
                        var filename = file_data['filename'] || 'filename1';
 
                        $filename_input.val(filename + '.' + proposed_ext);
 
                    });
 

	
 
                    // on type the new filename set mode
 
                    $filename_input.keyup(function(e){
 
                    $filename_input.keyup(function(){
 
                        var file_data = CodeMirror.getFilenameAndExt(this.value);
 
                        if(file_data['ext'] != null){
 
                            var detected_mode = CodeMirror.findModeByExtension(file_data['ext']) || CodeMirror.findModeByMIME('text/plain');
 
                            if (detected_mode){
 
                                setCodeMirrorMode(myCodeMirror, detected_mode);
 
                                $mimetype_select.val(detected_mode.mime);
 
                            }
 
                        }
 
                    });
 
                });
 
            </script>
 
        </div>
 
    </div>
 
</div>
 
</%def>
kallithea/templates/index_base.html
Show inline comments
 
@@ -30,42 +30,42 @@
 
                    <a href="${h.url('new_repo')}" class="btn btn-default btn-xs"><i class="icon-plus"></i>${_('Add Repository')}</a>
 
                    %if h.HasPermissionAny('hg.admin')():
 
                        <a href="${h.url('new_repos_group')}" class="btn btn-default btn-xs"><i class="icon-plus"></i>${_('Add Repository Group')}</a>
 
                    %endif
 
                  %endif
 
                %endif
 
                %if c.group and h.HasRepoGroupPermissionLevel('admin')(c.group.group_name):
 
                    <a href="${h.url('edit_repo_group',group_name=c.group.group_name)}" title="${_('You have admin right to this group, and can edit it')}" class="btn btn-default btn-xs"><i class="icon-pencil"></i>${_('Edit Repository Group')}</a>
 
                %endif
 
              </div>
 
            %endif
 
        </div>
 
        <div class="panel-body">
 
            <table class="table" id="repos_list_wrap" width="100%"></table>
 
        </div>
 
    </div>
 

	
 
      <script>'use strict';
 
        var data = ${h.js(c.data)},
 
            $dataTable = $("#repos_list_wrap").DataTable({
 
                data: data.records,
 
                columns: [
 
                    {data: "raw_name", visible: false, searchable: false},
 
                    {title: ${h.jshtml(_('Repository'))}, data: "name", orderData: [0,], render: {
 
                        filter: function(data, type, row, meta) {
 
                        filter: function(data, type, row) {
 
                            return row.just_name;
 
                        }
 
                    }},
 
                    {data: "following", defaultContent: '', sortable: false},
 
                    {data: "desc", title: ${h.jshtml(_('Description'))}, searchable: false},
 
                    {data: "last_change_iso", defaultContent: '', visible: false, searchable: false},
 
                    {data: "last_change", defaultContent: '', title: ${h.jshtml(_('Last Change'))}, orderData: [4,], searchable: false},
 
                    {data: "last_rev_raw", defaultContent: '', visible: false, searchable: false},
 
                    {data: "last_changeset", defaultContent: '', title: ${h.jshtml(_('Tip'))}, orderData: [6,], searchable: false},
 
                    {data: "owner", defaultContent: '', title: ${h.jshtml(_('Owner'))}, searchable: false},
 
                    {data: "atom", defaultContent: '', sortable: false}
 
                ],
 
                order: [[1, "asc"]],
 
                dom: '<"dataTables_left"f><"dataTables_right"ip>t',
 
                pageLength: 100
 
            });
 
      </script>
kallithea/templates/pullrequests/pullrequest.html
Show inline comments
 
@@ -149,67 +149,67 @@ ${self.repo_context_bar('showpullrequest
 
      var org_repo = $('#pull_request_form #org_repo').val();
 
      var org_ref = $('#pull_request_form #org_ref').val().split(':');
 
      ## TODO: make nice link like link_to_ref() do
 
      $('#org_rev_span').html(org_ref[2].substr(0,12));
 

	
 
      var other_repo = $('#pull_request_form #other_repo').val();
 
      var other_ref = $('#pull_request_form #other_ref').val().split(':');
 
      $('#other_rev_span').html(other_ref[2].substr(0,12));
 

	
 
      var rev_data = {
 
          '__org_repo__': org_repo,
 
          '__org_ref_name__': org_ref[2],
 
          '__other_repo__': other_repo,
 
          '__other_ref_name__': other_ref[2]
 
      }; // gather the org/other ref and repo here
 

	
 
      for (let k in rev_data){
 
          url = url.replace(k,rev_data[k]);
 
      }
 

	
 
      if (pendingajax) {
 
          pendingajax.abort();
 
          pendingajax = undefined;
 
      }
 
      pendingajax = asynchtml(url, $('#pull_request_overview'), function(o){
 
      pendingajax = asynchtml(url, $('#pull_request_overview'), function(){
 
          pendingajax = undefined;
 
      });
 
  }
 

	
 
  $(document).ready(function(){
 
      $("#org_repo").select2({
 
          dropdownAutoWidth: true
 
      });
 
      ## (org_repo can't change)
 

	
 
      $("#org_ref").select2({
 
          dropdownAutoWidth: true,
 
          maxResults: 50,
 
          sortResults: branchSort
 
      });
 
      $("#org_ref").on("change", function(e){
 
      $("#org_ref").on("change", function(){
 
          loadPreview();
 
      });
 

	
 
      $("#other_repo").select2({
 
          dropdownAutoWidth: true
 
      });
 
      $("#other_repo").on("change", function(e){
 
      $("#other_repo").on("change", function(){
 
          otherrepoChanged();
 
      });
 

	
 
      $("#other_ref").select2({
 
          dropdownAutoWidth: true,
 
          maxResults: 50,
 
          sortResults: branchSort
 
      });
 
      $("#other_ref").on("change", function(e){
 
      $("#other_ref").on("change", function(){
 
          loadPreview();
 
      });
 

	
 
      //lazy load overview after 0.5s
 
      setTimeout(loadPreview, 500);
 
  });
 

	
 
</script>
 

	
 
</%def>
kallithea/templates/pullrequests/pullrequest_show.html
Show inline comments
 
@@ -327,68 +327,68 @@ ${self.repo_context_bar('showpullrequest
 
    <div class="commentable-diff">
 
    <%namespace name="diff_block" file="/changeset/diff_block.html"/>
 
    ${diff_block.diff_block_js()}
 
    ${diff_block.diff_block(c.a_repo.repo_name, c.a_ref_type, c.a_ref_name, c.a_rev,
 
                            c.cs_repo.repo_name, c.cs_ref_type, c.cs_ref_name, c.cs_rev, c.file_diff_data)}
 
    % if c.limited_diff:
 
      <h4>${_('Changeset was too big and was cut off...')} <a href="${h.url.current(fulldiff=1, **request.GET.mixed())}">${_('Show full diff anyway')}</a></h4>
 
    % endif
 
    </div>
 

	
 
    ## template for inline comment form
 
    ${comment.comment_inline_form()}
 

	
 
    ## render comments and inlines
 
    ${comment.generate_comments()}
 

	
 
    ## main comment form and it status
 
    ${comment.comments(change_status=c.allowed_to_change_status)}
 

	
 
    <script>'use strict';
 
      $(document).ready(function(){
 
          PullRequestAutoComplete($('#user'));
 
          SimpleUserAutoComplete($('#owner'));
 

	
 
          $('.code-difftable').on('click', '.add-bubble', function(e){
 
          $('.code-difftable').on('click', '.add-bubble', function(){
 
              show_comment_form($(this));
 
          });
 

	
 
          var avail_jsdata = ${h.js(c.avail_jsdata)};
 
          var avail_r = new BranchRenderer('avail_graph_canvas', 'updaterevs-table', 'chg_available_');
 
          avail_r.render(avail_jsdata);
 

	
 
          $(window).resize(function(){
 
              avail_r.render(avail_jsdata);
 
          });
 

	
 
          move_comments($(".comments .comments-list-chunk"));
 

	
 
          $('#updaterevs input').change(function(e){
 
              var update = !!e.target.value;
 
              $('#pr-form-save').prop('disabled',update);
 
              $('#pr-form-clone').prop('disabled',!update);
 
          });
 
          var $org_review_members = $('#review_members').clone();
 
          $('#pr-form-reset').click(function(e){
 
          $('#pr-form-reset').click(function(){
 
              $('.pr-do-edit').hide();
 
              $('.pr-not-edit').show();
 
              $('#pr-form-save').prop('disabled',false);
 
              $('#pr-form-clone').prop('disabled',true);
 
              $('#review_members').html($org_review_members);
 
          });
 

	
 
          // hack: re-navigate to target after JS is done ... if a target is set and setting href thus won't reload
 
          if (window.location.hash != "") {
 
              window.location.href = window.location.href;
 
          }
 

	
 
          $('.missing_reviewer').click(function(){
 
            var $this = $(this);
 
            addReviewMember($this.data('user_id'), $this.data('fname'), $this.data('lname'), $this.data('nname'), $this.data('gravatar_lnk'), $this.data('gravatar_size'));
 
          });
 
      });
 
    </script>
 
    </div>
 

	
 
</div>
 

	
 
</%def>
kallithea/templates/summary/statistics.html
Show inline comments
 
@@ -135,99 +135,96 @@ function SummaryPlot(from,to,dataset,ove
 
            "from":from,
 
            "to":to
 
        }
 
    };
 
    for(var key in dataset){
 
      var data = dataset[key].data;
 
      for(var d in data){
 
        data[d].time *= 1000;
 
      }
 
    }
 
    for(var key in overview_dataset){
 
      overview_dataset[key][0] *= 1000;
 
    }
 
    var choiceContainer = $("#legend_choices")[0];
 
    var choiceContainerTable = $("#legend_choices_tables")[0];
 
    var $plotContainer = $('#commit_history');
 
    var plotContainer = $('#commit_history')[0];
 
    var $overviewContainer = $('#overview');
 
    var overviewContainer = $('#overview')[0];
 

	
 
    var plot_options = {
 
        bars: {show:true, align: 'center', lineWidth: 4},
 
        legend: {show:true,
 
                container: "#legend_container",
 
                labelFormatter: function(label, series) {
 
                        // series is the series object for the label
 
                labelFormatter: function(label) {
 
                        return '<a href="javascript:void(0)"> ' + label + '</a>';
 
                    }
 
        },
 
        points: {show:true, radius: 0, fill: false},
 
        yaxis: {tickDecimals: 0},
 
        xaxis: {
 
            mode: "time",
 
            timeformat: "%d/%m",
 
            min: from,
 
            max: to
 
        },
 
        grid: {
 
            hoverable: true,
 
            clickable: true,
 
            autoHighlight: true,
 
            color: "#999"
 
        },
 
        //selection: {mode: "x"}
 
    };
 
    var overview_options = {
 
        legend:{show:false},
 
        bars: {show:true, barWidth: 2},
 
        shadowSize: 0,
 
        xaxis: {mode: "time", timeformat: "%d/%m/%y"},
 
        yaxis: {ticks: 3, min: 0, tickDecimals:0},
 
        grid: {color: "#999"},
 
        selection: {mode: "x"}
 
    };
 

	
 
    /**
 
    *get dummy data needed in few places
 
    */
 
    function getDummyData(label){
 
        return {"label":label,
 
         "data":[{"time":0,
 
             "commits":0,
 
                 "added":0,
 
                 "changed":0,
 
                 "removed":0
 
            }],
 
            "schema":["commits"],
 
            "color":'#ffffff'
 
        }
 
    }
 

	
 
    /**
 
     * generate checkboxes accordingly to data
 
     * @param keys
 
     * @returns
 
     */
 
    function generateCheckboxes(data) {
 
        //append checkboxes
 
        var i = 0;
 
        choiceContainerTable.innerHTML = '';
 
        for(var pos in data) {
 

	
 
            data[pos].color = i;
 
            i++;
 
            if(data[pos].label != ''){
 
                choiceContainerTable.innerHTML +=
 
                    '<tr style="display:none"><td><label><input type="checkbox" id="id_user_{0}" name="{0}" checked="checked" /> \
 
                     {0}</label></td></tr>'.format(data[pos].label);
 
            }
 
        }
 
    }
 

	
 
    /**
 
     * ToolTip show
 
     */
 
    function showTooltip(x, y, contents) {
 
        var div=document.getElementById('tooltip');
 
        if(!div) {
 
            div = document.createElement('div');
kallithea/templates/summary/summary.html
Show inline comments
 
@@ -219,73 +219,73 @@ hg push ${c.clone_repo_url}
 
                %endif
 
                </pre>
 
            %endif
 
        </div>
 
    </div>
 
</div>
 

	
 
%if c.readme_data:
 
<div id="readme" class="anchor">
 
</div>
 
<div class="panel panel-primary">
 
    <div class="panel-heading" title="${_('Readme file from revision %s:%s') % (c.db_repo.landing_rev[0], c.db_repo.landing_rev[1])}">
 
        <div class="panel-title">
 
            <a href="${h.url('files_home',repo_name=c.repo_name,revision='tip',f_path=c.readme_file)}">${c.readme_file}</a>
 
        </div>
 
    </div>
 
    <div class="readme panel-body">
 
        ${c.readme_data|n}
 
    </div>
 
</div>
 
%endif
 

	
 
<script>'use strict';
 
$(document).ready(function(){
 
    $('#clone-url input').click(function(e){
 
    $('#clone-url input').click(function(){
 
        if($(this).hasClass('selected')){
 
            $(this).removeClass('selected');
 
            return ;
 
        }else{
 
            $(this).addClass('selected');
 
            $(this).select();
 
        }
 
    });
 

	
 
    var $clone_url = $('#clone-url');
 
    var $clone_by_name = $('#clone_by_name');
 
    var $clone_by_id = $('#clone_by_id');
 
    var $clone_ssh = $('#clone_ssh');
 
    $clone_url.on('click', '.btn.use-name', function(e){
 
    $clone_url.on('click', '.btn.use-name', function(){
 
        $clone_by_name.show();
 
        $clone_by_id.hide();
 
        $clone_ssh.hide();
 
    });
 
    $clone_url.on('click', '.btn.use-id', function(e){
 
    $clone_url.on('click', '.btn.use-id', function(){
 
        $clone_by_id.show();
 
        $clone_by_name.hide();
 
        $clone_ssh.hide();
 
    });
 
    $clone_url.on('click', '.btn.use-ssh', function(e){
 
    $clone_url.on('click', '.btn.use-ssh', function(){
 
        $clone_by_id.hide();
 
        $clone_by_name.hide();
 
        $clone_ssh.show();
 
    });
 

	
 
    var cache = {}
 
    $("#download_options").select2({
 
        placeholder: _TM['Select changeset'],
 
        dropdownAutoWidth: true,
 
        query: function(query){
 
          var key = 'cache';
 
          var cached = cache[key] ;
 
          if(cached) {
 
            var data = {results: []};
 
            //filter results
 
            $.each(cached.results, function(){
 
                var section = this.text;
 
                var children = [];
 
                $.each(this.children, function(){
 
                    if(query.term.length == 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0 ){
 
                        children.push({'id': this.id, 'text': this.text});
 
                    }
 
                });
 
                data.results.push({'text': section, 'children': children});
0 comments (0 inline, 0 general)