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 require([
'elgg/Ajax'],
function(Ajax) {
20 var ajax =
new Ajax();
22 ajax.action($form.attr(
'action'), {
23 data: ajax.objectify($form),
24 success:
function(result) {
25 var
$container = $form.closest(
'.elgg-comments');
26 var view_name =
'page/elements/comments';
27 var comment_guid = result.guid;
29 guid: $form.find(
'input[name="entity_guid"]').val(),
31 show_guid: comment_guid,
32 inline: $form.find(
'.elgg-input-text').length
35 if (!$container.length) {
36 $container = $form.closest(
'.elgg-river-responses');
37 view_name =
'river/elements/responses';
38 data.river_id = $container.closest(
'.elgg-river-item').parent().attr(
'id').replace(
'item-river-',
'');
41 if (!$container.length) {
47 function fix_pagination($container) {
48 function normalize(url) {
49 return url.replace(/#.*/,
'');
52 var base_url = normalize(location.href);
54 $container.find(
'.elgg-pagination a').each(
function () {
55 if (normalize(this.href) === base_url) {
56 $(
this).
on(
'click',
function () {
63 ajax.view(view_name, {
65 success:
function(result) {
66 if (view_name ===
'river/elements/responses') {
67 $container.html(result);
69 $container.html($(result).
filter(
'.elgg-comments').html());
72 var
$comment = $container.find(
'#elgg-object-' + comment_guid);
73 $comment.addClass(
'elgg-state-highlight');
75 $comment[0].scrollIntoView({behavior:
'smooth'});
77 fix_pagination($container);
84 event.preventDefault();
85 event.stopPropagation();
89 $(document).
on(
'click',
'.elgg-menu-item-edit > a',
function () {
90 var $trigger = $(
this).closest(
'.elgg-menu-hover').data(
'trigger');
91 if ((typeof $trigger ===
'undefined') || !$trigger.is(
'.elgg-item-object-comment a')) {
96 var dc = $(
this).data(
'Comment');
98 var guid = this.href.split(
'/').pop();
99 dc =
new Comment(guid, $trigger.closest(
'.elgg-item-object-comment'));
100 $(
this).data(
'Comment', dc);
105 require([
'elgg/popup'],
function(popup) {
112 function Comment(guid, item) {
117 Comment.prototype = {
123 getForm:
function () {
124 return this.
$item.find(
'#edit-comment-' + this.guid);
127 hideForm:
function () {
128 this.getForm().toggleClass(
'hidden');
129 this.getForm().prev().toggleClass(
'hidden');
132 showForm:
function () {
133 this.getForm().toggleClass(
'hidden');
134 this.getForm().prev().toggleClass(
'hidden');
137 loadForm:
function () {
140 require([
'elgg/Ajax'],
function(Ajax) {
141 var ajax =
new Ajax();
144 ajax.view(
'core/ajax/edit_comment?guid=' + that.guid, {
145 success: function(html) {
147 that.$item.find(
'.elgg-body').first().append(html);
151 var $form = that.getForm();
153 $form.find(
'.elgg-button-cancel').on(
'click', function () {
159 $form.on(
'submit', function () {
168 submitForm:
function () {
169 var $form = this.getForm();
171 require([
'elgg/Ajax'],
function(Ajax) {
172 var ajax =
new Ajax();
174 ajax.action($form.attr(
'action'), {
175 data: ajax.objectify($form),
176 success:
function(result) {
179 $form.closest(
'.elgg-item-object-comment').html(result.output);
188 toggleEdit:
function () {
189 var $form = this.getForm();
191 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