Skip to content

Commit

Permalink
update non-edited broadcasts from primary, disable maxlength plugin f…
Browse files Browse the repository at this point in the history
…or until bugs are resolved
  • Loading branch information
alexkingorg committed Apr 8, 2012
1 parent 68395c8 commit 91b1fad
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 9 deletions.
10 changes: 9 additions & 1 deletion assets/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,8 @@
.broadcast-interstitial li.account .checked .readonly,
.broadcast-interstitial li.account .checked a.edit,
.broadcast-interstitial li.account .checked textarea,
.broadcast-interstitial li.account .checked .counter {
.broadcast-interstitial li.account .checked .counter,
.broadcast-interstitial li.account .broadcast-edit:hover a.edit {
opacity: 1;
}
.broadcast-interstitial li.account .broadcast-edit.edit .readonly,
Expand All @@ -685,3 +686,10 @@
margin-right: 5px;
}

.maxlength-remaining-short {
color: #900;
}
.maxlength-remaining-empty {
color: #900;
font-weight: bold;
}
23 changes: 20 additions & 3 deletions assets/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,28 @@
}).change();

$('.broadcast-interstitial .broadcast-edit textarea').each(function() {
$(this).maxLengthDisplay({
displayTarget: $(this).closest('.broadcast-edit').find('.counter')
});
// $(this).maxLengthDisplay({
// 'displayTarget': $(this).closest('.broadcast-edit').find('.counter'),
// 'lengths': {
// 'short': 10,
// 'empty': 0
// }
// });
});

$('body.clean ul.accounts li.proto .broadcast-edit textarea').change(function() {
var val = $(this).val();
$(this).closest('ul.accounts').find('.broadcast-edit').not('.edit').each(function() {
$(this).find('.readonly').text(val).end()
.find('textarea').val(val);
});
}).keypress(function() {
$(this).change();
}).click(function() {
$(this).change();
}).focus(function() {
$(this).change();
});

});
})(jQuery);
11 changes: 8 additions & 3 deletions lib/social/controller/broadcast.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ public function action_options() {
}
$content = wpautop($content);
$data['broadcasts'][] = $content;
// already broadcasted? not editable by default
$data['edit'] = false;
}
}
// assign errors
Expand All @@ -271,9 +273,6 @@ public function action_options() {
'edit' => false,
'maxlength' => $service->max_broadcast_length(),
);
if ($i == 0) {
$data['edit'] = true;
}
// assign previous broadcasts
if (isset($broadcasted_ids[$key]) && isset($broadcasted_ids[$key][$child_account->id])) {
$data['broadcasts'] = $broadcasted_ids[$key][$child_account->id];
Expand Down Expand Up @@ -310,10 +309,14 @@ public function action_options() {
$broadcast_content = array();
}

// check to see if we have any previous broadcasts or saved content
$previous_activity = 0;

foreach ($_services as $key => $accounts) {
$broadcast_default = $services[$key]->format_content($post, Social::option('broadcast_format'));
// set content format and checked status for each
foreach ($accounts as $id => $data) {
$previous_activity += count($data['broadcasts']);
// check for error - populate with previouly posted content
if (count($errors)) {
$content = stripslashes($_POST['social_account_content'][$key][$id]);
Expand All @@ -326,6 +329,7 @@ public function action_options() {
// check for saved broadcast
if (isset($broadcast_content[$key]) && isset($broadcast_content[$key][$id])) {
$content = $broadcast_content[$key][$id];
$previous_activity++;
}
if (count($broadcast_accounts) && isset($broadcast_accounts[$key]) && isset($broadcast_accounts[$key][$id])) {
$checked = true;
Expand All @@ -343,6 +347,7 @@ public function action_options() {
}

echo Social_View::factory('wp-admin/post/broadcast/options', array(
'clean' => ($previous_activity ? '' : 'clean'),
'services' => $services,
'_services' => $_services,
'post' => $post,
Expand Down
13 changes: 11 additions & 2 deletions views/wp-admin/post/broadcast/options.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
do_action('admin_print_styles');
?>
</head>
<body>
<body class="<?php echo esc_attr($clean); ?>">
<h1 id="logo"><?php _e('Social Broadcasts', 'social'); ?></h1>
<form id="setup" method="post" class="broadcast-interstitial" action="<?php echo esc_url(admin_url('post.php?social_controller=broadcast&social_action=options')); ?>">
<?php wp_nonce_field(); ?>
Expand All @@ -28,9 +28,17 @@
</header>
<ul class="accounts">
<?php
$i = 0;
foreach ($accounts as $account) {
$classes = array();
if ($i == 0) {
$classes[] = 'proto';
}
if (!empty($account['error'])) {
$classes[] = 'error';
}
?>
<li class="account <?php echo (!empty($account['error']) ? ' error' : ''); ?>">
<li class="account <?php echo implode(' ', $classes); ?>">
<label for="<?php echo esc_attr($account['field_name_checked'].$account['field_value_checked']); ?>">
<img src="<?php echo esc_attr($account['avatar']); ?>" width="32" height="32" />
<span class="name"><?php echo esc_html($account['name']); ?></span>
Expand Down Expand Up @@ -66,6 +74,7 @@
</div>
</li>
<?php
$i++;
}
?>
</ul>
Expand Down

0 comments on commit 91b1fad

Please sign in to comment.