Browse files

removing informAngular method

  • Loading branch information...
1 parent 189c8f0 commit 1de157c3c577253054be0aa43fb67d5c01f93490 @ebidel ebidel committed Oct 8, 2012
Showing with 21 additions and 16 deletions.
  1. +11 −16 gdocs/js/app.js
  2. +10 −0 gdocs/js/util.js
View
27 gdocs/js/app.js
@@ -67,20 +67,6 @@ gDriveApp.factory('gdocs', function() {
function DocsController($scope, $http, gdocs) {
$scope.docs = [];
- function onResponse(doc, i, totalEntries, opt_inform) {
- var inform = opt_inform || false;
-
- $scope.docs.push(doc);
-
- // Only want to sort and call $apply() when we have all entries.
- if (totalEntries - 1 == i) {
- $scope.docs.sort(Util.sortByDate);
- if (inform) {
- $scope.$apply(); // Inform angular that we made changes.
- }
- }
- }
-
// Response handler that caches file icons int he filesystem API.
function successCallbackWithFsCaching(resp, status, headers, config) {
var docs = [];
@@ -110,7 +96,13 @@ function DocsController($scope, $http, gdocs) {
doc.icon = entry.toURL(); // should be === to fsURL, but whatevs.
- onResponse(doc, i, totalEntries, true);
+ $scope.docs.push(doc);
+
+ // Only want to sort and call $apply() when we have all entries.
+ if (totalEntries - 1 == i) {
+ $scope.docs.sort(Util.sortByDate);
+ $scope.$apply(function($scope) {}); // Inform angular we made changes.
+ }
}, function(e) {
$http.get(doc.icon, {responseType: 'blob'}).success(function(blob) {
@@ -122,7 +114,10 @@ function DocsController($scope, $http, gdocs) {
doc.icon = window.URL.createObjectURL(blob);
- onResponse(doc, i, totalEntries);
+ $scope.docs.push(doc);
+ if (totalEntries - 1 == i) {
+ $scope.docs.sort(Util.sortByDate);
+ }
});
});
View
10 gdocs/js/util.js
@@ -131,3 +131,13 @@ Util.sortByDate = function(a, b) {
}
return 0;
}
+
+Util.sortByTitle = function(a, b) {
+ if (a.title < b.title) {
+ return 1;
+ }
+ if (a.title > b.title) {
+ return -1;
+ }
+ return 0;
+}

0 comments on commit 1de157c

Please sign in to comment.