33425_v4.patch

Marius BALTEANU, 2020-10-12 00:10

Download (2.73 KB)

View differences:

public/javascripts/application.js
1049 1049
    if (element.dataset.tribute === 'true') {return;}
1050 1050

  
1051 1051
    const issuesUrl = element.dataset.issuesUrl;
1052
    const usersUrl = element.dataset.usersUrl;
1053 1052

  
1054 1053
    const remoteSearch = function(url, cb) {
1055 1054
      const xhr = new XMLHttpRequest();
......
1069 1068
    };
1070 1069

  
1071 1070
    const tribute = new Tribute({
1072
      trigger: '#',
1073
      values: function (text, cb) {
1074
        if (event.target.type === 'text' && $(element).attr('autocomplete') != 'off') {
1075
          $(element).attr('autocomplete', 'off');
1071
      collection: [
1072
        {
1073
          trigger: '#',
1074
          values: function (text, cb) {
1075
            if (event.target.type === 'text' && $(element).attr('autocomplete') != 'off') {
1076
              $(element).attr('autocomplete', 'off');
1077
            }
1078
            remoteSearch(issuesUrl + text, function (issues) {
1079
              return cb(issues);
1080
            });
1081
          },
1082
          lookup: 'label',
1083
          fillAttr: 'label',
1084
          requireLeadingSpace: true,
1085
          selectTemplate: function (issue) {
1086
            return '#' + issue.original.id;
1087
          },
1088
          noMatchTemplate: function () {
1089
            return '<span style:"visibility: hidden;"></span>';
1090
          }
1091
        },
1092
        {
1093
          trigger: '{{',
1094
          values: [
1095
            {name: 'collapse', value: '{{collapse\nThis is a block of text that is collapsed by default.\n}}'},
1096
            {name: 'child_pages', value: '{{child_pages}}'},
1097
            {name: 'include', value: '{{include(WikiPageName)}}'},
1098
            {name: 'thumbnail', value: '{{thumbnail(image.png, size=300, title=Thumbnail)}}'},
1099
            {name: 'issue', value: '{{issue(123, subject=true, project=true)}}'}
1100
          ],
1101
          lookup: 'name',
1102
          fillAttr: 'value',
1103
          requireLeadingSpace: true,
1104
          selectTemplate: function(item) {
1105
            return item.original.value;
1106
          },
1107
          noMatchTemplate: function () {
1108
            return '<span style:"visibility: hidden;"></span>';
1109
          }
1076 1110
        }
1077
        remoteSearch(issuesUrl + text, function (issues) {
1078
          return cb(issues);
1079
        });
1080
      },
1081
      lookup: 'label',
1082
      fillAttr: 'label',
1083
      requireLeadingSpace: true,
1084
      selectTemplate: function (issue) {
1085
        return '#' + issue.original.id;
1086
      },
1087
      noMatchTemplate: function () {
1088
        return '<span style:"visibility: hidden;"></span>';
1089
      }
1111
      ]
1090 1112
    });
1091 1113

  
1092 1114
    tribute.attach(element);