Skip to content

Commit

Permalink
Merge pull request #8 from voceconnect/fix_sorting_10-20
Browse files Browse the repository at this point in the history
disabling sorting now disables the ability to sort, bump to ver 1.0.10
  • Loading branch information
kevinlangleyjr committed Oct 28, 2014
2 parents 862b4e4 + 0342d24 commit 12676d3
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 deletions.
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
{
"name": "Michael Pretty",
"email": "[email protected]"
},
{
"name": "Gary Smirny",
"email": "[email protected]"
}
],
"autoload": {
Expand Down
30 changes: 23 additions & 7 deletions post-selection-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
$.fn.post_selection_ui = function() {

return this.each(function() {
var $selectedIDs, $selectionBox, $selectedPosts, $spinner, postIn, order, orderby, autoload, max_posts, is_full, post_type, post_status, update_box, ajax_request, add_post, remove_all_posts, remove_post, switch_to_tab, PostsTab, searchTab, listTab, $searchInput, name;
var $selectedIDs, $selectionBox, $selectedPosts, $spinner, postIn, order, orderby, autoload, max_posts, is_full, post_type, post_status, update_box, ajax_request, add_post, restore_post, remove_all_posts, remove_post, switch_to_tab, PostsTab, searchTab, listTab, $searchInput, name;

$selectionBox = $(this);

$thisID = $selectionBox.attr('id');
if($selectionBox.hasClass('psu-active')){
return false;
Expand All @@ -28,18 +29,32 @@
'class': 'psu-spinner'
});

restore_post = function($tr){
$tr.find('.psu-col-order').remove();
$tr.find('td.psu-col-delete').addClass('psu-col-create').removeClass('psu-col-delete')
.find('a').attr('title', 'Add');

$selectionBox.find('table.psu-results tbody').append($tr);
}

remove_all_posts = function(ev){
if (!confirm(PostSelectionUI.clearConfirmMessage))
return;
$selectedPosts.find('tbody').html('');

$selectedPosts.find('tbody tr').each(function(){
restore_post($(this));
});

update_box();
ev.preventDefault();
}

remove_post = function(ev){
var $self;
$self = $(ev.target);
$self.closest('tr').remove();
var $self = $(ev.target),
$tr = $self.closest('tr');

restore_post($tr);

update_box();
ev.preventDefault();
}
Expand All @@ -54,7 +69,8 @@
var psu_item_selected_event = jQuery.Event('psu_item_selected');
$selectionBox.trigger(psu_item_selected_event, [{post_id : $tr.data('post_id'), target : $tr}]);
if(!psu_item_selected_event.isDefaultPrevented() ) {
$tr.appendTo($selectedPosts).append('<td class="psu-col-order">&nbsp;</td>')
var handle = $selectedPosts.find('tbody.sortable').length ? '<td class="psu-col-order">&nbsp;</td>' : '';
$tr.appendTo($selectedPosts).append(handle)
.find('td.psu-col-create').removeClass('psu-col-create').addClass('psu-col-delete')
.find('a').attr('title', 'Remove');

Expand Down Expand Up @@ -118,7 +134,7 @@
return $.getJSON(ajaxurl + '?' + $.param(data), callback);
}

$selectedPosts.find('tbody').sortable({
$selectedPosts.find('tbody.sortable').sortable({
handle: 'td.psu-col-order',
helper: function(e, ui){
ui.children().each(function(){
Expand Down
8 changes: 4 additions & 4 deletions post-selection-ui.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
/*
Plugin Name: Post Selection UI
Description: An extraction of the post selection interface from the posts-to-posts plugin
Version: 1.0.9
Author: prettyboymp
Version: 1.0.10
Author: prettyboymp, banderon
Plugin URI: http://voceconnect.com
*/
Expand Down Expand Up @@ -326,7 +326,7 @@ public function render() {
</tr>
</thead>
<?php endif; ?>
<tbody>
<tbody class="<?php echo $this->args['sortable'] ? 'sortable' : ''; ?>">
<?php echo $this->render_selected_rows($this->args['selected']); ?>
</tbody>
</table>
Expand All @@ -336,7 +336,7 @@ public function render() {

<ul class="wp-tab-bar clearfix">
<?php
$html = '<li class="wp-tab-active" data-ref=".psu-tab-list"><a href="#">View All</a></li>';
$html = '<li class="wp-tab-active" data-ref=".psu-tab-list"><a href="#">View All</a></li>';
$html .= '<li data-ref=".psu-tab-search"><a href="#">Search</a></li>';
$html = apply_filters('psu_tab_list', $html, $post_type = $this->args['post_type'][0]);
echo $html;
Expand Down

0 comments on commit 12676d3

Please sign in to comment.