Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Edit comment is now an annotation menu item. Javascript also moved to…

… the javascript view.
  • Loading branch information...
commit 510138271f857bac856f01782a7aa834fcf5bb6d 1 parent 6871732
@sembrestels sembrestels authored
View
19 start.php
@@ -1,15 +1,28 @@
<?php
-elgg_register_event_handler('init','system','editable_comments_init');
+elgg_register_event_handler('init','system','editablecomments_init');
-function editable_comments_init() {
- // extend css
+function editablecomments_init() {
+ // extend CSS and Javascript
elgg_extend_view('css/elgg', 'editablecomments/css');
+ elgg_extend_view('js/elgg', 'editablecomments/js');
// extend the comment view with the form
elgg_extend_view('annotation/generic_comment', 'editablecomments/generic_comment');
+
+ elgg_register_plugin_hook_handler('register', 'menu:annotation', 'editablecomments_annotation_menu');
// register the update action
$actions_path = elgg_get_plugins_path() . "editablecomments/actions/editablecomments";
elgg_register_action('editablecomments/edit', "$actions_path/edit.php");
}
+
+/**
+ * Add a menu item to the annotations
+ */
+function editablecomments_annotation_menu($hook, $type, $return, $params) {
+ $url = "#edit-annotation-" . $params['annotation']->id;
+ $item = new ElggMenuItem('comment:edit', elgg_echo('edit'), $url);
+ $return[] = $item;
+ return $return;
+}
View
6 views/default/editablecomments/css.php
@@ -1,8 +1,4 @@
-.editablecomments_form {
+.editablecomments-form {
display: none;
padding: 15px 0;
}
-
-a.editablecomments_toggle {
- cursor: pointer;
-}
View
5 views/default/editablecomments/generic_comment.php
@@ -1,10 +1,7 @@
<?php
if ($vars['annotation']->canEdit()) {
- //display an edit link that will open up an edit area
- echo "<a class=\"editablecomments_toggle\" onclick=\"javascript:$('#editablecomments_form_{$vars['annotation']->id}').slideToggle('fast');\">".elgg_echo('comment:edit')."</a>";
-
- echo "<div class=\"editablecomments_form\" id=\"editablecomments_form_{$vars['annotation']->id}\">";
+ echo "<div class=\"editablecomments-form\" id=\"editablecomments-edit-annotation-{$vars['annotation']->id}\">";
echo elgg_view_form('editablecomments/edit', array(), array('annotation' => $vars['annotation']));
echo "</div>";
}
View
5 views/default/editablecomments/js.php
@@ -0,0 +1,5 @@
+$().ready(function(){
+ $('.elgg-menu-item-comment-edit a').click(function(){
+ $('#editablecomments-'+elgg.parse_url(this.href).fragment).toggle();
+ });
+});
Please sign in to comment.
Something went wrong with that request. Please try again.