Untitled diff
74 lines
/*jslint regexp: true, undef: true, sloppy: true, eqeq: true, vars: true, white: true, plusplus: true, maxerr: 50, indent: 4 */
/*jslint regexp: true, undef: true, sloppy: true, eqeq: true, vars: true, white: true, plusplus: true, maxerr: 50, indent: 4 */
var gdbbPressTools = {
var gdbbPressTools = {
storage: { },
storage: { },
get_selection: function() {
get_selection: function() {
var t = '';
var t = '';
if (window.getSelection){
if (window.getSelection){
t = window.getSelection();
t = window.getSelection();
} else if (document.getSelection){
} else if (document.getSelection){
t = document.getSelection();
t = document.getSelection();
} else if (document.selection){
} else if (document.selection){
t = document.selection.createRange().text;
t = document.selection.createRange().text;
}
}
return jQuery.trim(t.toString());
return jQuery.trim(t.toString());
},
},
init: function() {
init: function() {
jQuery(document).on("click", ".d4p-bbt-quote-link", function(e){
jQuery(document).on("click", ".d4p-bbt-quote-link", function(e){
e.preventDefault();
e.preventDefault();
if (jQuery("#bbp_reply_content").length > 0) {
if (jQuery("#bbp_reply_content").length > 0) {
var qout = gdbbPressTools.get_selection();
var qout = gdbbPressTools.get_selection();
var id = jQuery(this).attr("href").substr(1);
var id = jQuery(this).attr("href").substr(1);
var quote_id = '#d4p-bbp-quote-' + id;
var quote_id = '#d4p-bbp-quote-' + id;
if (qout === "") {
if (qout === "") {
qout = jQuery(quote_id).html();
qout = jQuery(quote_id).html();
}
}
qout = qout.replace(/ /g, " ");
qout = qout.replace(/ /g, " ");
qout = qout.replace(/<p>|<br>/g, "");
qout = qout.replace(/<p>|<br>/g, "");
qout = qout.replace(/<\/\s*p>/g, "\n");
qout = qout.replace(/<\/\s*p>/g, "\n");
if (gdbbPressToolsInit.quote_method === "bbcode") {
if (gdbbPressToolsInit.quote_method === "bbcode") {
qout = "[quote=" + id + "]" + qout + "[/quote]";
qout = "[quote=" + id + "]" + qout + "[/quote]";
} else {
} else {
var title = '<div class="d4p-bbp-quote-title"><a href="' + jQuery(this).attr("bbp-url") + '">';
var title = '<div class="d4p-bbp-quote-title"><a href="' + jQuery(this).attr("bbp-url") + '">';
title+= jQuery(this).attr("bbp-author") + ' ' + gdbbPressToolsInit.quote_wrote + ':</a></div>';
title+= jQuery(this).attr("bbp-author") + ' ' + gdbbPressToolsInit.quote_wrote + ':</a></div>';
qout = '<blockquote class="d4pbbc-quote">' + title + qout + '</blockquote>';
qout = '<blockquote class="d4pbbc-quote">' + title + qout + '</blockquote><br>';
}
}
if (gdbbPressToolsInit.wp_editor == 1 && !jQuery("#bbp_reply_content").is(":visible")) {
if (gdbbPressToolsInit.wp_editor == 1 && !jQuery("#bbp_reply_content").is(":visible")) {
if (gdbbPressToolsInit.wp_version > 38) {
if (gdbbPressToolsInit.wp_version > 38) {
tinymce.get("bbp_reply_content").execCommand("mceInsertContent", false, qout);
tinymce.get("bbp_reply_content").execCommand("mceInsertContent", false, qout);
} else {
} else {
tinyMCE.execInstanceCommand("bbp_reply_content", "mceInsertContent", false, qout);
tinyMCE.execInstanceCommand("bbp_reply_content", "mceInsertContent", false, qout);
}
}
} else {
} else {
var txtr = jQuery("#bbp_reply_content");
var txtr = jQuery("#bbp_reply_content");
var cntn = txtr.val();
var cntn = txtr.val();
if (jQuery.trim(cntn) != '') {
if (jQuery.trim(cntn) != '') {
qout = "\n\n" + qout;
qout = "\n\n" + qout;
}
}
txtr.val(cntn + qout);
txtr.val(cntn + qout);
}
}
var old_ie = jQuery.browser.msie && parseInt(jQuery.browser.version) < 9;
var old_ie = jQuery.browser.msie && parseInt(jQuery.browser.version) < 9;
if (!old_ie) {
if (!old_ie) {
jQuery("html, body").animate({scrollTop: jQuery("#new-post").offset().top}, 1000);
jQuery("html, body").animate({scrollTop: jQuery("#new-post").offset().top}, 1000);
} else {
} else {
document.location.href = "#new-post";
document.location.href = "#new-post";
}
}
}
}
});
});
}
}
};
};
jQuery(document).ready(function() {
jQuery(document).ready(function() {
gdbbPressTools.init();
gdbbPressTools.init();
});
});