first commit

This commit is contained in:
2024-11-10 21:08:49 +01:00
commit 0d932ce5ee
14455 changed files with 2567501 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
/* global edButtons, QTags, tinymce */
jQuery(document).ready( function() {
/* Use backticks instead of <code> for the Code button in the editor */
if ( typeof( edButtons ) !== 'undefined' ) {
edButtons[110] = new QTags.TagButton( 'code', 'code', '`', '`', 'c' );
QTags._buttonsInit();
}
/* Tab from topic title */
jQuery( '#bbp_topic_title' ).bind( 'keydown.editor-focus', function(e) {
if ( e.which !== 9 ) {
return;
}
if ( !e.ctrlKey && !e.altKey && !e.shiftKey ) {
if ( typeof( tinymce ) !== 'undefined' ) {
if ( ! tinymce.activeEditor.isHidden() ) {
var editor = tinymce.activeEditor.editorContainer;
jQuery( '#' + editor + ' td.mceToolbar > a' ).focus();
} else {
jQuery( 'textarea.bbp-the-content' ).focus();
}
} else {
jQuery( 'textarea.bbp-the-content' ).focus();
}
e.preventDefault();
}
});
/* Shift + tab from topic tags */
jQuery( '#bbp_topic_tags' ).bind( 'keydown.editor-focus', function(e) {
if ( e.which !== 9 ) {
return;
}
if ( e.shiftKey && !e.ctrlKey && !e.altKey ) {
if ( typeof( tinymce ) !== 'undefined' ) {
if ( ! tinymce.activeEditor.isHidden() ) {
var editor = tinymce.activeEditor.editorContainer;
jQuery( '#' + editor + ' td.mceToolbar > a' ).focus();
} else {
jQuery( 'textarea.bbp-the-content' ).focus();
}
} else {
jQuery( 'textarea.bbp-the-content' ).focus();
}
e.preventDefault();
}
});
});

View File

@@ -0,0 +1,3 @@
/*! This file is automatically generated. */
jQuery(document).ready(function(){"undefined"!=typeof edButtons&&(edButtons[110]=new QTags.TagButton("code","code","`","`","c"),QTags._buttonsInit()),jQuery("#bbp_topic_title").bind("keydown.editor-focus",function(e){if(9===e.which&&!e.ctrlKey&&!e.altKey&&!e.shiftKey){if("undefined"!=typeof tinymce)if(tinymce.activeEditor.isHidden())jQuery("textarea.bbp-the-content").focus();else{var t=tinymce.activeEditor.editorContainer;jQuery("#"+t+" td.mceToolbar > a").focus()}else jQuery("textarea.bbp-the-content").focus();e.preventDefault()}}),jQuery("#bbp_topic_tags").bind("keydown.editor-focus",function(e){if(9===e.which&&e.shiftKey&&!e.ctrlKey&&!e.altKey){if("undefined"!=typeof tinymce)if(tinymce.activeEditor.isHidden())jQuery("textarea.bbp-the-content").focus();else{var t=tinymce.activeEditor.editorContainer;jQuery("#"+t+" td.mceToolbar > a").focus()}else jQuery("textarea.bbp-the-content").focus();e.preventDefault()}})});

View File

@@ -0,0 +1,62 @@
/* global bbpEngagementJS */
jQuery( document ).ready( function ( $ ) {
function bbp_ajax_call( action, object, type, nonce, update_selector ) {
var $data = {
action : action,
id : object,
type : type,
nonce : nonce
};
$.post( bbpEngagementJS.bbp_ajaxurl, $data, function ( response ) {
if ( response.success ) {
$( update_selector ).html( response.content );
} else {
if ( !response.content ) {
response.content = bbpEngagementJS.generic_ajax_error;
}
window.alert( response.content );
}
} );
}
$( '#favorite-toggle' ).on( 'click', 'span a.favorite-toggle', function( e ) {
e.preventDefault();
bbp_ajax_call(
'favorite',
$( this ).data( 'bbp-object-id' ),
$( this ).data( 'bbp-object-type' ),
$( this ).data( 'bbp-nonce' ),
'#favorite-toggle'
);
} );
$( '#subscription-toggle' ).on( 'click', 'span a.subscription-toggle', function( e ) {
e.preventDefault();
bbp_ajax_call(
'subscription',
$( this ).data( 'bbp-object-id' ),
$( this ).data( 'bbp-object-type' ),
$( this ).data( 'bbp-nonce' ),
'#subscription-toggle'
);
} );
$( '.bbp-alert-outer' ).on( 'click', '.bbp-alert-close', function( e ) {
e.preventDefault();
$( this ).closest( '.bbp-alert-outer' ).fadeOut();
} );
$( '.bbp-alert-outer' ).on( 'click', function( e ) {
if ( this === e.target ) {
$( this ).closest( '.bbp-alert-outer' ).fadeOut();
}
} );
$( document ).keyup( function( e ) {
if ( e.keyCode === 27 ) {
$( '.bbp-alert-outer .bbp-alert-close' ).click();
}
} );
} );

View File

@@ -0,0 +1,3 @@
/*! This file is automatically generated. */
jQuery(document).ready(function(t){function e(e,o,n,a,c){var b={action:e,id:o,type:n,nonce:a};t.post(bbpEngagementJS.bbp_ajaxurl,b,function(e){e.success?t(c).html(e.content):(e.content||(e.content=bbpEngagementJS.generic_ajax_error),window.alert(e.content))})}t("#favorite-toggle").on("click","span a.favorite-toggle",function(o){o.preventDefault(),e("favorite",t(this).data("bbp-object-id"),t(this).data("bbp-object-type"),t(this).data("bbp-nonce"),"#favorite-toggle")}),t("#subscription-toggle").on("click","span a.subscription-toggle",function(o){o.preventDefault(),e("subscription",t(this).data("bbp-object-id"),t(this).data("bbp-object-type"),t(this).data("bbp-nonce"),"#subscription-toggle")}),t(".bbp-alert-outer").on("click",".bbp-alert-close",function(e){e.preventDefault(),t(this).closest(".bbp-alert-outer").fadeOut()}),t(".bbp-alert-outer").on("click",function(e){this===e.target&&t(this).closest(".bbp-alert-outer").fadeOut()}),t(document).keyup(function(e){27===e.keyCode&&t(".bbp-alert-outer .bbp-alert-close").click()})});

View File

@@ -0,0 +1,239 @@
/* globals tinyMCE */
addReply = {
/**
* Move the reply form when "Reply" is clicked.
*
* @since 2.6.2
* @param {string} replyId
* @param {string} parentId
* @param {string} respondId
* @param {string} postId
* @returns {undefined|Boolean}
*/
moveForm: function ( replyId, parentId, respondId, postId ) {
/* Get initial elements */
var t = this,
reply = t.getElement( replyId ),
respond = t.getElement( respondId ),
cancel = t.getElement( 'bbp-cancel-reply-to-link' ),
parent = t.getElement( 'bbp_reply_to' ),
post = t.getElement( 'bbp_topic_id' );
/* Remove the editor, if its already been moved */
t.removeEditor();
/* Allow click to go through */
if ( ! reply || ! respond || ! cancel || ! parent ) {
return;
}
t.respondId = respondId;
postId = postId || false;
/* Setup a temporary div for relocating back when clicking cancel */
if ( ! t.getElement( 'bbp-temp-form-div' ) ) {
var div = document.createElement( 'div' );
div.id = 'bbp-temp-form-div';
div.style.display = 'none';
respond.parentNode.appendChild( div );
}
/* Relocate the element */
reply.parentNode.appendChild( respond );
if ( post && postId ) {
post.value = postId;
}
parent.value = parentId;
cancel.style.display = '';
/* Add the editor where it now belongs */
t.addEditor();
/**
* When cancelling a Reply.
*
* @since 2.6.2
* @returns {void}
*/
cancel.onclick = function () {
t.cancelForm( this );
};
t.scrollToForm();
/* Prevent click from going through */
return false;
},
/**
* Cancel the reply form.
*
* @since 2.6.6
* @returns {void}
*/
cancelForm: function () {
var r = addReply,
temp = r.getElement( 'bbp-temp-form-div' ),
cancel = r.getElement( 'bbp-cancel-reply-to-link' ),
respond = r.getElement( r.respondId );
r.removeEditor();
/* Allow click to go through */
if ( ! temp || ! respond ) {
return;
}
r.getElement( 'bbp_reply_to' ).value = '0';
temp.parentNode.insertBefore( respond, temp );
temp.parentNode.removeChild( temp );
cancel.style.display = 'none';
cancel.onclick = null;
r.addEditor();
r.scrollToForm();
/* Prevent click from going through */
return false;
},
/**
* Scrolls to the top of the page.
*
* @since 2.6.2
* @return {void}
*/
scrollToForm: function() {
/* Get initial variables to start computing boundaries */
var t = this,
form = t.getElement( 'new-post' ),
elemRect = form.getBoundingClientRect(),
position = (window.pageYOffset || document.scrollTop) - (document.clientTop || 0),
destination = ( position + elemRect.top ),
negative = ( destination < position ), // jshint ignore:line
adminbar = t.getElement( 'wpadminbar'),
offset = 0;
/* Offset by the adminbar */
if ( adminbar && ( typeof ( adminbar ) !== 'undefined' ) ) {
offset = adminbar.scrollHeight;
}
/* Compute the difference, depending on direction */
/* jshint ignore:start */
distance = ( true === negative )
? ( position - destination )
: ( destination - position );
/* Do some math to compute the animation steps */
var vast = ( distance > 800 ),
speed_step = vast ? 30 : 20,
speed = Math.min( 12, Math.round( distance / speed_step ) ),
step = Math.round( distance / speed_step ),
steps = [],
timer = 0;
/* Scroll up */
if ( true === negative ) {
while ( position > destination ) {
position -= step;
if ( position < destination ) {
position = destination;
}
steps.push( position - offset );
setTimeout( function() {
window.scrollTo( 0, steps.shift() );
}, timer * speed );
timer++;
}
/* Scroll down */
} else {
while ( position < destination ) {
position += step;
if ( position > destination ) {
position = destination;
}
steps.push( position - offset );
setTimeout( function() {
window.scrollTo( 0, steps.shift() );
}, timer * speed );
timer++;
}
}
/* jshint ignore:end */
},
/**
* Get an element by ID
*
* @since 2.6.2
* @param {string} e
* @returns {HTMLElement} Element
*/
getElement: function (e) {
return document.getElementById(e);
},
/**
* Remove the Editor
*
* @since 2.6.2
* @returns {void}
*/
removeEditor: function () {
/* Bail to avoid error */
if ( typeof ( tinyMCE ) === 'undefined' ) {
return;
}
var tmce = tinyMCE.get( 'bbp_reply_content' );
if ( tmce && ! tmce.isHidden() ) {
this.mode = 'tmce';
tmce.remove();
} else {
this.mode = 'html';
}
},
/**
* Add the Editor
*
* @since 2.6.2
* @returns {void}
*/
addEditor: function () {
/* Bail to avoid error */
if ( typeof ( tinyMCE ) === 'undefined' ) {
return;
}
if ( 'tmce' === this.mode ) {
switchEditors.go( 'bbp_reply_content', 'tmce' );
} else if ( 'html' === this.mode ) {
switchEditors.go( 'bbp_reply_content', 'html' );
}
}
};

View File

@@ -0,0 +1,3 @@
/*! This file is automatically generated. */
addReply={moveForm:function(e,t,n,o){var i=this,d=i.getElement(e),l=i.getElement(n),r=i.getElement("bbp-cancel-reply-to-link"),m=i.getElement("bbp_reply_to"),c=i.getElement("bbp_topic_id");if(i.removeEditor(),d&&l&&r&&m){if(i.respondId=n,o=o||!1,!i.getElement("bbp-temp-form-div")){var p=document.createElement("div");p.id="bbp-temp-form-div",p.style.display="none",l.parentNode.appendChild(p)}return d.parentNode.appendChild(l),c&&o&&(c.value=o),m.value=t,r.style.display="",i.addEditor(),r.onclick=function(){i.cancelForm(this)},i.scrollToForm(),!1}},cancelForm:function(){var e=addReply,t=e.getElement("bbp-temp-form-div"),n=e.getElement("bbp-cancel-reply-to-link"),o=e.getElement(e.respondId);if(e.removeEditor(),t&&o)return e.getElement("bbp_reply_to").value="0",t.parentNode.insertBefore(o,t),t.parentNode.removeChild(t),n.style.display="none",n.onclick=null,e.addEditor(),e.scrollToForm(),!1},scrollToForm:function(){var e=this,t=e.getElement("new-post").getBoundingClientRect(),n=(window.pageYOffset||document.scrollTop)-(document.clientTop||0),o=n+t.top,i=o<n,d=e.getElement("wpadminbar"),l=0;d&&void 0!==d&&(l=d.scrollHeight),distance=!0===i?n-o:o-n;var r=distance>800?30:20,m=Math.min(12,Math.round(distance/r)),c=Math.round(distance/r),p=[],s=0;if(!0===i)for(;n>o;)(n-=c)<o&&(n=o),p.push(n-l),setTimeout(function(){window.scrollTo(0,p.shift())},s*m),s++;else for(;n<o;)(n+=c)>o&&(n=o),p.push(n-l),setTimeout(function(){window.scrollTo(0,p.shift())},s*m),s++},getElement:function(e){return document.getElementById(e)},removeEditor:function(){if("undefined"!=typeof tinyMCE){var e=tinyMCE.get("bbp_reply_content");e&&!e.isHidden()?(this.mode="tmce",e.remove()):this.mode="html"}},addEditor:function(){"undefined"!=typeof tinyMCE&&("tmce"===this.mode?switchEditors.go("bbp_reply_content","tmce"):"html"===this.mode&&switchEditors.go("bbp_reply_content","html"))}};