app/Resources/static-src/app/js/task/plugin/question/question.js
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
import notify from 'common/notify';
import postal from 'postal';
export default class {
constructor(url) {
this.url = url;
this.$element = $('.question-detail-block');
this.$form = null;
this.validator = null;
this.channel = postal.channel('task.plugin.question');
this.render();
}
initEvent() {
this.$element.on('click', '.back-to-list', () => {
this.channel.publish('back-to-list');
});
this.toggleShow();
this.$element.on('click', '.js-more-show', (event) => {
this.channel.publish('js-more-show', event);
});
this.$form.on('click', '.btn-primary', event => this.onSavePost(event));
}
toggleShow() {
this.$element.find('.task-question-plugin-pane-thread__content').each(function () {
let height = $(this).height();
if (height >= 76) {
$(this).next().show();
}
});
}
onSavePost(event) {
const self = this;
event.preventDefault();
if (!this.validator || !this.validator.form()) {
return;
}
$.post(this.$form.attr('action'), this.$form.serialize())
.done((html) => {
if (!$('.js-post-answer-item').length) {
$('.js-answer-title').removeClass('hidden');
}
this.$element.find('[data-role=post-list]').append(html);
if ($(event.target).data('type') === 'question') {
self.toggleShow();
}
const number = parseInt(this.$element.find('[data-role=post-number]').text());
this.$element.find('[data-role=post-number]').text(number + 1);
this.$form.find('textarea').val('');
})
.error(function (response) {
notify('danger', response.error.message);
});
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。