Skip to content

Commit

Permalink
Merge pull request #25 from live627/master
Browse files Browse the repository at this point in the history
Update ajaxqr
  • Loading branch information
Nao committed Apr 30, 2014
2 parents dcfb1f3 + 0ec9a95 commit 7f62784
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
6 changes: 5 additions & 1 deletion ajax_qr/AJAXQR.php
@@ -1,6 +1,10 @@
<?php

namespace AJAXQR;

if (!defined('WEDGE'))
die('Hacking attempt...');

class Integration
{
public static function load_theme()
Expand All @@ -15,7 +19,7 @@ public static function display_message_list(&$messages, &$times, &$all_posters)
{
global $context;

// If we are attempting to view a single post.. Lets make sure its safe to do so..
// I want that post right there, and nothing more.
if (isset($_REQUEST['ajaxqr']) && INFINITE)
{
$messages = array($context['topic_last_message']);
Expand Down
22 changes: 15 additions & 7 deletions ajax_qr/ajaxqr.js
@@ -1,7 +1,5 @@
(function ($) {

var errors = false, msg = 0;

$('form#postmodify').submit(function() {
var $that = $(this);

Expand All @@ -28,15 +26,20 @@
// Load the reply we've just posted. Fool me once...
weUrl('topic=' + we_topic + '.new;ajaxqr'),

// This asks Wedge to ignore the Ajax status, and load the index template for page indexes.
/*
This asks Wedge to:
- ignore the Ajax status;
- load the index template for page indexes (ootherwise a fatal error would occur);
- hide all the template layers.
*/
{ infinite: true },

function (html)
{
// Hide the message first so that we can properly animate it.
var
$html = $(html),
$root = $html.find('.msg').hide().appendTo($new_page);
$root = $html.hide().appendTo($new_page);

// We're rebuilding scripts from the string response, and inserting them to force jQuery to execute them.
// Please note that jQuery doesn't need to be reloaded, and script.js causes issues, so we'll avoid it for now.
Expand All @@ -52,22 +55,27 @@
});
});

// We don't need to retrieve the page index because we aren't loading a new page.
$('#pinf').remove();

// Update the num_replies counter so if the user replies more than once without refreshing, we don't get an error.
document.forms.postmodify.elements['last'].value = $root.attr('id').slice(3);

// And empty the post reply box
// And empty the post reply box.
$('#message', $that).val('');

hide_ajax();
$root.fadeIn();

// Prepare the new post for follow_me and relative dates.
page_showing();
}
);
}
}
);

if (!errors)
return false;
return false;
});

}) (jQuery);

0 comments on commit 7f62784

Please sign in to comment.