|
|
@@ -36,6 +36,7 @@ import MinioUploader from './components/MinioUploader.vue'; |
|
|
|
import ObsUploader from './components/ObsUploader.vue'; |
|
|
|
import EditAboutInfo from './components/EditAboutInfo.vue'; |
|
|
|
import Images from './components/Images.vue' |
|
|
|
import EditTopics from './components/EditTopics.vue' |
|
|
|
|
|
|
|
Vue.use(ElementUI); |
|
|
|
Vue.prototype.$axios = axios; |
|
|
@@ -2967,11 +2968,13 @@ $(document).ready(async () => { |
|
|
|
initVueUploader(); |
|
|
|
initObsUploader(); |
|
|
|
initVueEditAbout(); |
|
|
|
initVueEditTopic(); |
|
|
|
initVueImages(); |
|
|
|
initTeamSettings(); |
|
|
|
initCtrlEnterSubmit(); |
|
|
|
initNavbarContentToggle(); |
|
|
|
initTopicbar(); |
|
|
|
// initTopicbar(); |
|
|
|
// closeTopicbar(); |
|
|
|
initU2FAuth(); |
|
|
|
initU2FRegister(); |
|
|
|
initIssueList(); |
|
|
@@ -3666,7 +3669,19 @@ function initVueEditAbout() { |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function initVueEditTopic() { |
|
|
|
const el = document.getElementById('topic_edit1'); |
|
|
|
|
|
|
|
if (!el) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
new Vue({ |
|
|
|
el:'#topic_edit1', |
|
|
|
render:h=>h(EditTopics) |
|
|
|
}) |
|
|
|
} |
|
|
|
function initVueImages() { |
|
|
|
const el = document.getElementById('images'); |
|
|
|
console.log("el",el) |
|
|
@@ -3677,6 +3692,7 @@ function initVueImages() { |
|
|
|
|
|
|
|
new Vue({ |
|
|
|
el: '#images', |
|
|
|
|
|
|
|
render: h => h(Images) |
|
|
|
}); |
|
|
|
} |
|
|
@@ -3932,218 +3948,243 @@ function initNavbarContentToggle() { |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
function initTopicbar() { |
|
|
|
const mgrBtn = $('#manage_topic'); |
|
|
|
const editDiv = $('#topic_edit'); |
|
|
|
const viewDiv = $('#repo-topics'); |
|
|
|
const saveBtn = $('#save_topic'); |
|
|
|
const topicDropdown = $('#topic_edit .dropdown'); |
|
|
|
const topicForm = $('#topic_edit.ui.form'); |
|
|
|
const topicPrompts = getPrompts(); |
|
|
|
|
|
|
|
mgrBtn.on('click', () => { |
|
|
|
viewDiv.hide(); |
|
|
|
editDiv.css('display', ''); // show Semantic UI Grid |
|
|
|
}); |
|
|
|
|
|
|
|
function getPrompts() { |
|
|
|
const hidePrompt = $('div.hide#validate_prompt'); |
|
|
|
const prompts = { |
|
|
|
countPrompt: hidePrompt.children('#count_prompt').text(), |
|
|
|
formatPrompt: hidePrompt.children('#format_prompt').text() |
|
|
|
}; |
|
|
|
hidePrompt.remove(); |
|
|
|
return prompts; |
|
|
|
} |
|
|
|
|
|
|
|
saveBtn.on('click', () => { |
|
|
|
const topics = $('input[name=topics]').val(); |
|
|
|
|
|
|
|
$.post( |
|
|
|
saveBtn.data('link'), |
|
|
|
{ |
|
|
|
_csrf: csrf, |
|
|
|
topics |
|
|
|
}, |
|
|
|
(_data, _textStatus, xhr) => { |
|
|
|
if (xhr.responseJSON.status === 'ok') { |
|
|
|
viewDiv.children('.topic').remove(); |
|
|
|
if (topics.length) { |
|
|
|
const topicArray = topics.split(','); |
|
|
|
|
|
|
|
const last = viewDiv.children('a').last(); |
|
|
|
for (let i = 0; i < topicArray.length; i++) { |
|
|
|
const link = $('<a class="ui repo-topic small label topic"></a>'); |
|
|
|
link.attr( |
|
|
|
'href', |
|
|
|
`${AppSubUrl}/explore/repos?q=${encodeURIComponent( |
|
|
|
topicArray[i] |
|
|
|
)}&topic=1` |
|
|
|
); |
|
|
|
link.text(topicArray[i]); |
|
|
|
link.insertBefore(last); |
|
|
|
} |
|
|
|
} |
|
|
|
editDiv.css('display', 'none'); |
|
|
|
viewDiv.show(); |
|
|
|
} |
|
|
|
} |
|
|
|
) |
|
|
|
.fail((xhr) => { |
|
|
|
if (xhr.status === 422) { |
|
|
|
if (xhr.responseJSON.invalidTopics.length > 0) { |
|
|
|
topicPrompts.formatPrompt = xhr.responseJSON.message; |
|
|
|
|
|
|
|
const {invalidTopics} = xhr.responseJSON; |
|
|
|
const topicLables = topicDropdown.children('a.ui.label'); |
|
|
|
|
|
|
|
topics.split(',').forEach((value, index) => { |
|
|
|
for (let i = 0; i < invalidTopics.length; i++) { |
|
|
|
if (invalidTopics[i] === value) { |
|
|
|
topicLables |
|
|
|
.eq(index) |
|
|
|
.removeClass('green') |
|
|
|
.addClass('red'); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} else { |
|
|
|
topicPrompts.countPrompt = xhr.responseJSON.message; |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
.always(() => { |
|
|
|
topicForm.form('validate form'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
topicDropdown.dropdown({ |
|
|
|
allowAdditions: true, |
|
|
|
forceSelection: false, |
|
|
|
fields: {name: 'description', value: 'data-value'}, |
|
|
|
saveRemoteData: false, |
|
|
|
label: { |
|
|
|
transition: 'horizontal flip', |
|
|
|
duration: 200, |
|
|
|
variation: false, |
|
|
|
blue: true, |
|
|
|
basic: true |
|
|
|
}, |
|
|
|
className: { |
|
|
|
label: 'ui small label' |
|
|
|
}, |
|
|
|
apiSettings: { |
|
|
|
url: `${AppSubUrl}/api/v1/topics/search?q={query}`, |
|
|
|
throttle: 500, |
|
|
|
cache: false, |
|
|
|
onResponse(res) { |
|
|
|
const formattedResponse = { |
|
|
|
success: false, |
|
|
|
results: [] |
|
|
|
}; |
|
|
|
const stripTags = function (text) { |
|
|
|
return text.replace(/<[^>]*>?/gm, ''); |
|
|
|
}; |
|
|
|
|
|
|
|
const query = stripTags(this.urlData.query.trim()); |
|
|
|
let found_query = false; |
|
|
|
const current_topics = []; |
|
|
|
topicDropdown |
|
|
|
.find('div.label.visible.topic,a.label.visible') |
|
|
|
.each((_, e) => { |
|
|
|
current_topics.push(e.dataset.value); |
|
|
|
}); |
|
|
|
|
|
|
|
if (res.topics) { |
|
|
|
let found = false; |
|
|
|
for (let i = 0; i < res.topics.length; i++) { |
|
|
|
// skip currently added tags |
|
|
|
if (current_topics.includes(res.topics[i].topic_name)) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
if ( |
|
|
|
res.topics[i].topic_name.toLowerCase() === query.toLowerCase() |
|
|
|
) { |
|
|
|
found_query = true; |
|
|
|
} |
|
|
|
formattedResponse.results.push({ |
|
|
|
description: res.topics[i].topic_name, |
|
|
|
'data-value': res.topics[i].topic_name |
|
|
|
}); |
|
|
|
found = true; |
|
|
|
} |
|
|
|
formattedResponse.success = found; |
|
|
|
} |
|
|
|
|
|
|
|
if (query.length > 0 && !found_query) { |
|
|
|
formattedResponse.success = true; |
|
|
|
formattedResponse.results.unshift({ |
|
|
|
description: query, |
|
|
|
'data-value': query |
|
|
|
}); |
|
|
|
} else if (query.length > 0 && found_query) { |
|
|
|
formattedResponse.results.sort((a, b) => { |
|
|
|
if (a.description.toLowerCase() === query.toLowerCase()) return -1; |
|
|
|
if (b.description.toLowerCase() === query.toLowerCase()) return 1; |
|
|
|
if (a.description > b.description) return -1; |
|
|
|
if (a.description < b.description) return 1; |
|
|
|
return 0; |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
return formattedResponse; |
|
|
|
} |
|
|
|
}, |
|
|
|
onLabelCreate(value) { |
|
|
|
value = value.toLowerCase().trim(); |
|
|
|
this.attr('data-value', value) |
|
|
|
.contents() |
|
|
|
.first() |
|
|
|
.replaceWith(value); |
|
|
|
return $(this); |
|
|
|
}, |
|
|
|
onAdd(addedValue, _addedText, $addedChoice) { |
|
|
|
addedValue = addedValue.toLowerCase().trim(); |
|
|
|
$($addedChoice).attr('data-value', addedValue); |
|
|
|
$($addedChoice).attr('data-text', addedValue); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
$.fn.form.settings.rules.validateTopic = function (_values, regExp) { |
|
|
|
const topics = topicDropdown.children('a.ui.label'); |
|
|
|
const status = |
|
|
|
topics.length === 0 || (topics.last().attr('data-value').match(regExp) !== null && topics.last().attr('data-value').length <= 35); |
|
|
|
if (!status) { |
|
|
|
topics |
|
|
|
.last() |
|
|
|
.removeClass('green') |
|
|
|
.addClass('red'); |
|
|
|
} |
|
|
|
return status && topicDropdown.children('a.ui.label.red').length === 0; |
|
|
|
}; |
|
|
|
|
|
|
|
topicForm.form({ |
|
|
|
on: 'change', |
|
|
|
inline: true, |
|
|
|
fields: { |
|
|
|
topics: { |
|
|
|
identifier: 'topics', |
|
|
|
rules: [ |
|
|
|
{ |
|
|
|
type: 'validateTopic', |
|
|
|
value: /^[\u4e00-\u9fa5a-z0-9][\u4e00-\u9fa5a-z0-9-]{0,105}$/, |
|
|
|
prompt: topicPrompts.formatPrompt |
|
|
|
}, |
|
|
|
{ |
|
|
|
type: 'maxCount[25]', |
|
|
|
prompt: topicPrompts.countPrompt |
|
|
|
} |
|
|
|
] |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
// function initTopicbar() { |
|
|
|
// const mgrBtn = $('#manage_topic'); |
|
|
|
// const editDiv = $('#topic_edit'); |
|
|
|
// const viewDiv = $('#repo-topics'); |
|
|
|
// const saveBtn = $('#save_topic'); |
|
|
|
// const topicDropdown = $('#topic_edit .dropdown'); |
|
|
|
// const topicForm = $('#topic_edit.ui.form'); |
|
|
|
// const topicInput = $("#topics_input") |
|
|
|
// const topicPrompts = getPrompts(); |
|
|
|
|
|
|
|
|
|
|
|
// mgrBtn.on('click', (e) => { |
|
|
|
// // viewDiv.hide(); |
|
|
|
// editDiv.css('display', ''); // show Semantic UI Grid |
|
|
|
// topicInput.val('') |
|
|
|
// console.log("-----------------asdasd",$("#topics_input"),$("#topics_input").val()) |
|
|
|
// stopPropagation(e); |
|
|
|
|
|
|
|
// }); |
|
|
|
// $(document).bind('click',function(){ |
|
|
|
// editDiv.css('display','none'); |
|
|
|
|
|
|
|
// }) |
|
|
|
// editDiv.click(function(e){ |
|
|
|
// stopPropagation(e); |
|
|
|
// }) |
|
|
|
|
|
|
|
// function getPrompts() { |
|
|
|
// const hidePrompt = $('div.hide#validate_prompt'); |
|
|
|
// const prompts = { |
|
|
|
// countPrompt: hidePrompt.children('#count_prompt').text(), |
|
|
|
// formatPrompt: hidePrompt.children('#format_prompt').text() |
|
|
|
// }; |
|
|
|
// hidePrompt.remove(); |
|
|
|
// return prompts; |
|
|
|
// } |
|
|
|
|
|
|
|
// function stopPropagation(e) { |
|
|
|
// var ev = e || window.event; |
|
|
|
// if (ev.stopPropagation) { |
|
|
|
// ev.stopPropagation(); |
|
|
|
// } |
|
|
|
// else if (window.event) { |
|
|
|
// window.event.cancelBubble = true;//兼容IE |
|
|
|
// } |
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
// saveBtn.on('click', () => { |
|
|
|
// const topics = $('input[name=topics]').val(); |
|
|
|
|
|
|
|
// $.post( |
|
|
|
// saveBtn.data('link'), |
|
|
|
// { |
|
|
|
// _csrf: csrf, |
|
|
|
// topics |
|
|
|
// }, |
|
|
|
// (_data, _textStatus, xhr) => { |
|
|
|
// if (xhr.responseJSON.status === 'ok') { |
|
|
|
// console.log("--------saveBtn------------") |
|
|
|
// viewDiv.children('.topic').remove(); |
|
|
|
// if (topics.length) { |
|
|
|
// const topicArray = topics.split(','); |
|
|
|
|
|
|
|
// const last = viewDiv.children('a').last(); |
|
|
|
// for (let i = 0; i < topicArray.length; i++) { |
|
|
|
// const link = $('<a class="ui repo-topic small label topic"></a>'); |
|
|
|
// link.attr( |
|
|
|
// 'href', |
|
|
|
// `${AppSubUrl}/explore/repos?q=${encodeURIComponent( |
|
|
|
// topicArray[i] |
|
|
|
// )}&topic=1` |
|
|
|
// ); |
|
|
|
// link.text(topicArray[i]); |
|
|
|
// link.insertBefore(last); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// editDiv.css('display', 'none'); |
|
|
|
// viewDiv.show(); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// ) |
|
|
|
// .fail((xhr) => { |
|
|
|
// if (xhr.status === 422) { |
|
|
|
// if (xhr.responseJSON.invalidTopics.length > 0) { |
|
|
|
// topicPrompts.formatPrompt = xhr.responseJSON.message; |
|
|
|
|
|
|
|
// const {invalidTopics} = xhr.responseJSON; |
|
|
|
// const topicLables = topicDropdown.children('a.ui.label'); |
|
|
|
|
|
|
|
// topics.split(',').forEach((value, index) => { |
|
|
|
// for (let i = 0; i < invalidTopics.length; i++) { |
|
|
|
// if (invalidTopics[i] === value) { |
|
|
|
// topicLables |
|
|
|
// .eq(index) |
|
|
|
// .removeClass('green') |
|
|
|
// .addClass('red'); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// }); |
|
|
|
// } else { |
|
|
|
// topicPrompts.countPrompt = xhr.responseJSON.message; |
|
|
|
// } |
|
|
|
// } |
|
|
|
// }) |
|
|
|
// .always(() => { |
|
|
|
// topicForm.form('validate form'); |
|
|
|
// }); |
|
|
|
// }); |
|
|
|
|
|
|
|
// topicDropdown.dropdown({ |
|
|
|
// allowAdditions: true, |
|
|
|
// forceSelection: false, |
|
|
|
// fields: {name: 'description', value: 'data-value'}, |
|
|
|
// saveRemoteData: false, |
|
|
|
// label: { |
|
|
|
// transition: 'horizontal flip', |
|
|
|
// duration: 200, |
|
|
|
// variation: false, |
|
|
|
// blue: true, |
|
|
|
// basic: true |
|
|
|
// }, |
|
|
|
// className: { |
|
|
|
// label: 'ui small label' |
|
|
|
// }, |
|
|
|
// apiSettings: { |
|
|
|
// url: `${AppSubUrl}/api/v1/topics/search?q={query}`, |
|
|
|
// throttle: 500, |
|
|
|
// cache: false, |
|
|
|
// onResponse(res) { |
|
|
|
// const formattedResponse = { |
|
|
|
// success: false, |
|
|
|
// results: [] |
|
|
|
// }; |
|
|
|
// const stripTags = function (text) { |
|
|
|
// return text.replace(/<[^>]*>?/gm, ''); |
|
|
|
// }; |
|
|
|
|
|
|
|
// const query = stripTags(this.urlData.query.trim()); |
|
|
|
// let found_query = false; |
|
|
|
// const current_topics = []; |
|
|
|
// topicDropdown |
|
|
|
// .find('div.label.visible.topic,a.label.visible') |
|
|
|
// .each((_, e) => { |
|
|
|
// current_topics.push(e.dataset.value); |
|
|
|
// }); |
|
|
|
|
|
|
|
// if (res.topics) { |
|
|
|
// let found = false; |
|
|
|
// for (let i = 0; i < res.topics.length; i++) { |
|
|
|
// // skip currently added tags |
|
|
|
// if (current_topics.includes(res.topics[i].topic_name)) { |
|
|
|
// continue; |
|
|
|
// } |
|
|
|
|
|
|
|
// if ( |
|
|
|
// res.topics[i].topic_name.toLowerCase() === query.toLowerCase() |
|
|
|
// ) { |
|
|
|
// found_query = true; |
|
|
|
// } |
|
|
|
// formattedResponse.results.push({ |
|
|
|
// description: res.topics[i].topic_name, |
|
|
|
// 'data-value': res.topics[i].topic_name |
|
|
|
// }); |
|
|
|
// found = true; |
|
|
|
// } |
|
|
|
// formattedResponse.success = found; |
|
|
|
// } |
|
|
|
|
|
|
|
// if (query.length > 0 && !found_query) { |
|
|
|
// formattedResponse.success = true; |
|
|
|
// formattedResponse.results.unshift({ |
|
|
|
// description: query, |
|
|
|
// 'data-value': query |
|
|
|
// }); |
|
|
|
// } else if (query.length > 0 && found_query) { |
|
|
|
// formattedResponse.results.sort((a, b) => { |
|
|
|
// if (a.description.toLowerCase() === query.toLowerCase()) return -1; |
|
|
|
// if (b.description.toLowerCase() === query.toLowerCase()) return 1; |
|
|
|
// if (a.description > b.description) return -1; |
|
|
|
// if (a.description < b.description) return 1; |
|
|
|
// return 0; |
|
|
|
// }); |
|
|
|
// } |
|
|
|
|
|
|
|
// return formattedResponse; |
|
|
|
// } |
|
|
|
// }, |
|
|
|
// onLabelCreate(value) { |
|
|
|
// value = value.toLowerCase().trim(); |
|
|
|
// this.attr('data-value', value) |
|
|
|
// .contents() |
|
|
|
// .first() |
|
|
|
// .replaceWith(value); |
|
|
|
// return $(this); |
|
|
|
// }, |
|
|
|
// onAdd(addedValue, _addedText, $addedChoice) { |
|
|
|
// addedValue = addedValue.toLowerCase().trim(); |
|
|
|
// $($addedChoice).attr('data-value', addedValue); |
|
|
|
// $($addedChoice).attr('data-text', addedValue); |
|
|
|
// } |
|
|
|
// }); |
|
|
|
|
|
|
|
// $.fn.form.settings.rules.validateTopic = function (_values, regExp) { |
|
|
|
// const topics = topicDropdown.children('a.ui.label'); |
|
|
|
// const status = |
|
|
|
// topics.length === 0 || (topics.last().attr('data-value').match(regExp) !== null && topics.last().attr('data-value').length <= 35); |
|
|
|
// if (!status) { |
|
|
|
// topics |
|
|
|
// .last() |
|
|
|
// .removeClass('green') |
|
|
|
// .addClass('red'); |
|
|
|
// } |
|
|
|
// return status && topicDropdown.children('a.ui.label.red').length === 0; |
|
|
|
// }; |
|
|
|
|
|
|
|
// topicForm.form({ |
|
|
|
// on: 'change', |
|
|
|
// inline: true, |
|
|
|
// fields: { |
|
|
|
// topics: { |
|
|
|
// identifier: 'topics', |
|
|
|
// rules: [ |
|
|
|
// { |
|
|
|
// type: 'validateTopic', |
|
|
|
// value: /^[\u4e00-\u9fa5a-z0-9][\u4e00-\u9fa5a-z0-9-]{0,105}$/, |
|
|
|
// prompt: topicPrompts.formatPrompt |
|
|
|
// }, |
|
|
|
// { |
|
|
|
// type: 'maxCount[25]', |
|
|
|
// prompt: topicPrompts.countPrompt |
|
|
|
// } |
|
|
|
// ] |
|
|
|
// } |
|
|
|
// } |
|
|
|
// }); |
|
|
|
// } |
|
|
|
|
|
|
|
window.toggleDeadlineForm = function () { |
|
|
|
$('#deadlineForm').fadeToggle(150); |
|
|
|