Last active
August 29, 2015 14:01
-
-
Save ifyoumakeit/baae90ea5bfc9dd10c4e to your computer and use it in GitHub Desktop.
Reorder Social Wall
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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