| 1040 | 
  1040 | 
  
        // do not attach if Tribute is already initialized 
   | 
  | 1041 | 
  1041 | 
  
        if (element.dataset.tribute === 'true') {return;}
   | 
  | 1042 | 
  1042 | 
  
    
   | 
  | 1043 | 
   | 
  
        const issuesUrl = element.dataset.issuesUrl; 
   | 
  | 1044 | 
   | 
  
        const usersUrl = element.dataset.usersUrl; 
   | 
  | 1045 | 
   | 
  
    
   | 
  | 1046 | 
  1043 | 
  
        const remoteSearch = function(url, cb) {
   | 
  | 1047 | 
  1044 | 
  
          const xhr = new XMLHttpRequest(); 
   | 
  | 1048 | 
  1045 | 
  
          xhr.onreadystatechange = function () 
   | 
  | ... | ... |  | 
  | 1060 | 
  1057 | 
  
          xhr.send(); 
   | 
  | 1061 | 
  1058 | 
  
        }; 
   | 
  | 1062 | 
  1059 | 
  
    
   | 
  | 1063 | 
   | 
  
        const tribute = new Tribute({
   | 
  | 1064 | 
   | 
  
          trigger: '#', 
   | 
  | 1065 | 
   | 
  
          values: function (text, cb) {
   | 
  | 1066 | 
   | 
  
            if (event.target.type === 'text' && $(element).attr('autocomplete') != 'off') {
   | 
  | 1067 | 
   | 
  
              $(element).attr('autocomplete', 'off');
   | 
   | 
  1060 | 
  
        const AutoCompleteIssueId = 
   | 
   | 
  1061 | 
  
          {
   | 
   | 
  1062 | 
  
            trigger: '#', 
   | 
   | 
  1063 | 
  
            values: function (text, cb) {
   | 
   | 
  1064 | 
  
              if (event.target.type === 'text' && $(element).attr('autocomplete') != 'off') {
   | 
   | 
  1065 | 
  
                $(element).attr('autocomplete', 'off');
   | 
   | 
  1066 | 
  
              } 
   | 
   | 
  1067 | 
  
              remoteSearch(element.dataset.issuesUrl + text, function (issues) {
   | 
   | 
  1068 | 
  
                return cb(issues); 
   | 
   | 
  1069 | 
  
              }); 
   | 
   | 
  1070 | 
  
            }, 
   | 
   | 
  1071 | 
  
            lookup: 'label', 
   | 
   | 
  1072 | 
  
            fillAttr: 'label', 
   | 
   | 
  1073 | 
  
            requireLeadingSpace: true, 
   | 
   | 
  1074 | 
  
            selectTemplate: function (issue) {
   | 
   | 
  1075 | 
  
              return '#' + issue.original.id; 
   | 
   | 
  1076 | 
  
            }, 
   | 
   | 
  1077 | 
  
            noMatchTemplate: function () {
   | 
   | 
  1078 | 
  
              return '<span style:"visibility: hidden;"></span>'; 
   | 
  | 1068 | 
  1079 | 
  
            } 
   | 
  | 1069 | 
   | 
  
            remoteSearch(issuesUrl + text, function (issues) {
   | 
  | 1070 | 
   | 
  
              return cb(issues); 
   | 
  | 1071 | 
   | 
  
            }); 
   | 
  | 1072 | 
   | 
  
          }, 
   | 
  | 1073 | 
   | 
  
          lookup: 'label', 
   | 
  | 1074 | 
   | 
  
          fillAttr: 'label', 
   | 
  | 1075 | 
   | 
  
          requireLeadingSpace: true, 
   | 
  | 1076 | 
   | 
  
          selectTemplate: function (issue) {
   | 
  | 1077 | 
   | 
  
            return '#' + issue.original.id; 
   | 
  | 1078 | 
   | 
  
          }, 
   | 
  | 1079 | 
   | 
  
          noMatchTemplate: function () {
   | 
  | 1080 | 
   | 
  
            return '<span style:"visibility: hidden;"></span>'; 
   | 
  | 1081 | 
  1080 | 
  
          } 
   | 
  | 1082 | 
   | 
  
        }); 
   | 
   | 
  1081 | 
  
        const AutoCompleteWikiSyntax = 
   | 
   | 
  1082 | 
  
          {
   | 
   | 
  1083 | 
  
            trigger: '{{',
   | 
   | 
  1084 | 
  
            values: [ 
   | 
   | 
  1085 | 
  
              {name: 'collapse', value: '{{collapse\nThis is a block of text that is collapsed by default.\n}}'},
   | 
   | 
  1086 | 
  
              {name: 'child_pages', value: '{{child_pages}}'},
   | 
   | 
  1087 | 
  
              {name: 'include', value: '{{include(WikiPageName)}}'},
   | 
   | 
  1088 | 
  
              {name: 'thumbnail', value: '{{thumbnail(image.png, size=300, title=Thumbnail)}}'},
   | 
   | 
  1089 | 
  
              {name: 'issue', value: '{{issue(123, subject=true, project=true)}}'}
   | 
   | 
  1090 | 
  
            ], 
   | 
   | 
  1091 | 
  
            lookup: 'name', 
   | 
   | 
  1092 | 
  
            fillAttr: 'value', 
   | 
   | 
  1093 | 
  
            requireLeadingSpace: true, 
   | 
   | 
  1094 | 
  
            selectTemplate: function(item) {
   | 
   | 
  1095 | 
  
              return item.original.value; 
   | 
   | 
  1096 | 
  
            }, 
   | 
   | 
  1097 | 
  
            noMatchTemplate: function () {
   | 
   | 
  1098 | 
  
              return '<span style:"visibility: hidden;"></span>'; 
   | 
   | 
  1099 | 
  
            } 
   | 
   | 
  1100 | 
  
          } 
   | 
   | 
  1101 | 
  
    
   | 
   | 
  1102 | 
  
        const tribute = new Tribute({
   | 
   | 
  1103 | 
  
          collection: [ 
   | 
   | 
  1104 | 
  
            AutoCompleteIssueId, 
   | 
   | 
  1105 | 
  
            ($(element).closest('.jstEditor').length ? AutoCompleteWikiSyntax : {})
   | 
   | 
  1106 | 
  
          ]}); 
   | 
  | 1083 | 
  1107 | 
  
    
   | 
  | 1084 | 
  1108 | 
  
        tribute.attach(element); 
   | 
  | 1085 | 
  1109 | 
  
    } 
   | 
  | 1086 | 
  1110 | 
  
    
   | 
  | 1087 | 
   | 
  
    
   | 
  | 1088 | 
  1111 | 
  
    $(document).ready(setupAjaxIndicator); 
   | 
  | 1089 | 
  1112 | 
  
    $(document).ready(hideOnLoad); 
   | 
  | 1090 | 
  1113 | 
  
    $(document).ready(addFormObserversForDoubleSubmit); 
   |