]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #3200 ajax-based view previous link works for the wire
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Wed, 30 Mar 2011 02:07:59 +0000 (02:07 +0000)
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Wed, 30 Mar 2011 02:07:59 +0000 (02:07 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@8882 36083f99-b078-4883-b0ff-0f9b5a30f544

mod/thewire/js/thewire.js [deleted file]
mod/thewire/languages/en.php
mod/thewire/start.php
mod/thewire/views/default/js/thewire.php [new file with mode: 0644]
mod/thewire/views/default/object/thewire.php
mod/thewire/views/default/thewire/css.php
mod/thewire/views/default/thewire/previous.php [new file with mode: 0644]

diff --git a/mod/thewire/js/thewire.js b/mod/thewire/js/thewire.js
deleted file mode 100644 (file)
index 61f29db..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-elgg.provide('elgg.thewire');
-
-elgg.thewire.init = function() {
-       $("#thewire-textarea").live('keydown', function() {
-               elgg.thewire.textCounter(this, $("#thewire-characters-remaining span"), 140);
-       });
-       $("#thewire-textarea").live('keyup', function() {
-               elgg.thewire.textCounter(this, $("#thewire-characters-remaining span"), 140);
-       });
-}
-
-elgg.thewire.textCounter = function(textarea, status, limit) {
-
-       var remaining_chars = limit - textarea.value.length;
-       status.html(remaining_chars);
-
-       if (remaining_chars < 0) {
-               status.parent().css("color", "#D40D12");
-               $("#thewire-submit-button").attr('disabled', 'disabled');
-               $("#thewire-submit-button").addClass('elgg-state-disabled');
-       } else {
-               status.parent().css("color", "");
-               $("#thewire-submit-button").removeAttr('disabled', 'disabled');
-               $("#thewire-submit-button").removeClass('elgg-state-disabled');
-       }
-}
-
-elgg.register_hook_handler('init', 'system', elgg.thewire.init);
\ No newline at end of file
index 0896ecf14aeeaea35b6d6cfa9b06481426d14a38..226af187ed70106b1c9d2a5cb20a8528f32d2a48 100644 (file)
@@ -15,13 +15,17 @@ $english = array(
        'thewire:reply' => "Reply",
        'thewire:replying' => "Replying to %s who wrote",
        'thewire:thread' => "Thread",
-       'thewire:previous' => "Previous",
        'thewire:charleft' => "characters remaining",
        'thewire:tags' => "Wire posts tagged with '%s'",
        'thewire:noposts' => "No wire posts yet",
        'item:object:thewire' => "Wire posts",
        'thewire:update' => 'Update',
 
+       'thewire:previous' => "Previous",
+       'thewire:hide' => "Hide",
+       'thewire:previous:help' => "View previous post",
+       'thewire:hide:help' => "Hide previous post",
+
        /**
         * The wire river
         */
index 0c35b0231a385cf1ec9ac5c0d0b74cd1283fa308..770f8bce03b73bfb9c7d0734c9fd582652440fce 100644 (file)
@@ -23,8 +23,10 @@ function thewire_init() {
        if (!update_subtype('object', 'thewire', 'ElggWire')) {
                add_subtype('object', 'thewire', 'ElggWire');
        }
-       
-       elgg_register_js('elgg.thewire', 'mod/thewire/js/thewire.js', 'footer');
+
+       // register the wire's JavaScript
+       $thewire_js = elgg_get_simplecache_url('js', 'thewire');
+       elgg_register_js('elgg.thewire', $thewire_js, 'footer');
 
        // add a site navigation item
        $item = new ElggMenuItem('thewire', elgg_echo('thewire'), 'thewire/all');
@@ -400,6 +402,8 @@ function thewire_setup_entity_menu_items($hook, $type, $value, $params) {
                        'text' => elgg_echo('thewire:previous'),
                        'href' => "thewire/previous/$entity->guid",
                        'priority' => 160,
+                       'class' => 'thewire-previous',
+                       'title' => elgg_echo('thewire:previous:help'),
                );
                $value[] = ElggMenuItem::factory($options);
        }
diff --git a/mod/thewire/views/default/js/thewire.php b/mod/thewire/views/default/js/thewire.php
new file mode 100644 (file)
index 0000000..1eda90b
--- /dev/null
@@ -0,0 +1,86 @@
+<?php
+/**
+ * The wire's JavaScript
+ */
+
+$site_url = elgg_get_site_url();
+
+?>
+
+elgg.provide('elgg.thewire');
+
+elgg.thewire.init = function() {
+       $("#thewire-textarea").live('keydown', function() {
+               elgg.thewire.textCounter(this, $("#thewire-characters-remaining span"), 140);
+       });
+       $("#thewire-textarea").live('keyup', function() {
+               elgg.thewire.textCounter(this, $("#thewire-characters-remaining span"), 140);
+       });
+
+       $(".thewire-previous").live('click', elgg.thewire.viewPrevious);
+}
+
+/**
+ * Update the number of characters left with every keystroke
+ *
+ * @param {Object}  textarea
+ * @param {Object}  status
+ * @param {integer} limit
+ * @return void
+ */
+elgg.thewire.textCounter = function(textarea, status, limit) {
+
+       var remaining_chars = limit - textarea.value.length;
+       status.html(remaining_chars);
+
+       if (remaining_chars < 0) {
+               status.parent().css("color", "#D40D12");
+               $("#thewire-submit-button").attr('disabled', 'disabled');
+               $("#thewire-submit-button").addClass('elgg-state-disabled');
+       } else {
+               status.parent().css("color", "");
+               $("#thewire-submit-button").removeAttr('disabled', 'disabled');
+               $("#thewire-submit-button").removeClass('elgg-state-disabled');
+       }
+}
+
+/**
+ * Display the previous wire post
+ *
+ * Makes Ajax call to load the html and handles changing the previous link
+ *
+ * @param {Object} event
+ * @return void
+ */
+elgg.thewire.viewPrevious = function(event) {
+       var $link = $(this);
+       var postGuid = $link.attr("href").split("/").pop();
+       var $previousDiv = $("#thewire-previous-" + postGuid);
+
+       if ($link.html() == "<?php echo elgg_echo('thewire:hide'); ?>") {
+               $link.html("<?php echo elgg_echo('thewire:previous'); ?>");
+               $link.attr("title", "<?php echo elgg_echo('thewire:previous:help'); ?>");
+               $previousDiv.slideUp(400);
+       } else {
+               $link.html("<?php echo elgg_echo('thewire:hide'); ?>");
+               $link.attr("title", "<?php echo elgg_echo('thewire:hide:help'); ?>");
+               
+               $.ajax({type: "GET",
+                       url: "<?php echo $site_url . "ajax/view/thewire/previous"; ?>",
+                       dataType: "html",
+                       cache: false,
+                       data: {guid: postGuid},
+                       success: function(htmlData) {
+                               if (htmlData.length > 0) {
+                                       $previousDiv.html(htmlData);
+                                       $previousDiv.slideDown(600);
+                               }
+                       }
+               });
+
+       }
+
+       event.preventDefault();
+}
+
+elgg.register_hook_handler('init', 'system', elgg.thewire.init);
\ No newline at end of file
index bcc62f8166efcf9b1a514eac61e0674d7631aa2f..1c61d58863af50f02426720f9753af29f9508823 100644 (file)
@@ -53,3 +53,8 @@ $params = array(
 $list_body = elgg_view('page/components/summary', $params);
 
 echo elgg_view_image_block($owner_icon, $list_body);
+
+if ($post->reply) {
+       echo "<div class=\"thewire-parent hidden\" id=\"thewire-previous-{$post->guid}\">";
+       echo "</div>";
+}
index afc3a16aa36eaf9e1c50e33e948765b51dc307b6..d1ef31993168054b0d88359b28039e9d344210f0 100644 (file)
@@ -27,100 +27,6 @@ The Wire
        text-align: right;
        background: white;
 }
-<?php
-return true;
-?>
-
-/* new wire post form */
-.new_wire_post {
-       margin:10px 0 15px 0;
-       padding-bottom:15px;
-       border-bottom: 1px solid #dedede;
-}
-.new_wire_post input[type="submit"] {
-       margin:3px 0 0 0;
-       float:right;
-}
-.new_wire_post textarea {
-       width: 719px;
-       height: 52px;
-       padding: 2px 5px 5px 5px;
-       font-size: 120%;
-       color:#333333;
-}
-.character_count {
-       width: 642px;
-       color:#666666;
-}
-.character_count input { 
-       color:#666666;
-       border:none;
-       font-size: 100%;
-       font-weight: bold;
-       padding:0 2px 0 0;
-       margin:0;
-       text-align: right;
-       background: white;
-}
-.character_count input:focus {
-       border:none;
-       background:white;
-}
-
-
-/* wire posts listings */
-.wire_post {
-       padding-bottom:10px;
-       margin-bottom:5px;
-       background-image: url(<?php echo elgg_get_site_url(); ?>mod/thewire/graphics/thewire_speech_bubble.gif);
-       background-repeat: no-repeat;
-       background-position: right bottom; 
-}
-.members-list .wire_post { /* when displayed in lists of friends */
-       margin-top:4px;
-}
-.wire_post_contents {
-       background-color: #eee;
-       margin:0;
-       padding:5px;
-       line-height: 1.2em;
-       min-height: 34px;
-       position: relative;
-}
-.wire_post_icon {
-       float:left;
-       margin-right:8px;
-}
-.wire_post_info {
-       margin-top:-3px;
-       float:left;
-       width:620px;
-       overflow: hidden;
-}
-.wire_post_options {
-       float:right;
-       width:65px;
-}
-.wire_post_options .elgg-button-action.reply.small {
-       float:right;
-}
-.wire_post_options .elgg-button-delete {
-       position: absolute;
-       bottom:5px;
-       right:5px;
-}
-
-
-/* latest wire post on profile page */
-.wire_post .elgg-button-action.update.small {
-       float:right;
-       padding:4px;
-       position: absolute;
-       bottom:5px;
-       right:5px;
-}
-
-/* river wire entry */
-.river_item .reply_link {
-       display:block;
+.thewire-parent {
+       margin-left: 40px;
 }
diff --git a/mod/thewire/views/default/thewire/previous.php b/mod/thewire/views/default/thewire/previous.php
new file mode 100644 (file)
index 0000000..e1ca83e
--- /dev/null
@@ -0,0 +1,11 @@
+<?php
+/**
+ * Serve up html for a post
+ */
+
+$guid = (int) get_input('guid');
+
+$parent = thewire_get_parent($guid);
+if ($parent) {
+       echo elgg_view_entity($parent);
+}