diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-04-16 13:19:28 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-04-16 15:23:12 +0200 |
commit | 8df6d36d49d89f3bb7186b36436606adb039b3f8 (patch) | |
tree | 2fbbe1e55995d0f9277557838a25f351e371540e /js/public | |
parent | efc118431b6afbb7cc1df887e11195d8c7e761a7 (diff) |
move instantiation into file where object is declared, fix unittests that overwrote services for all unittests and caused them to fail
Diffstat (limited to 'js/public')
-rw-r--r-- | js/public/app.js | 886 |
1 files changed, 421 insertions, 465 deletions
diff --git a/js/public/app.js b/js/public/app.js index c76a338ee..ab3c73783 100644 --- a/js/public/app.js +++ b/js/public/app.js @@ -66,46 +66,6 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. }).call(this); -// Generated by CoffeeScript 1.4.0 - -/* - -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('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.6.2 /* @@ -159,40 +119,6 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. }).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); - // Generated by CoffeeScript 1.6.2 /* @@ -317,7 +243,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. markingRead = true; - angular.module('News').directive('scrollMarksRead', [ + angular.module('News').directive('newsItemScroll', [ '$rootScope', 'Config', function($rootScope, Config) { return function(scope, elm, attr) { return elm.bind('scroll', function() { @@ -338,8 +264,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. feedItem = $elems[_i]; offset = $(feedItem).position().top; if (offset <= -50) { - id = parseInt($(feedItem).data('id'), 10); - _results.push($rootScope.$broadcast('readItem', id)); + _results.push(id = parseInt($(feedItem).data('id'), 10)); } else { break; } @@ -347,7 +272,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. return _results; }, Config.MarkReadTimeout); } - return scope.$apply(attr.scrollMarksRead); + return scope.$apply(attr.newsItemScroll); } }); }; @@ -627,7 +552,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. (function() { - angular.module('News').factory('_ActiveFeed', function() { + angular.module('News').factory('ActiveFeed', function() { var ActiveFeed; ActiveFeed = (function() { @@ -655,7 +580,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. return ActiveFeed; })(); - return ActiveFeed; + return new ActiveFeed(); }); }).call(this); @@ -1617,8 +1542,8 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. var __hasProp = {}.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; - angular.module('News').factory('_FeedModel', [ - '_Model', '_EqualQuery', function(_Model, _EqualQuery) { + angular.module('News').factory('FeedModel', [ + '_Model', '_EqualQuery', 'Utils', function(_Model, _EqualQuery, Utils) { var FeedModel; FeedModel = (function(_super) { @@ -1788,7 +1713,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. return FeedModel; })(_Model); - return FeedModel; + return new FeedModel(Utils); } ]); @@ -1821,7 +1746,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. var __hasProp = {}.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; - angular.module('News').factory('_FolderModel', [ + angular.module('News').factory('FolderModel', [ '_Model', '_EqualQuery', function(_Model, _EqualQuery) { var FolderModel; @@ -1953,7 +1878,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. return FolderModel; })(_Model); - return FolderModel; + return new FolderModel(); } ]); @@ -1986,7 +1911,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. var __hasProp = {}.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; - angular.module('News').factory('_ItemModel', [ + angular.module('News').factory('ItemModel', [ '_Model', '_MaximumQuery', '_MinimumQuery', 'StatusFlag', function(_Model, _MaximumQuery, _MinimumQuery, StatusFlag) { var ItemModel; @@ -2093,7 +2018,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. return ItemModel; })(_Model); - return ItemModel; + return new ItemModel(); } ]); @@ -2237,442 +2162,515 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. (function() { - angular.module('News').factory('_Persistence', function() { - var Persistence; - - Persistence = (function() { - function Persistence(_request, _loading, _config, _activeFeed, _$rootScope) { - this._request = _request; - this._loading = _loading; - this._config = _config; - this._activeFeed = _activeFeed; - this._$rootScope = _$rootScope; - } + angular.module('News').factory('Persistence', [ + 'Request', 'FeedLoading', 'AutoPageLoading', 'NewLoading', 'Config', 'ActiveFeed', '$rootScope', function(Request, FeedLoading, AutoPageLoading, NewLoading, Config, ActiveFeed, $rootScope) { + var Persistence; - Persistence.prototype.init = function() { - /* - Loads the initial data from the server - */ + Persistence = (function() { + function Persistence(_request, _feedLoading, _autoPageLoading, _newLoading, _config, _activeFeed, _$rootScope) { + this._request = _request; + this._feedLoading = _feedLoading; + this._autoPageLoading = _autoPageLoading; + this._newLoading = _newLoading; + this._config = _config; + this._activeFeed = _activeFeed; + this._$rootScope = _$rootScope; + } - var triggerHideRead, - _this = this; + Persistence.prototype.init = function() { + /* + Loads the initial data from the server + */ + + var _this = this; - this._loading.increase(); - this.getActiveFeed(function() { - return _this.getItems(_this._activeFeed.getType(), _this._activeFeed.getId(), 0, function() { - return _this._loading.decrease(); + this.getActiveFeed(function() { + return _this.getItems(_this._activeFeed.getType(), _this._activeFeed.getId()); }); - }); - triggerHideRead = function() { - return _this._triggerHideRead; - }; - this.getAllFolders(triggerHideRead); - this.getAllFeeds(triggerHideRead); - this.userSettingsRead(triggerHideRead); - this.getStarredItems(triggerHideRead); - return this.userSettingsLanguage(); - }; + this.getAllFolders(); + this.getAllFeeds(); + this.userSettingsRead(); + this.getStarredItems(); + return this.userSettingsLanguage(); + }; - /* - ITEM CONTROLLER - */ + /* + ITEM CONTROLLER + */ - Persistence.prototype.getItems = function(type, id, offset, onSuccess, updatedSince) { - var data, params; + Persistence.prototype.getItems = function(type, id, offset, onSuccess, updatedSince) { + var data, failureCallbackWrapper, loading, params, successCallbackWrapper, + _this = this; - if (onSuccess == null) { - onSuccess = null; - } - if (updatedSince == null) { - updatedSince = null; - } - onSuccess || (onSuccess = function() {}); - if (updatedSince !== null) { - data = { - updatedSince: updatedSince, - type: type, - id: id + if (onSuccess == null) { + onSuccess = null; + } + if (updatedSince == null) { + updatedSince = null; + } + onSuccess || (onSuccess = function() {}); + if (offset === 0) { + loading = this._feedLoading; + } else { + loading = this._autoPageLoading; + } + loading.increase(); + successCallbackWrapper = function(data) { + onSuccess(); + return loading.decrease(); }; - } else { - data = { - limit: this._config.itemBatchSize, - offset: offset, - id: id, - type: type + failureCallbackWrapper = function(data) { + return loading.decrease(); }; - } - params = { - data: data, - onSuccess: onSuccess + if (updatedSince !== null) { + data = { + updatedSince: updatedSince, + type: type, + id: id + }; + } else { + data = { + limit: this._config.itemBatchSize, + offset: offset, + id: id, + type: type + }; + } + params = { + data: data, + onSuccess: successCallbackWrapper, + onFailure: failureCallbackWrapper + }; + return this._request.get('news_items', params); }; - return this._request.get('news_items', params); - }; - Persistence.prototype.getStarredItems = function(onSuccess) { - var params; + Persistence.prototype.getStarredItems = function(onSuccess) { + var failureCallbackWrapper, params, successCallbackWrapper, + _this = this; - params = { - onSuccess: onSuccess + onSuccess || (onSuccess = function() {}); + this._feedLoading.increase(); + successCallbackWrapper = function(data) { + onSuccess(); + return _this._feedLoading.decrease(); + }; + failureCallbackWrapper = function(data) { + return _this._feedLoading.decrease(); + }; + params = { + onSuccess: successCallbackWrapper, + onFailure: failureCallbackWrapper + }; + return this._request.get('news_items_starred', params); }; - return this._request.get('news_items_starred', params); - }; - Persistence.prototype.starItem = function(feedId, guidHash) { - /* - Stars an item - */ + Persistence.prototype.starItem = function(feedId, guidHash) { + /* + Stars an item + */ - var params; + var params; - params = { - routeParams: { - feedId: feedId, - guidHash: guidHash - } + params = { + routeParams: { + feedId: feedId, + guidHash: guidHash + } + }; + return this._request.post('news_items_star', params); }; - return this._request.post('news_items_star', params); - }; - Persistence.prototype.unstarItem = function(feedId, guidHash) { - /* - Unstars an item - */ + Persistence.prototype.unstarItem = function(feedId, guidHash) { + /* + Unstars an item + */ - var params; + var params; - params = { - routeParams: { - feedId: feedId, - guidHash: guidHash - } + params = { + routeParams: { + feedId: feedId, + guidHash: guidHash + } + }; + return this._request.post('news_items_unstar', params); }; - return this._request.post('news_items_unstar', params); - }; - Persistence.prototype.readItem = function(itemId) { - /* - Sets an item as read - */ + Persistence.prototype.readItem = function(itemId) { + /* + Sets an item as read + */ - var params; + var params; - params = { - routeParams: { - itemId: itemId - } + params = { + routeParams: { + itemId: itemId + } + }; + return this._request.post('news_items_read', params); }; - return this._request.post('news_items_read', params); - }; - Persistence.prototype.unreadItem = function(itemId) { - /* - Sets an item as unread - */ + Persistence.prototype.unreadItem = function(itemId) { + /* + Sets an item as unread + */ - var params; + var params; - params = { - routeParams: { - itemId: itemId - } + params = { + routeParams: { + itemId: itemId + } + }; + return this._request.post('news_items_unread', params); }; - return this._request.post('news_items_unread', params); - }; - /* - FEED CONTROLLER - */ + /* + FEED CONTROLLER + */ - Persistence.prototype.getAllFeeds = function(callback) { - var params; + Persistence.prototype.getAllFeeds = function(onSuccess) { + var failureCallbackWrapper, params, successCallbackWrapper, + _this = this; - callback || (callback = function() {}); - params = { - onSuccess: callback + onSuccess || (onSuccess = function() {}); + this._feedLoading.increase(); + successCallbackWrapper = function(data) { + onSuccess(); + return _this._feedLoading.decrease(); + }; + failureCallbackWrapper = function(data) { + return _this._feedLoading.decrease(); + }; + params = { + onSuccess: successCallbackWrapper, + onFailure: failureCallbackWrapper + }; + return this._request.get('news_feeds', params); }; - return this._request.get('news_feeds', params); - }; - Persistence.prototype.getActiveFeed = function(onSuccess) { - var params; + Persistence.prototype.getActiveFeed = function(onSuccess) { + var failureCallbackWrapper, params, successCallbackWrapper, + _this = this; - params = { - onSuccess: onSuccess + this._feedLoading.increase(); + successCallbackWrapper = function(data) { + onSuccess(); + return _this._feedLoading.decrease(); + }; + failureCallbackWrapper = function(data) { + return _this._feedLoading.decrease(); + }; + params = { + onSuccess: successCallbackWrapper, + onFailure: failureCallbackWrapper + }; + return this._request.get('news_feeds_active', params); }; - return this._request.get('news_feeds_active', params); - }; - - Persistence.prototype.createFeed = function(url, parentFolderId, onSuccess, onFailure) { - var params; - - if (onSuccess == null) { - onSuccess = null; - } - if (onFailure == null) { - onFailure = null; - } - onSuccess || (onSuccess = function() {}); - onFailure || (onFailure = function() {}); - params = { - data: { - parentFolderId: parentFolderId, - url: url - }, - onSuccess: onSuccess, - onFailure: onFailure - }; - return this._request.post('news_feeds_create', params); - }; - Persistence.prototype.deleteFeed = function(feedId) { - var params; + Persistence.prototype.createFeed = function(url, parentFolderId, onSuccess, onFailure) { + var params; - params = { - routeParams: { - feedId: feedId + if (onSuccess == null) { + onSuccess = null; } + if (onFailure == null) { + onFailure = null; + } + onSuccess || (onSuccess = function() {}); + onFailure || (onFailure = function() {}); + params = { + data: { + parentFolderId: parentFolderId, + url: url + }, + onSuccess: onSuccess, + onFailure: onFailure + }; + return this._request.post('news_feeds_create', params); }; - return this._request.post('news_feeds_delete', params); - }; - Persistence.prototype.moveFeed = function(feedId, folderId) { - /* - moves a feed to a new folder - */ - - var params; + Persistence.prototype.deleteFeed = function(feedId) { + var params; - params = { - routeParams: { - feedId: feedId - }, - data: { - parentFolderId: folderId - } + params = { + routeParams: { + feedId: feedId + } + }; + return this._request.post('news_feeds_delete', params); }; - return this._request.post('news_feeds_move', params); - }; - Persistence.prototype.setFeedRead = function(feedId, highestItemId) { - /* - sets all items of a feed as read - */ + Persistence.prototype.moveFeed = function(feedId, folderId) { + /* + moves a feed to a new folder + */ - var params; + var params; - params = { - routeParams: { - feedId: feedId - }, - data: { - highestItemId: highestItemId - } + params = { + routeParams: { + feedId: feedId + }, + data: { + parentFolderId: folderId + } + }; + return this._request.post('news_feeds_move', params); }; - return this._request.post('news_feeds_read', params); - }; - Persistence.prototype.updateFeed = function(feedId) { - /* - moves a feed to a new folder - */ + Persistence.prototype.setFeedRead = function(feedId, highestItemId) { + /* + sets all items of a feed as read + */ - var params; + var params; - params = { - routeParams: { - feedId: feedId - } + params = { + routeParams: { + feedId: feedId + }, + data: { + highestItemId: highestItemId + } + }; + return this._request.post('news_feeds_read', params); }; - return this._request.post('news_feeds_update', params); - }; - - /* - FOLDER CONTROLLER - */ + Persistence.prototype.updateFeed = function(feedId) { + /* + moves a feed to a new folder + */ - Persistence.prototype.getAllFolders = function(callback) { - var params; + var params; - callback || (callback = function() {}); - params = { - onSuccess: callback + params = { + routeParams: { + feedId: feedId + } + }; + return this._request.post('news_feeds_update', params); }; - return this._request.get('news_folders', params); - }; - Persistence.prototype.openFolder = function(folderId) { /* - Save if a folder was opened + FOLDER CONTROLLER */ - var params; - params = { - routeParams: { - folderId: folderId - } + Persistence.prototype.getAllFolders = function(onSuccess) { + var failureCallbackWrapper, params, successCallbackWrapper, + _this = this; + + onSuccess || (onSuccess = function() {}); + this._feedLoading.increase(); + successCallbackWrapper = function(data) { + onSuccess(); + return _this._feedLoading.decrease(); + }; + failureCallbackWrapper = function(data) { + return _this._feedLoading.decrease(); + }; + params = { + onSuccess: successCallbackWrapper, + onFailure: failureCallbackWrapper + }; + return this._request.get('news_folders', params); }; - return this._request.post('news_folders_open', params); - }; - Persistence.prototype.collapseFolder = function(folderId) { - /* - Save if a folder was collapsed - */ + Persistence.prototype.openFolder = function(folderId) { + /* + Save if a folder was opened + */ - var params; + var params; - params = { - routeParams: { - folderId: folderId - } + params = { + routeParams: { + folderId: folderId + } + }; + return this._request.post('news_folders_open', params); }; - return this._request.post('news_folders_collapse', params); - }; - Persistence.prototype.createFolder = function(folderName, parentFolderId, onSuccess, onFailure) { - var params; + Persistence.prototype.collapseFolder = function(folderId) { + /* + Save if a folder was collapsed + */ - if (parentFolderId == null) { - parentFolderId = 0; - } - if (onSuccess == null) { - onSuccess = null; - } - if (onFailure == null) { - onFailure = null; - } - onSuccess || (onSuccess = function() {}); - onFailure || (onFailure = function() {}); - params = { - data: { - folderName: folderName, - parentFolderId: parentFolderId - }, - onSuccess: onSuccess, - onFailure: onFailure - }; - return this._request.post('news_folders_create', params); - }; + var params; - Persistence.prototype.deleteFolder = function(folderId) { - /* - Save if a folder was collapsed - */ + params = { + routeParams: { + folderId: folderId + } + }; + return this._request.post('news_folders_collapse', params); + }; - var params; + Persistence.prototype.createFolder = function(folderName, parentFolderId, onSuccess, onFailure) { + var params; - params = { - routeParams: { - folderId: folderId + if (parentFolderId == null) { + parentFolderId = 0; } + if (onSuccess == null) { + onSuccess = null; + } + if (onFailure == null) { + onFailure = null; + } + onSuccess || (onSuccess = function() {}); + onFailure || (onFailure = function() {}); + params = { + data: { + folderName: folderName, + parentFolderId: parentFolderId + }, + onSuccess: onSuccess, + onFailure: onFailure + }; + return this._request.post('news_folders_create', params); }; - return this._request.post('news_folders_delete', params); - }; - Persistence.prototype.renameFolder = function(folderId, folderName) { - /* - Save if a folder was collapsed - */ + Persistence.prototype.deleteFolder = function(folderId) { + /* + Save if a folder was collapsed + */ - var params; + var params; - params = { - routeParams: { - folderId: folderId - }, - data: { - folderName: folderName - } + params = { + routeParams: { + folderId: folderId + } + }; + return this._request.post('news_folders_delete', params); }; - return this._request.post('news_folders_rename', params); - }; - /* - EXPORT CONTROLLER - */ + Persistence.prototype.renameFolder = function(folderId, folderName) { + /* + Save if a folder was collapsed + */ + + var params; + params = { + routeParams: { + folderId: folderId + }, + data: { + folderName: folderName + } + }; + return this._request.post('news_folders_rename', params); + }; - Persistence.prototype.exportOPML = function() { /* - Prompts for an OPML download + EXPORT CONTROLLER */ - return this._request.get('news_export_opml'); - }; - - /* - USERSETTINGS CONTROLLER - */ - Persistence.prototype.userSettingsRead = function(callback) { - var params; + Persistence.prototype.exportOPML = function() { + /* + Prompts for an OPML download + */ + return this._request.get('news_export_opml'); + }; - if (callback == null) { - callback = null; - } /* - Gets the configs for read settings + USERSETTINGS CONTROLLER */ - callback || (callback = function() {}); - params = { - onSuccess: callback + + Persistence.prototype.userSettingsRead = function(onSuccess) { + var failureCallbackWrapper, params, successCallbackWrapper, + _this = this; + + if (onSuccess == null) { + onSuccess = null; + } + /* + Gets the configs for read settings + */ + + onSuccess || (onSuccess = function() {}); + this._feedLoading.increase(); + successCallbackWrapper = function(data) { + onSuccess(); + return _this._feedLoading.decrease(); + }; + failureCallbackWrapper = function(data) { + return _this._feedLoading.decrease(); + }; + params = { + onSuccess: successCallbackWrapper, + onFailure: failureCallbackWrapper + }; + return this._request.get('news_usersettings_read', params); }; - return this._request.get('news_usersettings_read', params); - }; - Persistence.prototype.userSettingsReadShow = function(callback) { - /* - Sets the reader mode to show all - */ + Persistence.prototype.userSettingsReadShow = function(callback) { + /* + Sets the reader mode to show all + */ - var data; + var data; - data = { - onSuccess: callback + data = { + onSuccess: callback + }; + return this._request.post('news_usersettings_read_show', data); }; - return this._request.post('news_usersettings_read_show', data); - }; |