Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Store sidebar post IDs in a hidden span

instead of the id field to resolve Anthologize
regression with jQuery UI fix re: cloned IDs.
Fixes #52
  • Loading branch information...
commit 17c4f82a67edae91b74b1127d31a202a4c1ab7bc 1 parent bd69fab
@cazzerson cazzerson authored
View
3  css/project-organizer.css
@@ -120,6 +120,9 @@ div.anthologize h3 {
padding: 4px;
}
+span.fromNewId {
+ display:none;
+}
/* Right column (Parts) */
#partlist {
View
2  includes/class-project-organizer.php
@@ -485,7 +485,7 @@ function get_sidebar_posts() {
?>
<ul id="sidebar-posts">
<?php while ( $big_posts->have_posts() ) : $big_posts->the_post(); ?>
- <li class="item" id="new-<?php the_ID() ?>"><h3 class="part-item"><?php the_title() ?></h3></li>
+ <li class="item"><span class="fromNewId">new-<?php the_ID() ?></span><h3 class="part-item"><?php the_title() ?></h3></li>
<?php endwhile; ?>
</ul>
<?php
View
44 js/anthologize-sortlist.js
@@ -74,7 +74,8 @@ var anthologize = {
var i = 0;
ui.item.after(jQuery("#sidebar-posts li").clone().each(function(){
- var orig_id = anthologize.cleanPostIds(jQuery(this).attr("id"));
+ var sidePostId = jQuery(this).find("span.fromNewId").first().text();
+ var orig_id = anthologize.cleanPostIds(sidePostId);
var added_id = "item-" + orig_id;
jQuery(this).attr("id", added_id);
item_ids[i] = added_id;
@@ -314,6 +315,13 @@ var anthologize = {
result = resultArray.join(' ');
}
return result;
+ },
+ "fixFromNewId": function ( newEl ) {
+ var fromNewId = jQuery(newEl).find("span.fromNewId");
+ if (fromNewId.length){
+ jQuery(newEl).attr("id", jQuery(fromNewId[0]).text());
+ jQuery(fromNewId).remove();
+ }
}
};
@@ -325,14 +333,14 @@ jQuery.fn.anthologizeSortList = function (options){
start: function(event, ui){
anthologize.src_id = null;
anthologize.org_seq_num = ui.item.index() + 1;
- anthologize.src_seq = {};
- var pos = 1;
- ui.item.siblings().each(function(){
- if (! jQuery(this).hasClass("anthologize-drop-item")){
- anthologize.src_seq[anthologize.cleanPostIds(jQuery(this).attr("id"))] = pos;
- pos++;
- }
- });
+ anthologize.src_seq = {};
+ var pos = 1;
+ ui.item.siblings().each(function(){
+ if (! jQuery(this).hasClass("anthologize-drop-item")){
+ anthologize.src_seq[anthologize.cleanPostIds(jQuery(this).attr("id"))] = pos;
+ pos++;
+ }
+ });
anthologize.fromNew = false;
anthologize.newItem = null;
ui.item.addClass("anthologize-drag-selected");
@@ -340,14 +348,28 @@ jQuery.fn.anthologizeSortList = function (options){
stop: function (event, ui){
anthologize.newItem = ui.item;
if (ui.item.hasClass('part-header')){
+
+ ui.item.find("li.item").each(function(postItem) {
+ anthologize.fixFromNewId(postItem);
+ });
+
anthologize.addMultiItems(event, ui);
}else{
- anthologize.callBack(event, ui);
+ anthologize.fixFromNewId(ui.item);
+ anthologize.callBack(event, ui);
}
ui.item.removeClass("anthologize-drag-selected");
},
receive: function(event, ui){
- anthologize.src_id = ui.sender.closest("li").attr('id');
+ var senderLi = ui.sender.closest("li");
+ var senderId = senderLi.attr("id");
+ if (senderLi.hasClass("item")){
+ var fromNewId = senderLi.find("span.fromNewId").first();
+ if (fromNewId.length){
+ senderId = jQuery(fromNewId).text();
+ }
+ }
+ anthologize.src_id = senderId;
}
},
options);
View
2  js/project-organizer.js
@@ -32,7 +32,7 @@ function do_filter(){
success: function(response){
j('#sidebar-posts').empty();
j.each( response, function(post_id, post_title) {
- var h = '<li class="item" id="new-' + post_id + '"><h3 class="part-item">' + post_title + '</h3></li>';
+ var h = '<li class="item"><span class="fromNewId">new-' + post_id + '</span><h3 class="part-item">' + post_title + '</h3></li>';
j('#sidebar-posts').append(h);
});
anthologize.initSidebar();
Please sign in to comment.
Something went wrong with that request. Please try again.