Skip to content

Instantly share code, notes, and snippets.

@ifyoumakeit
Last active August 29, 2015 14:01
Show Gist options
  • Save ifyoumakeit/baae90ea5bfc9dd10c4e to your computer and use it in GitHub Desktop.
Save ifyoumakeit/baae90ea5bfc9dd10c4e to your computer and use it in GitHub Desktop.
Reorder Social Wall
// PASS OBJECT WITH SEARCH TERM & POSITION ( first, middle, last, or an integer )
// SEARCH TERMS are processed in the order they are added.
var searches = {
"fire" : "last",
"if" : "first",
"what" : "middle",
"why" : 2
};
reorderWall(searches);
function reorderWall(searches){
for(var s in searches){
var container = $('.xContainerSocialContentWall .xContainerInner'),
items = container.find(".xItem"),
search = container.find(".xItem:contains('"+s+"')" ),
middle = items.eq(Math.floor(container.find(".xItem").length/2));
if(searches[s]==="first")
search.prependTo(container);
else if(searches[s]==="last")
search.appendTo(container);
else if(searches[s]==="middle")
search.insertAfter(middle);
else
search.insertAfter(items.eq(searches[s]));
}
container.packery({itemSelector:'.xItem'}).packery("reloadItems").packery("layout");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment