From b472188b1e3fe4ff8a0da791910d12496b1de348 Mon Sep 17 00:00:00 2001 From: cash Date: Wed, 30 Mar 2011 02:07:59 +0000 Subject: Fixes #3200 ajax-based view previous link works for the wire git-svn-id: http://code.elgg.org/elgg/trunk@8882 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/thewire/views/default/js/thewire.php | 86 ++++++++++++++++++++++ mod/thewire/views/default/object/thewire.php | 5 ++ mod/thewire/views/default/thewire/css.php | 98 +------------------------- mod/thewire/views/default/thewire/previous.php | 11 +++ 4 files changed, 104 insertions(+), 96 deletions(-) create mode 100644 mod/thewire/views/default/js/thewire.php create mode 100644 mod/thewire/views/default/thewire/previous.php (limited to 'mod/thewire/views/default') diff --git a/mod/thewire/views/default/js/thewire.php b/mod/thewire/views/default/js/thewire.php new file mode 100644 index 000000000..1eda90bee --- /dev/null +++ b/mod/thewire/views/default/js/thewire.php @@ -0,0 +1,86 @@ + + +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() == "") { + $link.html(""); + $link.attr("title", ""); + $previousDiv.slideUp(400); + } else { + $link.html(""); + $link.attr("title", ""); + + $.ajax({type: "GET", + url: "", + 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 diff --git a/mod/thewire/views/default/object/thewire.php b/mod/thewire/views/default/object/thewire.php index bcc62f816..1c61d5886 100644 --- a/mod/thewire/views/default/object/thewire.php +++ b/mod/thewire/views/default/object/thewire.php @@ -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 "
guid}\">"; + echo "
"; +} diff --git a/mod/thewire/views/default/thewire/css.php b/mod/thewire/views/default/thewire/css.php index afc3a16aa..d1ef31993 100644 --- a/mod/thewire/views/default/thewire/css.php +++ b/mod/thewire/views/default/thewire/css.php @@ -27,100 +27,6 @@ The Wire text-align: right; background: white; } - - -/* 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(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 index 000000000..e1ca83e24 --- /dev/null +++ b/mod/thewire/views/default/thewire/previous.php @@ -0,0 +1,11 @@ +