Version Description
- Moved JavaScript to own file
- Added comments to the history, so now you can see who approved a comment (or unapproved, or marked as spam, or moved to trash, or restored from the trash)
Download this release
Release Info
| Developer | eskapism |
| Plugin | |
| Version | 0.3.3 |
| Comparing to | |
| See all releases | |
Code changes from version 0.3.2 to 0.3.3
- index.php +95 -108
- readme.txt +6 -0
- screenshot-3.png +0 -0
- scripts.js +78 -0
index.php
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
Plugin Name: Simple History
|
| 4 |
Plugin URI: http://eskapism.se/code-playground/simple-history/
|
| 5 |
Description: Get a log of the changes made by users in WordPress.
|
| 6 |
-
Version: 0.3.
|
| 7 |
Author: Pär Thernström
|
| 8 |
Author URI: http://eskapism.se/
|
| 9 |
License: GPL2
|
|
@@ -25,7 +25,7 @@ License: GPL2
|
|
| 25 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
| 26 |
*/
|
| 27 |
|
| 28 |
-
define( "SIMPLE_HISTORY_VERSION", "0.3.
|
| 29 |
define( "SIMPLE_HISTORY_NAME", "Simple History");
|
| 30 |
define( "SIMPLE_HISTORY_URL", WP_PLUGIN_URL . '/simple-history/');
|
| 31 |
|
|
@@ -87,88 +87,6 @@ function simple_history_dashboard() {
|
|
| 87 |
}
|
| 88 |
|
| 89 |
function simple_history_admin_head() {
|
| 90 |
-
?>
|
| 91 |
-
<script type="text/javascript">
|
| 92 |
-
/* <![CDATA[ */
|
| 93 |
-
/**
|
| 94 |
-
* load history items via ajax
|
| 95 |
-
*/
|
| 96 |
-
var simple_history_current_page = 0;
|
| 97 |
-
jQuery(".simple-history-filter a").live("click", function() {
|
| 98 |
-
$t = jQuery(this);
|
| 99 |
-
$t.closest("ul").find("li").removeClass("selected");
|
| 100 |
-
$t.closest("li").addClass("selected");
|
| 101 |
-
$ol = jQuery("ol.simple-history");
|
| 102 |
-
|
| 103 |
-
jQuery(".simple-history-added-by-ajax").remove();
|
| 104 |
-
|
| 105 |
-
var $wrapper = jQuery("#simple-history-ol-wrapper");
|
| 106 |
-
$wrapper.height($wrapper.height()); // so dashboard widget does not collapse when loading new items
|
| 107 |
-
|
| 108 |
-
jQuery("#simple-history-load-more").hide("fast");
|
| 109 |
-
$ol.fadeOut("fast");
|
| 110 |
-
jQuery("#simple-history-no-more-items").hide();
|
| 111 |
-
|
| 112 |
-
simple_history_current_page = 0;
|
| 113 |
-
var data = {
|
| 114 |
-
"action": "simple_history_ajax",
|
| 115 |
-
"type": jQuery(".simple-history-filter-type li.selected a").text(),
|
| 116 |
-
"user": jQuery(".simple-history-filter-user li.selected a").text()
|
| 117 |
-
};
|
| 118 |
-
jQuery.post(ajaxurl, data, function(data, textStatus, XMLHttpRequest){
|
| 119 |
-
$ol.html(data);
|
| 120 |
-
$ol.fadeIn("fast");
|
| 121 |
-
$wrapper.height("auto");
|
| 122 |
-
jQuery("#simple-history-load-more").fadeIn("fast");
|
| 123 |
-
});
|
| 124 |
-
|
| 125 |
-
return false;
|
| 126 |
-
});
|
| 127 |
-
|
| 128 |
-
jQuery("#simple-history-load-more a").live("click", function() {
|
| 129 |
-
simple_history_current_page++;
|
| 130 |
-
|
| 131 |
-
jQuery("#simple-history-load-more,#simple-history-load-more-loading").toggle();
|
| 132 |
-
|
| 133 |
-
$ol = jQuery("ol.simple-history:last");
|
| 134 |
-
var data = {
|
| 135 |
-
"action": "simple_history_ajax",
|
| 136 |
-
"type": jQuery(".simple-history-filter-type li.selected a").text(),
|
| 137 |
-
"user": jQuery(".simple-history-filter-user li.selected a").text(),
|
| 138 |
-
"page": simple_history_current_page
|
| 139 |
-
};
|
| 140 |
-
jQuery.post(ajaxurl, data, function(data, textStatus, XMLHttpRequest){
|
| 141 |
-
|
| 142 |
-
// if data = simpleHistoryNoMoreItems then no more items found, so hide load-more-link
|
| 143 |
-
if (data == "simpleHistoryNoMoreItems") {
|
| 144 |
-
jQuery("#simple-history-load-more,#simple-history-load-more-loading").hide();
|
| 145 |
-
jQuery("#simple-history-no-more-items").show();
|
| 146 |
-
} else {
|
| 147 |
-
var $new_elm = jQuery("<ol class='simple-history simple-history-added-by-ajax'>" + data + "</ol>");
|
| 148 |
-
$new_elm.hide();
|
| 149 |
-
$ol.after($new_elm);
|
| 150 |
-
$new_elm.show("slow");
|
| 151 |
-
jQuery("#simple-history-load-more,#simple-history-load-more-loading").toggle();
|
| 152 |
-
}
|
| 153 |
-
});
|
| 154 |
-
return false;
|
| 155 |
-
});
|
| 156 |
-
|
| 157 |
-
jQuery("ol.simple-history .when").live("mouseover", function() {
|
| 158 |
-
jQuery(this).closest("li").find(".when_detail").fadeIn("fast");
|
| 159 |
-
});
|
| 160 |
-
jQuery("ol.simple-history .when").live("mouseout", function() {
|
| 161 |
-
jQuery(this).closest("li").find(".when_detail").fadeOut("fast");
|
| 162 |
-
});
|
| 163 |
-
|
| 164 |
-
// show occasions
|
| 165 |
-
jQuery("a.simple-history-occasion-show").live("click", function() {
|
| 166 |
-
jQuery(this).closest("li").find("ul.simple-history-occasions").toggle("fast");
|
| 167 |
-
return false;
|
| 168 |
-
});
|
| 169 |
-
/* ]]> */
|
| 170 |
-
</script>
|
| 171 |
-
<?php
|
| 172 |
}
|
| 173 |
|
| 174 |
|
|
@@ -184,21 +102,6 @@ delete_category
|
|
| 184 |
edit_category
|
| 185 |
Runs when a category is updated/edited, including when a post or blogroll link is added/deleted or its categories are updated (which causes the count for the category to update). Action function arguments: category ID.
|
| 186 |
|
| 187 |
-
edit_comment
|
| 188 |
-
Runs after a comment is updated/edited in the database. Action function arguments: comment ID
|
| 189 |
-
|
| 190 |
-
delete_comment
|
| 191 |
-
Runs just before a comment is deleted. Action function arguments: comment ID.
|
| 192 |
-
|
| 193 |
-
comment_closed
|
| 194 |
-
Runs when the post is marked as not allowing comments while trying to display comment entry form. Action function argument: post ID.
|
| 195 |
-
|
| 196 |
-
edit_comment
|
| 197 |
-
Runs after a comment is updated/edited in the database. Action function arguments: comment ID.
|
| 198 |
-
|
| 199 |
-
delete_comment
|
| 200 |
-
Runs just before a comment is deleted. Action function arguments: comment ID.
|
| 201 |
-
|
| 202 |
add_link
|
| 203 |
Runs when a new blogroll link is first added to the database. Action function arguments: link ID.
|
| 204 |
|
|
@@ -215,7 +118,8 @@ switch_theme
|
|
| 215 |
*/
|
| 216 |
|
| 217 |
function simple_history_init() {
|
| 218 |
-
|
|
|
|
| 219 |
add_action("wp_login", "simple_history_wp_login");
|
| 220 |
add_action("wp_logout", "simple_history_wp_logout");
|
| 221 |
add_action("delete_user", "simple_history_delete_user");
|
|
@@ -308,6 +212,21 @@ function simple_history_admin_init() {
|
|
| 308 |
add_action("edit_attachment", "simple_history_edit_attachment");
|
| 309 |
add_action("delete_attachment", "simple_history_delete_attachment");
|
| 310 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 311 |
add_settings_section("simple_history_settings_general", SIMPLE_HISTORY_NAME, "simple_history_settings_page", "general");
|
| 312 |
add_settings_field("simple_history_settings_field_1", "Show Simple History", "simple_history_settings_field", "general", "simple_history_settings_general");
|
| 313 |
add_settings_field("simple_history_settings_field_2", "RSS feed", "simple_history_settings_field_rss", "general", "simple_history_settings_general");
|
|
@@ -315,6 +234,8 @@ function simple_history_admin_init() {
|
|
| 315 |
register_setting("general", "simple_history_show_as_page");
|
| 316 |
|
| 317 |
wp_enqueue_style( "simple_history_styles", SIMPLE_HISTORY_URL . "styles.css", false, SIMPLE_HISTORY_VERSION );
|
|
|
|
|
|
|
| 318 |
|
| 319 |
}
|
| 320 |
function simple_history_settings_page() {
|
|
@@ -395,16 +316,76 @@ function simple_history_deactivated_plugin($plugin_name) {
|
|
| 395 |
simple_history_add("action=deactivated&object_type=plugin&object_name=$plugin_name");
|
| 396 |
}
|
| 397 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 398 |
|
| 399 |
function simple_history_update_option($option, $oldval, $newval) {
|
| 400 |
/*
|
| 401 |
-
echo "<br><br>simple_history_update_option()";
|
| 402 |
-
|
| 403 |
-
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
*/
|
| 408 |
|
| 409 |
if ($option == "active_plugins") {
|
| 410 |
|
|
@@ -1184,9 +1165,15 @@ function simple_history_print_history($args = null) {
|
|
| 1184 |
|
| 1185 |
$user_out = ucfirst($user_out);
|
| 1186 |
echo $user_out;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1187 |
} else {
|
| 1188 |
|
| 1189 |
-
// unknown type
|
| 1190 |
echo ucwords($object_type) . " $object_subtype <span class='simple-history-title'>\"$object_name\"</span> $action";
|
| 1191 |
|
| 1192 |
}
|
| 3 |
Plugin Name: Simple History
|
| 4 |
Plugin URI: http://eskapism.se/code-playground/simple-history/
|
| 5 |
Description: Get a log of the changes made by users in WordPress.
|
| 6 |
+
Version: 0.3.3
|
| 7 |
Author: Pär Thernström
|
| 8 |
Author URI: http://eskapism.se/
|
| 9 |
License: GPL2
|
| 25 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
| 26 |
*/
|
| 27 |
|
| 28 |
+
define( "SIMPLE_HISTORY_VERSION", "0.3.3");
|
| 29 |
define( "SIMPLE_HISTORY_NAME", "Simple History");
|
| 30 |
define( "SIMPLE_HISTORY_URL", WP_PLUGIN_URL . '/simple-history/');
|
| 31 |
|
| 87 |
}
|
| 88 |
|
| 89 |
function simple_history_admin_head() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
}
|
| 91 |
|
| 92 |
|
| 102 |
edit_category
|
| 103 |
Runs when a category is updated/edited, including when a post or blogroll link is added/deleted or its categories are updated (which causes the count for the category to update). Action function arguments: category ID.
|
| 104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
add_link
|
| 106 |
Runs when a new blogroll link is first added to the database. Action function arguments: link ID.
|
| 107 |
|
| 118 |
*/
|
| 119 |
|
| 120 |
function simple_history_init() {
|
| 121 |
+
|
| 122 |
+
// users and stuff
|
| 123 |
add_action("wp_login", "simple_history_wp_login");
|
| 124 |
add_action("wp_logout", "simple_history_wp_logout");
|
| 125 |
add_action("delete_user", "simple_history_delete_user");
|
| 212 |
add_action("edit_attachment", "simple_history_edit_attachment");
|
| 213 |
add_action("delete_attachment", "simple_history_delete_attachment");
|
| 214 |
|
| 215 |
+
add_action("edit_comment", "simple_history_edit_comment");
|
| 216 |
+
add_action("delete_comment", "simple_history_delete_comment");
|
| 217 |
+
add_action("wp_set_comment_status", "simple_history_set_comment_status", 10, 2);
|
| 218 |
+
/*
|
| 219 |
+
edit_comment
|
| 220 |
+
Runs after a comment is updated/edited in the database. Action function arguments: comment ID.
|
| 221 |
+
|
| 222 |
+
delete_comment
|
| 223 |
+
Runs just before a comment is deleted. Action function arguments: comment ID.
|
| 224 |
+
|
| 225 |
+
wp_set_comment_status
|
| 226 |
+
Runs when the status of a comment changes. Action function arguments: comment ID, status string indicating the new status ("delete", "approve", "spam", "hold").
|
| 227 |
+
*/
|
| 228 |
+
// comments
|
| 229 |
+
|
| 230 |
add_settings_section("simple_history_settings_general", SIMPLE_HISTORY_NAME, "simple_history_settings_page", "general");
|
| 231 |
add_settings_field("simple_history_settings_field_1", "Show Simple History", "simple_history_settings_field", "general", "simple_history_settings_general");
|
| 232 |
add_settings_field("simple_history_settings_field_2", "RSS feed", "simple_history_settings_field_rss", "general", "simple_history_settings_general");
|
| 234 |
register_setting("general", "simple_history_show_as_page");
|
| 235 |
|
| 236 |
wp_enqueue_style( "simple_history_styles", SIMPLE_HISTORY_URL . "styles.css", false, SIMPLE_HISTORY_VERSION );
|
| 237 |
+
|
| 238 |
+
wp_enqueue_script("simple_history", SIMPLE_HISTORY_URL . "scripts.js", array("jquery"), SIMPLE_HISTORY_VERSION);
|
| 239 |
|
| 240 |
}
|
| 241 |
function simple_history_settings_page() {
|
| 316 |
simple_history_add("action=deactivated&object_type=plugin&object_name=$plugin_name");
|
| 317 |
}
|
| 318 |
|
| 319 |
+
function simple_history_edit_comment($comment_id) {
|
| 320 |
+
|
| 321 |
+
$comment_data = get_commentdata($comment_id, 0, true);
|
| 322 |
+
$comment_post_ID = $comment_data["comment_post_ID"];
|
| 323 |
+
$post = get_post($comment_post_ID);
|
| 324 |
+
$post_title = get_the_title($comment_post_ID);
|
| 325 |
+
$excerpt = get_comment_excerpt($comment_id);
|
| 326 |
+
$author = get_comment_author($comment_id);
|
| 327 |
+
|
| 328 |
+
$str = sprintf( "$excerpt [" . __('From %1$s on %2$s') . "]", $author, $post_title );
|
| 329 |
+
$str = urlencode($str);
|
| 330 |
+
|
| 331 |
+
simple_history_add("action=edited&object_type=comment&object_name=$str&object_id=$comment_id");
|
| 332 |
+
}
|
| 333 |
+
|
| 334 |
+
function simple_history_delete_comment($comment_id) {
|
| 335 |
+
|
| 336 |
+
$comment_data = get_commentdata($comment_id, 0, true);
|
| 337 |
+
$comment_post_ID = $comment_data["comment_post_ID"];
|
| 338 |
+
$post = get_post($comment_post_ID);
|
| 339 |
+
$post_title = get_the_title($comment_post_ID);
|
| 340 |
+
$excerpt = get_comment_excerpt($comment_id);
|
| 341 |
+
$author = get_comment_author($comment_id);
|
| 342 |
+
|
| 343 |
+
$str = sprintf( "$excerpt [" . __('From %1$s on %2$s') . "]", $author, $post_title );
|
| 344 |
+
$str = urlencode($str);
|
| 345 |
+
|
| 346 |
+
simple_history_add("action=deleted&object_type=comment&object_name=$str&object_id=$comment_id");
|
| 347 |
+
}
|
| 348 |
+
|
| 349 |
+
function simple_history_set_comment_status($comment_id, $new_status) {
|
| 350 |
+
#echo "<br>new status: $new_status<br>"; // 0
|
| 351 |
+
// $new_status hold (unapproved), approve, spam, trash
|
| 352 |
+
$comment_data = get_commentdata($comment_id, 0, true);
|
| 353 |
+
$comment_post_ID = $comment_data["comment_post_ID"];
|
| 354 |
+
$post = get_post($comment_post_ID);
|
| 355 |
+
$post_title = get_the_title($comment_post_ID);
|
| 356 |
+
$excerpt = get_comment_excerpt($comment_id);
|
| 357 |
+
$author = get_comment_author($comment_id);
|
| 358 |
+
|
| 359 |
+
$action = "";
|
| 360 |
+
if ("approve" == $new_status) {
|
| 361 |
+
$action = "approved";
|
| 362 |
+
} elseif ("hold" == $new_status) {
|
| 363 |
+
$action = "unapproved";
|
| 364 |
+
} elseif ("spam" == $new_status) {
|
| 365 |
+
$action = "marked as spam";
|
| 366 |
+
} elseif ("trash" == $new_status) {
|
| 367 |
+
$action = "trashed";
|
| 368 |
+
} elseif ("0" == $new_status) {
|
| 369 |
+
$action = "untrashed";
|
| 370 |
+
}
|
| 371 |
+
|
| 372 |
+
$action = urlencode($action);
|
| 373 |
+
|
| 374 |
+
$str = sprintf( "$excerpt [" . __('From %1$s on %2$s') . "]", $author, $post_title );
|
| 375 |
+
$str = urlencode($str);
|
| 376 |
+
|
| 377 |
+
simple_history_add("action=$action&object_type=comment&object_name=$str&object_id=$comment_id");
|
| 378 |
+
}
|
| 379 |
|
| 380 |
function simple_history_update_option($option, $oldval, $newval) {
|
| 381 |
/*
|
| 382 |
+
echo "<br><br>simple_history_update_option()";
|
| 383 |
+
echo "<br>Updated option $option";
|
| 384 |
+
echo "<br>oldval: ";
|
| 385 |
+
bonny_d($oldval);
|
| 386 |
+
echo "<br>newval:";
|
| 387 |
+
bonny_d($newval);
|
| 388 |
+
*/
|
| 389 |
|
| 390 |
if ($option == "active_plugins") {
|
| 391 |
|
| 1165 |
|
| 1166 |
$user_out = ucfirst($user_out);
|
| 1167 |
echo $user_out;
|
| 1168 |
+
|
| 1169 |
+
} elseif ("comment" == $object_type) {
|
| 1170 |
+
|
| 1171 |
+
$comment_link = get_edit_comment_link($object_id);
|
| 1172 |
+
echo ucwords($object_type) . " $object_subtype <a href='$comment_link'><span class='simple-history-title'>$object_name\"</span></a> $action";
|
| 1173 |
+
|
| 1174 |
} else {
|
| 1175 |
|
| 1176 |
+
// unknown/general type
|
| 1177 |
echo ucwords($object_type) . " $object_subtype <span class='simple-history-title'>\"$object_name\"</span> $action";
|
| 1178 |
|
| 1179 |
}
|
readme.txt
CHANGED
|
@@ -60,8 +60,14 @@ I can do something about it.
|
|
| 60 |
2. Simple History settings. Choose to show the plugin on your dashboard, or as a separately page. Or both. Or none, since you can choose
|
| 61 |
to only use the secret RSS feed to keep track of the changes on you web site/WordPress installation.
|
| 62 |
|
|
|
|
|
|
|
| 63 |
== Changelog ==
|
| 64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
= 0.3.2 =
|
| 66 |
- fixed some php notice messages + some other small things I don't remember..
|
| 67 |
|
| 60 |
2. Simple History settings. Choose to show the plugin on your dashboard, or as a separately page. Or both. Or none, since you can choose
|
| 61 |
to only use the secret RSS feed to keep track of the changes on you web site/WordPress installation.
|
| 62 |
|
| 63 |
+
3. The RSS feed with changes, as shown in Firefox.
|
| 64 |
+
|
| 65 |
== Changelog ==
|
| 66 |
|
| 67 |
+
= 0.3.3 =
|
| 68 |
+
- Moved JavaScript to own file
|
| 69 |
+
- Added comments to the history, so now you can see who approved a comment (or unapproved, or marked as spam, or moved to trash, or restored from the trash)
|
| 70 |
+
|
| 71 |
= 0.3.2 =
|
| 72 |
- fixed some php notice messages + some other small things I don't remember..
|
| 73 |
|
screenshot-3.png
ADDED
|
Binary file
|
scripts.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
/**
|
| 3 |
+
* load history items via ajax
|
| 4 |
+
*/
|
| 5 |
+
var simple_history_current_page = 0;
|
| 6 |
+
jQuery(".simple-history-filter a").live("click", function() {
|
| 7 |
+
$t = jQuery(this);
|
| 8 |
+
$t.closest("ul").find("li").removeClass("selected");
|
| 9 |
+
$t.closest("li").addClass("selected");
|
| 10 |
+
$ol = jQuery("ol.simple-history");
|
| 11 |
+
|
| 12 |
+
jQuery(".simple-history-added-by-ajax").remove();
|
| 13 |
+
|
| 14 |
+
var $wrapper = jQuery("#simple-history-ol-wrapper");
|
| 15 |
+
$wrapper.height($wrapper.height()); // so dashboard widget does not collapse when loading new items
|
| 16 |
+
|
| 17 |
+
jQuery("#simple-history-load-more").hide("fast");
|
| 18 |
+
$ol.fadeOut("fast");
|
| 19 |
+
jQuery("#simple-history-no-more-items").hide();
|
| 20 |
+
|
| 21 |
+
simple_history_current_page = 0;
|
| 22 |
+
var data = {
|
| 23 |
+
"action": "simple_history_ajax",
|
| 24 |
+
"type": jQuery(".simple-history-filter-type li.selected a").text(),
|
| 25 |
+
"user": jQuery(".simple-history-filter-user li.selected a").text()
|
| 26 |
+
};
|
| 27 |
+
jQuery.post(ajaxurl, data, function(data, textStatus, XMLHttpRequest){
|
| 28 |
+
$ol.html(data);
|
| 29 |
+
$ol.fadeIn("fast");
|
| 30 |
+
$wrapper.height("auto");
|
| 31 |
+
jQuery("#simple-history-load-more").fadeIn("fast");
|
| 32 |
+
});
|
| 33 |
+
|
| 34 |
+
return false;
|
| 35 |
+
});
|
| 36 |
+
|
| 37 |
+
jQuery("#simple-history-load-more a").live("click", function() {
|
| 38 |
+
simple_history_current_page++;
|
| 39 |
+
|
| 40 |
+
jQuery("#simple-history-load-more,#simple-history-load-more-loading").toggle();
|
| 41 |
+
|
| 42 |
+
$ol = jQuery("ol.simple-history:last");
|
| 43 |
+
var data = {
|
| 44 |
+
"action": "simple_history_ajax",
|
| 45 |
+
"type": jQuery(".simple-history-filter-type li.selected a").text(),
|
| 46 |
+
"user": jQuery(".simple-history-filter-user li.selected a").text(),
|
| 47 |
+
"page": simple_history_current_page
|
| 48 |
+
};
|
| 49 |
+
jQuery.post(ajaxurl, data, function(data, textStatus, XMLHttpRequest){
|
| 50 |
+
|
| 51 |
+
// if data = simpleHistoryNoMoreItems then no more items found, so hide load-more-link
|
| 52 |
+
if (data == "simpleHistoryNoMoreItems") {
|
| 53 |
+
jQuery("#simple-history-load-more,#simple-history-load-more-loading").hide();
|
| 54 |
+
jQuery("#simple-history-no-more-items").show();
|
| 55 |
+
} else {
|
| 56 |
+
var $new_elm = jQuery("<ol class='simple-history simple-history-added-by-ajax'>" + data + "</ol>");
|
| 57 |
+
$new_elm.hide();
|
| 58 |
+
$ol.after($new_elm);
|
| 59 |
+
$new_elm.show("slow");
|
| 60 |
+
jQuery("#simple-history-load-more,#simple-history-load-more-loading").toggle();
|
| 61 |
+
}
|
| 62 |
+
});
|
| 63 |
+
return false;
|
| 64 |
+
});
|
| 65 |
+
|
| 66 |
+
jQuery("ol.simple-history .when").live("mouseover", function() {
|
| 67 |
+
jQuery(this).closest("li").find(".when_detail").fadeIn("fast");
|
| 68 |
+
});
|
| 69 |
+
jQuery("ol.simple-history .when").live("mouseout", function() {
|
| 70 |
+
jQuery(this).closest("li").find(".when_detail").fadeOut("fast");
|
| 71 |
+
});
|
| 72 |
+
|
| 73 |
+
// show occasions
|
| 74 |
+
jQuery("a.simple-history-occasion-show").live("click", function() {
|
| 75 |
+
jQuery(this).closest("li").find("ul.simple-history-occasions").toggle("fast");
|
| 76 |
+
return false;
|
| 77 |
+
});
|
| 78 |
+
|
