aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/styles/prosilver/template/ajax.js
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/styles/prosilver/template/ajax.js')
-rw-r--r--phpBB/styles/prosilver/template/ajax.js111
1 files changed, 111 insertions, 0 deletions
diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js
new file mode 100644
index 0000000000..54f34e4204
--- /dev/null
+++ b/phpBB/styles/prosilver/template/ajax.js
@@ -0,0 +1,111 @@
+(function($) { // Avoid conflicts with other libraries
+
+"use strict";
+
+// This callback finds the post from the delete link, and removes it.
+phpbb.add_ajax_callback('post_delete', function() {
+ var el = $(this),
+ post_id;
+
+ if (el.attr('data-refresh') === undefined)
+ {
+ post_id = el[0].href.split('&p=')[1];
+ var post = el.parents('#p' + post_id).css('pointer-events', 'none');
+ if (post.hasClass('bg1') || post.hasClass('bg2'))
+ {
+ var posts1 = post.nextAll('.bg1');
+ post.nextAll('.bg2').removeClass('bg2').addClass('bg1');
+ posts1.removeClass('bg1').addClass('bg2');
+ }
+ post.fadeOut(function() {
+ $(this).remove();
+ });
+ }
+});
+
+// This callback removes the approve / disapprove div or link.
+phpbb.add_ajax_callback('post_approve', function(res) {
+ var remove = (res.approved) ? $(this) : $(this).parents('.post');
+ $(remove).css('pointer-events', 'none').fadeOut(function() {
+ $(this).remove();
+ });
+});
+
+// This removes the parent row of the link or form that fired the callback.
+phpbb.add_ajax_callback('row_delete', function() {
+ $(this).parents('tr').remove();
+});
+
+// This handles friend / foe additions removals.
+phpbb.add_ajax_callback('zebra', function(res) {
+ var zebra;
+
+ if (res.success) {
+ zebra = $('.zebra');
+ zebra.first().html(res.MESSAGE_TEXT);
+ zebra.not(':first').html(' ').prev().html(' ');
+ }
+});
+
+
+
+$('[data-ajax]').each(function() {
+ var $this = $(this),
+ ajax = $this.attr('data-ajax'),
+ fn;
+
+ if (ajax !== 'false')
+ {
+ fn = (ajax !== 'true') ? ajax : null;
+ phpbb.ajaxify({
+ selector: this,
+ refresh: $this.attr('data-refresh') !== undefined,
+ callback: fn
+ });
+ }
+});
+
+
+/**
+ * This simply appends #preview to the action of the
+ * QR action when you click the Full Editor & Preview button
+ */
+$('#qr_full_editor').click(function() {
+ $('#qr_postform').attr('action', function(i, val) {
+ return val + '#preview';
+ });
+});
+
+
+
+/**
+ * This AJAXifies the quick-mod tools. The reason it cannot be a standard
+ * callback / data attribute is that it requires filtering - some of the options
+ * can be ajaxified, while others cannot.
+ */
+phpbb.ajaxify({
+ selector: '#quickmodform',
+ refresh: true,
+ filter: function (data) {
+ var action = $('#quick-mod-select').val();
+
+ if (action === 'make_normal')
+ {
+ return $(this).find('select option[value="make_global"]').length > 0;
+ }
+ else if (action === 'lock' || action === 'unlock')
+ {
+ return true;
+ }
+
+ if (action === 'delete_topic' || action === 'make_sticky' || action === 'make_announce' || action === 'make_global') {
+ return true;
+ }
+
+ return false;
+ }
+});
+
+
+
+})(jQuery); // Avoid conflicts with other libraries