Created
January 14, 2016 16:15
-
-
Save arieljannai/8d73612ecfb1f953bae0 to your computer and use it in GitHub Desktop.
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
// for this purpose we used the icon propery of our tree object to identify that it is a file (a folder doesn't have an icon, it uses the default one) | |
var customTreeSort = function(a, b) { | |
if (this.get_node(a).icon === 'jstree-file' && this.get_node(b).icon === 'jstree-file') { | |
// organize files | |
return this.get_text(a).localeCompare(this.get_text(b)); | |
} else { | |
// files before folders | |
if (this.get_node(a).icon === 'jstree-file') { | |
return -1; | |
} | |
if (this.get_node(b).icon === 'jstree-file') { | |
return 1; | |
} | |
// organize folders | |
return this.get_text(a).localeCompare(this.get_text(b)); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment