diff options
Diffstat (limited to 'js')
-rw-r--r-- | js/app/controllers/controllers.coffee | 10 | ||||
-rw-r--r-- | js/app/services/persistence.coffee | 23 | ||||
-rw-r--r-- | js/public/app.js | 26 | ||||
-rw-r--r-- | js/tests/services/persistenceSpec.coffee | 24 |
4 files changed, 46 insertions, 37 deletions
diff --git a/js/app/controllers/controllers.coffee b/js/app/controllers/controllers.coffee index b3a246fda..27603ef52 100644 --- a/js/app/controllers/controllers.coffee +++ b/js/app/controllers/controllers.coffee @@ -20,22 +20,22 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. ### -angular.module('News').controller 'SettingsController', -['$scope', '_SettingsController', +angular.module('News').controller 'SettingsController', +['$scope', '_SettingsController', ($scope, _SettingsController)-> return new _SettingsController($scope) ] -angular.module('News').controller 'FeedController', -['$scope', '_FeedController', 'FolderModel', 'FeedModel', +angular.module('News').controller 'FeedController', +['$scope', '_FeedController', 'FolderModel', 'FeedModel', ($scope, _FeedController, FolderModel, FeedModel)-> return new _FeedController($scope, FolderModel, FeedModel) ] -angular.module('News').controller 'ItemController', +angular.module('News').controller 'ItemController', ['$scope', '_ItemController', 'ItemModel', 'FeedLoading', ($scope, _ItemController, ItemModel, FeedLoading)-> diff --git a/js/app/services/persistence.coffee b/js/app/services/persistence.coffee index 6f75d4601..fab268518 100644 --- a/js/app/services/persistence.coffee +++ b/js/app/services/persistence.coffee @@ -40,10 +40,13 @@ angular.module('News').factory '_Persistence', -> @getItems @_activeFeed.getType(), @_activeFeed.getId(), 0, => @_loading.decrease() - @getAllFolders(@_triggerHideRead) - @getAllFeeds(@_triggerHideRead) - @userSettingsRead(@_triggerHideRead) - @getStarredItems(@_triggerHideRead) + triggerHideRead = => + @_triggerHideRead + + @getAllFolders(triggerHideRead) + @getAllFeeds(triggerHideRead) + @userSettingsRead(triggerHideRead) + @getStarredItems(triggerHideRead) ### @@ -126,7 +129,7 @@ angular.module('News').factory '_Persistence', -> FEED CONTROLLER ### getAllFeeds: (callback) -> - callback or= angular.noop + callback or= -> params = onSuccess: callback @@ -200,7 +203,7 @@ angular.module('News').factory '_Persistence', -> FOLDER CONTROLLER ### getAllFolders: (callback) -> - callback or= angular.noop + callback or= -> params = onSuccess: callback @@ -231,8 +234,8 @@ angular.module('News').factory '_Persistence', -> createFolder: (folderName, parentFolderId=0, onSuccess=null, onFailure=null) -> - onSuccess or= angular.noop - onFailure or= angular.noop + onSuccess or= -> + onFailure or= -> params = data: @@ -287,7 +290,7 @@ angular.module('News').factory '_Persistence', -> ### Gets the configs for read settings ### - callback or= angular.noop + callback or= -> params = onSuccess: callback @@ -308,7 +311,7 @@ angular.module('News').factory '_Persistence', -> @_request.post 'news_usersettings_read_hide' - _trigerHideRead: -> + _triggerHideRead: -> @_$rootScope.$broadcast('triggerHideRead') diff --git a/js/public/app.js b/js/public/app.js index f57367fa0..f711b637e 100644 --- a/js/public/app.js +++ b/js/public/app.js @@ -653,17 +653,21 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. Loads the initial data from the server */ - var _this = this; + var triggerHideRead, + _this = this; this._loading.increase(); this.getActiveFeed(function() { return _this.getItems(_this._activeFeed.getType(), _this._activeFeed.getId(), 0, function() { return _this._loading.decrease(); }); }); - this.getAllFolders(this._triggerHideRead); - this.getAllFeeds(this._triggerHideRead); - this.userSettingsRead(this._triggerHideRead); - return this.getStarredItems(this._triggerHideRead); + triggerHideRead = function() { + return _this._triggerHideRead; + }; + this.getAllFolders(triggerHideRead); + this.getAllFeeds(triggerHideRead); + this.userSettingsRead(triggerHideRead); + return this.getStarredItems(triggerHideRead); }; /* @@ -768,7 +772,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. Persistence.prototype.getAllFeeds = function(callback) { var params; - callback || (callback = angular.noop); + callback || (callback = function() {}); params = { onSuccess: callback }; @@ -861,7 +865,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. Persistence.prototype.getAllFolders = function(callback) { var params; - callback || (callback = angular.noop); + callback || (callback = function() {}); params = { onSuccess: callback }; @@ -907,8 +911,8 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. if (onFailure == null) { onFailure = null; } - onSuccess || (onSuccess = angular.noop); - onFailure || (onFailure = angular.noop); + onSuccess || (onSuccess = function() {}); + onFailure || (onFailure = function() {}); params = { data: { folderName: folderName, @@ -977,7 +981,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. Gets the configs for read settings */ - callback || (callback = angular.noop); + callback || (callback = function() {}); params = { onSuccess: callback }; @@ -998,7 +1002,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. return this._request.post('news_usersettings_read_hide'); }; - Persistence.prototype._trigerHideRead = function() { + Persistence.prototype._triggerHideRead = function() { return this._$rootScope.$broadcast('triggerHideRead'); }; diff --git a/js/tests/services/persistenceSpec.coffee b/js/tests/services/persistenceSpec.coffee index ea2483af0..788b05539 100644 --- a/js/tests/services/persistenceSpec.coffee +++ b/js/tests/services/persistenceSpec.coffee @@ -64,7 +64,7 @@ describe '_Persistence', -> id: 5 limit: @config.itemBatchSize offset: 3 - onSuccess: angular.noop + onSuccess: -> pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope) pers.getItems(params.data.type, params.data.id, params.data.offset, @@ -79,7 +79,7 @@ describe '_Persistence', -> type: 2 id: 5 updatedSince: 1333 - onSuccess: angular.noop + onSuccess: -> pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope) pers.getItems(params.data.type, params.data.id, 0, params.onSuccess, @@ -90,7 +90,7 @@ describe '_Persistence', -> it 'send a correct get starred items request', => params = - onSuccess: angular.noop + onSuccess: -> pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope) pers.getStarredItems(params.onSuccess) @@ -149,10 +149,11 @@ describe '_Persistence', -> ### it 'should get all feeds', => pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope) - pers.getAllFeeds() params = - onSuccess: angular.noop + onSuccess: -> + + pers.getAllFeeds(params.onSuccess) expect(@req.get).toHaveBeenCalledWith('news_feeds', params) @@ -197,7 +198,7 @@ describe '_Persistence', -> it 'send a correct get active feed request', => params = - onSuccess: angular.noop + onSuccess: -> pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope) pers.getActiveFeed(params.onSuccess) @@ -221,8 +222,8 @@ describe '_Persistence', -> data: parentFolderId: 5 url: 'http://google.de' - onSuccess: angular.noop - onFailure: angular.noop + onSuccess: -> + onFailure: -> pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope) pers.createFeed(params.data.url, params.data.parentFolderId, @@ -237,7 +238,7 @@ describe '_Persistence', -> ### it 'should do a proper get all folders request', => params = - onSuccess: angular.noop + onSuccess: -> pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope) pers.getAllFolders(params.onSuccess) @@ -321,10 +322,11 @@ describe '_Persistence', -> ### it 'should do a proper get user settings read request', => pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope) - pers.userSettingsRead() params = - onSuccess: angular.noop + onSuccess: -> + + pers.userSettingsRead(params.onSuccess) expect(@req.get).toHaveBeenCalledWith('news_usersettings_read', params) |