aboutsummaryrefslogtreecommitdiff
path: root/mod/messageboard/views/default
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-19 05:19:31 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-19 05:19:31 +0000
commit458af185465d2fb2377b0c2151627e0a9b9eb65a (patch)
tree65f1868aa6b8e4222d22ee1583163e9214292170 /mod/messageboard/views/default
parent0d4fe65e8ebb11a44fa33b72c4e32cc89e58a25f (diff)
downloadelgg-458af185465d2fb2377b0c2151627e0a9b9eb65a.tar.gz
elgg-458af185465d2fb2377b0c2151627e0a9b9eb65a.tar.bz2
Refs #2916: Moved messageboard js into elgg.messageboard object. Moved forms into forms/messageboard. Can post now, but wow this plugin needs cleaned up.
git-svn-id: http://code.elgg.org/elgg/trunk@8320 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/messageboard/views/default')
-rw-r--r--mod/messageboard/views/default/forms/messageboard/add.php21
-rw-r--r--mod/messageboard/views/default/messageboard/forms/add.php25
-rw-r--r--mod/messageboard/views/default/messageboard/js.php24
-rw-r--r--mod/messageboard/views/default/widgets/messageboard/content.php70
4 files changed, 52 insertions, 88 deletions
diff --git a/mod/messageboard/views/default/forms/messageboard/add.php b/mod/messageboard/views/default/forms/messageboard/add.php
new file mode 100644
index 000000000..4698abf28
--- /dev/null
+++ b/mod/messageboard/views/default/forms/messageboard/add.php
@@ -0,0 +1,21 @@
+<?php
+/**
+ * Elgg Message board add form
+ *
+ * @package ElggMessageBoard
+ */
+
+$textarea = elgg_view('input/plaintext', array(
+ 'name' => 'message_content'
+));
+
+$owner_input = elgg_view('input/hidden', array(
+ 'name' => 'owner_guid',
+ 'value' => elgg_get_page_owner_guid()
+));
+
+$submit = elgg_view('input/submit', array(
+ 'value' => elgg_echo('post')
+));
+
+echo $textarea . $owner_input . $submit; \ No newline at end of file
diff --git a/mod/messageboard/views/default/messageboard/forms/add.php b/mod/messageboard/views/default/messageboard/forms/add.php
deleted file mode 100644
index cacb5712f..000000000
--- a/mod/messageboard/views/default/messageboard/forms/add.php
+++ /dev/null
@@ -1,25 +0,0 @@
-<?php
-
-/**
- * Elgg Message board add form
- *
- * @package ElggMessageBoard
- */
-
-?>
-<div id="mb_input_wrapper">
- <form action="<?php echo elgg_get_site_url(); ?>action/messageboard/add" method="post" name="messageboardForm">
-
- <!-- textarea for the contents -->
- <textarea name="message_content" value="" class="elgg-input-textarea"></textarea><br />
-
- <!-- the page owner, this will be the profile owner -->
- <input type="hidden" name="pageOwner" value="<?php echo elgg_get_page_owner_guid(); ?>" />
-
- <?php echo elgg_view('input/securitytoken'); ?>
-
- <!-- submit messages input -->
- <input type="submit" id="postit" value="<?php echo elgg_echo('messageboard:postit'); ?>">
-
- </form>
-</div>
diff --git a/mod/messageboard/views/default/messageboard/js.php b/mod/messageboard/views/default/messageboard/js.php
new file mode 100644
index 000000000..c76040945
--- /dev/null
+++ b/mod/messageboard/views/default/messageboard/js.php
@@ -0,0 +1,24 @@
+elgg.provide('elgg.messageboard');
+
+elgg.messageboard.init = function() {
+ $('form.elgg-messageboard input[type=submit]').live('click', elgg.messageboard.submit);
+}
+
+elgg.messageboard.submit = function(e) {
+ var form = $(this).parents('form');
+ var data = form.serialize();
+
+ elgg.action('messageboard/add', {
+ data: data,
+ success: function(json) {
+ form.parent().find('#messageboard_wrapper').prepend(json.output.post);
+ form.find('textarea').val('');
+ }
+ });
+
+ e.preventDefault();
+}
+
+
+
+elgg.register_event_handler('init', 'system', elgg.messageboard.init); \ No newline at end of file
diff --git a/mod/messageboard/views/default/widgets/messageboard/content.php b/mod/messageboard/views/default/widgets/messageboard/content.php
index 45d4426a2..5f0cc8676 100644
--- a/mod/messageboard/views/default/widgets/messageboard/content.php
+++ b/mod/messageboard/views/default/widgets/messageboard/content.php
@@ -1,81 +1,25 @@
<?php
-
/**
- * Elgg messageboard widget view
+ * Elgg messageboard widget view
*
*
* @package ElggMessageBoard
*/
-//get the full page owner entity
$user = elgg_get_page_owner_entity();
-
-//the number of message to display
$num_display = 5;
+
if (isset($vars['entity']->num_display)) {
$num_display = $vars['entity']->num_display;
}
-//Just the loggedin user can post messages
if (elgg_is_logged_in()) {
-?>
-<?php //@todo JS 1.8: no ?>
-<script type="text/javascript">
- $(document).ready(function(){
-
- $("#postit").click(function(){
-
- //display the ajax loading gif at the start of the function call
- //$('#loader').html('<img src="<?php echo elgg_get_site_url(); ?>_graphics/ajax-loader.gif" />');
- $('#loader').html('<?php echo elgg_view('graphics/ajax_loader', array('slashes' => TRUE)); ?>');
-
- //load the results back into the message board contents and remove the loading gif
- //remember that the actual div being populated is determined on views/default/messageboard/messageboard.php
- $("#messageboard_wrapper").load("<?php echo elgg_get_site_url(); ?>mod/messageboard/ajax_endpoint/load.php", {messageboard_content:$("[name=message_content]").val(), pageOwner:$("[name=pageOwner]").val(), numToDisplay:<?php echo $num_display; ?>}, function(){
- $('#loader').empty(); // remove the loading gif
- $('[name=message_content]').val(''); // clear the input textarea
- }); //end
-
- }); // end of the main click function
-
- }); //end of the document .ready function
-</script>
-
-<div id="mb_input_wrapper"><!-- start of mb_input_wrapper div -->
-
- <!-- message textarea -->
- <textarea name="message_content" class="elgg-input-textarea"></textarea>
-
- <!-- the page owner, this will be the profile owner -->
- <input type="hidden" name="pageOwner" value="<?php echo elgg_get_page_owner_guid(); ?>" class="pageOwner" />
-
- <!-- submit button -->
- <input type="submit" id="postit" value="<?php echo elgg_echo('messageboard:postit'); ?>">
-
- <!-- menu options -->
- <div id="messageboard_widget_menu">
- <a href="<?php echo elgg_get_site_url(); ?>pg/messageboard/<?php echo $user->username; ?>"><?php echo elgg_echo("messageboard:viewall"); ?></a>
- </div>
-
- <!-- loading graphic -->
- <div id="loader" class="loading"> </div>
-
-</div><!-- end of mb_input_wrapper div -->
-
- <?php
-} // if(elgg_is_logged_in())
+ echo elgg_view_form('messageboard/add', array('class' => 'elgg-messageboard'));
+}
//this for the first time the page loads, grab the latest messages.
$contents = $user->getAnnotations('messageboard', $num_display, 0, 'desc');
-//as long as there is some content to display, display it
-if (!empty($contents)) {
-
- echo elgg_view('messageboard/messageboard',array('annotation' => $contents));
-
-} else {
-
- //put the required div on the page for the first message
- echo "<div id=\"messageboard_wrapper\"></div>";
-
-}
+if ($contents) {
+ echo elgg_view('messageboard/messageboard', array('annotation' => $contents));
+} \ No newline at end of file