2021-07-13 21:09:19 +03:00
|
|
|
import Vue from 'vue';
|
2020-02-12 04:53:18 +03:00
|
|
|
|
2021-07-13 21:09:19 +03:00
|
|
|
import ContextPopup from '../components/ContextPopup.vue';
|
2020-02-12 04:53:18 +03:00
|
|
|
|
|
|
|
export default function initContextPopups() {
|
2020-01-20 07:39:21 +03:00
|
|
|
const refIssues = $('.ref-issue');
|
|
|
|
if (!refIssues.length) return;
|
|
|
|
|
|
|
|
refIssues.each(function () {
|
|
|
|
const [index, _issues, repo, owner] = $(this).attr('href').replace(/[#?].*$/, '').split('/').reverse();
|
|
|
|
|
2021-07-13 21:09:19 +03:00
|
|
|
const el = document.createElement('div');
|
|
|
|
el.className = 'ui custom popup hidden';
|
|
|
|
el.innerHTML = '<div></div>';
|
|
|
|
this.parentNode.insertBefore(el, this.nextSibling);
|
2020-01-20 07:39:21 +03:00
|
|
|
|
2021-07-13 21:09:19 +03:00
|
|
|
const View = Vue.extend({
|
|
|
|
render: (createElement) => createElement(ContextPopup),
|
|
|
|
});
|
2020-01-20 07:39:21 +03:00
|
|
|
|
2021-07-13 21:09:19 +03:00
|
|
|
const view = new View();
|
2020-01-20 07:39:21 +03:00
|
|
|
|
2021-07-13 21:09:19 +03:00
|
|
|
try {
|
|
|
|
view.$mount(el.firstChild);
|
|
|
|
} catch (err) {
|
|
|
|
console.error(err);
|
|
|
|
el.textContent = 'ContextPopup failed to load';
|
2020-01-20 07:39:21 +03:00
|
|
|
}
|
|
|
|
|
2021-07-13 21:09:19 +03:00
|
|
|
$(this).popup({
|
2020-01-20 07:39:21 +03:00
|
|
|
variation: 'wide',
|
|
|
|
delay: {
|
|
|
|
show: 250
|
|
|
|
},
|
2021-07-13 21:09:19 +03:00
|
|
|
onShow: () => {
|
|
|
|
view.$emit('load-context-popup', {owner, repo, index}, () => {
|
|
|
|
$(this).popup('reposition');
|
|
|
|
});
|
|
|
|
},
|
|
|
|
popup: $(el),
|
2020-01-20 07:39:21 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|