diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-03-27 20:44:20 +0100 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-03-27 20:44:20 +0100 |
commit | eb532ff3186faf58523dd509c6d208bdd9195e53 (patch) | |
tree | 942dae047e30d3e973494d1a2e38d3a0e8066ddd /js | |
parent | bf93d491cefd19fe8ab339725d4c7ce627b6308b (diff) |
adding dudes
Diffstat (limited to 'js')
-rw-r--r-- | js/app/controllers/feedcontroller.coffee | 10 | ||||
-rw-r--r-- | js/app/directives/clickfocus.coffee (renamed from js/app/directives/addfolderselect.coffee) | 26 | ||||
-rw-r--r-- | js/app/directives/focus.coffee | 32 | ||||
-rw-r--r-- | js/app/services/models/feedmodel.coffee | 1 | ||||
-rw-r--r-- | js/public/app.js | 113 | ||||
-rw-r--r-- | js/tests/controllers/feedcontrollerSpec.coffee | 1 |
6 files changed, 128 insertions, 55 deletions
diff --git a/js/app/controllers/feedcontroller.coffee b/js/app/controllers/feedcontroller.coffee index 33d23d935..82586378f 100644 --- a/js/app/controllers/feedcontroller.coffee +++ b/js/app/controllers/feedcontroller.coffee @@ -99,15 +99,16 @@ angular.module('News').factory '_FeedController', -> @_persistence.createFeed(feedUrl.trim(), parentFolderId, onSuccess, onError) + @$scope.addFolder = (folderName) => @$scope.folderEmptyError = false @$scope.folderExistsError = false - folderName = folderName.trim() - if angular.isUndefined(folderName) or folderName == '' + if angular.isUndefined(folderName) or folderName.trim() == '' @$scope.folderEmptyError = true else + folderName = folderName.trim() if @_folderModel.nameExists(folderName) @$scope.folderExistsError = true @@ -115,13 +116,10 @@ angular.module('News').factory '_FeedController', -> @_isAddingFolder = true @_persistence.createFolder folderName, 0, => @$scope.folderName = '' + @$scope.addNewFolder = false @_isAddingFolder = false - @$scope.$on 'createFolder', (scope, folderName) => - $scope.addFolder(folderName) - - toggleFolder: (folderId) -> folder = @_folderModel.getById(folderId) diff --git a/js/app/directives/addfolderselect.coffee b/js/app/directives/clickfocus.coffee index 41a111823..725ca46c4 100644 --- a/js/app/directives/addfolderselect.coffee +++ b/js/app/directives/clickfocus.coffee @@ -1,6 +1,6 @@ ### -ownCloud - News +ownCloud - news @author Bernhard Posselt @copyright 2012 Bernhard Posselt nukeawhale@gmail.com @@ -21,26 +21,12 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. ### -### -Turns a normal select into a folder select with the ability to create new -folders -### -angular.module('News').directive 'addFolderSelect', -['$rootScope', 'FolderModel', ($rootScope, FolderModel) -> +angular.module('News').directive 'clickFocus', -> return (scope, elm, attr) -> + options = scope.$eval(attr.clickFocus) - options = - singleSelect: true - selectedFirst: true - createText: $(elm).data('create') - createCallback: (selected, value) -> - if FolderModel.nameExists(value) - return false - else - $rootScope.$broadcast 'createFolder', value - - - $(elm).multiSelect(options) + if angular.isDefined(options) and angular.isDefined(options.selector) + elm.click -> + $(options.selector).focus() -]
\ No newline at end of file diff --git a/js/app/directives/focus.coffee b/js/app/directives/focus.coffee new file mode 100644 index 000000000..725ca46c4 --- /dev/null +++ b/js/app/directives/focus.coffee @@ -0,0 +1,32 @@ +### + +ownCloud - news + +@author Bernhard Posselt +@copyright 2012 Bernhard Posselt nukeawhale@gmail.com + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE +License as published by the Free Software Foundation; either +version 3 of the License, or any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU AFFERO GENERAL PUBLIC LICENSE for more details. + +You should have received a copy of the GNU Affero General Public +License along with this library. If not, see <http://www.gnu.org/licenses/>. + +### + + +angular.module('News').directive 'clickFocus', -> + + return (scope, elm, attr) -> + options = scope.$eval(attr.clickFocus) + + if angular.isDefined(options) and angular.isDefined(options.selector) + elm.click -> + $(options.selector).focus() + diff --git a/js/app/services/models/feedmodel.coffee b/js/app/services/models/feedmodel.coffee index 96f187e75..bd10ccb8b 100644 --- a/js/app/services/models/feedmodel.coffee +++ b/js/app/services/models/feedmodel.coffee @@ -67,7 +67,6 @@ angular.module('News').factory '_FeedModel', entry[key] = value - removeById: (id) -> item = @getById(id) delete @_urlHash[item.urlHash] diff --git a/js/public/app.js b/js/public/app.js index 8105c27dd..74e80c2c8 100644 --- a/js/public/app.js +++ b/js/public/app.js @@ -68,7 +68,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. /* -ownCloud - News +ownCloud - news @author Bernhard Posselt @copyright 2012 Bernhard Posselt nukeawhale@gmail.com @@ -88,34 +88,93 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. */ +(function() { + + angular.module('News').directive('clickFocus', function() { + return function(scope, elm, attr) { + var options; + options = scope.$eval(attr.clickFocus); + if (angular.isDefined(options) && angular.isDefined(options.selector)) { + return elm.click(function() { + return $(options.selector).focus(); + }); + } + }; + }); + +}).call(this); + +// Generated by CoffeeScript 1.4.0 + /* -Turns a normal select into a folder select with the ability to create new -folders + +ownCloud - news + +@author Bernhard Posselt +@copyright 2012 Bernhard Posselt nukeawhale@gmail.com + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE +License as published by the Free Software Foundation; either +version 3 of the License, or any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU AFFERO GENERAL PUBLIC LICENSE for more details. + +You should have received a copy of the GNU Affero General Public +License along with this library. If not, see <http://www.gnu.org/licenses/>. */ (function() { - angular.module('News').directive('addFolderSelect', [ - '$rootScope', 'FolderModel', function($rootScope, FolderModel) { - return function(scope, elm, attr) { - var options; - options = { - singleSelect: true, - selectedFirst: true, - createText: $(elm).data('create'), - createCallback: function(selected, value) { - if (FolderModel.nameExists(value)) { - return false; - } else { - return $rootScope.$broadcast('createFolder', value); - } - } - }; - return $(elm).multiSelect(options); - }; - } - ]); + angular.module('News').directive('clickFocus', function() { + return function(scope, elm, attr) { + var options; + options = scope.$eval(attr.clickFocus); + if (angular.isDefined(options) && angular.isDefined(options.selector)) { + return elm.click(function() { + return $(options.selector).focus(); + }); + } + }; + }); + +}).call(this); + +// Generated by CoffeeScript 1.4.0 + +/* + +ownCloud - App Framework + +@author Bernhard Posselt +@copyright 2012 Bernhard Posselt nukeawhale@gmail.com + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE +License as published by the Free Software Foundation; either +version 3 of the License, or any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU AFFERO GENERAL PUBLIC LICENSE for more details. + +You should have received a copy of the GNU Affero General Public +License along with this library. If not, see <http://www.gnu.org/licenses/>. +*/ + + +(function() { + + angular.module('OC').directive('focusFirstInput', function() { + return function(scope, elm, attr) { + return elm.find('input:first').focus(); + }; + }); }).call(this); @@ -280,10 +339,10 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. this.$scope.addFolder = function(folderName) { _this.$scope.folderEmptyError = false; _this.$scope.folderExistsError = false; - folderName = folderName.trim(); - if (angular.isUndefined(folderName) || folderName === '') { + if (angular.isUndefined(folderName) || folderName.trim() === '') { _this.$scope.folderEmptyError = true; } else { + folderName = folderName.trim(); if (_this._folderModel.nameExists(folderName)) { _this.$scope.folderExistsError = true; } @@ -292,13 +351,11 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. _this._isAddingFolder = true; return _this._persistence.createFolder(folderName, 0, function() { _this.$scope.folderName = ''; + _this.$scope.addNewFolder = false; return _this._isAddingFolder = false; }); } }; - this.$scope.$on('createFolder', function(scope, folderName) { - return $scope.addFolder(folderName); - }); } FeedController.prototype.toggleFolder = function(folderId) { diff --git a/js/tests/controllers/feedcontrollerSpec.coffee b/js/tests/controllers/feedcontrollerSpec.coffee index a37430d26..af3f40d00 100644 --- a/js/tests/controllers/feedcontrollerSpec.coffee +++ b/js/tests/controllers/feedcontrollerSpec.coffee @@ -333,6 +333,7 @@ describe '_FeedController', -> expect(@scope.folderName).toBe('') expect(@scope.isAddingFolder()).toBeFalsy() + expect(@scope.addNewFolder).toBeFalsy() it 'should not add feeds that have no url', => |