diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-02-11 15:30:31 +0100 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-02-11 15:30:55 +0100 |
commit | 5492e60510379add1523454f322def81167be8be (patch) | |
tree | 8fff208ff6492758cff1b17aae7ec02c797cd322 /coffee | |
parent | e10d99e13da782e4c4bed03974bb10959ed333b4 (diff) |
new style and style cleanup for the news app
Diffstat (limited to 'coffee')
-rw-r--r-- | coffee/controllers/addnewcontroller.coffee | 20 | ||||
-rw-r--r-- | coffee/controllers/controllers.coffee | 11 | ||||
-rw-r--r-- | coffee/controllers/feedcontroller.coffee | 55 | ||||
-rw-r--r-- | coffee/controllers/settingscontroller.coffee | 82 | ||||
-rw-r--r-- | coffee/directives/addfolderselect.coffee | 33 | ||||
-rw-r--r-- | coffee/directives/droppable.coffee | 4 | ||||
-rw-r--r-- | coffee/lib/owncloud.coffee | 4 |
7 files changed, 122 insertions, 87 deletions
diff --git a/coffee/controllers/addnewcontroller.coffee b/coffee/controllers/addnewcontroller.coffee new file mode 100644 index 000000000..348b1ecb1 --- /dev/null +++ b/coffee/controllers/addnewcontroller.coffee @@ -0,0 +1,20 @@ +### +# ownCloud news app +# +# @author Alessandro Cosentino +# @author Bernhard Posselt +# Copyright (c) 2012 - Alessandro Cosentino <cosenal@gmail.com> +# Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com> +# +# This file is licensed under the Affero General Public License version 3 or +# later. +# +# See the COPYING-README file +# +### +angular.module('News').factory '_AddNewController', +['Controller', (Controller) -> + + class AddNewController extends Controller + +]
\ No newline at end of file diff --git a/coffee/controllers/controllers.coffee b/coffee/controllers/controllers.coffee index 606ad9ac4..62476443f 100644 --- a/coffee/controllers/controllers.coffee +++ b/coffee/controllers/controllers.coffee @@ -18,9 +18,8 @@ angular.module('News').controller 'SettingsController', 'FolderModel', 'FeedModel', 'OPMLParser', (_SettingsController, $scope, $rootScope, ShowAll, PersistenceNews, FolderModel, FeedModel, OPMLParser) -> - return new _SettingsController($scope, $rootScope, ShowAll, - PersistenceNews, FolderModel, FeedModel, - OPMLParser) + return new _SettingsController($scope, $rootScope, PersistenceNews, + OPMLParser) ] angular.module('News').controller 'ItemController', @@ -43,4 +42,10 @@ StarredCount, ShowAll, ItemModel, GarbageRegistry, $rootScope, Loading, Config) ActiveFeed, PersistenceNews, StarredCount, ShowAll, ItemModel, GarbageRegistry, $rootScope, Loading, Config) +] + +angular.module('News').controller 'AddNewController', +['_AddNewController', '$scope', +(_AddNewController, $scope) -> + return new _AddNewController($scope) ]
\ No newline at end of file diff --git a/coffee/controllers/feedcontroller.coffee b/coffee/controllers/feedcontroller.coffee index 6ce5ef5c0..4717a6594 100644 --- a/coffee/controllers/feedcontroller.coffee +++ b/coffee/controllers/feedcontroller.coffee @@ -25,7 +25,62 @@ angular.module('News').factory '_FeedController', ['Controller', (Controller) -> @$scope.feeds = @feedModel.getItems() @$scope.folders = @folderModel.getItems() @$scope.feedType = @feedType + + @$scope.getShowAll = => + return @showAll.showAll + + @$scope.setShowAll = (value) => + @showAll.showAll = value + @persistence.showAll(value) + @$rootScope.$broadcast('triggerHideRead') + + @$scope.addFeed = (url, folder) => + @$scope.feedEmptyError = false + @$scope.feedExistsError = false + @$scope.feedError = false + if url == undefined or url.trim() == '' + @$scope.feedEmptyError = true + else + url = url.trim() + for feed in @feedModel.getItems() + if url == feed.url # FIXME: can we really compare this + @$scope.feedExistsError = true + + if not (@$scope.feedEmptyError or @$scope.feedExistsError) + if folder == undefined + folderId = 0 + else + folderId = folder.id + @addingFeed = true + onSuccess = => + @$scope.feedUrl = '' + @addingFeed = false + onError = => + @$scope.feedError = true + @addingFeed = false + @persistence.createFeed(url, folderId, onSuccess, onError) + + + @$scope.addFolder = (name) => + @$scope.folderEmptyError = false + @$scope.folderExistsError = false + + if name == undefined or name.trim() == '' + @$scope.folderEmptyError = true + else + name = name.trim() + for folder in @folderModel.getItems() + if name.toLowerCase() == folder.name.toLowerCase() + @$scope.folderExistsError = true + + if not (@$scope.folderEmptyError or @$scope.folderExistsError) + @addingFolder = true + onSuccess = => + @$scope.folderName = '' + @addingFolder = false + @persistence.createFolder(name, onSuccess) + @$scope.toggleFolder = (folderId) => folder = @folderModel.getItemById(folderId) folder.open = !folder.open diff --git a/coffee/controllers/settingscontroller.coffee b/coffee/controllers/settingscontroller.coffee index 38036f89f..9afda5407 100644 --- a/coffee/controllers/settingscontroller.coffee +++ b/coffee/controllers/settingscontroller.coffee @@ -18,94 +18,16 @@ angular.module('News').factory '_SettingsController', ['Controller', class SettingsController extends Controller - constructor: (@$scope, @$rootScope, @showAll, @persistence, @folderModel, - @feedModel, @opmlParser) -> + constructor: (@$scope, @$rootScope, @persistence, @opmlParser) -> @add = false @settings = false @addingFeed = false @addingFolder = false - @$scope.getFolders = => - return @folderModel.getItems() - - @$scope.getShowAll = => - return @showAll.showAll - - @$scope.setShowAll = (value) => - @showAll.showAll = value - @persistence.showAll(value) - @$rootScope.$broadcast('triggerHideRead') - - @$scope.toggleSettings = => - @settings = !@settings - - @$scope.toggleAdd = => - @add = !@add - - @$scope.addIsShown = => - return @add - - @$scope.settingsAreShown = => - return @settings - - @$scope.isAddingFeed = => - return @addingFeed - - @$scope.isAddingFolder = => - return @addingFolder - - @$scope.addFeed = (url, folder) => - @$scope.feedEmptyError = false - @$scope.feedExistsError = false - @$scope.feedError = false - - if url == undefined or url.trim() == '' - @$scope.feedEmptyError = true - else - url = url.trim() - for feed in @feedModel.getItems() - if url == feed.url # FIXME: can we really compare this - @$scope.feedExistsError = true - - if not (@$scope.feedEmptyError or @$scope.feedExistsError) - if folder == undefined - folderId = 0 - else - folderId = folder.id - @addingFeed = true - onSuccess = => - @$scope.feedUrl = '' - @addingFeed = false - onError = => - @$scope.feedError = true - @addingFeed = false - @persistence.createFeed(url, folderId, onSuccess, onError) - - - @$scope.addFolder = (name) => - @$scope.folderEmptyError = false - @$scope.folderExistsError = false - - if name == undefined or name.trim() == '' - @$scope.folderEmptyError = true - else - name = name.trim() - for folder in @folderModel.getItems() - if name.toLowerCase() == folder.name.toLowerCase() - @$scope.folderExistsError = true - - if not (@$scope.folderEmptyError or @$scope.folderExistsError) - @addingFolder = true - onSuccess = => - @$scope.folderName = '' - @addingFolder = false - @persistence.createFolder(name, onSuccess) - @$scope.$on 'readFile', (scope, fileContent) => structure = @opmlParser.parseXML(fileContent) - @parseOPMLStructure(structure) - + @parseOPMLStructure(structure) @$scope.$on 'hidesettings', => @add = false diff --git a/coffee/directives/addfolderselect.coffee b/coffee/directives/addfolderselect.coffee new file mode 100644 index 000000000..1aa77c556 --- /dev/null +++ b/coffee/directives/addfolderselect.coffee @@ -0,0 +1,33 @@ +### +# ownCloud news app +# +# @author Alessandro Cosentino +# @author Bernhard Posselt +# Copyright (c) 2012 - Alessandro Cosentino <cosenal@gmail.com> +# Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com> +# +# This file is licensed under the Affero General Public License version 3 or +# later. +# +# See the COPYING-README file +# +### + +### +Turns a normal select into a folder select with the ability to create new folders +### +angular.module('News').directive 'addFolderSelect', ['$rootScope', -> + + return (scope, elm, attr) -> + + options = + singleSelect: true + selectedFirst: true + createText: $(elm).data('create') + createdCallback: (selected, value) -> + console.log selected + console.log value + + $(elm).multiSelect(options) + +]
\ No newline at end of file diff --git a/coffee/directives/droppable.coffee b/coffee/directives/droppable.coffee index e00545d31..a9c134096 100644 --- a/coffee/directives/droppable.coffee +++ b/coffee/directives/droppable.coffee @@ -20,11 +20,11 @@ angular.module('News').directive 'droppable', ['$rootScope', ($rootScope) -> details = accept: '.feed' - hoverClass: 'dnd_over' + hoverClass: 'drag-and-drop' greedy: true drop: (event, ui) -> # in case jquery ui did something weird - $('.dnd_over').removeClass('dnd_over') + $('.drag-and-drop').removeClass('drag-and-drop') data = folderId: parseInt($elem.data('id'), 10) diff --git a/coffee/lib/owncloud.coffee b/coffee/lib/owncloud.coffee index 537499135..aaed235a3 100644 --- a/coffee/lib/owncloud.coffee +++ b/coffee/lib/owncloud.coffee @@ -34,11 +34,11 @@ angular.module('OC', []).config ['$httpProvider', ($httpProvider) -> return $.param(data) ] -angular.module('OC').init ['$rootScope', 'Router', ($rootScope, Router) -> +angular.module('OC').run ['$rootScope', 'Router', ($rootScope, Router) -> init = -> $rootScope.$broadcast('routesLoaded') # this registers a callback that is executed once the routes have # finished loading. Before this you cant really do request - OC.Router.registerLoadedCallback(init) + Router.registerLoadedCallback(init) ]
\ No newline at end of file |