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(
'submit',
'.elgg-form-comment-save',
function (event) {
19 $form.find(
'.elgg-button-submit').prop(
'disabled',
true);
21 require([
'elgg/Ajax'],
function(Ajax) {
22 var ajax =
new Ajax();
24 ajax.action($form.attr(
'action'), {
25 data: ajax.objectify($form),
26 success:
function(result) {
27 var
$container = $form.closest(
'.elgg-comments');
28 var view_name =
'page/elements/comments';
29 var comment_guid = result.guid;
31 guid: $form.find(
'input[name="entity_guid"]').val(),
33 show_guid: comment_guid,
34 inline: $form.find(
'.elgg-input-text').length
37 if (!$container.length) {
38 $container = $form.closest(
'.elgg-river-responses');
39 view_name =
'river/elements/responses';
40 data.river_id = $container.closest(
'.elgg-river-item').parent().attr(
'id').replace(
'item-river-',
'');
43 if (!$container.length) {
44 $form.find(
'.elgg-button-submit').prop(
'disabled',
true);
50 function fix_pagination($container) {
51 function normalize(url) {
52 return url.replace(/#.*/,
'');
55 var base_url = normalize(location.href);
57 $container.find(
'.elgg-pagination a').each(
function () {
58 if (normalize(this.href) === base_url) {
59 $(
this).
on(
'click',
function () {
66 ajax.view(view_name, {
68 success:
function(result) {
69 if (view_name ===
'river/elements/responses') {
70 $container.html(result);
72 $container.html($(result).
filter(
'.elgg-comments').html());
75 var
$comment = $container.find(
'#elgg-object-' + comment_guid);
76 $comment.addClass(
'elgg-state-highlight');
78 $comment[0].scrollIntoView({behavior:
'smooth'});
80 fix_pagination($container);
83 $form.find(
'.elgg-button-submit').prop(
'disabled',
false);
88 $form.find(
'.elgg-button-submit').prop(
'disabled',
false);
93 event.preventDefault();
94 event.stopPropagation();
98 $(document).
on(
'click',
'.elgg-menu-item-edit > a',
function () {
99 var $trigger = $(
this).closest(
'.elgg-menu-hover').data(
'trigger');
100 if ((typeof $trigger ===
'undefined') || !$trigger.is(
'.elgg-item-object-comment a')) {
105 var dc = $(
this).data(
'Comment');
107 var guid = $(
this).data().commentGuid;
108 dc =
new Comment(guid, $trigger.closest(
'.elgg-item-object-comment'));
109 $(
this).data(
'Comment', dc);
114 require([
'elgg/popup'],
function(popup) {
121 function Comment(guid, item) {
126 Comment.prototype = {
132 getForm:
function () {
133 return this.
$item.find(
'#edit-comment-' + this.guid);
136 hideForm:
function () {
137 this.getForm().toggleClass(
'hidden');
138 this.getForm().prev().toggleClass(
'hidden');
141 showForm:
function () {
142 this.getForm().toggleClass(
'hidden');
143 this.getForm().prev().toggleClass(
'hidden');
145 this.getForm().find(
'textarea, [contenteditable]').filter(
':visible').first().focus();
148 loadForm:
function () {
151 require([
'elgg/Ajax'],
function(Ajax) {
152 var ajax =
new Ajax();
155 ajax.view(
'core/ajax/edit_comment?guid=' + that.guid, {
156 success: function(html) {
158 that.$item.find(
'.elgg-body').first().append(html);
162 var $form = that.getForm();
164 $form.find(
'.elgg-button-cancel').on(
'click', function () {
170 $form.on(
'submit', function () {
179 submitForm:
function () {
180 var $form = this.getForm();
181 $form.find(
'.elgg-button-submit').prop(
'disabled',
true);
183 require([
'elgg/Ajax'],
function(Ajax) {
184 var ajax =
new Ajax();
186 ajax.action($form.attr(
'action'), {
187 data: ajax.objectify($form),
188 success:
function(result) {
191 $form.closest(
'.elgg-item-object-comment').html(result.output);
195 $form.find(
'.elgg-button-submit').prop(
'disabled',
false);
203 toggleEdit:
function () {
204 var $form = this.getForm();
206 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