Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var jrpc = new rpc(!0),
- JournalMessage = {
- url: '/journal-messages-ajax-action',
- action: jrpc.action,
- del: function (e, r) {
- jrpc.callPool(this.action('messages.delete', [e, r]), (function (e) {
- !1 === e.result && '' != e.error && alert(e.error)
- }))
- },
- note_unread: function (e) {
- jrpc.callPool(this.action('messages.note_unread', [e]), (function (e) {
- !1 === e.result && '' != e.error && alert(e.error)
- }))
- },
- note_read: function (e) {
- jrpc.callPool(this.action('messages.note_read', [e]), (function (e) {
- !1 === e.result && '' != e.error && alert(e.error)
- }))
- },
- send_view: function () {
- var e = [];
- $('nobr[id^="fid_"]').children('input:checked').each((function () {
- var r = $(this.parentNode);
- e.push({
- 'fid': r.attr('fid') ? r.attr('fid') : r.attr('id').substr(4),
- 'filename': r.attr('filename')
- })
- }));
- var r = [];
- $('#resources-checkboxes').children('label').children('input:checked').each((function () {
- r.push($(this).val())
- })),
- r = r.join(';');
- var n = [];
- if (window.additional_receivers.length > 0 && (n = n.concat(window.additional_receivers)), void 0 !== window.multipleViewReceiversIsActive) if (!0 === window.multipleViewReceiversIsActive) {
- var t = window.allReceivers;
- n = (t = t.concat(window.partReceivers)).map((function (e) {
- return e.id || e.uid
- }))
- } else if (!1 === window.multipleViewReceiversIsActive) {
- var a = window.receiversArray;
- n = (a = a.concat(window.partReceivers)).map((function (e) {
- return e.id || e.uid
- }))
- }
- void 0 !== window.receiversArray && window.receiversArray instanceof Array && window.receiversArray.length && (n = n.concat(window.receiversArray)),
- n = n.join(';'),
- jrpc.addParameter('subject', subject),
- jrpc.addParameter('reply', $('#msgReply').val()),
- jrpc.addParameter('receivers', n),
- jrpc.addParameter('message_id', message_id),
- jrpc.addParameter('vfiles', JSON.stringify(e)),
- jrpc.addParameter('resources', r),
- $('#msgReply').attr('disabled', !0),
- $('#send').attr('disabled', !0),
- window.showLoadingScreen(window.trans('messaging.wait_sending')),
- jrpc.post(this.action('messages.send_view'), (function (e) {
- try {
- var r = e;
- !1 === r.result && '' !== r.error && (removeDisable(), alert(r.error, !0)),
- r.result > 0 && (removeDisable(), msg_view_cancel(), $('#msgReply').val(''), $('div nobr').remove(), alert(intlmsg.msg_send))
- } catch (e) {
- alert(window.trans('messaging.error.send'), !0)
- }
- }))
- }
- };
- function msg_send(e) {
- if (e && e.preventDefault && e.preventDefault(), $('#subject').length > 0 && '' == $.trim($('#subject').val())) return alert(err_subject),
- !1;
- var r = [];
- if ($('#rec').children('a').each((function () {
- r.push($(this).attr('name'))
- })), r = r.join(';'), $('#receivers').val(r), '' == r) return alert(err_receivers),
- !1;
- if ('' == $.trim($('#message').val())) return alert(err_message),
- !1;
- var n = [];
- return $('nobr[id^="fid_"]').children('input:checked').each((function () {
- var e = $(this.parentNode);
- n.push({
- 'fid': e.attr('fid') ? e.attr('fid') : e.attr('id').substr(4),
- 'filename': e.attr('filename')
- })
- })),
- $('#vfiles').val(JSON.stringify(n)),
- !0
- }
- function msg_cancel(e) {
- return e && e.preventDefault && e.preventDefault(),
- window.location.href = '/journal-messages-action',
- !1
- }
- function msg_view_reply(e) {
- return e = e || !1,
- $('#msgReply').slideDown('normal', (function () {
- $('#reply, #reply_all, #delete, #another, #forward, #matOn').hide(),
- $('#send, #cancel, #receivers_new, #receivers_new_instruction, #upload_new, #attach_resource').show(),
- e && (window.additional_receivers = allReceivers, $('#receivers_new').find('.count').text('(' + window.additional_receivers.length + ')'))
- })),
- !1
- }
- function msg_view_delete(e) {
- return e && e.preventDefault && e.preventDefault(),
- Boxy.confirm(intlmsg.msg_del_confirm, (function () {
- JournalMessage.del(message_id, msg_type),
- alert(intlmsg.msg_del),
- $('table.message').fadeTo('fast', .5),
- $('#reply, #reply_all, #send, #cancel, #delete, #another, #forward, #matOn').fadeOut('slow')
- })),
- !1
- }
- function msg_view_send(e) {
- return e && e.preventDefault && e.preventDefault(),
- '' == $.trim($('#msgReply').val()) ? (alert(intlmsg.msg_empty), !1) : (JournalMessage.send_view(), !1)
- }
- function msg_view_cancel(e) {
- return e && e.preventDefault && e.preventDefault(),
- window.additional_receivers = [],
- $('#receivers_new').find('.count').text('(' + window.additional_receivers.length + ')'),
- $('#msgReply').slideUp(),
- $('#reply, #reply_all, #delete, #another, #forward, #matOn').show(),
- $('#send, #cancel, #receivers_new, #receivers_new_instruction, #upload_new, #attach_resource').hide(),
- !1
- }
- function msg_view_forward(e) {
- e && e.preventDefault && e.preventDefault();
- var r = '/journal-messages-forward-action/id.' + message_id;
- return '' != teacher && (r += '/teacher.' + teacher),
- window.location.href = r,
- !1
- }
- function removeDisable() {
- $('#msgReply').attr('disabled', !1),
- $('#send').attr('disabled', !1),
- window.hideLoadingScreen()
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement