Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

change tab title when replying to a comment, fixes #9

  • Loading branch information...
commit 07209af6af7dc90d6bcc26bca74548dba2b29f68 1 parent 8df8f4c
@alexkingorg alexkingorg authored
View
27 assets/social.js
@@ -192,9 +192,17 @@
$('.comment-reply-link').click(function() {
$('.comment-reply-link').show();
$(this).hide();
- var $parent = $(this).closest('li'),
+ var $title = $('#reply-title'),
+ $cancel = null,
+ $parent = $(this).closest('li'),
$textarea = $parent.find('textarea'),
$form = $('#commentform');
+ // set data attr for current title
+ // set title to Sociali18n.commentReplyTitle
+ $cancel = $title.find('small').hide().appendTo($title);
+ $title.data('orig-title', $title.find('span').text())
+ .find('span').html(Sociali18n.commentReplyTitle + ' ')
+ .append($cancel.show());
if ($parent.hasClass('social-twitter')) {
// check to see if the current user has a Twitter profile
if ($('#post_accounts option[data-type="twitter"]').size() == 0 &&
@@ -229,8 +237,8 @@
$('#post_accounts').val($option.attr('value')).change();
}
$('#post_to_service').prop('checked', true);
- var $author = $parent.find('.social-comment-author a');
- var author_rel = $author.attr('rel').split(' ');
+ var $author = $parent.find('.social-comment-author a'),
+ author_rel = $author.attr('rel').split(' ');
$('#in_reply_to_status_id').val(author_rel[0]);
insertTwitterUsername($author, $textarea);
}
@@ -240,15 +248,20 @@
$('.comment-reply-link').show();
$('#post_to_service').prop('checked', false);
$('#in_reply_to_status_id').val('');
- var $parent = $(this).closest('li');
- var $textarea = $parent.find('textarea');
- var $author = $parent.find('.social-comment-author a');
+ var $title = $('#reply-title'),
+ $cancel = null,
+ $parent = $(this).closest('li'),
+ $textarea = $parent.find('textarea'),
+ $author = $parent.find('.social-comment-author a');
+ // restore title
+ $cancel = $title.find('small').hide().appendTo($title);
+ $title.find('span').html($title.data('orig-title') + ' ').append($cancel);
removeTwitterUsername($author, $textarea);
});
var $avatar = $('#commentform .avatar');
var original_avatar = $avatar.attr('src');
- $('#post_accounts').live('change', function() {
+ $('#post_accounts').on('change', function() {
$(this).find('option:selected').each(function() {
var avatar = $(this).attr('rel');
if (avatar !== undefined) {
View
18 lib/social/comment/form.php
@@ -332,24 +332,6 @@ public function get_also_post_to_controls() {
}
/**
- * Hook for 'comment_form_before' action.
- *
- * @return void
- */
- public function before() {
- if ($this->is_logged_in) {
- $tab = __('Post a Comment', 'social');
- }
- else {
- $tab = __('Profile', 'social');
- }
-
- echo Social_View::factory('comment/before', array(
- 'tab' => $tab
- ));
- }
-
- /**
* Hook for 'comment_form_top' action.
*
* @return void
View
3  social.php
@@ -390,6 +390,9 @@ public function enqueue_assets() {
if (SOCIAL_COMMENTS_JS !== false) {
wp_enqueue_script('jquery');
wp_enqueue_script('social_js', SOCIAL_COMMENTS_JS, array('jquery'), Social::$version, true);
+ wp_localize_script('social_js', 'Sociali18n', array(
+ 'commentReplyTitle' => __('Post a Reply', 'social'),
+ ));
}
if (!is_admin()) {
View
3  views/comment/before.php
@@ -1,3 +0,0 @@
-<div class="social-heading">
- <h2 class="social-title social-tab-active"><span><?php echo $tab; ?></span></h2>
-</div>
Please sign in to comment.
Something went wrong with that request. Please try again.