summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--js/app/controllers/feedcontroller.coffee45
-rw-r--r--js/app/directives/droppable.coffee44
-rw-r--r--js/public/app.js100
-rw-r--r--templates/part.listfeed.php8
4 files changed, 153 insertions, 44 deletions
diff --git a/js/app/controllers/feedcontroller.coffee b/js/app/controllers/feedcontroller.coffee
index 7785f3de6..0e2078b75 100644
--- a/js/app/controllers/feedcontroller.coffee
+++ b/js/app/controllers/feedcontroller.coffee
@@ -25,63 +25,63 @@ angular.module('News').factory '_FeedController', ->
class FeedController
- constructor: (@$scope, @_persistence, @_folderBl, @_feedBl,
+ constructor: (@_$scope, @_persistence, @_folderBl, @_feedBl,
@_subscriptionsBl, @_starredBl, @_unreadCountFormatter) ->
@_isAddingFolder = false
@_isAddingFeed = false
# bind internal stuff to scope
- @$scope.folderBl = @_folderBl
- @$scope.feedBl = @_feedBl
- @$scope.subscriptionsBl = @_subscriptionsBl
- @$scope.starredBl = @_starredBl
- @$scope.unreadCountFormatter = @_unreadCountFormatter
+ @_$scope.folderBl = @_folderBl
+ @_$scope.feedBl = @_feedBl
+ @_$scope.subscriptionsBl = @_subscriptionsBl
+ @_$scope.starredBl = @_starredBl
+ @_$scope.unreadCountFormatter = @_unreadCountFormatter
- @$scope.isAddingFolder = =>
+ @_$scope.isAddingFolder = =>
return @_isAddingFolder
- @$scope.isAddingFeed = =>
+ @_$scope.isAddingFeed = =>
return @_isAddingFeed
- @$scope.addFeed = (feedUrl, parentFolderId=0) =>
- @$scope.feedEmptyError = false
- @$scope.feedError = false
+ @_$scope.addFeed = (feedUrl, parentFolderId=0) =>
+ @_$scope.feedEmptyError = false
+ @_$scope.feedError = false
if angular.isUndefined(feedUrl) or feedUrl.trim() == ''
- @$scope.feedEmptyError = true
+ @_$scope.feedEmptyError = true
- if not @$scope.feedEmptyError
+ if not @_$scope.feedEmptyError
@_isAddingFeed = true
onError = =>
- @$scope.feedError = true
+ @_$scope.feedError = true
@_isAddingFeed = false
onSuccess = (data) =>
if data.status == 'error'
onError()
else
- @$scope.feedUrl = ''
+ @_$scope.feedUrl = ''
@_isAddingFeed = false
@_persistence.createFeed(feedUrl.trim(), parentFolderId,
onSuccess, onError)
- @$scope.addFolder = (folderName) =>
- @$scope.folderEmptyError = false
- @$scope.folderExistsError = false
+ @_$scope.addFolder = (folderName) =>
+ @_$scope.folderEmptyError = false
+ @_$scope.folderExistsError = false
if angular.isUndefined(folderName) or folderName.trim() == ''
- @$scope.folderEmptyError = true
+ @_$scope.folderEmptyError = true
else
folderName = folderName.trim()
if @_folderModel.nameExists(folderName)
- @$scope.folderExistsError = true
+ @_$scope.folderExistsError = true
- if not (@$scope.folderEmptyError or @$scope.folderExistsError)
+ if not (@_$scope.folderEmptyError or @_$scope.folderExistsError)
@_isAddingFolder = true
@_persistence.createFolder folderName, 0, =>
@$scope.folderName = ''
@@ -89,4 +89,7 @@ angular.module('News').factory '_FeedController', ->
@_isAddingFolder = false
+ @_$scope.$on 'moveFeedToFolder', (scope, data) =>
+ console.log data
+
return FeedController \ No newline at end of file
diff --git a/js/app/directives/droppable.coffee b/js/app/directives/droppable.coffee
new file mode 100644
index 000000000..dce9e987b
--- /dev/null
+++ b/js/app/directives/droppable.coffee
@@ -0,0 +1,44 @@
+###
+
+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 'droppable', ['$rootScope', ($rootScope) ->
+
+ return (scope, elm, attr) ->
+ $elem = $(elm)
+
+ details =
+ accept: '.feed'
+ hoverClass: 'drag-and-drop'
+ greedy: true
+ drop: (event, ui) ->
+ # in case jquery ui did something weird
+ $('.drag-and-drop').removeClass('drag-and-drop')
+
+ data =
+ folderId: parseInt($elem.data('id'), 10)
+ feedId: parseInt($(ui.draggable).data('id'), 10)
+
+ $rootScope.$broadcast('moveFeedToFolder', data)
+ scope.$apply attr.droppable
+
+ $elem.droppable(details)
+] \ No newline at end of file
diff --git a/js/public/app.js b/js/public/app.js
index f5fdf95ae..767c957e1 100644
--- a/js/public/app.js
+++ b/js/public/app.js
@@ -103,6 +103,59 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
}).call(this);
+// Generated by CoffeeScript 1.6.2
+/*
+
+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('droppable', [
+ '$rootScope', function($rootScope) {
+ return function(scope, elm, attr) {
+ var $elem, details;
+
+ $elem = $(elm);
+ details = {
+ accept: '.feed',
+ hoverClass: 'drag-and-drop',
+ greedy: true,
+ drop: function(event, ui) {
+ var data;
+
+ $('.drag-and-drop').removeClass('drag-and-drop');
+ data = {
+ folderId: parseInt($elem.data('id'), 10),
+ feedId: parseInt($(ui.draggable).data('id'), 10)
+ };
+ $rootScope.$broadcast('moveFeedToFolder', data);
+ return scope.$apply(attr.droppable);
+ }
+ };
+ return $elem.droppable(details);
+ };
+ }
+ ]);
+
+}).call(this);
+
// Generated by CoffeeScript 1.4.0
/*
@@ -209,10 +262,10 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
var FeedController;
FeedController = (function() {
- function FeedController($scope, _persistence, _folderBl, _feedBl, _subscriptionsBl, _starredBl, _unreadCountFormatter) {
+ function FeedController(_$scope, _persistence, _folderBl, _feedBl, _subscriptionsBl, _starredBl, _unreadCountFormatter) {
var _this = this;
- this.$scope = $scope;
+ this._$scope = _$scope;
this._persistence = _persistence;
this._folderBl = _folderBl;
this._feedBl = _feedBl;
@@ -221,57 +274,57 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
this._unreadCountFormatter = _unreadCountFormatter;
this._isAddingFolder = false;
this._isAddingFeed = false;
- this.$scope.folderBl = this._folderBl;
- this.$scope.feedBl = this._feedBl;
- this.$scope.subscriptionsBl = this._subscriptionsBl;
- this.$scope.starredBl = this._starredBl;
- this.$scope.unreadCountFormatter = this._unreadCountFormatter;
- this.$scope.isAddingFolder = function() {
+ this._$scope.folderBl = this._folderBl;
+ this._$scope.feedBl = this._feedBl;
+ this._$scope.subscriptionsBl = this._subscriptionsBl;
+ this._$scope.starredBl = this._starredBl;
+ this._$scope.unreadCountFormatter = this._unreadCountFormatter;
+ this._$scope.isAddingFolder = function() {
return _this._isAddingFolder;
};
- this.$scope.isAddingFeed = function() {
+ this._$scope.isAddingFeed = function() {
return _this._isAddingFeed;
};
- this.$scope.addFeed = function(feedUrl, parentFolderId) {
+ this._$scope.addFeed = function(feedUrl, parentFolderId) {
var onError, onSuccess;
if (parentFolderId == null) {
parentFolderId = 0;
}
- _this.$scope.feedEmptyError = false;
- _this.$scope.feedError = false;
+ _this._$scope.feedEmptyError = false;
+ _this._$scope.feedError = false;
if (angular.isUndefined(feedUrl) || feedUrl.trim() === '') {
- _this.$scope.feedEmptyError = true;
+ _this._$scope.feedEmptyError = true;
}
- if (!_this.$scope.feedEmptyError) {
+ if (!_this._$scope.feedEmptyError) {
_this._isAddingFeed = true;
onError = function() {
- _this.$scope.feedError = true;
+ _this._$scope.feedError = true;
return _this._isAddingFeed = false;
};
onSuccess = function(data) {
if (data.status === 'error') {
return onError();
} else {
- _this.$scope.feedUrl = '';
+ _this._$scope.feedUrl = '';
return _this._isAddingFeed = false;
}
};
return _this._persistence.createFeed(feedUrl.trim(), parentFolderId, onSuccess, onError);
}
};
- this.$scope.addFolder = function(folderName) {
- _this.$scope.folderEmptyError = false;
- _this.$scope.folderExistsError = false;
+ this._$scope.addFolder = function(folderName) {
+ _this._$scope.folderEmptyError = false;
+ _this._$scope.folderExistsError = false;
if (angular.isUndefined(folderName) || folderName.trim() === '') {
- _this.$scope.folderEmptyError = true;
+ _this._$scope.folderEmptyError = true;
} else {
folderName = folderName.trim();
if (_this._folderModel.nameExists(folderName)) {
- _this.$scope.folderExistsError = true;
+ _this._$scope.folderExistsError = true;
}
}
- if (!(_this.$scope.folderEmptyError || _this.$scope.folderExistsError)) {
+ if (!(_this._$scope.folderEmptyError || _this._$scope.folderExistsError)) {
_this._isAddingFolder = true;
return _this._persistence.createFolder(folderName, 0, function() {
_this.$scope.folderName = '';
@@ -280,6 +333,9 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
});
}
};
+ this._$scope.$on('moveFeedToFolder', function(scope, data) {
+ return console.log(data);
+ });
}
return FeedController;
diff --git a/templates/part.listfeed.php b/templates/part.listfeed.php
index 0c3a48a19..73087af28 100644
--- a/templates/part.listfeed.php
+++ b/templates/part.listfeed.php
@@ -6,7 +6,13 @@
ng-show="feedBl.isVisible(feed.id)"
data-id="{{ feed.id }}"
class="feed"
- draggable>
+ oc-draggable="{
+ revert: true,
+ stack: '> li',
+ zIndex: 1000,
+ axis: 'y',
+ helper: 'clone'
+ }">
<a ng-style="{ backgroundImage: feed.faviconLink }"
href="#"
class="title"