| author | Andrew Eisenberg | 2012-01-18 17:24:22 (EST) |
|---|---|---|
| committer | sfranklin | 2012-01-20 17:43:32 (EST) |
| commit | b1f8698989ce161cfe62db222d6d8ea59748581b (patch) (side-by-side diff) | |
| tree | 4d1d8b4250c3a7e3199f3f5b12b4e6354205bc0d | |
| parent | f66f9cfa23c7c10483ced5fbccdbb51a533caf7b (diff) | |
| download | org.eclipse.orion.client-b1f8698989ce161cfe62db222d6d8ea59748581b.zip org.eclipse.orion.client-b1f8698989ce161cfe62db222d6d8ea59748581b.tar.gz org.eclipse.orion.client-b1f8698989ce161cfe62db222d6d8ea59748581b.tar.bz2 | |
Fix for Bug 368896. Correct sorting of favorites.
| -rw-r--r-- | bundles/org.eclipse.orion.client.core/web/orion/favorites.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/bundles/org.eclipse.orion.client.core/web/orion/favorites.js b/bundles/org.eclipse.orion.client.core/web/orion/favorites.js index 6b3c6b2..a27db64 100644 --- a/bundles/org.eclipse.orion.client.core/web/orion/favorites.js +++ b/bundles/org.eclipse.orion.client.core/web/orion/favorites.js @@ -63,12 +63,27 @@ define(['require', 'dojo', 'orion/util'], function(require, dojo, mUtil){ this._notifyListeners(); }, + /** + * Checks to see if the favorite already exists + * @param path the path to the favorite to search for + * @return true iff the path exists in the favorites list + */ + favoriteExists: function(path) { + for (var i in this._favorites) { + if (this._favorites[i].path === path) { + return true; + } + } + return false; + }, + addFavoriteUrl: function(url) { this.addFavorite(url, url, false, true); }, addFavorite: function(theName, thePath, isDirectory, isExternalResource) { this._favorites.push({ "name": theName, "path": thePath, "directory": isDirectory, "isFavorite": true, "isExternalResource": isExternalResource }); + this._favorites.sort(this._sorter); this._storeFavorites(); this._notifyListeners(); }, @@ -80,6 +95,7 @@ define(['require', 'dojo', 'orion/util'], function(require, dojo, mUtil){ break; } } + this._favorites.sort(this._sorter); this._storeFavorites(); this._notifyListeners(); }, @@ -96,6 +112,7 @@ define(['require', 'dojo', 'orion/util'], function(require, dojo, mUtil){ } } if (changed) { + this._favorites.sort(this._sorter); this._storeFavorites(); this._notifyListeners(); } @@ -104,6 +121,7 @@ define(['require', 'dojo', 'orion/util'], function(require, dojo, mUtil){ addFavoriteSearch: function(theName, theQuery) { this._searches.push({ "name": theName, "query": theQuery, "isSearch": true }); + this._searches.sort(this._sorter); this._storeSearches(); this._notifyListeners(); }, @@ -115,6 +133,7 @@ define(['require', 'dojo', 'orion/util'], function(require, dojo, mUtil){ break; } } + this._searches.sort(this._sorter); this._storeSearches(); this._notifyListeners(); }, @@ -131,6 +150,7 @@ define(['require', 'dojo', 'orion/util'], function(require, dojo, mUtil){ } } if (changed) { + this._searches.sort(this._sorter); this._storeSearches(); this._notifyListeners(); } @@ -160,6 +180,7 @@ define(['require', 'dojo', 'orion/util'], function(require, dojo, mUtil){ favorites._searches.push(search[i]); } } + favorites._favorites.sort(favorites._sorter); favorites._notifyListeners(); }); }, @@ -178,6 +199,16 @@ define(['require', 'dojo', 'orion/util'], function(require, dojo, mUtil){ }); }, + _sorter: function(fav1,fav2) { + if (fav1.name > fav2.name) { + return 1; + } else if (fav1.name < fav2.name) { + return -1; + } else { + return 0; + } + }, + getFavorites: function() { return {navigator: this._favorites, search: this._searches}; } |

