Skip to content
Snippets Groups Projects
Commit 2a43416c authored by AlexisWilke's avatar AlexisWilke
Browse files

Changed the use of the cookie with the better, cleaner use of the

?destination=... option
parent 76b7faf6
No related branches found
No related tags found
No related merge requests found
/* Code by Zewa */
/* Code first created by Zewa,
* fixed up by AlexisWilke so it works with any type of page
*/
/**
* Reply button for comments.
* Reply, Edit & Delete buttons for included comments.
*
* Store where the user was when clicking add comment or reply,
* and bring him back there afterwards.
* and bring him or her back there afterwards.
*/
$("a[href*='comment/reply']").click(function () {
$.cookie('reply_topic_url', location.href);
});
$("a[href*='comment/edit']").click(function () {
$.cookie('reply_topic_url', location.href);
});
$("a[href*='comment/delete']").click(function () {
$.cookie('reply_topic_url', location.href);
});
/**
* Check on each forum site.
* When the cookie has been placed, we know a forum thread was created.
*/
$("div[class='breadcrumb']").children().each(function(){
if($(this).attr("href") == '/drupal/?q=forum') {
var loc = $.cookie('reply_topic_url');
if(loc != null && loc != undefined) {
$.cookie('reply_topic_url', "");
document.location.href = loc + '#attached_comment_start';
}
}
});
function node_insert_destination(link){
attr=jQuery(link).attr('href');
attr+=attr.indexOf('?')==-1?'?':'&';
url=location.pathname.substring(1);
jQuery(link).attr('href',attr+'destination='+url);
}
jQuery("a[href*='comment/reply'],a[href*='comment/edit'],a[href*='comment/delete']").click(function(){node_insert_destination(this);});
......@@ -9,7 +9,10 @@
function insert_node_init() {
// If you experience side effects, feel free to comment out this add.
// All you lose is the coming back to the node including the comment.
drupal_add_js(drupal_get_path('module', 'insert_node') .'/back_from_comment.js');
if (function_exists('jquery_plugin_add')) {
jquery_plugin_add('cookie');
drupal_add_js(drupal_get_path('module', 'insert_node') .'/back_from_comment.js');
}
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment