3 $(document).
on(
'elgg_ui_toggle',
function (e, data) {
4 var $toggle = $(e.target);
5 var $elements = data.$toggled_elements;
7 if ($elements.is(
'.elgg-river-responses > .elgg-form-comment-save')) {
8 if ($toggle.hasClass(
'elgg-state-active')) {
9 $elements.find(
'.elgg-input-text').focus();
16 $(document).
on(
'click',
'.elgg-toggle-comment',
function (event) {
17 var $anchor = $(
this);
18 var comment_guid = $anchor.data().loadComment;
20 require([
'elgg/Ajax',
'elgg/toggle'],
function(Ajax) {
21 var ajax =
new Ajax();
23 ajax.form(
'comment/save', {
27 success:
function(result) {
28 $(
'div[data-comments-placeholder=' + comment_guid +
']')
30 .slideToggle(
'medium')
31 .find(
'textarea, [contenteditable]').filter(
':visible').first().focus();
33 $anchor.toggleClass(
'elgg-toggle elgg-toggle-comment');
39 $(document).
on(
'submit',
'.elgg-form-comment-save',
function (event) {
42 $form.find(
'.elgg-button-submit').prop(
'disabled',
true);
44 require([
'elgg/Ajax'],
function(Ajax) {
45 var ajax =
new Ajax();
47 ajax.action($form.attr(
'action'), {
48 data: ajax.objectify($form),
49 success:
function(result) {
50 var
$container = $form.closest(
'.elgg-comments');
51 var view_name =
'page/elements/comments';
52 var comment_guid = result.guid;
54 guid: $form.find(
'input[name="entity_guid"]').val(),
56 show_guid: comment_guid,
57 inline: $form.find(
'.elgg-input-text').length
60 if (!$container.length) {
61 $container = $form.closest(
'.elgg-river-responses');
62 view_name =
'river/elements/responses';
63 data.river_id = $container.closest(
'.elgg-river-item').parent().attr(
'id').replace(
'item-river-',
'');
66 if (!$container.length) {
67 $form.find(
'.elgg-button-submit').prop(
'disabled',
true);
73 function fix_pagination($container) {
74 function normalize(url) {
75 return url.replace(/#.*/,
'');
78 var base_url = normalize(location.href);
80 $container.find(
'.elgg-pagination a').each(
function () {
81 if (normalize(this.href) === base_url) {
82 $(
this).
on(
'click',
function () {
89 ajax.view(view_name, {
91 success:
function(result) {
92 if (view_name ===
'river/elements/responses') {
93 $container.html(result);
95 $container.html($(result).
filter(
'.elgg-comments').html());
98 var
$comment = $container.find(
'#elgg-object-' + comment_guid);
99 $comment.addClass(
'elgg-state-highlight');
101 $comment[0].scrollIntoView({behavior:
'smooth'});
103 fix_pagination($container);
106 $form.find(
'.elgg-button-submit').prop(
'disabled',
false);
111 $form.find(
'.elgg-button-submit').prop(
'disabled',
false);
116 event.preventDefault();
117 event.stopPropagation();
121 $(document).
on(
'click',
'.elgg-menu-item-edit > a',
function () {
122 var $trigger = $(
this).closest(
'.elgg-menu-hover').data(
'trigger');
123 if ((typeof $trigger ===
'undefined') || !$trigger.is(
'.elgg-item-object-comment a')) {
128 var dc = $(
this).data(
'Comment');
130 var guid = $(
this).data().commentGuid;
131 dc =
new Comment(guid, $trigger.closest(
'.elgg-item-object-comment'));
132 $(
this).data(
'Comment', dc);
137 require([
'elgg/popup'],
function(popup) {
144 function Comment(guid, item) {
149 Comment.prototype = {
155 getForm:
function () {
156 return this.
$item.find(
'#edit-comment-' + this.guid);
159 hideForm:
function () {
160 this.getForm().toggleClass(
'hidden');
161 this.getForm().prev().toggleClass(
'hidden');
164 showForm:
function () {
165 this.getForm().toggleClass(
'hidden');
166 this.getForm().prev().toggleClass(
'hidden');
168 this.getForm().find(
'textarea, [contenteditable]').filter(
':visible').first().focus();
171 loadForm:
function () {
174 require([
'elgg/Ajax'],
function(Ajax) {
175 var ajax =
new Ajax();
178 ajax.view(
'core/ajax/edit_comment?guid=' + that.guid, {
179 success: function(html) {
181 that.$item.find(
'.elgg-body').first().append(html);
185 var $form = that.getForm();
187 $form.find(
'.elgg-button-cancel').on(
'click', function () {
193 $form.on(
'submit', function () {
202 submitForm:
function () {
203 var $form = this.getForm();
204 $form.find(
'.elgg-button-submit').prop(
'disabled',
true);
206 require([
'elgg/Ajax'],
function(Ajax) {
207 var ajax =
new Ajax();
209 ajax.action($form.attr(
'action'), {
210 data: ajax.objectify($form),
211 success:
function(result) {
214 $form.closest(
'.elgg-item-object-comment').html(result.output);
218 $form.find(
'.elgg-button-submit').prop(
'disabled',
false);
226 toggleEdit:
function () {
227 var $form = this.getForm();
229 if ($form.hasClass(
'hidden')) {
function filter(array, term)
Bundled plugins(the contents of the"/mod"directory) are available only under the GPLv2 license.The remainder of the project is available under either MIT or GPLv2.Both licenses can be found below.More info and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two distribute and or modify the software for each author s protection and we want to make certain that everyone understands that there is no warranty for this free software If the software is modified by someone else and passed on