diff options
author | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-03-30 02:07:59 +0000 |
---|---|---|
committer | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-03-30 02:07:59 +0000 |
commit | b472188b1e3fe4ff8a0da791910d12496b1de348 (patch) | |
tree | 63cc52ab126372ba532e7c246fe06b5e1364f764 /mod/thewire | |
parent | 030f72d81b76823e4f3b85675beb896b00b6af5d (diff) | |
download | elgg-b472188b1e3fe4ff8a0da791910d12496b1de348.tar.gz elgg-b472188b1e3fe4ff8a0da791910d12496b1de348.tar.bz2 |
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
Diffstat (limited to 'mod/thewire')
-rw-r--r-- | mod/thewire/js/thewire.js | 28 | ||||
-rw-r--r-- | mod/thewire/languages/en.php | 6 | ||||
-rw-r--r-- | mod/thewire/start.php | 8 | ||||
-rw-r--r-- | mod/thewire/views/default/js/thewire.php | 86 | ||||
-rw-r--r-- | mod/thewire/views/default/object/thewire.php | 5 | ||||
-rw-r--r-- | mod/thewire/views/default/thewire/css.php | 98 | ||||
-rw-r--r-- | mod/thewire/views/default/thewire/previous.php | 11 |
7 files changed, 115 insertions, 127 deletions
diff --git a/mod/thewire/js/thewire.js b/mod/thewire/js/thewire.js deleted file mode 100644 index 61f29db81..000000000 --- a/mod/thewire/js/thewire.js +++ /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 diff --git a/mod/thewire/languages/en.php b/mod/thewire/languages/en.php index 0896ecf14..226af187e 100644 --- a/mod/thewire/languages/en.php +++ b/mod/thewire/languages/en.php @@ -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 */ diff --git a/mod/thewire/start.php b/mod/thewire/start.php index 0c35b0231..770f8bce0 100644 --- a/mod/thewire/start.php +++ b/mod/thewire/start.php @@ -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 index 000000000..1eda90bee --- /dev/null +++ b/mod/thewire/views/default/js/thewire.php @@ -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 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 "<div class=\"thewire-parent hidden\" id=\"thewire-previous-{$post->guid}\">"; + echo "</div>"; +} 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; } -<?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 index 000000000..e1ca83e24 --- /dev/null +++ b/mod/thewire/views/default/thewire/previous.php @@ -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); +} |