summaryrefslogtreecommitdiffstats
path: root/js/app
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-04-15 12:06:14 +0200
committerBernhard Posselt <nukeawhale@gmail.com>2013-04-15 12:06:14 +0200
commit360966ab4bdafd15cdef21e34492f5d7d3151b74 (patch)
tree0d196a502d41a5234a2da5903fda09e7d51ddaed /js/app
parentfe2bb06a2cc7bf3cd70388d6179728a600eabc9f (diff)
get language from server and save it in a language object, dont use a seperate file for instantiating controllers
Diffstat (limited to 'js/app')
-rw-r--r--js/app/controllers/feedcontroller.coffee13
-rw-r--r--js/app/controllers/itemcontroller.coffee10
-rw-r--r--js/app/services/language.coffee (renamed from js/app/controllers/controllers.coffee)31
-rw-r--r--js/app/services/persistence.coffee10
-rw-r--r--js/app/services/services.coffee5
5 files changed, 43 insertions, 26 deletions
diff --git a/js/app/controllers/feedcontroller.coffee b/js/app/controllers/feedcontroller.coffee
index 8f9f4e7b6..e9171a455 100644
--- a/js/app/controllers/feedcontroller.coffee
+++ b/js/app/controllers/feedcontroller.coffee
@@ -21,9 +21,12 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
###
-angular.module('News').factory '_FeedController',
-['_ExistsError',
-(_ExistsError)->
+angular.module('News').controller 'FeedController',
+['$scope', '_ExistsError', 'Persistence', 'FolderBl', 'FeedBl',
+'SubscriptionsBl', 'StarredBl', 'unreadCountFormatter',
+($scope, _ExistsError, Persistence, FolderBl, FeedBl, SubscriptionsBl,
+StarredBl, unreadCountFormatter) ->
+
class FeedController
@@ -105,6 +108,8 @@ angular.module('News').factory '_FeedController',
@_$scope.$on 'moveFeedToFolder', (scope, data) =>
@_feedBl.move(data.feedId, data.folderId)
- return FeedController
+
+ return new FeedController($scope, Persistence, FolderBl, FeedBl,
+ SubscriptionsBl, StarredBl, unreadCountFormatter)
] \ No newline at end of file
diff --git a/js/app/controllers/itemcontroller.coffee b/js/app/controllers/itemcontroller.coffee
index 514186393..71bbb13be 100644
--- a/js/app/controllers/itemcontroller.coffee
+++ b/js/app/controllers/itemcontroller.coffee
@@ -21,12 +21,14 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
###
-angular.module('News').factory '_ItemController', ->
+angular.module('News').controller 'ItemController',
+['$scope', 'ItemBl', 'FeedModel', 'FeedLoading', 'FeedBl', 'Language',
+($scope, ItemBl, FeedModel, FeedLoading, FeedBl, Language) ->
class ItemController
constructor: (@_$scope, @_itemBl, @_feedModel, @_feedLoading,
- @_feedBl) ->
+ @_feedBl, @_language) ->
@_$scope.itemBl = @_itemBl
@_$scope.feedBl = @_feedBl
@@ -42,4 +44,6 @@ angular.module('News').factory '_ItemController', ->
return ''
- return ItemController \ No newline at end of file
+ return new ItemController($scope, ItemBl, FeedModel, FeedLoading, FeedBl,
+ Language)
+] \ No newline at end of file
diff --git a/js/app/controllers/controllers.coffee b/js/app/services/language.coffee
index 8a73549cf..85a405fc7 100644
--- a/js/app/controllers/controllers.coffee
+++ b/js/app/services/language.coffee
@@ -20,19 +20,18 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
###
-angular.module('News').controller 'FeedController',
-['$scope', '_FeedController', 'Persistence', 'FolderBl', 'FeedBl',
-'SubscriptionsBl', 'StarredBl', 'unreadCountFormatter',
-($scope, _FeedController, Persistence, FolderBl, FeedBl, SubscriptionsBl,
-StarredBl, unreadCountFormatter)->
-
- return new _FeedController($scope, Persistence, FolderBl, FeedBl,
- SubscriptionsBl, StarredBl, unreadCountFormatter)
-]
-
-angular.module('News').controller 'ItemController',
-['$scope', '_ItemController', 'ItemBl', 'FeedModel', 'FeedLoading', 'FeedBl',
-($scope, _ItemController, ItemBl, FeedModel, FeedLoading, FeedBl)->
-
- return new _ItemController($scope, ItemBl, FeedModel, FeedLoading, FeedBl)
-] \ No newline at end of file
+angular.module('News').factory 'Language', ->
+
+ class Language
+
+ constructor: ->
+ @_language = 'en'
+
+ handle: (data) ->
+ @_language = data.language
+
+ getLanguage: ->
+ return @_language
+
+
+ return new Language()
diff --git a/js/app/services/persistence.coffee b/js/app/services/persistence.coffee
index b6a9cd2c6..2b627301a 100644
--- a/js/app/services/persistence.coffee
+++ b/js/app/services/persistence.coffee
@@ -47,7 +47,8 @@ angular.module('News').factory '_Persistence', ->
@getAllFeeds(triggerHideRead)
@userSettingsRead(triggerHideRead)
@getStarredItems(triggerHideRead)
-
+ @userSettingsLanguage()
+
###
ITEM CONTROLLER
@@ -320,6 +321,13 @@ angular.module('News').factory '_Persistence', ->
@_request.post 'news_usersettings_read_hide', data
+ userSettingsLanguage: (callback=null) ->
+ callback or= ->
+ data =
+ onSuccess: callback
+ @_request.get 'news_usersettings_language', data
+
+
_triggerHideRead: ->
@_$rootScope.$broadcast('triggerHideRead')
diff --git a/js/app/services/services.coffee b/js/app/services/services.coffee
index 83e76e20e..19e4b990d 100644
--- a/js/app/services/services.coffee
+++ b/js/app/services/services.coffee
@@ -82,14 +82,15 @@ angular.module('News').factory 'ItemModel', ['_ItemModel', (_ItemModel) ->
angular.module('News').factory 'Publisher',
['_Publisher', 'ActiveFeed', 'ShowAll', 'StarredCount', 'ItemModel',
-'FolderModel', 'FeedModel',
+'FolderModel', 'FeedModel', 'Language',
(_Publisher, ActiveFeed, ShowAll, StarredCount, ItemModel,
-FolderModel, FeedModel) ->
+FolderModel, FeedModel, Language) ->
# register items at publisher to automatically add incoming items
publisher = new _Publisher()
publisher.subscribeObjectTo(ActiveFeed, 'activeFeed')
publisher.subscribeObjectTo(ShowAll, 'showAll')
+ publisher.subscribeObjectTo(Language, 'language')
publisher.subscribeObjectTo(StarredCount, 'starred')
publisher.subscribeObjectTo(FolderModel, 'folders')
publisher.subscribeObjectTo(FeedModel, 'feeds')